Home > other >  Consult the lambda in the class the use of parameters
Consult the lambda in the class the use of parameters

Time:10-03

Recently discovered in watching some python framework source code, the call to the parameters of the class and found a lot of lambda modify parameters, especially the meaning of the incoming side
Such as my pop-up in WXPython framework method with
 MessageDialogStyle=property (lambda self: object (), lambda self, v: None, lambda self: None) # default 

Personally, I have been use common lambda expressions to understand lambda self: object () is the self as a parameter to return the object (), can it really be object () was introduced into the property in the class as a parameter,
Lambda self what is said here, why to decorate with lambda,
I understand there is certainly a wrong here, so I hope to get the best solution,

CodePudding user response:

The self only parameter, it doesn't matter with other parameter name such as MessageDialogStyle=property (lambda s1: object (), lambda s2, v: None, lambda s3: None)
With lambda because the property needs to receive the input parameter is a function, if it's not lambda expressions, write three functions, hand in the three functions as parameters may be used

CodePudding user response:

Still don't understand how can be written as a lambda s1: object (), he should not be the meaning of the current instance of the class as a parameter to the incoming?
  • Related