Re: [Python-Dev] No __bases__ in dir()
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | In Py3k, dir() will allow any class to makes its instances special | cases by defining __dir__(). Nice. Then the current special case will become explainable as type.__dir__ excluding type's numerous attibutes, to avoid clutter, and we should have fewer discussions about what dir() 'ought' to return ;-) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] No __bases__ in dir()
On Sat, Mar 15, 2008 at 1:11 PM, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > This is because dir() special-cases classes, isn't it? > > Avoiding infinite recursion in dir(type) might be fun if that special > case was removed without due care and attention... I wasn't suggeting removing the special-casing -- rather I was explaining the observed behavior. In Py3k, dir() will allow any class to makes its instances special cases by defining __dir__(). -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] No __bases__ in dir()
Guido van Rossum wrote: > This is because dir() special-cases classes, isn't it? Avoiding infinite recursion in dir(type) might be fun if that special case was removed without due care and attention... Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://www.boredomandlaziness.org ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] No __bases__ in dir()
This is because dir() special-cases classes, isn't it? On Sat, Mar 15, 2008 at 11:09 AM, Christian Heimes <[EMAIL PROTECTED]> wrote: > > Why __bases__ does not appear in dir()? > > > > Is there a good reason for this or should I file a bug? > > __bases__ and several other methods like mro and __subclasses__ are > defined on the meta class. dir() doesn't list the attributes of the meta > class of a class. > > > >>> class C(object): > ... pass > ... > >>> dir(type(C)) > ['__base__', '__bases__', '__basicsize__', '__call__', '__class__', > '__cmp__', '__delattr__', '__dict__', '__dictoffset__', '__doc__', > '__flags__', '__getattribute__', '__hash__', '__init__', '__itemsize__', > '__module__', '__mro__', '__name__', '__new__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasses__', > '__weakrefoffset__', 'mro'] > > Christian > > > > ___ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] No __bases__ in dir()
> Why __bases__ does not appear in dir()? > > Is there a good reason for this or should I file a bug? __bases__ and several other methods like mro and __subclasses__ are defined on the meta class. dir() doesn't list the attributes of the meta class of a class. >>> class C(object): ... pass ... >>> dir(type(C)) ['__base__', '__bases__', '__basicsize__', '__call__', '__class__', '__cmp__', '__delattr__', '__dict__', '__dictoffset__', '__doc__', '__flags__', '__getattribute__', '__hash__', '__init__', '__itemsize__', '__module__', '__mro__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasses__', '__weakrefoffset__', 'mro'] Christian ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] No __bases__ in dir()
Hi! My head crashed into this: >>> class C(object): ...: pass ...: >>> >>> dir(C) ['__class__', ...] >>> C.__bases__ (,) Why __bases__ does not appear in dir()? Is there a good reason for this or should I file a bug? Thanks! -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com