Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'arguments': 0.05; 'names.': 0.07; 'python': 0.08; 'identifier,': 0.09; 'rename': 0.09; 'wrote:': 0.15; '"import': 0.16; "'/'": 0.16; '(note:': 0.16; 'received:192.168.1.40': 0.16; 'this:': 0.16; 'work,': 0.20; 'header:In-Reply-To:1': 0.22; 'thus': 0.23; 'code': 0.24; '(or': 0.25; '(the': 0.28; 'import': 0.29; 'example': 0.30; 'module': 0.30; 'nested': 0.30; 'looks': 0.30; "won't": 0.32; 'named': 0.32; 'file.': 0.32; 'me?': 0.33; 'initial': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; 'operating': 0.34; 'someone': 0.34; 'subject:getting': 0.35; 'file': 0.36; 'passed': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'run': 0.39; 'perhaps': 0.39; 'received:192.168.1': 0.39; 'subject:from': 0.39; 'help': 0.39; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'meaning': 0.40; 'plain': 0.40; 'your': 0.60; 'received:62': 0.67; 'special': 0.67; 'note:': 0.68; 'from:addr:t': 0.84 Date: Sat, 23 Jul 2011 02:19:02 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: run a script getting 4 arguments from another script References: <38a06421-c05d-42d0-b0e5-9bd85ccf3c0b@12g2000yqr.googlegroups.com> In-Reply-To: <38a06421-c05d-42d0-b0e5-9bd85ccf3c0b@12g2000yqr.googlegroups.com> X-Enigmail-Version: 1.1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311380339 news.xs4all.nl 23843 [2001:888:2000:d::a6]:52387 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10160 On 23/07/11 00:46, souleymane yo wrote: > my initial file name is SpO2Sweep.loops.py > In the new file I write this code to run the first one. > > [code:] > import SpO2Sweep.loops.py > SpO2Sweep.loops.py.run("com1","0","30","0.0001") > > > and It looks like the arguments are not passed to the first file. can > someone help me? tl;dr: rename your file to a valid Python identifier, without periods, for example "loops.py". Then, you can use "import loops" (note: no .py), and loops.run(...) tl: When you say "import SpO2Sweep.loops.py", Python interpets the '.' as a separator between nested package/module names, much like your operating system interpets '/' (or perhaps '\') as a separator between directory/file names. Python thus looks for the module or package "py" within the package "loops" within the package "SpO2Sweep". For this to work, you'd need the following directory layout: ./ SpO2Sweep/ __init__.py loop/ __init__.py py.py Note: A file named __init__.py turns a plain directory into a package that Python recognises. What you actually have is this: ./ SpO2Sweep.loop.py (That won't work) Since Python treats periods specially, and names in Python cannot contain periods (the special meaning of '.' trumps), you can never import a file with that name. - Thomas