May-20-2022, 06:20 PM
Here a kind of hidden👻 secrets.
Can test this with:
>>> dte1 = 1 >>> dte2 = 2 >>> dte3 = 3When make 3 variables like this Python store them in a internal dictionary called
globals()
Can test this with:
>>> globals()['dte3'] 3 >>> globals().get('dte1') 1So as mention use a data structure like eg dictionary and do not make 50 variables.
>>> d = {f'dte{i}':i for i in range(0,10)} >>> d {'dte0': 0, 'dte1': 1, 'dte2': 2, 'dte3': 3, 'dte4': 4, 'dte5': 5, 'dte6': 6, 'dte7': 7, 'dte8': 8, 'dte9': 9} # Same result but now have made a own visible dictionary >>> d['dte3'] 3 >>> d.get('dte1') 1