problem(s) with import from parent dir: "from ../brave.py import sir_robin"

Carsten Haese carsten at uniqsys.com
Fri Feb 24 08:34:44 EST 2006


On Fri, 2006-02-24 at 08:10, per9000 wrote:
> Dear Black Knight,
> 
> I have no quarrel with you sir Knight, but I must import your parents.
> 
> 
> SHORT VERSION:
> 
> I tried three variants of "from ../brave.py import sir_robin", one
> works. I want to use it in a py-file to execute command-line-style and
> that does not work.
> 
> Can someone please give me, not a bucket with the desert(s) on top, but
> just the thin chocolate?

1) Read and understand
http://docs.python.org/tut/node8.html#SECTION008110000000000000000
2) insert something that prints sys.path at the beginning of your script
and run the script command-line-style.
3) print sys.path in an interactive session
4) note the difference in output from steps 2 and 3

This should explain why you're getting different behavior between
running your script from the command line and running it line-by-line in
a python interpreter session. It should also give you a hint as to how
to solve your problem.

-Carsten




More information about the Python-list mailing list