Getting a class name
Gabriel Genellina
gagsl-py at yahoo.com.ar
Mon Feb 19 00:11:33 EST 2007
More information about the Python-list mailing list
Mon Feb 19 00:11:33 EST 2007
- Previous message (by thread): Getting a class name
- Next message (by thread): Getting a class name
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
En Sun, 18 Feb 2007 20:56:48 -0300, Fuzzyman <fuzzyman at gmail.com> escribió: > [somebody] wrote: >> >>> > def getCodeName(deap=0): >> >>> > return sys._getframe(deap+1).f_code.co_name >> >> >>> > class MyClass (object): >> >>> > name = getCodeName() + '!' >> >> >>> What's the advantage over MyClass.__name__? >> > I were asking, why do you want a "name" attribute since "__name__" >> > already exists and has the needed information. And worst, using an >> > internal implementation function to do such task. >> >> This might be useful to avoid metaclass hacks when trying to initialize >> a class attribute that would require the class name. (my 2 cents) > > It's still an ugly hack. :-) > (But a nice implementation detail to know about none-the-less.) Having class decorators would be nice... -- Gabriel Genellina
- Previous message (by thread): Getting a class name
- Next message (by thread): Getting a class name
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list