|
@@ -2,22 +2,26 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
"""
|
|
|
-A class that uses different static function depending of a parameter passed in init
|
|
|
-Note the use of a single dictionnary instead of multiple conditions
|
|
|
+A class that uses different static function depending of a parameter passed in
|
|
|
+init. Note the use of a single dictionnary instead of multiple conditions
|
|
|
"""
|
|
|
__author__ = "Ibrahim Diop <http://ibrahim.zinaria.com>"
|
|
|
__gist__ = "<https://gist.github.com/diopib/7679559>"
|
|
|
|
|
|
+
|
|
|
class Catalog():
|
|
|
"""
|
|
|
- catalog of multiple static methods that are executed depending on an init parameter
|
|
|
+ catalog of multiple static methods that are executed depending on an init
|
|
|
+ parameter
|
|
|
"""
|
|
|
|
|
|
def __init__(self, param):
|
|
|
|
|
|
- # dictionary that will be used to determine which static method is to be executed but
|
|
|
- # that will be also used to store possible param value
|
|
|
- self.static_method_choices = {'param_value_1': self.static_method_1, 'param_value_2': self.static_method_2}
|
|
|
+ # dictionary that will be used to determine which static method is
|
|
|
+ # to be executed but that will be also used to store possible param
|
|
|
+ # value
|
|
|
+ self.static_method_choices = {'param_value_1': self.static_method_1,
|
|
|
+ 'param_value_2': self.static_method_2}
|
|
|
|
|
|
# simple test to validate param value
|
|
|
if param in self.static_method_choices.keys():
|