Using 2.6, what I saw was that I had to ask for __bases__ from the __class__ attribute of my object. So given your example, I'd check:
c.__class__.__bases__[0].__name__ And for the immediate superclass, this also seems to work: c.__class__.__base__ Chris Hunter chun...@wondertwinpowers.net On Sat, Feb 20, 2010 at 4:34 PM, Timothy Kinney <timothyjkin...@gmail.com>wrote: > This is strange. When I duplicate your code, thanos, I get an error that > says: > AttributeError: SubClass instance has no attribute '__bases__' > > What's different about my setup? > I'm running Python 2.5.3 > > -Tim > > > > On Fri, Feb 19, 2010 at 6:43 PM, thanos <than...@gmail.com> wrote: > >> How about: >> >> >>> class MySuperClass: pass >> ... >> >>> class MySubClass(MySuperClass): pass >> ... >> >>> c = MySubClass >> >>> >> >>> c.__bases__[0].__name__ >> 'MySuperClass' >> >>> >> >> What I always ask develoeprs hwo join my team is "Please read the >> Language Reference!" Its a great read, I'm not joking and your answer >> is there some where under Data Model. >> >> >> Thanos >> >> >> >> >> >> On Feb 19, 5:51 pm, Joel Stransky <j...@stranskydesign.com> wrote: >> > Bit of a python question here. >> > Say I have a class named MySuperClass and an extension of that class >> called >> > MySubClass. When referring to MySubClass (the class, not an instance of >> it), >> > how would I retrieve the class name of its super class. >> > >> > For instance if I had: >> > c = MySubClass >> > >> > I'd like to know if there is a method that would work to the effect of: >> > b = superclassname(c) >> > which would return MySuperClass >> > >> > Thanks. >> > >> > -- >> > --Joel Stransky >> > stranskydesign.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.