Hello,

I am writing a program that analyzes files of different formats. I
would like to use a function for each format. Obviously, functions can
be mapped to file formats. E.g. like this:

if file.endswith('xyz'):
    xyz(file)
elif file.endswith('abc'):
    abc(file)

...

Yet, I would prefer to do something of the following kind:

func = file[-3:]
apply_func(func, file)

Can something of this kind be done in Python?

Klaus

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to