Is it ok to use --> obj = object()?

A

aurora

Sometimes I find it useful to create an instance of some dummy class so
that I can bind abitrary attributes to it. I sometimes prefer this to
mapping object.



Rather that creating a dummy class, why not just instantiate from the
object class? However:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'x'


I know I must have misunderstood something. Can you tell me what was wrong?
 
M

M.E.Farmer

aurora said:
Sometimes I find it useful to create an instance of some dummy class so
that I can bind abitrary attributes to it. I sometimes prefer this to
mapping object.


Rather that creating a dummy class, why not just instantiate from the
object class? However:
I know I must have misunderstood something. Can you tell me what was wrong?

This is deja vu!
You really should do a search before asking this.
It was discussed just a few days ago.
The answer is you can't do that.
object() isn't bent like that.
The internals just aren't there.
It cannot be used as a 'Bunch'.
Just use classes.
HTH,
M.E.Farmer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,686
Latest member
scamivo

Latest Threads

Top