Is there any use case for a closure where the inner function doesn't have its own parameter?( Python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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 :-)

17th Nov 2022, 11:32 PM
Korkunç el Gato
Korkunç el Gato - avatar
4 Answers
+ 1
You can use the translator built into the browser if you are using chrome
17th Dec 2022, 12:27 PM
Knight
Knight - avatar
0
</CODER> It's in Russian :-) Didn't see language oprion in desktop mode but I'll look at the examples, thank you 😊
17th Dec 2022, 12:21 PM
Korkunç el Gato
Korkunç el Gato - avatar
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.
17th Dec 2022, 12:44 PM
Korkunç el Gato
Korkunç el Gato - avatar