3 ms·
What I really want (but Python doesn't have) is: credit = user?.get_balance()?.credit_amount() if credit is not None and credit > 0: discount_prog
by NoboruWataya 3y ago
What I really want (but Python doesn't have) is:
credit = user?.get_balance()?.credit_amount()
if credit is not None and credit > 0:
discount_program = choose_discount(credit)
- Izkata 3y agoI swear I remember once seeing a library that enabled this by wrapping the first object: Foo(user).get_balance().credit_amount() Maybe with an additional .get() at the end to unwrap it? Though I imagine a dynamically-created class could avoid that.
- hprotagonist 3y agohttps://peps.python.org/pep-0505/ https://peps.python.org/pep-0505/ there's a PEP. But it's been pocket-vetoed, i think.