Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3697
| From | Arthur Mc Coy <1984docmccoy@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Non hashable object (without __dict__) |
| Date | 2011-04-20 06:07 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <6bbd2f78-3139-4a9f-b0df-4c35a16cec2a@l6g2000vbn.googlegroups.com> (permalink) |
Hello,
I have a C++ application, I used SWIG to call the python code. I pass
myModule.myObject object to the method of python code and what to
store it in JSON format.
The problem is when I do:
o = myModule.myObject()
inside python, the o object has __dict__ property, but if I take the
passed object o like:
def myMethod(self, objects):
for o in objects:
print o.__dict__
it fails saying no SwigPyObject does not have __dict__ property. The
only way to use o properties is to call it by name like here:
print o.MyProperty
But in order to use json.dump( objects, file, default =
self.MyJSONEncode ) I MUST to pass to MyJSONEncode method an object
that has __dict__ as its property.
So, what is the best way to correct my objects, which are coming from C
++ code to make them available for putting in JSON format ?
Thank you.
Back to comp.lang.python | Previous | Next | Find similar
Non hashable object (without __dict__) Arthur Mc Coy <1984docmccoy@gmail.com> - 2011-04-20 06:07 -0700
csiph-web