More random python observations from a perl programmer
Tom Christiansen
tchrist at jhereg.perl.com
Thu Aug 19 12:34:12 EDT 1999
>> How is that a singleton tuple?
>It's not. For format strings, if the item (here 4.5/100) is a single
>thing, the items need not be a tuple. i.e.
That's painfully inconsistent.
>> print "You have $%0.2f bucks" % (4.5/100,)
>> illegal,
>No, it's perfectly fine. Didn't try it, I guess.
No, I thought I had.
>> print "You have $%0.2f bucks" % ((4.5/100,) * 2)
>This, on the other hand is wrong since ((4.5/100,) * 2) yields (0.045,
>0.045) and you only have one formatting bit in the string (only 1
>%0.2f).
Typo.
>> mandatory? Was this (elt,) thing just an, er, unforeseen design
>> misfeature? Yes, I tripped me up again. :-(
>Try reading the docs...
Thanks for nothing: there are no manpages. I read the Lutz book.
You'll note that I even MENTIONED this issue in a gotcha.
It's just easy to get tripped up by the inconsistency.
You seem to be looking for a fight. Please say nothing
at all if that's all you want to do.
--tom
More information about the Python-list
mailing list