Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'importerror:': 0.05; 'subject:file': 0.07; 'python': 0.09; 'etc).': 0.09; 'script,': 0.09; 'subdir': 0.09; 'def': 0.10; 'instantiate': 0.16; 'subject:class': 0.16; 'module': 0.19; 'to:name:python-list@python.org': 0.20; 'trying': 0.21; 'bit': 0.21; 'import': 0.21; 'assignment': 0.22; 'help.': 0.22; 'kevin': 0.23; 'this:': 0.23; 'script': 0.24; '(most': 0.27; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'parent': 0.29; 'skip:& 10': 0.29; 'class': 0.29; 'classes': 0.30; 'worked': 0.30; 'file': 0.32; 'running': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'dir': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'skip:_ 40': 0.35; 'skip:m 40': 0.36; 'received:209': 0.37; 'sure': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'called': 0.39; 'skip:" 10': 0.40; 'skip:_ 50': 0.69; 'played': 0.84; 'url:domain': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=zxreJm23aRMq6GjaWLS2ZS0xSi9vnEC381l39ub24EE=; b=Bg/4cZ2wFNKjM7teUZy2Xx073R2zpa2S/4/vJ7MUmUBQjPhO0FZQCtXgmqUTg7tBa0 R0QXm/r+j8D6gUYUPvgEVsF5FP02bAmabBSz1zTJsJT8sIehAHyQhK6ZGo0hbfJdQW81 vef785bGq2sxTL/w3PUoRoFPcgqREoGm7ZLjwe5NyAHd6YKJAk8nx+Q2wRXRasAfJurY R4Ub03AaAHmkDV6WDAN1AmcuHk2h7C1qTl2/c/0u8iyG+YScUxpkyMJujb0kKyvQw7kD Cm5shZnTflh0OdIEmDg2RRBjeCZQThRY0RA2tmwXIqPcH7MYg55gWRGtQAP9N0AL5eSz ZXpQ== MIME-Version: 1.0 X-Received: by 10.112.16.203 with SMTP id i11mr9666287lbd.135.1358883225281; Tue, 22 Jan 2013 11:33:45 -0800 (PST) Date: Tue, 22 Jan 2013 14:33:45 -0500 Subject: Importing class from another file From: Kevin Holleran To: "python-list@python.org" Content-Type: multipart/alternative; boundary=f46d0401f99def24b904d3e5a792 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358883233 news.xs4all.nl 6929 [2001:888:2000:d::a6]:58180 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37340 --f46d0401f99def24b904d3e5a792 Content-Type: text/plain; charset=ISO-8859-1 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 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 --f46d0401f99def24b904d3e5a792 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello,

I have a class called My_Class i= n a subdir called Sub_Dir.

in My_Class.py is= the following

class My_Class_Connector:

=A0 =A0 def __init__(self,un,pw,qs_sr= v=3D"domain.com&quo= t;):

=A0 =A0 =A0 =A0 self.username =3D un<= /p>

=A0 =A0 =A0 =A0 self.password =3D pw

...

=



Then I am t= rying to call from a script in the parent dir like this:

from Sub_Dir.My_Class import *

q_api =3D My_Class.My_Class= _Connector(string1,string2)


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


Traceback= (most recent call last):

=A0 File "testing.py",= line 1, in <module>

=A0 =A0 from Sub_Dir.My_Class i= mport *

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


--f46d0401f99def24b904d3e5a792--