Using functional tools

Pekka Niiranen krissepu at vip.fi
Sat May 4 04:37:01 EDT 2002


I would like to feed every second (or 3rd or 4th .etc) item in a list to
a function.

list = ['a', 'b', 'c', 'd', 'e']

**some fancy map/filter -trick here**

=> list = ['a', function('b'), 'c', function('d'), 'e']

Is there a (functional) way without using for or while -structures ?

If I only manipulate every second line of a file with that function,
is there a faster way than reading the whole file into a list ?:

list = open ("myfile.txt", "rb").readlines()
**modify every 2nd line with set of functions**
** write the whole list into a new file**

The size of a file is max 2Mb.

-pekka-








More information about the Python-list mailing list