None assigment

amused at webamused.com amused at webamused.com
Thu Feb 8 20:26:25 CET 2001


In article <95unqf$4j3$1 at nnrp1.deja.com>,
  Mark Pilgrim <f8dy at my-deja.com> wrote:
>
> Indeed.  I once had a similar experience; while playing around in the
> Python IDE, I defined a variable 'dir' to hold some directory path.
> Then days later (having never shut down Python), I wondered why the
> built-in 'dir' function didn't work.
>
> Which leads to the following questions:
> - Are there any true constants in Python?  (I don't think so, but
> correct me if I'm wrong.)
> - Once you've redefined a built-in function like 'dir', is there any
> way to get it back without restarting Python?
>
> -M
> --

You can delete it from the local namespace with del:

Python 2.1a1 (#9, Jan 22 2001, 20:58:30) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> dir
<built-in function dir>
>>> dir = "Spam"
>>> dir
'Spam'
>>> del dir
>>> dir
<built-in function dir>
>>>

  Joshua



Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list