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

Mailing List Archive: Python: Bugs

[issue15660] In str.format there is a misleading error message about alignment

 

 

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


report at bugs

Aug 14, 2012, 9:20 PM

Post #1 of 6 (241 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment

New submission from py.user:

>>> '{:02}'.format('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: '=' alignment not allowed in string format specifier
>>>


according to http://docs.python.org/py3k/library/string.html#formatspec
the default alignment is '<' or '>'

----------
components: Interpreter Core
messages: 168258
nosy: py.user
priority: normal
severity: normal
status: open
title: In str.format there is a misleading error message about alignment
type: behavior
versions: Python 3.2

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


report at bugs

Aug 14, 2012, 9:22 PM

Post #2 of 6 (237 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment [In reply to]

Changes by Ezio Melotti <ezio.melotti [at] gmail>:


----------
nosy: +eric.smith, ezio.melotti
stage: -> needs patch
versions: +Python 2.7, Python 3.3, Python 3.4

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


report at bugs

Aug 14, 2012, 9:27 PM

Post #3 of 6 (237 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment [In reply to]

py.user added the comment:

found a small string in the doc about zero padding, which enables alignment equal to =

----------
versions: -Python 2.7, Python 3.3, Python 3.4

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


report at bugs

Aug 17, 2012, 12:13 PM

Post #4 of 6 (230 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment [In reply to]

Terry J. Reedy added the comment:

As I read the docs, the error message is correct and this issue is invalid as a behavior issue. I read the OP's second message as more or less saying this also.

"'=' Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form ‘+000000120’. This alignment option is only valid for numeric types."

"If the width field is preceded by a zero ('0') character, this enables zero-padding. This is equivalent to an alignment type of '=' and a fill character of '0'."

So ":02" is equivalent to ":0=2", which is invalid.

>>> '{:02d}'.format(1)
'01'
works fine.

I decided make this a doc issue and add " for numeric types" after "this enables zero-padding" before closing this.

----------
assignee: -> docs [at] pytho
components: +Documentation -Interpreter Core
nosy: +docs [at] pytho, terry.reedy
versions: +Python 2.7, Python 3.3

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


report at bugs

Aug 17, 2012, 12:42 PM

Post #5 of 6 (234 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment [In reply to]

Roundup Robot added the comment:

New changeset 85cd54b2d3a1 by Terry Jan Reedy in branch '2.7':
Issue 15660: Clarify 0 prefix for width field in str.format doc.
http://hg.python.org/cpython/rev/85cd54b2d3a1

New changeset 6bc14974024f by Terry Jan Reedy in branch '3.2':
Issue 15660: Clarify 0 prefix for width field in str.format doc.
http://hg.python.org/cpython/rev/6bc14974024f

New changeset f181dd088e63 by Terry Jan Reedy in branch 'default':
Merge with 3.2 #15660
http://hg.python.org/cpython/rev/f181dd088e63

----------
nosy: +python-dev

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


report at bugs

Aug 17, 2012, 12:43 PM

Post #6 of 6 (234 views)
Permalink
[issue15660] In str.format there is a misleading error message about alignment [In reply to]

Changes by Terry J. Reedy <tjreedy [at] udel>:


----------
resolution: -> fixed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15660>
_______________________________________
_______________________________________________
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.