This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python 2.6 Printing Error
Type: Stage:
Components: IO Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mesheb82
Priority: normal Keywords:

Created on 2012-04-26 17:37 by mesheb82, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg159403 - (view) Author: mesheb82 (mesheb82) Date: 2012-04-26 17:37
I’m running:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32

I was testing out some print functionality and I made an error in typing (I meant to use %8.8f), but is this behavior intentional or is it an error?
>> print '%8.8s' %(10000000001.)
>> '10000000'


I would expect this to return a TypeError.

I also tested this on Python 2.4 and Python 2.5 on linux and had the same behavior.

Steve
msg159409 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-04-26 18:01
The "s" causes the argument to be converted to a string, then the formatting is applied. So it's working as designed.

This is the logical equivalent of:
'%8.8s' % str(10000000001.)
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58882
2012-04-26 18:01:33eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg159409

resolution: not a bug
2012-04-26 17:37:43mesheb82create