[issue22790] some class attributes missing from dir(Class)

2021-03-27 Thread Siddharth Chabra
Change by Siddharth Chabra : -- nosy: +siddharthchabra versions: -Python 3.10, Python 3.8, Python 3.9 ___ Python tracker ___ ___

[issue22790] some class attributes missing from dir(Class)

2021-03-07 Thread Eryk Sun
Eryk Sun added the comment: >> Why are __flags__, __basicsize__, __itemsize__, >>__dictoffset__, and __weakrefoffset__ interesting? > > I haven't said they are, but on the other hand I don't see > why consistency is a bad thing. IMO, they're not interesting because they're not documented

[issue22790] some class attributes missing from dir(Class)

2015-07-21 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- nosy: -ethan.furman ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___ ___ Python-bugs-list

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: @Amaury: this is not what I read there: If the object is a type or class object, the list contains the names of its attributes, and recursively of the attributes of its bases. This implies that class attributes are definitely supposed to be in there.

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Sam Bishop
Sam Bishop added the comment: I specified 'during class initialisation' because that was the only case I confirmed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: The missing attributes are some of those defined in type_getsets, i.e. __name__ __qualname__ __bases__ __abstractmethods__ __text_signature__ The latter two are obscure enough that it probably doesn't matter, but the first three should definitely be there.

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: Ah yes, and some type_members are also missing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___ ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread eryksun
eryksun added the comment: You won't find the __qualname__ data descriptor in dir(Foo.Bar) because it's defined by the metaclass, `type`. Attributes from the metaclass have always been excluded from the dir() of a class. -- nosy: +eryksun ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread eryksun
eryksun added the comment: See type_dir: https://hg.python.org/cpython/file/ab2c023a9432/Objects/typeobject.c#l2984 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: Attributes from the metaclass have always been excluded from the dir() of a class. Be that as it may, I think it is wrong. I can understand excluding methods of the metaclass, but __qualname__ (and friends) are only defined in the metaclass because they are

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: BTW, the same implementation detail means that you can ask an instance for its class' __module__, but not the __name__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: However, it may not be possible to change this for backward compatibility reasons. People shouldn't be using dir() for determining attributes and the like, but they do, as documented by the multiprocessing module in the stdlib. This should at least be noted

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: I definitely think this should be changed. I just don't know how to do it :-) -- stage: - needs patch versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___ ___ Python-bugs-list

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: Attaching prototype patch without test suite adjustments. -- keywords: +patch Added file: http://bugs.python.org/file37126/type_dir_patch.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: I have a question: why would do it for classes and not for regular objects? -- assignee: docs@python - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ah, I misunderstood the patch, sorry. Nevermind. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___ ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: Basically beacuse with the current patch, this is because object_dir also does merge_class_dict, to get class attributes. This means that attributes like __qualname__ would show up in dir(instance), but are not actually available on the instance. Fixing this

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- Removed message: http://bugs.python.org/msg230614 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790 ___

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread eryksun
eryksun added the comment: __doc__ and __module__ are also getsets (to support built-in types), but it's nothing to worry about since the attributes can't be deleted. I think the most value added here is for listing __mro__ and the others that Georg mentioned. Should the following attributes

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Arfrever Frehtes Taifersar Arahesis
Arfrever Frehtes Taifersar Arahesis added the comment: __base__ exists also in Jython and PyPy (#22456). I think that all attributes could be listed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22790

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: So, dir(C) contains '__mro__', but not 'mro'? I'm -1 on the change. From https://docs.python.org/3.4/library/functions.html#dir : Note Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: So, dir(C) contains '__mro__', but not 'mro'? That can be discussed. But I would argue that at least __name__, __bases__ and __qualname__ are interesting attributes for the user. Same for methods like __subclasses__(). Otherwise, it's quite ironic to prevent

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Ethan Furman
Ethan Furman added the comment: Why are __flags__, __basicsize__, __itemsize__, __dictoffset__, and __weakrefoffset__ interesting? I agree with Georg about the others. -- nosy: +ethan.furman ___ Python tracker rep...@bugs.python.org

[issue22790] some class attributes missing from dir(Class)

2014-11-04 Thread Georg Brandl
Georg Brandl added the comment: Why are __flags__, __basicsize__, __itemsize__, __dictoffset__, and __weakrefoffset__ interesting? I haven't said they are, but on the other hand I don't see why consistency is a bad thing. -- ___ Python tracker