473,497 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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.

class A: pass .... a = A()
a.x = 1
class B(object): pass .... b = B()
b.x = 1

Rather that creating a dummy class, why not just instantiate from the
object class? However:
obj = object()
obj.x = 1

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?
Jul 18 '05 #1
1 1296
aurora <au******@gmail.com> wrote in message
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.
class A: pass ... a = A()
a.x = 1 class B(object): pass ... b = B()
b.x = 1
Rather that creating a dummy class, why not just instantiate from the
object class? However:
obj = object()
obj.x = 1

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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
6907
by: keweiming | last post by:
I have a project which needs to open hundreds to thousands of files for writing. The following is a simplified test program I wrote to see if I can use a map<string, ofstream> object to keep the...
3
7704
by: Pete Wilson | last post by:
How can I highlight the <input type="submit"> object that I want to highlight? 1. In my form, the user enters his ID. He sees two submit "buttons," left labeled Cancel, the right labeled Signup....
1
3971
by: shade1383 | last post by:
I have a web service that runs fine on my local machine and works fine with a VB .Net project remotely, but when I try to run using Access 2002 I get the following error. Server was unable to...
2
2012
by: Frank | last post by:
Hi, I've got a problem with calling a unmanged function : function call in the .H file : DWORD _stdcall DoCmdRequest(long lMode, long * plTagType); my definition in C#
6
3702
by: Craig Lister | last post by:
I have a treeview with a Root, a Contact Type, and a Contact. Like MSN Messenger. Is there a way that I can say something like if treenode.tag is classContact then string Surname =...
0
8035
by: Dica | last post by:
Hi all I've got a java microEdition client trying to make soap requests to my .Net service. i keep getting "Server was unable to process request..." err msg when attempting to make the request....
1
7197
by: Florencio Laso | last post by:
Hola to all: We have created a service web that works perfectly while is invoked in the localhost of the machine of development or from the IE of the servant where we have published it....
5
2371
by: taumuon | last post by:
I've got an object, Person, that supports IEquatable<Person>. It implements bool Equals(Person obj) as well as overriding bool Equals(object obj) I've got a container type that holds a member...
0
3540
by: Abuzar755 | last post by:
Hello, I have problem with Postgre Sql. I am beginner in Delphi and also in DataBase. I want to connect to Postgre Sql via Delphi,I use AdoConnection, DataSource, AdoTable and DBGrid.OnCreate...
2
4879
by: David Thielen | last post by:
Hi; I have a small XML file that I need to read/change from my app. Is there some easy way to map from XML to my objects so I can just read it in to my objects, change the objects as needed,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.