Peter Hansen wrote:
> Dave Benjamin wrote:
>
>> def add_thingy():
>> def func(thingy_id):
>> print 'got thingy id:', thingy_id
>> def funnc(doodad_id):
>> print 'got doodad id:', doodad_id
>> def func(thingy_doodad):
>> print 'thingy dood
Dave Benjamin wrote:
> def add_thingy():
> def func(thingy_id):
> print 'got thingy id:', thingy_id
> def funnc(doodad_id):
> print 'got doodad id:', doodad_id
> def func(thingy_doodad):
> print 'thingy doodad created, froobling...'
>
Fredrik Lundh wrote:
> Dave Benjamin wrote:
>
>>>so name them all "func" or "next" or something, so you don't have
>>>to think. once the object is bound, the name is irrlevant.
>>
>>Sure, you could do this, but then you'd have multiple functions at
>>different nesting levels with the same name, w
Dave Benjamin wrote:
> > so name them all "func" or "next" or something, so you don't have
> > to think. once the object is bound, the name is irrlevant.
>
> Sure, you could do this, but then you'd have multiple functions at
> different nesting levels with the same name, which would be confusing.
Fredrik Lundh wrote:
> Dave Benjamin wrote:
>
>>In this case, having to name these callback functions is tiring and
>>awkward, and (IMHO) disrupts the flow of my function:
>
> so name them all "func" or "next" or something, so you don't have
> to think. once the object is bound, the name is irrl
Fredrik Lundh wrote:
>
> so name them all "func" or "next" or something, so you don't have
> to think. once the object is bound, the name is irrlevant.
>
Or, you could tell him about the reserved word anonymous which can be
used to created unnamed functions of values. A sample definition and
use
Dave Benjamin wrote:
> In this case, having to name these callback functions is tiring and
> awkward, and (IMHO) disrupts the flow of my function:
so name them all "func" or "next" or something, so you don't have
to think. once the object is bound, the name is irrlevant.
> def add_thingy():
>
On Thu, 05 May 2005 07:45:33 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote:
>Jason Mobarak wrote:
>> What's wrong with:
>>
>> def blah():
>> def _ (a, b, c):
>> a = a + 2
>> print "stmt 2"
>> return a+b/c
>> return doSomethingWith(_)
>>
>> It's basically "anonymous", it just uses
Peter Hansen wrote:
> I doubt there's a valid usecase for a "anonymous" function that has more
> than a line or two. Personally, I don't think there's a good usecase
> for an anonymous function longer than one line...
The case that I keep running into regards event-driven programming. I
need t
Peter Hansen wrote:
> Jason Mobarak wrote:
>
>> What's wrong with:
>>
>> def blah():
>> def _ (a, b, c):
>> a = a + 2
>> print "stmt 2"
>> return a+b/c
>> return doSomethingWith(_)
>>
>> It's basically "anonymous", it just uses a name that you don't care
>> about. AFAIK, it can be
Jason Mobarak wrote:
> What's wrong with:
>
> def blah():
> def _ (a, b, c):
> a = a + 2
> print "stmt 2"
> return a+b/c
> return doSomethingWith(_)
>
> It's basically "anonymous", it just uses a name that you don't care
> about. AFAIK, it can be immediately clobbered later if nee
What's wrong with:
def blah():
def _ (a, b, c):
a = a + 2
print "stmt 2"
return a+b/c
return doSomethingWith(_)
It's basically "anonymous", it just uses a name that you don't care
about. AFAIK, it can be immediately clobbered later if need be.
Otherwise, the function shouldn't be
On Wed, 04 May 2005 23:08:16 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
>Mayer wrote:
>
>> I would like to define a very large annonymous function, one with
>> several statements in sequence. I know how to define annonymous
>> functions, but I don't know how to define a sequence of statements i
Mayer wrote:
> I would like to define a very large annonymous function, one with
> several statements in sequence. I know how to define annonymous
> functions, but I don't know how to define a sequence of statements in
> their body. Can this be done in Python? If so, how?
No, it can't. Why do you
Hello:
I would like to define a very large annonymous function, one with
several statements in sequence. I know how to define annonymous
functions, but I don't know how to define a sequence of statements in
their body. Can this be done in Python? If so, how?
Thanks,
Mayer
--
http://mail.python
15 matches
Mail list logo