How to make Self-Invoking Anonymous Functions in Python?
For example with JavaScript:
Standard way:
function fn (a) {
if (a == 1) {
alert(a);
}
else {
alert(0);
}
/...
}
fn(1);
Self-Invoking Anonymous call:
!function(a) {
if (a == 1) {
alert(a);
}
else {
alert(0);
}
/...
}(1);
Are there any analogues in Python?
dict) that is meant to be imported from inside another module without having to assign/define an actual function or explicitly pickle:STATIC_CONST_D = (lambda S: {x: transform(x) for x in S})(set(1,2,3))from module import STATIC_CONST_D