Define Constants
Eric Nieuwland
eric.nieuwland at xs4all.nl
Wed Apr 20 17:22:23 EDT 2005
codecraig wrote:
> My directory structure looks like...
>
> C:\
> --> abc.py
> --> utils
> --> __init__.py
> --> CustomThing.py
>
> Ok, CustomThing looks like...
>
> TOP = 0
> LEFT = 1
>
> class CustomThing:
> def __init__(self):
> self.foo = "foo"
>
> so, from abc.py I have
>
> from utils.CustomThing import CustomThing
>
> print CustomThing.TOP
>
> but i get an error: AttributeError: class 'CustomThing' has no
> attribute 'TOP'
>
> How can I access those??
You're only importing the class. Try importing the whole module:
from utils import CustomThing
print CustomThing.TOP
--eric
More information about the Python-list
mailing list