Stupid Newbie
Marc Christiansen
tolot at utolot.toppoint.de
Wed Jan 17 14:31:46 EST 2001
DAVID <david34 at mdx.ac.uk> wrote:
> To run this file (spam.py), I type:
> python spam.py a b c
>
> I get following message:
> File "<stdin>", line 1
> python spam.py a b c
> SyntaxError: Invalid syntax
>
> Any ideas??
Yes. "python" is not a python command. The line you're typing works only
from the commandline (DOS-Box it's called iirc). To use a module from
within python you use "import modulename_without_extention". But then
you can't supply parameters to the module, except by setting up argv
yourself. Or you implement a function in the module which when called,
does the same as the module does when called from the commandline.
And take care, when you use "import" the module is read in only once,
subsequent imports only create a new reference in the current namespace.
To re-read the module use reload(modulename_without_extention).
Ciao
Marc
--
Save the rainforest: Go to http://rainforest.care2.com/welcome?w=190056410
PGP-Key fingerprint EE 2E C1 06 D1 28 89 D2 F9 CE 35 7B F8 F4 42 52
Marc Christiansen 24109 Kiel
More information about the Python-list
mailing list