Augmented assignment (ie. += and friends) for Python!

Philip 'Yes, that's my address' Newton nospam.newton at gmx.li
Thu May 18 02:08:07 EDT 2000


On Sun, 14 May 2000 11:18:39 +0200, Thomas Wouters <thomas at xs4all.net>
wrote:

>Perl supplies the &&= and ||= operators as shortcuts for the above
>construct.

Hence, "$val ||= 'spam';" means "Give $val the value 'spam' unless it
had a true value previously."

Some people argue there should also be something like "$val ??= 'spam';"
meaning "Give $val the value 'spam' unless it had a *defined* value
previously."

Cheers,
Philip
-- 
Philip Newton <nospam.newton at gmx.li>
If you're not part of the solution, you're part of the precipitate.



More information about the Python-list mailing list