|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: [PLUG] python, lambda, map
|
On Sun, Oct 17, 2004 at 07:52:27PM -0400, Jeff Abrahamson wrote:
> >>> def foo(x):
> ... return [x,x+1]
> ...
> >>> foo(3)
> [3, 4]
> >>> foo(3).extend(foo(5))
> >>> L=foo(3).extend(foo(5))
> >>> L
> >>>
So, I'm not answering your map question. However, I noticed that I got the
same results as your interactive session without expecting it. I had to
L=foo(3), then L.extend(foo(5)). Why? Perhaps foo() is not returning a
modifiable object? Can someone answer that?
I have a suspicion that fixing that issue will help you do the mapping you
want, the way you wanted to, Jeff.
In fact, with lists in general:
>>> b=[1,2,3]
>>> b
[1, 2, 3]
>>> b.append(7)
>>> b
[1, 2, 3, 7]
>>> [1,2,3]
[1, 2, 3]
>>> [1,2,3].append(7)
>>>
So I suppose it's a problem of incorrectly applying a method to an anonymous
type instance.
Dan W.
--
-- Daniel Widyono --
-- www.widyono.net --
-- www.cis.upenn.edu/~widyono --
--
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|