[Tutor] Newline

Alex Hall mehgcap at gmail.com
Sat Dec 4 16:50:02 CET 2010


On 12/4/10, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "Steven D'Aprano" <steve at pearwood.info> wrote
>
>> >>> for i in (1, 2, 3):
>> ...     print(i, "spam", end="\n" if i==3 else "***")
>
> Ooooh! A new trick.
> I hadn't thought of using the conditional expression there but it
> makes a lot of sense.
> Definitely more fun and flexible than the old comma at the end of a
> print in v2 :-)
So is this a python3.x feature only? Is there an equivallent in 2.x? I
had not realized if statements could be used in calling functions like
that or that they could be arranged in that way, but I am sticking to
python2 since most packages are still written for it.
>
> Thanks for that,
>
> Alan G.
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list