Christian Lyra wrote:
>> I realised this... :)
>>
>> from pprint import pformat
>> print pformat(item)
>> I have done this in a few of the media item modules so a:
>> print '%s' % item
>> may show you what you need.
>>
> pformat only shows this:
> <CD-1 [Artes_Marciais_1]: <class directory.DirItem at 0xb53e6f5c>>

Looks like the __repr__ function is being printed, the __str__ function
is called when a print '%s' is used.

> but a if hasattr(item, 'id'): print item['id'] did the trick.  Maybe
> this is a elementary python question, but how to print all the
> attributes a class has?

There are two ways, either dir(item) or item.__dict__, they are a bit
different.

>> CDs and DVDs do have a unique id, so item['id'] may report the value.
> 
> ah.. now I see..

Took me ages to see what was going on and I still don't know all of it.

Duncan


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to