Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Suggested coding style
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="rantingrick, post: 4248594"] py> "{0:-010d}".format(-1234) '-000001234' My point was: Use the {char}{repeat}d format for integers and the {char}{<|>|=}{repeat} for strings. Problem solved. No more need for zfill. py> "{0:0>10}".format(-1234) '00000-1234' What result would you expect from that string argument? I think it behaves as anyone would expect. If you have a str and you want it interpreted as a negative integer then cast it. py> "{0:010d}".format(int("-1234")) '-000001234' If you would like for the spec to handle the case of integers and strings transparently then you need to lobby to have the API changed. Maybe they could add a !i like the !s and !r which would be explicit. However, i don't think implicit coercion of strings to integers is a good idea. Using the int function or !i removes and ambiguities. For me, the spec works just fine as is. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Suggested coding style
Top