Il giorno ven, 09/10/2009 alle 09.14 +0200, Nicola Ferrari ha scritto: > ... non ho capito se la tua era una domanda "provocatoria", ma credo > non sia possibile .... > Non penso si riesca a "mescolare" assegnazione e print... o sbaglio?!
appunto... era per mostra che non è un "modo alternativo" di fare if...then...else, come altri meglio di me ti hanno illustrato ciao Pietro > > Il giorno 09 ottobre 2009 08.53, Pietro Battiston <too...@email.it> ha > scritto: > Il giorno ven, 09/10/2009 alle 08.38 +0200, Nicola Ferrari ha > scritto: > > In questo caso si tratta di un operatore ternario, > simile > > al ?: presente > > in altri linguaggi (Java, C, Javascript, Perl) e non > e' un > > modo > > alternativo di esprimere il costrutto "if.. then.. > elif.. > > else" > > > > Non è un modo alternativo? > > Nell'esempio che ho citato, non è come scrivere > > > > if val==1: > > print 'prova' > > else: > > print 'aaaa' > > > in questo caso sì, ma prova un po' a tradurci questo codice: > > if val==1: > print 'prova' > else: > > val=1 > > > > ciao > > Pietro > > > > > > ???? > > > > 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" > > > > > > 2009/10/8 Marco Mariani <marco.mari...@prometeia.it> > > Nicola Ferrari wrote: > > > > > val = 1 > > > print ('prova' if vall==1 else 'aaa') > > > > > > Dove posso trovare le spiegazioni di tutte le > "forme > > ridotte"? > > > > > > Non esistono "forme ridotte" o abbreviazioni come in > COBOL :) > > > > In questo caso si tratta di un operatore ternario, > simile > > al ?: presente > > in altri linguaggi (Java, C, Javascript, Perl) e non > e' un > > modo > > alternativo di esprimere il costrutto "if.. then.. > elif.. > > else" > > > > > > > Questa forma ridotta l'ho capita, ma vorrei capire > se ce ne > > sono altre > > > ed eventualmente impararle =) =) > > > > > > Ti conviene leggere il tutorial ufficiale, e' > scritto bene e > > abbastanza > > completo. > > > > 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. > > > > > > -- > > 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 > > > > > > > > -- > > Nicola Ferrari > > website: http://www.nicolaferrari.name > > > > skype: nick.ferro > > > > _______________________________________________ > > Python mailing list > > Python@lists.python.it > > http://lists.python.it/mailman/listinfo/python > > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > > > > > -- > Nicola Ferrari > website: http://www.nicolaferrari.name > > skype: nick.ferro > > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python