weka / easypy

This repository will no longer be maintained. See instead https://github.com/real-easypy/easypy
BSD 3-Clause "New" or "Revised" License
14 stars 0 forks source link

contexts: added 'breakable_section' #216

Closed koreno closed 4 years ago

koreno commented 4 years ago

What do you think about this? Kinda like "goto", but more pythonic...

In retrospect there were many situations where I used a closure/function just for its return capability ("quick" exit out of deep nesting). I think I'd prefer this construct instead.

idanarye commented 4 years ago

Is easypy.contexts the right module though? It should have functions/classes that deal with contexts, not that are contexts.

Maybe this should go in a new module - easypy.flowcontrol?

YuvalEvron commented 4 years ago

Honestly, I can't imagine myself using this feature.

koreno commented 4 years ago

Is easypy.contexts the right module though? It should have functions/classes that deal with contexts, not that are contexts.

Maybe this should go in a new module - easypy.flowcontrol?

I'm don't want to create a new module just for this... contexts also has KeyedStack which is a context-manager itself. Besides, this is a "context which can be safely broken out of".