470,618 Members | 1,822 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,618 developers. It's quick & easy.

Having trouble with relative imports

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

--
-Echo
Apr 9 '07 #1
0 1014

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Randall Smith | last post: by
reply views Thread by Anders J. Munch | last post: by
1 post views Thread by Alexey Borzenkov | last post: by
12 posts views Thread by Alan Isaac | last post: by
9 posts views Thread by rbygscrsepda | last post: by
reply views Thread by Kay Schluehr | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.