KaekeaSchmear
KaekeaSchmear

Reputation: 1578

Import/Include config Python

Is it possible to store config such as config['webapp2_extras.API'] in a different file, and then include it in an other?

Pseudocode:

# config.py
config['webapp2_extras.API'] = {
  'option' : value,
}

# frontcontroller.py
webapp2.WSGIApplication([
    webapp2.Route('/',handler='MainHandler')
  ], config={{CONFIG_FROM_CONFIG.PY}})

I would really like to be able to store my config(s) elsewhere than my frontcontroller!! Thanks!

Upvotes: 1

Views: 133

Answers (2)

N M
N M

Reputation: 616

Try while putting config in the same folder as frontcaller.py

# config.py
config['webapp2_extras.API'] = {
  'option' : value,
}

# frontcontroller.py
from . import config

webapp2.WSGIApplication([
    webapp2.Route('/',handler='MainHandler')
  ], config=config.config)

Upvotes: 0

user2313067
user2313067

Reputation: 603

Have you tried importing config in frontcontroller.py? For example

# config.py
config['webapp2_extras.API'] = {
  'option' : value,
}

# frontcontroller.py
import config

webapp2.WSGIApplication([
    webapp2.Route('/',handler='MainHandler')
  ], config=config)

Upvotes: 1

Related Questions