[Python-3000] PEP 3101 clarification requests

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Aug 22 02:11:50 CEST 2007


Eric Smith wrote:
> The problem is that if an object does does its own 
> __format__, it either needs to understand all of the string formatting, 
> or at least recognize a string format and send it along to 
> string.__format__() (or object.__format__, which will convert to string 
> for you).

No, all it needs to do is tell when it *doesn't*
recognise the format and call its inherited __format__
method. Eventually that will get to object.__format__
which will delegate to str.

> Note the collision with the 's' format_spec in this example.

I'd say you should normally design your format specs
so that they don't conflict with string formats.

If you want to implement the string formats your own
way, that's okay, but then it's your responsibility
to support all of them.

--
Greg


More information about the Python-3000 mailing list