Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

I think we need to handle only two cases: short and fully qualified names. 
__qualname__ without __module__ doesn't make sense, and the value of tp_name 
depends on implementation details (is it Python class or builtin class, heap 
class or dynamic class?). Maybe use %t and %T?

But we may want to support formatting the name of the type itself and the name 
of the object's type. This give us 4 variants.

For old string formatting we can introduce new % codes (with possible 
modifiers). But in modern string formatting "T" can have meaning for some types 
(e.g. for datetime). We can implement __format__ for the type type itself 
(though it can cause confusion if cls.__format__() is different from 
cls.__format__(instance)), but for formatting the name of  the object's type 
(as in your original proposition) we need to add a new  conversion flag like 
"!r".

----------

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

Reply via email to