Using class without importing module

Discussion in 'Python' started by Thomas Aanensen, Feb 10, 2004.

  1. 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
     
    Thomas Aanensen, Feb 10, 2004
    #1
    1. Advertisements

  2. 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
     
    Josiah Carlson, Feb 10, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.