break in a module

Ben Finney ben+python at benfinney.id.au
Tue Jun 14 21:33:22 EDT 2011


Eric Snow <ericsnowcurrently at gmail.com> writes:

> I apologize if my example was unclear.  I kept it pretty simple.

That's a good goal, but unfortunately in this case it means the purpose
is opaque.

> In general it would be nice to do some checks up front and decide
> whether or not to continue executing the module, rather than waiting
> until the end to decide:
>
>   if condition_1:
>       ...
>       return
>   if condition_2:
>       ...
>       return
>
>   # now do my expensive module stuff

I have never seen code that needs this, and can't imagine why the above
would be a good design for a module. Is there real code online somewhere
that we can see which serves as a real example for your use case?

-- 
 \           “There is no reason anyone would want a computer in their |
  `\     home.” —Ken Olson, president, chairman and founder of Digital |
_o__)                                            Equipment Corp., 1977 |
Ben Finney



More information about the Python-list mailing list