Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37340
| Date | 2013-01-22 14:33 -0500 |
|---|---|
| Subject | Importing class from another file |
| From | Kevin Holleran <kdawg44@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.830.1358883233.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hello,
I have a class called My_Class in a subdir called Sub_Dir.
in My_Class.py is the following
class My_Class_Connector:
def __init__(self,un,pw,qs_srv="domain.com"):
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 "testing.py", 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.
Kevin
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Importing class from another file Kevin Holleran <kdawg44@gmail.com> - 2013-01-22 14:33 -0500
Re: Importing class from another file John Gordon <gordon@panix.com> - 2013-01-22 19:47 +0000
Re: Importing class from another file Kevin Holleran <kdawg44@gmail.com> - 2013-01-22 15:44 -0500
csiph-web