0

I am trying to create a Config class which will hold all my static values for an etl im developing to call them neatly like this reducing variables loaded and keeping the lower part of my script clean of parameter objects

Config.S3.bucket >> 'CYBERPUNK'
Config.S3.partition >> '2042'

code:

class Config:
    class DT:
        today_str = '2077' #str(date.today())
        yesterday_str = '2042' #str(date.today() - timedelta(days=1))
    class S3:
        bucket = 'CYBERPUNK'
        partition = Config.DT.yesterday_str #2042 <-- the problem

How do I load this class? it seems that because i'm referencing to the parent class and its subclass i am getting an error because i have not yet loaded the class.

NameError: name 'DT' is not defined

Can anyone help me pull this off? I've been reading on python inheritances, static methods class methods and multilevel classess but none seem to be able to give me the solution.I tried adding def init aswell but couldn't picture how to make it work

Kel
  • 51
  • 6
  • You could add `global DT` immediately inside `class Config:` and assign it like `partition = DT.yesterday_str`. – Axe319 Jun 09 '21 at 16:42
  • Does this answer your question? [Python - reference inner class from other inner class](https://stackoverflow.com/questions/42185472/python-reference-inner-class-from-other-inner-class) – Axe319 Jun 09 '21 at 16:48

0 Answers0