On Fri, Aug 07, 2020 at 12:22:28PM +1200, Greg Ewing wrote:
On 7/08/20 2:47 am, David Mertz wrote:
The only difference is that in the usual existing style, 'a' doesn't know that it's called "a". You and Steven have both, basically, said "Why would you possibly care about that?"
I've only really been thinking about attributes, but I suppose it might be useful for things in other contexts to know their names, so I guess my original proposal is not completely dead. But I don't have any real-world use case to put forward.
The classic example is namedtuple:
myrecord = namedtuple("myrecord", ...)
The three-argument form of type() also needs a name argument.
On the other hand, it is arguable that the status quo is more flexible, as you don't have to pass the same class name as the variable name you bind to.