Where is quote (again)?

Hans Nowak wurmy at earthlink.net
Fri Mar 8 11:31:22 EST 2002


N Becker wrote:
> 
> Back in 1999, I asked "where is quote?".  I was looking for
> a way to quote a function (delay evaluation).

Python is not Lisp...

<ponder> It would be interesting to have lazy evaluation though...
I'm not sure if it's possible to implement, or if it will be
useful at all. It sure makes sense in functional languages,
but in Python? Hm. 
</ponder>

> I wonder if there is anything new.  It looks to me that the
> best answer is to use lambda.
> 
> example:
> 
> def f():
>   return lambda: os.chmod(""/root/.rhosts", 0644)
> 
> def g():
>   f()

Writing your code like this is asking for trouble. Not
only does it make your code less clear, but it also
introduces a Lisp-ish idiom, which is fine when you're
writing Lisp, but in Python there are certainly better
ways to do what you want, depending on what you are
trying to do. (Unless you're writing an entry for the
Obfuscated Python Contest... <wink>)

-- 
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==')) 
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/



More information about the Python-list mailing list