Re: chop() and empty() functions

2006-05-27 Thread John Machin
On 27/05/2006 7:10 AM, Jeremy L. Moles wrote: > On Sat, 2006-05-27 at 06:22 +1000, John Machin wrote: >> On 27/05/2006 2:54 AM, Jeremy L. Moles wrote: >> >> ["chop" snipped] >> >>> Furthermore, what do people think about the idea of adding a truly >>> empty, no-op global lambda somewhere in Python?

Re: chop() and empty() functions

2006-05-27 Thread bearophileHUGS
Jeremy L. Moles>It's just an iterative way to say, "Okay, give me some default behavior for everything, and I'll come back around later and set the explicit handlers later."< There's some correlation with the Null Object pattern: http://www.cs.oberlin.edu/~jwalker/nullObjPattern/ Bye, bearophile

Re: chop() and empty() functions

2006-05-26 Thread John Machin
On 27/05/2006 6:41 AM, Paul Rubin wrote: > John Machin <[EMAIL PROTECTED]> writes: >> What is the use case? Why write something like """empty(foo, 42, >> cmd="xyzzy")""" when you could merely write "pass" or nothing at all? > > The function might be a parameter to something. Please bear with me;

Re: chop() and empty() functions

2006-05-26 Thread Jeremy L. Moles
On Sat, 2006-05-27 at 06:22 +1000, John Machin wrote: > On 27/05/2006 2:54 AM, Jeremy L. Moles wrote: > > ["chop" snipped] > > > > > Furthermore, what do people think about the idea of adding a truly > > empty, no-op global lambda somewhere in Python? I use them a lot > > What is the use case?

Re: chop() and empty() functions

2006-05-26 Thread Paul Rubin
John Machin <[EMAIL PROTECTED]> writes: > What is the use case? Why write something like """empty(foo, 42, > cmd="xyzzy")""" when you could merely write "pass" or nothing at all? The function might be a parameter to something. -- http://mail.python.org/mailman/listinfo/python-list

Re: chop() and empty() functions

2006-05-26 Thread John Machin
On 27/05/2006 2:54 AM, Jeremy L. Moles wrote: ["chop" snipped] > > Furthermore, what do people think about the idea of adding a truly > empty, no-op global lambda somewhere in Python? I use them a lot What is the use case? Why write something like """empty(foo, 42, cmd="xyzzy")""" when you cou

Re: chop() and empty() functions

2006-05-26 Thread Terry Reedy
"Jeremy L. Moles" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Furthermore, what do people think about the idea of adding a truly > empty, no-op global lambda somewhere in Python? In an important sense, there is no such object as a 'lambda' in Python. There are only function ob

chop() and empty() functions

2006-05-26 Thread Jeremy L. Moles
I've been using the following lambda/function for a number of months now (I got the idea from someone in #python, though I don't remember who): def chop(s, n): """Chops a sequence, s, into n smaller tuples.""" return zip(*[iter(s)] * n) ...or... chop = lambda s, n: zip(*[iter(s)