Sep-20-2019, 06:59 AM
With code above you will get NameError (if you haven't somewhere in your code defined none, which would be bad practice).
a, b, c are the same in both cases, so no need to write those two times or put into conditionals. If you like 'clever' one-liners then you can do following regarding x, y, z:
a, b, c are the same in both cases, so no need to write those two times or put into conditionals. If you like 'clever' one-liners then you can do following regarding x, y, z:
>>> condition = '' >>> x, y, z = ([x, None][bool(condition)] for x in range(10, 13)) >>> x, y, z (10, 11, 12) >>> condition = 'abc' >>> x, y, z = ([x, None][bool(condition)] for x in range(10, 13)) >>> x, y, z (None, None, None)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.