Last active
January 10, 2022 03:53
-
-
Save Natim/f95344db0838b6b8a9b58a5b4a5666a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
RULES = { | |
'six_h': {'high': 390, 'low': 330}, | |
'twelve_h': {'high': 750, 'low': 690}, | |
'twentyfour_h': {'high': 1490, 'low': 1410}, | |
'seven_d': {'high': 169, 'low': 168} | |
} | |
class StatsHelper(object): | |
def __init__(self, *args, **kwargs): | |
for k, v in RULES.items(): | |
setattr(self, 'get_stats_{}'.format(k), partial(self._get_stats, low=v['low'], high=v['high'])) | |
super(StatsHelper, self).__init__(*args, **kwargs) | |
def _get_stats(self, low, high): | |
print('CALLED with {}, {}'.format(low, high)) | |
if __name__ == '__main__': | |
s = StatsHelper() | |
print(s) | |
# import pdb ; pdb.set_trace() | |
s.get_stats_six_h() | |
s.get_stats_seven_d() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment