helper function in a class' namespace
Arnaud Delobelle
arnodel at googlemail.com
Thu Jan 31 17:45:51 EST 2008
On Jan 31, 10:39 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Thu, 31 Jan 2008 20:05:44 +0000, Stargaming wrote:
> > String concatenation is generally considered unpythonic, better use
> > string interpolation::
>
> > 'H> %s' % (M,)
[...]
> Also, the tuple above is totally unnecessary. 'H> %s' % M will work fine.
...except if M is a tuple:
>>> M = 'spam', 'eggs'
>>> 'H> %s' % (M,)
"H> ('spam', 'eggs')"
>>> 'H> %s' % M
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
Pedantically yours,
--
Arnaud
More information about the Python-list
mailing list