Is there "let binding" in Python?

Donn Cave donn at u.washington.edu
Mon Sep 15 14:22:04 EDT 2003


In article <mailman.1063644809.12116.python-list at python.org>,
 Rob Hunter <rhunter007 at yahoo.com> wrote:
...
> I'm simply trying to learn to write in Python in
> a way that I will find tolerable.  I really like
> a lot of it, so far, and I find it fun to write
> it, and very pretty and easy to read.  
> 
> In general, in most cases, I find it
> *unacceptable* to use mutation.  And, since
> Python is very much a Scheme-like language, and
> has functional components (like map, and
> uh...functions :) with proper scoping) I think
> that this is quite a reasonable thing to want. 
> The trick is knowing when mutation happens, so
> that the programmer is aware when s/he is
> entering a scary land where things may not be
> what they seem.  And it seems from your
> references and my tests that the "=" operator is
> mutative.  In Scheme there's no issue..you
> introduce a binding with LET and you mutate a
> binding with SET!.  In Python, the way I see it,
> you introduce a binding with "=" and you mutate a
> binding with "=".

I sympathize, to some degree.  I agree that this feature,
call it mutation or as Python users would say "rebinding",
has the potential to make it harder to reason about code.

I am not convinced though that Python is so very much like
Scheme, nor that the resemblance would be grounds for Python
to go ahead and make all of Scheme's mistakes.  Scheme users
can continue to glory in their shining example of the
perfectability of computing languages, because Python is
just not like Scheme in this respect, and more in general
is not a functional programming language.  If you like the
FP features that have been strapped onto it, that's great,
many people do, but you don't make a donkey into a marine
mammal by strapping on flotation.  And for that matter it
isn't clear that it's an overall improvement for the donkey.

It's also not clear to me that Scheme gains an impressive
victory here in terms of reasoning about code, if it still
supports that pesky mutation.  Is this sort of a kitchen
sink language that tries to support every possible thing?
If you like the FP route, wouldn't something like Haskell
be better, more rigorously pure functional?

   Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list