[Python-ideas] Restore the __members__ behavior to python3 for C extension writers

Thomas Jollans tjol at tjol.eu
Mon Jun 19 03:37:44 EDT 2017

On 2017-06-18 20:10, Barry Scott wrote:
> What is the way to tell python about 'value' in the python3 world? 

Implement a __dir__ method. This should call the superclass' (e.g.
object's) __dir__ and add whatever it is you want to add to the list.

In general I'd recommend using properties for this kind of thing rather
than messing with __getattr__, __setattr__ and __dir__, especially in
pure Python. I'm no expert on the C API, but I think this should be
possible by setting PyTypeObject.tp_getset

-- Thomas

More information about the Python-ideas mailing list