When passing functions as args, how to pass extra args for passed function?

python at sarcastic-horse.com python at sarcastic-horse.com
Tue Sep 16 17:08:53 EDT 2003


When I pass a function as an arg, like for map(...), how do I pass args to
use for that function?

If I have a function like this:

def pretty_format(f, fmt='%0.3f'):
    return fmt % f

I want to use it with map() like this:

formatted = map(pretty_format, unformatted_list)
#exept I want fmt='%4.5f' !!!

I need to figure out how to pass a non-default value for fmt.  How do I do
that?







More information about the Python-list mailing list