Alan Gauld wrote: >>> 1. in your roundNumber function, you define a function >>> incrementDigit. >>> I'm pretty sure that this function is destroyed and recreated >>> every time >>> you call the function roundNumber. >> I don't understand. What's another way? > > def f(): > def g(): return 42 > return g() > > def g(): return 42 > def f() return g() > > The two bits of code do the same thing but the first > constructs/deletes g() each time. > >> And what's the downside of the way I've done it? > > Its slow...
Actually it is not particularly slow. The actual function code is created once, when the module is compiled; creating a function object and binding it to a name is pretty fast. There is a good discussion here: http://tinyurl.com/gzfyl Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor