format sring question
lkirsh at cs.ubc.ca
Sat Sep 4 01:02:30 CEST 2004
thanks to both of you. bye bye second version.
Lowell Kirsh wrote:
> In Peter Norvig's Infrequently Answered Questions he explains that the
> following 2 fnctions look almost identical but are not the same:
> def printf(format, *args): print format % args,
> def printf(format, *args): print str(format) % args,
> The only difference is that in the second one, str(format) replaces
> format. If args are not given and the format string contains a '%', the
> first will work but the second will not. Why is this so? It seems to me
> like '100%' and str('100%) are the same object, no?
More information about the Python-list