Python from Wise Guy's Viewpoint
John Thingstad
john.thingstad at chello.no
Sun Oct 19 09:41:04 EDT 2003
On Sun, 19 Oct 2003 15:24:18 +0200, Frode Vatvedt Fjeld <frodef at cs.uit.no>
wrote:
>> mike420 at ziplip.com <mike420 at ziplip.com> pisze:
>>
>>> 8. Can you undefine a function, value, class or unimport a module?
>>> (If the answer is no to any of these questions, Python is simply
>>> not interactive enough)
>
> Jarek Zgoda <jzgoda at gazeta.usun.pl> writes:
>
>> Yes. By deleting a name from namespace. You better read some
>> tutorial, this will save you some time.
>
> Excuse my ignorance wrt. to Python, but to me this seems to imply that
> one of these statements about functions in Python are true:
>
> 1. Function names (strings) are resolved (looked up in the
> namespace) each time a function is called.
>
> 2. You can't really undefine a function such that existing calls to
> the function will be affected.
>
> Is this (i.e. one of these) correct?
>
Neither is complely correct. Functions are internally delt with using
dictionaies.
The bytecode compiler gives it a ID and the look up is done using a
dictionary.
Removing the function from the dictionary removes the function.
(pythonese for hash-table)
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
More information about the Python-list
mailing list