I am new at writing production code, and I want inspiration on how to use variables when I write classes. I use Python here but this can be generilzed to other languages. What is good programming practice? Declaring in the same document or do it in a seperate.
import pandas as pd
someValue = 'Variable value'
data_col1 = 'col1'
class MyClass:
def __init__(self, data: pd.DataFrame):
self.variable1 = someValue
self.variable2 = data[data_col1].max()
Alternatively have another document with declaring the variables and do this:
import pandas as pd
import variables as var
class MyClass:
def __init__(self, myData: pd.DataFrame):
self.variable1 = var.someValue
self.variable2 = myData[var.data_col1].max()
How would you structure this. number 1, number 2 or something entirely different?