I often use the same set of nested functions inside which I call different functions. Something with analogous structure to this:
data = 'example'
...
for i in range(10):
# use data here
another_data='another'
for j in range(10):
some_func(i, j, data)
...
for i in range(10):
# use data here
another_data='another'
for j in range(10):
another_func(i, j, another_data)
Which pattern should I use to avoid coping the code?
I tried with decorator, but I didn't know how to pass arguments to some_func
that were created in inside wrapper function and omit passing arguments them when calling some_func
.
Aucun commentaire:
Enregistrer un commentaire