[Tutor] mapping/filtering a sequence
kevin parks
kp8 at mac.com
Sat Sep 5 17:49:14 CEST 2009
Yeah the list seems flaky at the moment. Additionally, my query is an
incredibly stupid one. But what you have works and represents an
improvement over the unreadable kludge I was doing. Thanks to all who
responded.
cheers,
k
On Sep 6, 2009, at 12:26 AM, Douglas Philips wrote:
> On or about 2009 Sep 5, at 10:45 AM, Martin A. Brown indited:
>
> I must have missed a message or two, because I don't understand why
> math is being done on constants like that.
> Given my misunderstanding, I'd go with:
>
> my_map = { 38: 34, 40: 39 }
>
> def filter_item(item):
> return my_map.get(item, item)
>
> l = [ ... ]
> l = map(filter_item, l)
>
>
> -Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090906/693fa12c/attachment.htm>
More information about the Tutor
mailing list