self modifying code
Robin Becker
robin at NOSPAMreportlab.com
Sat Apr 29 12:51:45 EDT 2006
When young I was warned repeatedly by more knowledgeable folk that self
modifying code was dangerous.
Is the following idiom dangerous or unpythonic?
def func(a):
global func, data
data = somethingcomplexandcostly()
def func(a):
return simple(data,a)
return func(a)
It could be replaced by
data = somethingcomplexandcostly()
def func(a):
return simple(data,a)
but this always calculates data.
--
Robin Becker
More information about the Python-list
mailing list