control structures (was "Re: Sins")

skaller skaller at maxtal.com.au
Sun Jan 9 09:51:06 EST 2000


Skip Montanaro wrote:
> 
>     >> This is a common thing, does this express the idea ?
>     [ ... out-of-line example snipped ... ]
> 
>     skaller> Yes, that provides the required functionality, but has a
>     skaller> serious problem: cases have to be defined 'out of line', and
>     skaller> therefore do not have access to the current scope.
> 
>     skaller> So I'm looking for a syntax for providing the above
>     skaller> functionality _inline_.
> 
> While not strictly inline, why not define your actions as methods of a
> common class, then share the state they need access to as instance
> attributes?

	Precisely because it isn't inline. Localisation is lost.
Access to local state is lost, in Python, it cannot be recovered
in the case we want to rebind variables.

	put it this way: how would you object, if I said
you should always use a function:

	iterate(f, sequence)

instead of a for loop? The objection is the same.

-- 
John (Max) Skaller, mailto:skaller at maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850




More information about the Python-list mailing list