Message302510
getname sounds good, but is in fact very confusing. In most cases, what you'd actually want, and end up writing, is getname(type(x)), but we can't make it the default since for classes we would actually like x.__name__ directly. It seems you say the same with "get the names of various things (e.g. via `__class__`)", but the interface is very complicated if we try to guess what people meant, and clumsy if we force people to write type almost all the time.
The point is, we want to be explicit about whether we are speaking about x or type(x). Everything else is simply presentation details. type does it perfectly well, only the presentation details are canonically handled via str and repr. And it's perfectly natural, BTW. Imagine if str(5) gave you '<integer 5>'. :-o |
|
Date |
User |
Action |
Args |
2017-09-19 08:42:48 | veky | set | recipients:
+ veky, gvanrossum, ncoghlan, pitrou, vstinner, rbcollins, ezio.melotti, eric.araujo, eric.snow, martin.panter, serhiy.storchaka |
2017-09-19 08:42:48 | veky | set | messageid: <1505810568.52.0.0226470508799.issue13224@psf.upfronthosting.co.za> |
2017-09-19 08:42:48 | veky | link | issue13224 messages |
2017-09-19 08:42:48 | veky | create | |
|