Linux.com: Python 3 makes a big break

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Oct 19 04:02:38 EDT 2008


On Sat, 18 Oct 2008 21:34:13 -0700, Kay Schluehr wrote:

> On 18 Okt., 22:01, Jean-Paul Calderone <exar... at divmod.com> wrote:
> 
>> Perhaps it also omitted the fact that nothing prevents you from
>> defining a function to write things to stdout (or elsewhere) in Python
>> 2.5, making the Python 3.x change largely a non-feature. ;)
>>
>> Jean-Paul
> 
> Even more. If someone had solved the hard problem of finding a less
> cumbersome way of writing sys.stdout.write(...) the request for
> multiline lambdas ( multi expression lambdas actually ) could have been
> decreased about 75-80%.


Er, am I missing something? How about this?

import sys
pr = sys.stdout.write

pr('Is this less cumbersome enough for you?')

But of course, that doesn't really help you avoid multi-expression 
lambdas, unless you want to write obfuscated code:

def foo(x):
    y = x+1
    print y
    return y

is roughly, but inefficiently, equivalent to:

lambda x: sys.stdout.write(x+1) or x+1

But that's cumbersome and obfuscated, and not scalable at all.



-- 
Steven



More information about the Python-list mailing list