hi

On Feb 18, 2008 4:09 PM, Ramaswamy, Vivek <[EMAIL PROTECTED]> wrote:
> Hello~
>
>
> >>> g=lambda m:lambda: ++m
> >>> incre=g(0)
> >>> incre()
> 0
> >>> incre()
> 0
> >>> incre()
> 0
> >>>
>
> I would want each call to incre() increase the value by one.
>

i dont understand why you call incre()(is that a function call?)  the
one you are doing is something like
a = 0
print a
0

I think you like to do something like this

>>> def make_incrementor (n): return lambda x: x + n
>>>
>>> f = make_incrementor(2)
>>> g = make_incrementor(6)
>>>
>>> print f(42), g(42)
44 48
>>>
>>> print make_incrementor(22)(33)
55

-- 
regards,

Prashanth
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to