Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31808

Re: How to see the __name__ attribute of a class by using dir()

From Jennie <nameDOTportua@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to see the __name__ attribute of a class by using dir()
Date 2012-10-20 13:19 +0200
Organization Aioe.org NNTP Server
Message-ID <508288A9.807@gmail.com> (permalink)
References <k5tm0k$sph$1@speranza.aioe.org> <mailman.2554.1350721484.27098.python-list@python.org> <508267F8.5030302@gmail.com> <mailman.2557.1350726214.27098.python-list@python.org>

Show all headers | View raw


On 10/20/2012 11:43 AM, Peter Otten wrote:

> In Python 3 the way to specify the metaclass has changed:
>
>>>> class FooType(type):
> ...     def __dir__(self): return ["python"]
> ...
>>>> class Foo(metaclass=FooType):
> ...     pass
> ...
>>>> dir(Foo)
> ['python']

Thanks! :)


-- 
Jennie

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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