using an instance of Object as an empty class
AlienBaby
matt.j.warren at gmail.com
Wed Jun 29 06:51:40 EDT 2011
More information about the Python-list mailing list
Wed Jun 29 06:51:40 EDT 2011
- Previous message (by thread): Attribute Error in xml.sax.saxutils.XMLGenerator on Arch Linux (64bit)
- Next message (by thread): using an instance of Object as an empty class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, I'm just wondering why something is so, and whats going on under the hood. Now and again I use something like class empty(object): pass simply so I can make an instance, and set some attributes on it. a=empty() a.whatever=something Poking around with this, I assumed I could instead say a=object() a.whatever=something but I get an attribute error. 'object object has no attribute whatever' I tried setattr() but get the same result. So, it seems to me there is something special about instances of object, and making an empty class that inherits from object, or creating an instance of that class, is doing some 'magic' somewhere that enables setting attributes etc.. Whats actually going on here, and why? Matt.
- Previous message (by thread): Attribute Error in xml.sax.saxutils.XMLGenerator on Arch Linux (64bit)
- Next message (by thread): using an instance of Object as an empty class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list