✘Python broken %

Gary E. Miller gem at rellim.com
Fri Sep 9 05:05:59 UTC 2016


Yo All!

Yet another undocumented Python failure:

i>>> d = {}
>>> d[1] = "one"
>>> d[2] = "two"
>>> str(d[2])
'two'
>>> echo "%s(d[2])s" % locals
  File "<stdin>", line 1
    echo "%s(d[2])s" % locals
                   ^
SyntaxError: invalid syntax


Python says %s(x)s works for any x that str(x) works.

Here is the Python doc:

https://docs.python.org/2.7/library/stdtypes.html#string-formatting

"'s' 	String (converts any Python object using str())."

WRONG!

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ntpsec.org/pipermail/devel/attachments/20160908/d00c0f9e/attachment.bin>


More information about the devel mailing list