You can already do compact conditional returns with the current syntax:
def foo(a, b):
return (a != b or None) and a * b
or even:
foo = (lambda a, b: (a != b or None) and a * b)
both return:
foo(2, 5) # 10
foo(1, 1) # None
... but clarity would be better.
On Fri, Jun 19, 2020 at 4:
This is not really the best syntax, but I thought this generator expression
might be of interest:
counter = (d.update(n=d['n']+1) or d['n'] for d in [dict(n=-1)] for _ in
iter(int,1))
It counts forever starting at 0. I was playing with only using generator
syntax...
On Fri, Jun 19, 2020 at 1:32
I like Atsou's suggestion of omitting the key for literals:
d = {:name, :addr, ’tel': '123-4567’}
but using empty kwargs feels gross:
d = dict(=name, =addr, tel='123-456')
And this feels like it could easily lead to confusion:
d = dict(name, addr, tell='123-456')
On Thu, Jun 11, 2020 at 4:05