Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Is there any use case for a closure where the inner function doesn't have its own parameter?( Python)
Because I got no replies, I'll try to ask this using snippets: def f_outer(x): def f_inner(): return x * 2 # or whatever return f_inner # fin = f_inner(5) print(fin()) Is there any weird chance on Earth for this to be better than def f_outer(x): def f_inner(): return x * 2 return f_inner() # changed print(f_outer(5)), If f_inner() takes no argument? May I generalize that the only use for closure is having a "closure factory"? Thanks in advance :-)
4 Answers
+ 1
I think you can find the answer here:
https://www.google.com/amp/s/proglib.io/p/kak-v-JUMP_LINK__&&__python__&&__JUMP_LINK-primenyayutsya-vlozhennye-funkcii-2021-02-09/amp/
+ 1
You can use the translator built into the browser if you are using chrome
0
</CODER> It's in Russian :-) Didn't see language oprion in desktop mode but I'll look at the examples, thank you 😊
0
</CODER> Hehe no I try to stay away from unnervingly friendly, doublespeaking psychopathic cyclopses(google and derivatives and all other monopolies) on phone as much as I can but I'll definitely look it up when on pc, thanks for the tip.