Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31803
| Date | 2012-10-20 10:59 +0200 |
|---|---|
| From | Jennie <marco.buttu@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to see the __name__ attribute of a class by using dir() |
| References | <k5tm0k$sph$1@speranza.aioe.org> <mailman.2554.1350721484.27098.python-list@python.org> |
| Message-ID | <mailman.2555.1350723588.27098.python-list@python.org> (permalink) |
On 10/20/2012 10:24 AM, Peter Otten wrote: > So if you want to customise dir(Foo) you have to modify the metaclass: > >>>> >>>class Foo: > ... class __metaclass__(type): > ... def __dir__(self): return ["python"] > ... >>>> >>>dir(Foo) > ['python'] > > Hi Peter, thanks for your answer, but it does not work (Python 3.3): >>> class Foo: ... class __metaclass__(type): ... def __dir__(self): return ["python"] ... >>> dir(Foo) ['__class__', '__delattr__', '__dict__', '__dir__', ...] Regards, -- Jennie
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to see the __name__ attribute of a class by using dir() Jennie <nameDOTportua@gmail.com> - 2012-10-20 10:05 +0200
Re: How to see the __name__ attribute of a class by using dir() Peter Otten <__peter__@web.de> - 2012-10-20 10:24 +0200
Re: How to see the __name__ attribute of a class by using dir() Jennie <nameDOTportua@gmail.com> - 2012-10-20 10:59 +0200
Re: How to see the __name__ attribute of a class by using dir() Peter Otten <__peter__@web.de> - 2012-10-20 11:43 +0200
Re: How to see the __name__ attribute of a class by using dir() Jennie <nameDOTportua@gmail.com> - 2012-10-20 13:19 +0200
Re: How to see the __name__ attribute of a class by using dir() Jennie <marco.buttu@gmail.com> - 2012-10-20 13:19 +0200
Re: How to see the __name__ attribute of a class by using dir() Jennie <marco.buttu@gmail.com> - 2012-10-20 10:59 +0200
csiph-web