➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 eric.smith
收信人 BreamoreBoy, eric.smith, ezio.melotti, flox, hct, mark.dickinson, meador.inge, python-dev, r.david.murray
日期 2014-03-20.00:47:28
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1395276449.1.0.669210727474.issue7994@psf.upfronthosting.co.za>
In-reply-to
内容
BreamoreBoy:

This is basically the definition of object.__format__:

def __format__(self, specifier):
  if len(specifier) == 0:
    return str(self)
  raise TypeError('non-empty format string passed to object.__format__')

Which is why it works for an empty specifier.



As a reminder, the point of raising this type error is described in the first message posted in this bug. This caused us an actual problem when we implemented complex.__format__, and I don't see object.__format__ changing.

Implementing NoneType.__format__ and having it understand some string specifiers would be possible, but I'm against it, for reasons I hope I've made clear.


As to why None.__format__ appears to be implemented, it's the same as this:

>>> class Foo: pass
... 
>>> Foo().__format__
<built-in method __format__ of Foo object at 0xb74e6a4c>

That's really object.__format__, bound to a Foo instance.
历史
日期 用户 动作 参数
2014-03-20 00:47:29eric.smith修改recipients: + eric.smith, mark.dickinson, ezio.melotti, r.david.murray, flox, meador.inge, BreamoreBoy, python-dev, hct
2014-03-20 00:47:29eric.smith修改messageid: <1395276449.1.0.669210727474.issue7994@psf.upfronthosting.co.za>
2014-03-20 00:47:29eric.smith链接issue7994 messages
2014-03-20 00:47:28eric.smith创建