Python module variables -
in root of application have app_db.py file sets variable. in app/models/models.py try
from app_db import *
and try access variables, gives error variable not defined. app/models contains init.py file , models.py file. doing wrong? app_db.py file simple
if os.environ.get('database_url') none: sqlalchemy_database_uri = 'postgresql://mfrtdskrujqfer:tikrp25zsl7w3mqtrw0@ec2-184-78-175-240.compute-1.amazonaws.com:5432/dev03fouea9lm' else: sqlalchemy_database_uri = os.environ['database_url']
if going from package import *
things available must listed in package/__init__.py
files __all__
entry.
if from package import (name1, name2,...)
not have unless names prefixed underscores, (see pep8 section on name mangling).
better still of course use import package
, access package.name1
, etc.
Comments
Post a Comment