There's a thread in the standard list (with this very Subject) that talks about implicit coercing with "%d" in strings replacement. jfouhy posted this example: >>> pow(2, 31) 2147483648L >>> '%d' % 2147483647.0 # python will convert to int '2147483647' >>> '%d' % 2147483648.0 # too big for an int, so error. Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: int argument required >>> '%d' % long(2147483648.0) # but yet, no trouble accepting a long. '2147483648' >>> '%d' % int(2147483648.0) # and int() converts to long anyway '2147483648' I think that here's a bug, but don't know where: Should %d accept only integer values? So this is a bug: >>> '%d' % 2147483647.0 '2147483647' Should %d accept also floats, and make the conversion? So there're two bugs: - In the doc (it's not explicited that it should accept a other data types) - In this behaviour difference: >>> '%d' % 2147483647.0 '2147483647' >>> '%d' % 2147483648.0 Traceback (most recent call last): ... TypeError: int argument required I really don't know about opening a bug, because I don't know which to open, :p . Facundo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20041112/929d3980/attachment.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4