[Tutor] Refreshing the interpreter environment

Javier Ruere javier at ruere.com.ar
Mon Jun 20 19:40:37 CEST 2005


lawrence wang wrote:
> How do I refresh the interpreter environment without restarting it, if
> possible? For example, I'm using the interpreter to test a class I'm
> writing; importing and instantiating it reveals a typo; I go and fix
> the typo. Now, is there any way to reload the class afresh? Simply
> importing again doesn't seem to do it. Thanks in advance for your
> help.

Yes:

(echo "a=1" > a.py)
>>> import a
>>> a.a
1
(echo "a=2" > a.py)
>>> a = reload(a)
>>> a.a
2

Javier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20050620/08b62fbb/signature.pgp


More information about the Tutor mailing list