I'm using a 2 python class as configuration file. One of them contain old parameters (deprecated) and I would like to display a message if a deprecated param is used.
Here is how I used the different class:
config_backup.py
class _ConfigBackup:
PARAM1 = 'a'
PARAM2 = 'b'
config_new.py
class Config(_ConfigBackup):
PARAM3 = 'c'
PARAM4 = 'd'
cfg = Config
Then I can call cfg and have result like this:
>>> cfg.PARAM3
'c'
>>> cfg.PARAM1
Parameter PARAM1 is deprecated.
'a'
The function or method would look like this I think:
def warning(param):
print(f"Parameter {param.__name__} is deprecated.")
return param
I am not exactly sure if this is possible, maybe by using decorator or with statement, any idea ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…