Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10158 > unrolled thread
| Started by | souleymane yo <souleymaneyo@gmail.com> |
|---|---|
| First post | 2011-07-22 15:46 -0700 |
| Last post | 2011-07-23 02:19 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
run a script getting 4 arguments from another script souleymane yo <souleymaneyo@gmail.com> - 2011-07-22 15:46 -0700
Re: run a script getting 4 arguments from another script Thomas Jollans <t@jollybox.de> - 2011-07-23 02:19 +0200
| From | souleymane yo <souleymaneyo@gmail.com> |
|---|---|
| Date | 2011-07-22 15:46 -0700 |
| Subject | run a script getting 4 arguments from another script |
| Message-ID | <38a06421-c05d-42d0-b0e5-9bd85ccf3c0b@12g2000yqr.googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2011-07-23 02:19 +0200 |
| Message-ID | <mailman.1395.1311380339.1164.python-list@python.org> |
| In reply to | #10158 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web