Message341355
Python 2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:^10}'.format(None))
None
However this does not work with Python3:
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:^10}'.format(None))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to NoneType.__format__
Given that the None type is output as a string, it makes sense for string formatting options to be usable with it. It also makes code less fragile and avoids having to write special cases for when values
could be None. |
|
Date |
User |
Action |
Args |
2019-05-03 20:30:35 | Gawain Bolton | set | recipients:
+ Gawain Bolton |
2019-05-03 20:30:35 | Gawain Bolton | set | messageid: <1556915435.58.0.661540149736.issue36787@roundup.psfhosted.org> |
2019-05-03 20:30:35 | Gawain Bolton | link | issue36787 messages |
2019-05-03 20:30:35 | Gawain Bolton | create | |
|