[Tutor] list of functions
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Mar 30 03:29:28 EDT 2017
On 29/03/17 22:23, kay Cee wrote:
> func_list = ('func1', 'func2', 'func3')
>
> for f in func_list:
> eval(f)()
Instead of using strings just use the functions directly:
func_list = (func1, func2, func3)
for f in func_list:
f()
That avoids the potentially insecure eval and will be faster too.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list