Having trouble with relative imports

E

Echo

Here is my setup:
rpg
-objects
--__init__.py
--gameobject.py
--material.py
-__init__.py
-run_tests.py
-stats.py

the contents of run_test.py is:
import objects as o

the contents of objects/__init__.py is:
from material import *

in objects/material.py I have:
from .gameobject import GameObject
from ..stats import stats

When I try to run run_tests.py, I get this traceback:
(1:30:59 PM) OshEcho: echo@MobileEcho ~/projects/rpg $ python run_tests.py
Traceback (most recent call last):
File "run_tests.py", line 4, in <module>
import objects as o
File "/home/echo/projects/rpg/objects/__init__.py", line 3, in <module>
from material import *
File "/home/echo/projects/rpg/objects/material.py", line 4, in <module>
from ..stats import stats
ValueError: Attempted relative import beyond toplevel package


Could someone point out to me what I am doing wrong?
I'm running Python 2.5 on Gentoo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top