I am trying to learn design patterns in Python. The recommended approach for implementing global variables is through the Borg pattern.
class Borg:
__shared_state = {}
def __init__(self):
self.__dict__ = self.__shared_state
This seems to be a dictionary. How would I store more complicated data structures, say a Pandas dataframe or a custom class, to be used by globally? I would appreciate any guidance.
Aucun commentaire:
Enregistrer un commentaire