Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'importing': 0.04; 'try:': 0.07; 'subject:module': 0.09; 'thread': 0.11; 'sat,': 0.15; '(note,': 0.16; '.py': 0.16; '10:05': 0.16; 'did:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:accessing': 0.16; 'subject:created': 0.16; 'string': 0.17; 'wrote:': 0.17; 'code,': 0.18; 'variable': 0.20; 'followed': 0.20; 'trying': 0.21; 'import': 0.21; 'skip:_ 20': 0.22; 'flexibility': 0.23; "haven't": 0.23; 'command': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'leave': 0.26; 'replace': 0.27; 'message-id:@mail.gmail.com': 0.27; 'gather': 0.29; 'name?': 0.29; 'call.': 0.30; 'file': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'whatever': 0.35; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; '2013': 0.84; "user',": 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=6srr5BdPrH3eDptAzztUUnqAUrrVQJckljJBsuoPMCg=; b=dpL88veUduUnzLqBr5KoIP8cH/thw4Ve5Tcfmify9xnGhqh/rusJLoxsCqwLJihNGb MmbnpoQHnSf8SH7CQZvwLzffNLT6hjtnMWxSg8PL3ksUEnLGpIHN9LC8enlhZF5gIcmQ SVh3V5+4FVl9a3fByYzEik3KR2xruQe7dCiTPRSwGFUcjwtedXsi7gj4aROo0UYFrd6u wWT7Axyl8/FtVO8nI7moyHw1njk+G9Yf/OcLV9aTYVHlvp3uqATOwUSZijN/A3pkHsns vIByzwibdjQttZXUBMN8Og7x7aW49F3Chu7lqqiJKZMI7wVsIRKu26HnShvrsRGM3v5+ fBXQ== MIME-Version: 1.0 X-Received: by 10.58.75.46 with SMTP id z14mr2306516vev.52.1362829673249; Sat, 09 Mar 2013 03:47:53 -0800 (PST) In-Reply-To: References: <513aecd3$0$6512$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 9 Mar 2013 22:47:52 +1100 Subject: Re: Running external module and accessing the created objects From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362829682 news.xs4all.nl 6964 [2001:888:2000:d::a6]:49092 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40943 On Sat, Mar 9, 2013 at 10:05 PM, Kene Meniru wrote: > I have tried importing "user.py" and/or "app.py". However there is no > single command to call. I haven't followed the thread in detail, but I gather you're trying to import a file with a variable name? Instead of 'import user', try: user = __import__("foobar") You can then replace the quoted string with whatever you need (note, leave off the .py extension). In your code, it'll be as if you did: import foobar as user but with the flexibility of using whatever run-time-chosen name you need. ChrisA