classification
Title: Make member objects inspectable.
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: pablogsal, rhettinger
Priority: normal Keywords: easy (C)

Created on 2020-04-14 01:12 by rhettinger, last changed 2020-04-15 08:42 by rhettinger. This issue is now closed.

Messages (3)
msg366356 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-14 01:12
Given:

    class A:
        __slots__ = ['x', 'y', 'z')

    mo = vars(A)['x']

The field number should be viewable:

    >>> mo.offset
    0

And the __repr__ should be:

    >>> mo
    <member 'x' at slot_offset 0 of 'A' objects>
msg366492 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-04-15 08:10
What should this return?

>>> class A:
...   __slots__ = ['x', 'y', 'z']
...
>>> class B(A):
...   __slots__ = ['g','i']
...


>>> B.x.offset
msg366497 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 08:42
Good point.  I'll withdraw this.
History
Date User Action Args
2020-04-15 08:42:42rhettingersetstatus: open -> closed

messages: + msg366497
stage: resolved
2020-04-15 08:10:53pablogsalsetnosy: + pablogsal
messages: + msg366492
2020-04-14 01:12:01rhettingercreate