Message189068
| Author |
Yogesh.Chaudhari |
| Recipients |
Ankur.Ankan, Arfrever, Yogesh.Chaudhari, asvetlov, eric.smith, flox, krinart, python-dev, terry.reedy |
| Date |
2013年05月12日.22:06:22 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1368396382.88.0.0798872466725.issue9856@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
>It's this case that is currently an error, but it need not be:
>>>> format(object(), '1')
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>TypeError: non-empty format string passed to object.__format__
I believe that should continue to remain an error. Please note that this works
>>> format(object(), '')
'<object object at 0xb74fd688>'
From what I can tell, specifying '1' or '2' or '100' makes no sense because unlike string or int (and like list or tuple ) this 'number' does not represent anything sensible.
This works fine as it should:
>>> format('q', '5')
'q '
>>> format(1, '5')
' 1'
>>> format(1, '05')
'00001'
>>>
But this does not and IMHO *should* not 'work'
>>> format([1,2,3], '5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-empty format string passed to object.__format__
>>> format((1,2,3), '5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-empty format string passed to object.__format__
an object() CANNOT have specific behavior like str or int. You can of-course argue as to what kind of error/exception/warning this may raise, but it does not make any sense (AFAIK) to 'fix' this. |
|