More random python observations from a perl programmer

Andrew Csillag andrew at
Thu Aug 19 23:24:00 CEST 1999

Tom Christiansen wrote:
> >> 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.

No, just extremely convienent.  Why have to have a single item tuple for
a single item?  It's not that inconsistant, there are two options for
it:  either a single item, or a tuple of items (which may be one item). 
The only time I get tripped up by this is when I do things like:
    foo = "some format string %s" % b
and b turns out to be a tuple, but for me, at least, it happens
infrequently and is easily fixed by using a 1 item tuple instead:
    foo = "some format string %s" % (b,)
or since I'm using %s anyway,
    foo = "some format string %s" % str(b) 

> >>     print "You have $%0.2f bucks" % (4.5/100,)
> >> illegal,
> >No, it's perfectly fine.  Didn't try it, I guess.
Not an attack, just a clarification.

> 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. 
Manpages don't work very well if you're stuck on a Windows box :(.  If
only the world were Unix... <sigh>

There are the python manuals which are excellent, available at: (linked to from the homepage)
available in your choice of HTML, PostSript, PDF, Info, LaTeX and
windows help.

Not to mention that they're searchable via:

But for the most part, I usually don't need the search portal since the
indexes are really good.  But if you want a greppable form, there's Info
(although I don't like info in general, but info (both standalone and
emacs versions) does have the document search key 's'), HTML, and the
LaTeX versions grep quite well.

> I read the Lutz book.

I personally think that the Lutz book (the big thick one) isn't all that
great (sorry Mark).  Not an offence to you, I bought it also.  The
online tutorial:
last I looked is quite good.  The Learning Python book seems to be quite
a bit better.  The pocket reference is also quite handy.

> 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.

No, actually, just trying to help you out, so chill out alright?  I've
got better things to do then get in a flame war with you over nothing.

Jees, try to be nice and have to go and buy asbestos clothing!

"Programmers are just machines that convert coffee to executable code"

"Drew Csillag" <drew_csillag at>

More information about the Python-list mailing list