[Tutor] Relative import help

Matthew Ngaha chigga101 at gmail.com
Sat Sep 22 19:38:26 CEST 2012

> You had forward slashes in your description of the folder layout, so I
> assumed you were on a linux box or a mac. I think I have now learned the
> lesson and will make fewer assumptions in the future.
> First, in idle's "shell" window type
>>>> import sys
>>>> print(sys.executable)
> (dont' type the ">>>", that will appear automatically) This should print
> something like
> C:\python32\python3.exe
> Now use Windows Explorer to navigate to the parent folder of "Project" and
> follow the instructions on
> http://www.windows7hacker.com/index.php/2009/08/how-to-open-dos-prompt-
> command-here-in-windows-7-and-more/
> (hold the shift key and right-click, then choose [Open Command Window Here])
> You should now see an ugly little black box. Type in
> C:\python32\python3 -c 'import Project.Domestic.Europe.winners'
> but remember to replace C:\python32\python3 with the actual contents of
> sys.executable.
> Whew ;)

:p.. whew!! well i followed your instructions and everything went well
with inputting the sys.executable into my Project's cmd shell. Sadly
my winners.py still can't directly access silverware.py in the
directory further up. Not to worry though, i spent all of yesterday
and most of today trying to get it to work, im mentally tired with
this import stuff, i just want to work through the rest of the book
now:) Thats whats important. maybe i'll revisit relative importing
when i actually need to use it. I'm still a far way away from those
types of projects as im still reading beginner tutorials, and the
normal absolute imports seem to be doing just fine. Thanks for all
your help and efforts:)

More information about the Tutor mailing list