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

Jennie nameDOTportua at gmail.com
Sat Oct 20 07:19:05 EDT 2012


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



More information about the Python-list mailing list