Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-21 Thread garyrob
> I don't understand why the critics of lambda don't understand that > having to use so many temp variables, for either numbers or functions, > can work against both concision and clarity. I agree with this completely. My company has a rather large application written in Python (http://www.goombah

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-09 Thread tutufan
Re using the same variable name over and over for different objects in the same scope: Argh--don't do this. It makes a mess for the guy (or gal) that comes after you and has to understand the code. Our forefathers fought and died so that we could have as many unique variable names as we like. So

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-08 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > > if cond: > > my x = 7# make a new scope for x, goes out of scope at end of if > > > If this genuinely troubles you then you can always isolate the scope > with a function, though of course you also no longer have the code > inline then. > >>I d

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-08 Thread Scott David Daniels
Steve Holden wrote: > Paul Rubin wrote: >> I think it's a Python weakness that you can't declare a local var like >> in other languages, to go out of scope at the end of the current block, e.g.: >> >> if cond: >> my x = 7# make a new scope for x, goes out of scope at end of if >>

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-08 Thread Steve Holden
Paul Rubin wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > >>>All joking aside, when I have names (temporary variables or scaffolding >>>functions) that I need to initialise a module or data structure, but then >>>outlive their usefulness, I del the name afterwards. Am I the only one? I >>>can

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-08 Thread Steve Holden
Steven D'Aprano wrote: > On Wed, 07 Dec 2005 10:59:09 +0100, Sybren Stuvel wrote: [...] > But then you have all these small functions lying around in your module. > If you intend to use them multiple times, then obviously you should > keep them. But if they are intended to be used once, and once on

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Sybren Stuvel
Steven D'Aprano enlightened us with: > Once the lookup table is created, you shouldn't use that function > again -- at best it is just sitting around like a third wheel, at > worst it might have side-effects you don't want. So I del the > function. I'd prefer to check the lookup table, and raise a

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steven D'Aprano
On Wed, 07 Dec 2005 10:59:09 +0100, Sybren Stuvel wrote: > Steven D'Aprano enlightened us with: >> All joking aside, when I have names (temporary variables or >> scaffolding functions) that I need to initialise a module or data >> structure, but then outlive their usefulness, I del the name >> aft

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Dan Sommers
On 07 Dec 2005 03:25:53 -0800, Paul Rubin wrote: > Steve Holden <[EMAIL PROTECTED]> writes: >> > All joking aside, when I have names (temporary variables or >> > scaffolding functions) that I need to initialise a module or data >> > structure, but then outlive their use

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > > All joking aside, when I have names (temporary variables or scaffolding > > functions) that I need to initialise a module or data structure, but then > > outlive their usefulness, I del the name afterwards. Am I the only one? I > > can't say I've seen an

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steve Holden
Steven D'Aprano wrote: [...] > All joking aside, when I have names (temporary variables or scaffolding > functions) that I need to initialise a module or data structure, but then > outlive their usefulness, I del the name afterwards. Am I the only one? I > can't say I've seen anyone else doing that

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 19:31:46 -0800, bonono wrote: > > Paul Rubin wrote: >> > Why use temporary variables when all you have to do is make your >> > expressions three lines long to avoid "polluting the namespace"? >> >> Indeed. I'd much rather say >> >> x = a + b + (c * d) + e >> >> than >> >>

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Antoon Pardon
Op 2005-12-07, Steven D'Aprano schreef <[EMAIL PROTECTED]>: > On Tue, 06 Dec 2005 00:33:17 +0100, Fredrik Lundh wrote: > >> Sybren Stuvel wrote: >> >>> def somefunc(x): return x*5 >>> >>> How is that a multi-line function definition? >> >> but that's namespace pollution! if you do this, nobody wi

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Sybren Stuvel
Steven D'Aprano enlightened us with: > All joking aside, when I have names (temporary variables or > scaffolding functions) that I need to initialise a module or data > structure, but then outlive their usefulness, I del the name > afterwards. Am I the only one? I don't do that. I tend to split up

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steven D'Aprano
On Tue, 06 Dec 2005 00:33:17 +0100, Fredrik Lundh wrote: > Sybren Stuvel wrote: > >> def somefunc(x): return x*5 >> >> How is that a multi-line function definition? > > but that's namespace pollution! if you do this, nobody will never ever be > able to use the name somefunc again! won't somebody

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Sybren Stuvel
Steve Holden enlightened us with: > I think you need to turn your irony detector up a little - it looks > like hte gain is currently way too low :o) Consider my detector tweaked ;-) Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity,

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Steve Holden
Sybren Stuvel wrote: > Fredrik Lundh enlightened us with: > >>>def somefunc(x): return x*5 >>> >>>How is that a multi-line function definition? >> >>but that's namespace pollution! if you do this, nobody will never ever be >>able to use the name somefunc again! won't somebody please think about >>

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Sybren Stuvel
Fredrik Lundh enlightened us with: >> def somefunc(x): return x*5 >> >> How is that a multi-line function definition? > > but that's namespace pollution! if you do this, nobody will never ever be > able to use the name somefunc again! won't somebody please think about > the children! If you use th

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Antoon Pardon
Op 2005-12-06, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Steve Holden wrote: > >> One perhaps needs to be a little more careful with instance variables, >> but again most *temporaries* are simply local to the method in which >> they're called, they don't exist for the lifetime of the instance. >

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Fredrik Lundh
Steve Holden wrote: > One perhaps needs to be a little more careful with instance variables, > but again most *temporaries* are simply local to the method in which > they're called, they don't exist for the lifetime of the instance. and more importantly, temporary variables can be reused. they'r

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Paul Rubin wrote: > >>[EMAIL PROTECTED] writes: >> >>>I think there is, for python. Not that I agree with it. The language >>>doesn't prevent you from using the short one-liner style but the idioms >>>prefer the line by line(and one single op/action per line) style. >> >

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread bonono
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > I think there is, for python. Not that I agree with it. The language > > doesn't prevent you from using the short one-liner style but the idioms > > prefer the line by line(and one single op/action per line) style. > > Are you serious?!! You're sa

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Antoon Pardon
Op 2005-12-06, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: > > Antoon Pardon wrote: >> Op 2005-12-06, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: >> > >> > Paul Rubin wrote: >> >> > Why use temporary variables when all you have to do is make your >> >> > expressions three lines long to avoid

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Paul Rubin
[EMAIL PROTECTED] writes: > I think there is, for python. Not that I agree with it. The language > doesn't prevent you from using the short one-liner style but the idioms > prefer the line by line(and one single op/action per line) style. Are you serious?!! You're saying idiomatic Python prefers

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread bonono
Antoon Pardon wrote: > Op 2005-12-06, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: > > > > Paul Rubin wrote: > >> > Why use temporary variables when all you have to do is make your > >> > expressions three lines long to avoid "polluting the namespace"? > >> > >> Indeed. I'd much rather say > >>

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-06 Thread Antoon Pardon
Op 2005-12-06, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: > > Paul Rubin wrote: >> > Why use temporary variables when all you have to do is make your >> > expressions three lines long to avoid "polluting the namespace"? >> >> Indeed. I'd much rather say >> >> x = a + b + (c * d) + e >> >> th

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: > > > [EMAIL PROTECTED] wrote: > > > > > and, as you just found out, a rather restrictive one > > > > > at that. > > > > > > > > In part because Python's designers failed to make "print" a function > > > > or provide

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Devan L
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > "Gary Herron" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>--snip-- > >>So just use a def. It is constantly pointed out on > >>this list that the lambda provides no extra expressive power, it is > >>merely a shortcut > >

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread bonono
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: > > > > and, as you just found out, a rather restrictive one > > > > at that. > > > > > > In part because Python's designers failed to make "print" a function > > > or provide an if-then-else expression. > > > > > Wh

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread rurpy
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > > and, as you just found out, a rather restrictive one > > > at that. > > > > In part because Python's designers failed to make "print" a function > > or provide an if-then-else expression. > > > Why would one need print in lambda ? I like t

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread bonono
Paul Rubin wrote: > > Why use temporary variables when all you have to do is make your > > expressions three lines long to avoid "polluting the namespace"? > > Indeed. I'd much rather say > > x = a + b + (c * d) + e > > than > > temp1 = a + b > temp2 = c * d > temp3 = temp1 + temp2 > x

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Defining a function, and giving it a name, > isn't "polluting the namespace", any more than assigning > sub-expressions to temporary variables is polluting the namespace. Nor any less. > Why use temporary variables when all you have to do is make your >

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Steve Holden
[EMAIL PROTECTED] wrote: > "Gary Herron" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>--snip-- >>So just use a def. It is constantly pointed out on >>this list that the lambda provides no extra expressive power, it is >>merely a shortcut > > > No, it is not merely a shortcu

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread bonono
[EMAIL PROTECTED] wrote: > > and, as you just found out, a rather restrictive one > > at that. > > In part because Python's designers failed to make "print" a function > or provide an if-then-else expression. > Why would one need print in lambda ? I like ternary operator(and there is ugly work ar

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Fredrik Lundh
Sybren Stuvel wrote: > def somefunc(x): return x*5 > > How is that a multi-line function definition? but that's namespace pollution! if you do this, nobody will never ever be able to use the name somefunc again! won't somebody please think about the children! -- http://mail.python.org/mailm

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Paul Rubin
Sybren Stuvel <[EMAIL PROTECTED]> writes: > > No, it is not merely a shortcut. It often allows one to avoid > > polluting the namespace with a completely superfluous function name, > > thus reducing code smell. > > Which can also be done by using inner functions. Inner functions with no names?

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > No, it is not merely a shortcut. It often allows one to avoid > polluting the namespace with a completely superfluous function name, > thus reducing code smell. Which can also be done by using inner functions. > It can also avoid a multi-line function def

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread rurpy
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > --snip-- > So just use a def. It is constantly pointed out on > this list that the lambda provides no extra expressive power, it is > merely a shortcut No, it is not merely a shortcut. It often allows one to avoid pollu

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Bengt Richter
On Mon, 05 Dec 2005 10:38:25 +0100, bruno at modulix <[EMAIL PROTECTED]> wrote: >Gary Herron wrote: >> Mohammad Jeffry wrote: >> >>> Dear All, >>> >>> Can't a lambda uses the input parameter more then once in the lambda >>> body? >>> eg: >>> lambda x : print x/60,x%60 >>> >>> I tried with def and

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread bruno at modulix
Gary Herron wrote: > Mohammad Jeffry wrote: > >> Dear All, >> >> Can't a lambda uses the input parameter more then once in the lambda >> body? >> eg: >> lambda x : print x/60,x%60 >> >> I tried with def and it works but got syntax error with lambda. Below >> is an interactive sample: > > > Lambd

