Nicola Ferrari wrote:

>     Se incontri qualche caratteristica gia' presente in linguaggi che gia'
>     conosci, stai particolarmente attento e non saltare parti del
>     tutorial,
>     perche' potresti avere delle sorprese.
>
>
> Nel tutorial, se erroneamente non ho saltato parti, non mi era 
> capitato di trovare questa "forma ridotta"

Vero, nel tutorial non c'e', e' nella reference:

http://docs.python.org/reference/expressions.html#boolean-operations

Pero' scusa se insisto, non si chiama "forma ridotta". Il blocco 
"if...then..else" non e' un operatore, non e' utilizzabile come 
espressione, puo' contenere statement, etc.

Le alternative di "b if a else c" sono, semmai:
 - a and b or c
 - [b,c][not a]

con la differenza che nell'operatore ternario non vengono mai valutati 
entrambi i valori b e c

E' un bene che non sia nel tutorial, perche' e' brutto.
Utile pero' in contesti in cui non puoi utilizzare statement, come il 
markup XML:

<ul>
  <li py:for="user in context.users()">
    ${user.ragione_sociale if user.piva else user.nome}
  </li>
</ul>


-- 
This e-mail (and any attachment(s)) is strictly confidential and for use only 
by intended recipient(s). Any use, distribution, reproduction or disclosure by 
any other person is strictly prohibited. The content of this e-mail does not 
constitute a commitment by the Company except where provided for in a written 
agreement between this e-mail addressee and the Company. If you are not an 
intended recipient(s), please notify the sender promptly and destroy this 
message and its attachments without reading or saving it in any manner. Any non 
authorized use of the content of this message constitutes a violation of the 
obligation to abstain from learning of the correspondence among other subjects, 
except for more serious offence, and exposes the person responsible to the 
relevant consequences.

_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a