[Tutor] Better construct? (was no subject)

Alan Gauld alan.gauld at btinternet.com
Sat Jun 12 21:59:52 CEST 2010


"bob gailer" <bgailer at gmail.com> wrote

> You can collect functions in a sequence, then iterate over it. This 
> allows for easy expansion (when you decide to add another function).
>
> funcs = (dosomething(), dosomethingelse())

I suspect Bob meant to leave off the (). You would normally just
use the function name. (Unless these are factory functions
returning another function but I don't think that was the intent! :-)

funcs = (doSomething, doSomethingElse)

> for func in funcs:
>   getid()
>   func()

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list