[Python] python - forma "ridotta"

Lawrence Oluyede l.oluyede a gmail.com
Ven 9 Ott 2009 16:48:33 CEST


2009/10/9 Marco Beri <marcoberi a gmail.com>:
> Ricordo che l'orrido operatore ternario, per essere precisi, era questo:
>
>>>> (a and [b] or [c])[0]
>
> Altrimenti se b era per esempio 0 o None, ti tornava c anche in presenza di
> un valore True di a.

Faccio finta di non avere del codice fatto cosi`:

("a", "b")[c=='d']

:P

-- 
Lawrence Oluyede
[eng] http://oluyede.org - http://twitter.com/lawrenceoluyede
[ita] http://neropercaso.it - http://twitter.com/rhymes
[flickr] http://www.flickr.com/photos/rhymes


Maggiori informazioni sulla lista Python