Using class without importing module

T

Thomas Aanensen

Hi all.

I'm sending a class over a socket connection, and I want to use this class
at the new location. The problem is that I get a "module blah does not
exist" error.

Is it possible for me to use this class without importing the module? How?

Any other suggestions?


Cheers,
Thomas
 
J

Josiah Carlson

Thomas said:
Hi all.

I'm sending a class over a socket connection, and I want to use this class
at the new location. The problem is that I get a "module blah does not
exist" error.

Is it possible for me to use this class without importing the module? How?

Any other suggestions?

It sounds like you are using:

import Pickle
socketinstance.send(Pickle.dumps(classinstance))

The above doesn't work. Pickle only encodes the data associated with
that class, not the bytecode required for the functionality. It refers
to the module.class reference to deal with reconstructing it later from
the pickle.

In general, you do need to import the module in order to use the class.

- Josiah
 

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
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top