[Python-ideas] In-place assignment for "boolean or"?
Rhodri James
rhodri at kynesim.co.uk
Mon Mar 26 10:11:50 EDT 2018
On 26/03/18 13:48, Cammil Taank wrote:
> Hi,
>
> I find a common idiom in Python is:
>
> x = x or 'some other value'
I believe this is a historic idiom from back before the ternary operator
was added to Python:
x = x if x else 'some other value'
though honestly both of those are poor ways of spelling
if not x:
x = 'some other value'
> This is highly reminiscent of the problem inplace operators solve.
It really isn't, particularly not in Python
> Would it be a good idea to consider an inplace operator for this, perhaps:
>
> x or= 'some other value'
I don't find the combination of letters and symbols appealing, sorry.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list