Hi,
On 22 September 2012 11:56, Matthew Ngaha wrote:
> from ..silverware import Silverware
> heres my error mesages: ... ValueError: Attempted relative import in
> non-package
Just an off the cuff remark since no one else picked up on this, but
the above errir message to me implies there's poss
> 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
Matthew Ngaha wrote:
>> You probably have a path that reaches into Domestic or Europe
>> sub-package. That can happen if e. g. Project/Domestic/Europe is your
>> current working directory.
>>
>> Try to cd into the Project folder's parent directory and see if
>>
>> $ python -c 'import Project.Domes
> You probably have a path that reaches into Domestic or Europe sub-package.
> That can happen if e. g. Project/Domestic/Europe is your current working
> directory.
>
> Try to cd into the Project folder's parent directory and see if
>
> $ python -c 'import Project.Domestic.Europe.winners'
>
> works
> cd is a shell command; you do it before starting Python. You didn't
> mention what OS you're running, but cd should be about the same for
> Linux, Windows, or Mac.
im on windows. i always start Python via IDLE. ive never started it
for editing though the shell, run > cmd etc? ill type that int
> try
> import ../my_module
> instead of
> import ..my_module
> and see what happens.
> Your problem may be just that you haven't included the separator.
>
> .. means one directory higher but you must separate it from the file name.
>
> Two directories higher would be
> ../../my_module
sadly this
On 09/22/2012 08:33 AM, Matthew Ngaha wrote:
>> You probably have a path that reaches into Domestic or Europe sub-package.
>> That can happen if e. g. Project/Domestic/Europe is your current working
>> directory.
>>
>> Try to cd into the Project folder's parent directory and see if
>>
>> $ python -
> You probably have a path that reaches into Domestic or Europe sub-package.
> That can happen if e. g. Project/Domestic/Europe is your current working
> directory.
>
> Try to cd into the Project folder's parent directory and see if
>
> $ python -c 'import Project.Domestic.Europe.winners'
>
> works
> Not impossible, but I doubt that.
>
> Have you followed the instructions *exactly*? If not, you have
> probably missed something. What book is it?
>
> Otherwise, the book and you are probably using different versions of
> Python. What version of Python are you using, and what is the book
> using?
Matthew Ngaha wrote:
> i have an assignment from a book to practice implementing relative
> imports. it gave a very clear and easy to follow explanation, but my
> results are proving the instructions are wrong. here's what i have
> tried. my folder structure:
>
> Project /
>
>__init__.py
>
On 22/09/12 20:56, Matthew Ngaha wrote:
i have an assignment from a book to practice implementing relative
imports. it gave a very clear and easy to follow explanation, but my
results are proving the instructions are wrong.
Not impossible, but I doubt that.
Have you followed the instructions
i have an assignment from a book to practice implementing relative
imports. it gave a very clear and easy to follow explanation, but my
results are proving the instructions are wrong. here's what i have
tried. my folder structure:
Project /
__init__.py
main.py
Domestic /
__init__
12 matches
Mail list logo