Eric V. Smith <e...@trueblade.com> added the comment:

The problem is that type.__format__ doesn't exist, so object.__format__ is 
being called, and it throws an error if you provide a format spec. This is done 
for future expansion: if we do want to add type.__format__ in the future, we 
don't have to worry about existing cases that are using format specs that might 
not work with the new type.__format__.

No format spec is the same as calling str() on the argument and returning that, 
which is what is happening in your working examples.

If you want to apply a str formatting spec, you should covert the argument to a 
str first, using either !s or str():

>>> print('{a!s: >10}'.format(a=type(a)))
<class 'str'>
>>> print('{a: >10}'.format(a=str(type(a))))
<class 'str'>

----------
nosy: +eric.smith

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33410>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to