Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7335] int/long discrepancy when formatting zero with ".0d"

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 16, 2009, 10:28 AM

Post #1 of 1 (146 views)
Permalink
[issue7335] int/long discrepancy when formatting zero with ".0d"

New submission from Mark Dickinson <dickinsm [at] gmail>:

In Python 2.x we have:

>>> "%.0d" % 0
''
>>> "%.0d" % 0L
'0'

In Python 3.x:

>>> "%.0d" % 0
'0'

I think the 2.x behaviour for int comes directly from C's sprintf
behaviour: section 7.19.6.1, p8 of the C99 standard says:

"The result of converting a zero value with a precision of zero is no
characters."

I'm not sure which the more sensible behaviour is, but in 2.x, int and
long should behave in the same way. Fixing long to behave like int
seems both simplest and least likely to break existing code.

----------
components: Interpreter Core
messages: 95356
nosy: eric.smith, mark.dickinson
priority: normal
severity: normal
status: open
title: int/long discrepancy when formatting zero with ".0d"
type: behavior
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.