Python style questions

François Granger francois.granger at free.fr
Sat Mar 17 07:47:34 EST 2001


Alex Martelli <aleaxit at yahoo.com> wrote:

> There are several ways you can use a dictionary to dispatch pieces
> of code;
[...]
> def toy2(fileob, operation, *data):
>     switch = {'leggi': fileob.read, 'scrivi': fileob.write,
>         'chiudi': fileob.close }
>     return switch[operation](*data)

Fine, great, i'll test it.
Thanks

-- 
[fr, en, es, ia]
Information sur la hiérarchie usenet europa.* :
http://europa.usenet.eu.org



More information about the Python-list mailing list