Sybren Stuvel wrote:
> Tal Einat enlightened us with:
> > Actually, the common work-around for this is:
> >
> > (thing and [thing+1] or [-1])[0]
> >
> > This works since non-empty lists are always considered true in
> > conditional context. This is more generic, and IMO more readable.
>
> I think it's not readable at all. It's confusing - you create a
> singleton list, only to extract the first element from it and discard
> the list again. I'd rather read a proper if-statement.
>
I agree that an "if" statement is by far more readble; I was referring
only to the dicussion of the "and-or trick", not the entire issue.

I meant to say that:

(thing and [thing+1] or [-1])[0]

is more readable (IMO) than:

thing != -1 and (thing and thing+1 or -1) or 0

- Tal

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to