logo       

Re: how to obtain a (python) object's __name__ special attribute: msg#00262

python.c++

Subject: Re: how to obtain a (python) object's __name__ special attribute

--- Stefan Seefeld <seefeld@xxxxxxxxxxxx> wrote:
> I'v successfully read in a derived class definition from a python script
> into my C++ application, and I have instantiated it. How can I now determine
> the 'type name' of the object ? I try attr("__name__") but it appears
> the __name__ attribute isn't visible as an ordinary attribute, i.e. this
> call raises an exception.

The object should have __class__, which should have a __name__:

>>> l = list()
>>> l.__class__.__name__
'list'
>>> l.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'list' object has no attribute '__name__'
>>>

Could this be your problem?

Ralf


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise