OT: Re: Just took a look in the perl newsgroup....
Aahz
aahz at pythoncraft.com
Wed May 28 09:11:25 EDT 2003
In article <mailman.1054126363.18886.python-list at python.org>,
Michael Chermside <mcherm at mcherm.com> wrote:
>
>Thanks, I think I get it now. What you're saying is that if you
>use a dict of functions as a stand-in for a case statement, then
>the functions can modify GLOBAL variables, and (of course) variables
>local to the functions themselves, but they can't modify nested-scope
>variables. So it's as if you can write a case statement, but
>within the cases you can't SET any variables (except global
>variables or variables that exist only within the case itself).
>
>That's a big limitation. I guess I should probably fall back on
>just promoting if-elif-else as the solution for "case" in Python.
It's less of a limitation in Python. The problem is that you're limiting
yourself by thinking of "variables". Use a mutable object passed in to
the functions (or even a global object), and Tim's your uncle. This is
one of the key reasons I push for using name/binding instead of
variable/reference -- it keeps attention focused on Pythonic idioms.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list
mailing list