mapping the read() fonction

Alex cut_me_out at hotmail.com
Mon Jul 24 13:57:05 EDT 2000


> I've used the map function to open my list of file but I can't do the
> same for the read() function, because it is a method function of the
> file class

You could do this sort of thing (untested)

files          = map(open,    filename_list)
read_functions = map(getattr, files, len(files) * ['read'])
file_contents  = map(apply,   read_functions)

...but I'd just use a for loop if I were you.

Alex.



More information about the Python-list mailing list