On 6/13/2017 2:42 PM, Barry Scott wrote:
I have been trying to get dir(c_ext_obj) to work for PyCXX as the method used 
with
python2 was removed in python3, namely use the list of names returned from
the __members__ attribute.

__members__ was deprecated about 15 years ago and gone from the stdlib before 2.7. The 2.7 doc says

"object.__members__
Deprecated since version 2.2: Use the built-in function dir() to get a list of an object’s attributes. This attribute is no longer available."

Ditto for __methods__. These were pre-2.2, pre type-class unification hacks. Only a few builtin types has a .__members__ for non-function data attributes.

I have failed to find a simple replacement for the python3 API.

It seems that I have implement __dir__.
But to do that I need to know what dir() will return and add the member 
variables to the answer.

dir includes __methods__ + __members__.

I have been able to figure out what is necessary to write such code.
No one on python users or python dev responded to an earlier query on this 
subject.

Framed in terms of something so ancient, the question makes no sense to most people. If you ask again, don't refer to __members__.

Would it be possible to simply put back the support for the __members__ 
attribute in python3?

No.

Perhaps you are looking for __dir__, called by dir().

" dir([object])

Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.

If the object has a method named __dir__(), this method will be called and must return the list of attributes."

--
Terry Jan Reedy


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to