Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-17 Thread Paul Boddie
Theerasak Photha skrev: > On 14 Oct 2006 09:25:00 -0700, Paul Boddie <[EMAIL PROTECTED]> wrote: > > > Unlike Java, Python's first class functions and > > methods are already highly useful for callback-based systems > > Curious: how well does the use of returning inner functions work as a > strategy

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-17 Thread Theerasak Photha
On 14 Oct 2006 09:25:00 -0700, Paul Boddie <[EMAIL PROTECTED]> wrote: > Unlike Java, Python's first class functions and > methods are already highly useful for callback-based systems Curious: how well does the use of returning inner functions work as a strategy for providing effectively 'anonymou

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread jmdeschamps
Bruno Desthuilliers wrote: > Kay Schluehr wrote: > > Bruno Desthuilliers wrote: > > > >> Just for the record : Ruby's code-blocks (closures, really) come from > >> Smalltalk, which is still the OneTrueObjectLanguage(tm). > > > > IsTheOneTrueObjectLanguage(tm)ReallyCamelCased? > > > ThatsAGoodQuest

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread Bruno Desthuilliers
Kay Schluehr wrote: > Bruno Desthuilliers wrote: > >> Just for the record : Ruby's code-blocks (closures, really) come from >> Smalltalk, which is still the OneTrueObjectLanguage(tm). > > IsTheOneTrueObjectLanguage(tm)ReallyCamelCased? > ThatsAGoodQuestion. DoYouMeanIsTheIdentifierTheOneTrueObj

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread Kay Schluehr
Bruno Desthuilliers wrote: > Just for the record : Ruby's code-blocks (closures, really) come from > Smalltalk, which is still the OneTrueObjectLanguage(tm). IsTheOneTrueObjectLanguage(tm)ReallyCamelCased? -- http://mail.python.org/mailman/listinfo/python-list

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-16 Thread Bruno Desthuilliers
Paul Boddie wrote: > Kay Schluehr wrote: >> Spreading tiny function definitions all over the code >> may be finally not such a good idea compared with a few generic methods >> that get just called? OO might run out of fashion these days but Python >> is not Java and Pythons OO is pretty lightweight

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-15 Thread Steven D'Aprano
On Sat, 14 Oct 2006 09:00:53 +, James Stroud wrote: > > Compared to the Python I know and love, Ruby isn't quite the same. > > However, it has at least one terrific feature: "blocks". [snip 220-odd quoted lines] > http://mail.python.org/pipermail/python-list/2004-April/215805.html Hi James

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-15 Thread [EMAIL PROTECTED]
Alexey Borzenkov wrote: > [EMAIL PROTECTED] wrote: > > but maybe it reduces code readabilty a bit for people > > that have just started to program: > > > > mul2 = def(a, b): > > return a * b > > > > Instead of: > > > > def mul2(a, b): > > return a * b > > For such simple cases, yes. What ab

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-15 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > Kay Schluehr wrote: > > The with statement is already implemented in Python 2.5. > > > > http://docs.python.org/whatsnew/pep-343.html > > > > The main difference between the with statement and Ruby blocks is that > > the with-statement does not support loops. Yielding a v

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-15 Thread Kay Schluehr
Paul Boddie wrote: > Kay Schluehr wrote: > > > > Spreading tiny function definitions all over the code > > may be finally not such a good idea compared with a few generic methods > > that get just called? OO might run out of fashion these days but Python > > is not Java and Pythons OO is pretty lig

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Alexey Borzenkov
[EMAIL PROTECTED] wrote: > but maybe it reduces code readabilty a bit for people > that have just started to program: > > mul2 = def(a, b): > return a * b > > Instead of: > > def mul2(a, b): > return a * b For such simple cases, yes. What about: button.click += def(obj): # do stuff

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread bearophileHUGS
Alexey Borzenkov: > I was so attached to these "nameless" def-forms that I was even shocked > when I found that this doesn't work in python: > f = def(a, b): > return a*b > Another good feature of Boo, btw. I think Boo has some good things worth consideration (and maybe worth to copy) and so

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Alexey Borzenkov
[EMAIL PROTECTED] wrote: > Compared to the Python I know and love, Ruby isn't quite the same. > However, it has at least one terrific feature: "blocks". Well, I particularly like how Boo (http://boo.codehaus.org) has done it: func(a, b, c) def(p1, p2, p3): stmts I was so attached to these

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread brenocon
Kay Schluehr wrote: > The with statement is already implemented in Python 2.5. > > http://docs.python.org/whatsnew/pep-343.html > > The main difference between the with statement and Ruby blocks is that > the with-statement does not support loops. Yielding a value of a > function decorated with a c

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Paul Boddie
Kay Schluehr wrote: > > Spreading tiny function definitions all over the code > may be finally not such a good idea compared with a few generic methods > that get just called? OO might run out of fashion these days but Python > is not Java and Pythons OO is pretty lightweight. I think you've succe

Twisted Deferreds (was: Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python)

2006-10-14 Thread Bjoern Schliessmann
Paul Rubin wrote: > But that's just ugly. The fetchPage function should take the > callback as an argument. In an asynchronous system it would even > be buggy. It won't, in my understanding/experience, since the local context must first terminate before the reactor takes control again and hand

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi all -- > > Compared to the Python I know and love, Ruby isn't quite the same. > However, it has at least one terrific feature: "blocks". Whereas in > Python a > "block" is just several lines of locally-scoped-together code, in Ruby > a > "block" defines a closure (an

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Duncan Booth
Paul Rubin wrote: > [EMAIL PROTECTED] writes: >> deferred = fetchPage('http://python.org') >> def _showResponse(response) >> print "fancy formatting: %s" % response.text >> deferred.addCallback(_showResponse) >> >> Lots of Twisted code has to be writ

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Kay Schluehr wrote: > [EMAIL PROTECTED] wrote: > >> Many have complained about this crippled-ness of lambda, but it >> actually makes some sense. Since Python uses colons and indentation to >> define blocks of code, it would be awkward to close a multiline lambda. >> The

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Kay Schluehr
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > deferred = fetchPage('http://python.org') > > def _showResponse(response) > > print "fancy formatting: %s" % response.text > > deferred.addCallback(_showResponse) > > > > Lots of Twisted code has to be written backwards like this

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Paul Rubin
[EMAIL PROTECTED] writes: > deferred = fetchPage('http://python.org') > def _showResponse(response) > print "fancy formatting: %s" % response.text > deferred.addCallback(_showResponse) > > Lots of Twisted code has to be written backwards like this. But that's just ugly. The f

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-13 Thread Kay Schluehr
[EMAIL PROTECTED] wrote: > But [embedding a definition, ks] is awkward since the lambda is constrained > to be one > line; you > can't come back later and add much to the callback's code. > Furthermore, this example isn't even legal, because 'print' isn't a > function, but a statement -- lambda i

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-13 Thread brenocon
[repost -- fixed formatting] Hi all -- Compared to the Python I know and love, Ruby isn't quite the same. However, it has at least one terrific feature: "blocks". Whereas in Python a "block" is just several lines of locally-scoped-together code, in Ruby a "block" defines a closure (anonymous func

A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-13 Thread brenocon
Hi all -- Compared to the Python I know and love, Ruby isn't quite the same. However, it has at least one terrific feature: "blocks". Whereas in Python a "block" is just several lines of locally-scoped-together code, in Ruby a "block" defines a closure (anonymous function). To avoid confusion le