New submission from Mark Dickinson <dicki...@gmail.com>:

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue7335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to