Greetings, I've found what might be a bug in Python's % string formatting operator. Consider the following code: "%%(%s)=%%s" % "hello" On "Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin" this produces the string "%(hello)s=%s" which is what I'd expect. On "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32" this produces the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: not enough arguments for format string Note that this is the exact same revision running on the same machine, but it doesn't work for the win32 version and does work for the cygwin version. I wish I had time to track down the source of the problem and submit a patch. But unfortunately I need to get back to work, and I won't even have the free time after work to tackle this. So I figured I'd kick it off to the Python Dev list in case anyone deems this important enough to be worth their time. By the way, Python is my favorite language and I use it whenever possible and have even gotten some co-workers to start using it. Thanks for the great language! - Eli
On Mon, Oct 08, 2007, Eli Courtwright wrote:
I've found what might be a bug in Python's % string formatting operator. Consider the following code:
"%%(%s)=%%s" % "hello"
On "Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin" this produces the string "%(hello)s=%s" which is what I'd expect.
On "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32" this produces the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: not enough arguments for format string
Note that this is the exact same revision running on the same machine, but it doesn't work for the win32 version and does work for the cygwin version.
Please submit a bug report to http://bugs.python.org/ -- that way it won't get lost. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ The best way to get information on Usenet is not to ask a question, but to post the wrong information.
Eli Courtwright schrieb:
Greetings,
I've found what might be a bug in Python's % string formatting operator. Consider the following code:
"%%(%s)=%%s" % "hello"
On "Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin" this produces the string "%(hello)s=%s" which is what I'd expect.
There must be some confusion, because the above gives "%(hello)=%s"... are you sure you tried the same format strings on both versions? Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
2007/10/8, Eli Courtwright
On "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32" this produces the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: not enough arguments for format string
Please check it again, because in my machine... Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
"%%(%s)=%%s" % "hello" '%(hello)=%s'
If you still think that something is wrong somewhere, feel free to post a bug in the tracker: http://bugs.python.org/ Regards, -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/
Facundo Batista wrote:
2007/10/8, Eli Courtwright
: On "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32" this produces the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: not enough arguments for format string
Please check it again, because in my machine...
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
"%%(%s)=%%s" % "hello" '%(hello)=%s'
If you still think that something is wrong somewhere, feel free to post a bug in the tracker:
It even works on my Cygwin build: $ python Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type "help", "copyright", "credits" or "license" for more information.
"%%(%s)=%%s" % "hello" '%(hello)=%s'
I suspect the problem may lie somewhere else. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline so I couldn't cat it
participants (5)
-
Aahz
-
Eli Courtwright
-
Facundo Batista
-
Georg Brandl
-
Steve Holden