[New-bugs-announce] [issue33410] Using type in a format with padding causes TypeError

alex report at bugs.python.org
Wed May 2 10:22:10 EDT 2018


New submission from alex <alex.payne22 at gmail.com>:

When trying to print a type in a formatted string with padding TypeError is raised. See examples below.

These work:
>>> a = 'abc'
>>> print('{a}'.format(a=type(a)))
<class 'str'>
>>> print('{a}'.format(a=str(type(a))))
<class 'str'>

These don't:
>>> print('{a: >10}'.format(a=type(a)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to type.__format__
>>> t = type(a)
>>> print('{a: >10}'.format(a=t))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to type.__format__

----------
messages: 316072
nosy: alexomics
priority: normal
severity: normal
status: open
title: Using type in a format with padding causes TypeError
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33410>
_______________________________________


More information about the New-bugs-announce mailing list