How to display name of elements in list?

Diez B. Roggisch deets at nospam.web.de
Wed Jul 12 10:00:56 EDT 2006


cz wrote:

>> The list above is not a valid Python list. What is it that you store in
>> that list?
>>
>> Or is it maybe a dictionary?
>>
>> Stefan
> 
> Thanks for your help. How can I find out about what this is? As I said
> it's generated by a insufficiently documented module. So if this is a
> user defined datatype, is there still a possibility to find the name of
> the data fields storing the xx, xy, ... ?

I guess the objects stored in the list have a __repr__-method overloaded
that produces the text you see. 

What you should do is to install rlcompleter2, fire up a python prompt and
write code that produces a list of your objects. Then you can play around
with the objects and utilize the reflection capabilities of python, which
are conveniently exposed using rlcompleter2.

Another option is to look into the source of that module and identify the
objects created. Documentation is overrated - use the source, Luke!

Diez



More information about the Python-list mailing list