@@ -54,13 +54,15 @@ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 2.7.9
54
54
55
55
``` python
56
56
class SampleClass (object ):
57
- def __init__ (self , params ):
58
- # params is dictionary
57
+ def __init__ (self , arg1 , arg2 = ' arg2 ' , arg3 = ' arg3 ' , ** arg4 ):
58
+ # initializing
59
59
# blow BQL sample will set like:
60
- # params['v1'] = -1
61
- # params['v2'] = 'string'
60
+ # arg1 = 'arg1'
61
+ # arg2 = 'arg2' # default value
62
+ # arg3 = 'arg3a' # overwritten
63
+ # arg4 = {'new_arg1':1, 'new_arg2':'2'} # variable named arguments
62
64
63
- def sample_method (self , v1 , v2 ):
65
+ def sample_method (self , v1 , v2 , v3 ):
64
66
# do something
65
67
66
68
def write_method (self , value ):
@@ -76,8 +78,10 @@ CREATE STATE sample_module TYPE pystate
76
78
class_name = ' SampleClass' , -- required
77
79
write_method = ' write_method' , -- optional
78
80
-- rest parameters are used for initializing constructor arguments.
79
- v1 = - 1 ,
80
- v2 = ' string'
81
+ arg1 = ' arg1' ,
82
+ arg3 = ' arg3a' ,
83
+ new_arg1 = 1 ,
84
+ new_arg2 = ' 2'
81
85
;
82
86
```
83
87
@@ -100,7 +104,7 @@ Those UDS creation query and UDF are same as following python code.
100
104
import sample_module
101
105
102
106
# same as CREATE STATE
103
- sm = sample_module.SampleClass({ ' v1 ' : - 1 , ' v2 ' : ' string ' } )
107
+ sm = sample_module.SampleClass(arg1 = ' arg1 ' , arg3 = ' arg3a ' , new_arg1 = 1 , new_arg2 = ' 2 ' )
104
108
105
109
# same as EVAL
106
110
sm.sample_method(arg1, arg2, arg3)
0 commit comments