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

2
  • You could add global DT immediately inside class Config: and assign it like partition = DT.yesterday_str. Commented Jun 9, 2021 at 16:42
  • Does this answer your question? Python - reference inner class from other inner class Commented Jun 9, 2021 at 16:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.