Represent object type as

Jason jason.heeris at
Fri Mar 26 01:49:30 CET 2010

On Mar 26, 12:00 am, Bruno Desthuilliers <bruno.
42.desthuilli... at websiteburo.invalid> wrote:
>            attrs['type'] = type(self)
> Do the same thing with less work !-)

Ah, silly me :P

>      attrs['__typename__'] = type(self).__name__

That's exactly what I needed — I was not aware of the "__name__"

> Warning: won't be very useful if your code still uses old-style classes.

No, all the objects are new-style classes so that's fine.

> Depends on what you do with this dict, DBUS etc. And of your definition
> of "better", of course.

Simplest possible :P But this looks like it, so thanks very much :)


More information about the Python-list mailing list