Importing class from another file

Kevin Holleran kdawg44 at
Tue Jan 22 20:33:45 CET 2013


I have a class called My_Class in a subdir called Sub_Dir.

in is the following

class My_Class_Connector:

    def __init__(self,un,pw,qs_srv=""):

        self.username = un

        self.password = pw


Then I am trying to call from a script in the parent dir like this:

from Sub_Dir.My_Class import *

q_api = My_Class.My_Class_Connector(string1,string2)

I have not worked much with Python classes so I am not sure what I am doing
wrong.  When running this from my script, I get the following error:

Traceback (most recent call last):

  File "", line 1, in <module>

    from Sub_Dir.My_Class import *

ImportError: No module named Sub_Dir.My_Class

I have played around a bit with the calls (removing the My_Class in the
q_api assignment to instantiate the object, etc).

Thanks for any help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list