[Python-ideas] list…pushed, or something

Bruce Leban bruce at leapyear.org
Thu Mar 28 06:58:54 CET 2013

On Wed, Mar 27, 2013 at 10:48 PM, Shane Green <shane at umbrellacode.com>wrote:

> That's clever: even works for zero because it's returned by or as second
> false.  Cool.  So I suppose I have to come up with more examples now ;-)
> Actually, on that point, I actually think the seen.added(value)  (with a
> better name) is quite a bit cleaner than the one using "or".   Clever as it
> is, I think someone learning the language would flinch when they saw that…
> :-)

Yes, I suppose it's a bit obscure but you're only going to use it in a case
where you value brevity over clarity, right?

The C comma operator which always returns the second value, not depending
that the first value is false. You can write this in Python as:

    (foo, bar)[1]

or is there some cleaner way to write that?

    #define comma  and False or

--- Bruce
Latest blog post: Alice's Puzzle Page http://www.vroospeak.com
Learn how hackers think: http://j.mp/gruyere-security
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130327/ffaad023/attachment.html>

More information about the Python-ideas mailing list