What is Python good for?
markus at schabi.de
Thu Sep 13 20:40:51 CEST 2001
maxm <maxm at normik.dk> schrub:
> "Ignacio Vazquez-Abrams" <ignacio at openservices.net> wrote in message
>> Here's something that came up recently that if it doesn't make you go
>> "ooh-ahh", then it will make you go "whoa":
>> >>> def a():
>> ... return 'abc'
>> >>> def b():
>> ... return 123
>> >>> a.func_code=b.func_code
> wouldn't a = b satisfy your need for whoas here ?
No, not always.
Imagine there's some other reference to the function referenced by a.
Then your assignment would have no effect on the third reference, but
Ignacios example would change the function itsself (instead of
assigning a new function to the name a), so the change is visible to
the user of the other reference, too.
"The strength of the Constitution lies entirely in the determination of
each citizen to defend it. Only if every single citizen feels duty
bound to do his share in this defense are the constitutional rights
secure." -- Albert Einstein
More information about the Python-list