Re: What's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Klaus Alexander Seistrup
Justin Ezequiel wrote: > Try > > lambda_hrs = lambda x: (x/60,x%60) Or #v+ lambda_hrs = lambda x: divmod(x, 60) #v- Cheers, -- Klaus Alexander Seistrup PNX · http://pnx.dk/ -- http://mail.python.org/mailman/listinfo/python-list

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Gary Herron
Mohammad Jeffry wrote: > Dear All, > > Can't a lambda uses the input parameter more then once in the lambda > body? > eg: > lambda x : print x/60,x%60 > > I tried with def and it works but got syntax error with lambda. Below > is an interactive sample: Lambda evaluates a single *expression* and

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Ezequiel, Justin
Try lambda_hrs = lambda x: (x/60,x%60) -- http://mail.python.org/mailman/listinfo/python-list

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Mohammad Jeffry
without the "print" also gives me error:- >>> lambda_hrs = lambda x : x/60,x%60 Traceback (most recent call last):   File "", line 1, in ? NameError: name 'x' is not defined On 12/5/05, Mohammad Jeffry <[EMAIL PROTECTED]> wrote: Dear All, Can't a lambda uses the input parameter more then once in

what's wrong with "lambda x : print x/60,x%60"

2005-12-04 Thread Mohammad Jeffry
Dear All, Can't a lambda uses the input parameter more then once in the lambda body? eg: lambda x : print x/60,x%60 I tried with def and it works but got syntax error with lambda. Below is an interactive sample: [EMAIL PROTECTED] ~ $ python Python 2.4.2 (#1, Nov 18 2005, 19:32:15) [GCC 3.3.6