[Neal Norwitz] > The intent was to convert an int/long to a double in the case of > '%g' et al and from a double to an int in the case of '%d'. [Greg Ewing] > Are you sure the latter part of that is a good idea? As a general > principle, I don't think float->int conversions should be done > automatically. What is the Python philosophy on that? The philosophy for format codes is looser than elsewhere, else, e.g., "%s" % object would raise TypeError whenever object was a number or list, etc. I've often used %d with floats when I want them rounded to int and don't want to bother remembering how to trick a float format into suppressing the decimal point. Unfortunately, that's not quite what %d does (it truncates). Whatever, %s is like invoking str(), %r like invoking repr(), %d like invoking long(), and %g/e/f like invoking float() (although these are variants of long() and float() that refuse string arguments -- that's the exception that makes the rule easy to remember <wink>).
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