Reloading function obtained via 'from xxx import yyy'

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Fri May 23 16:30:14 EDT 2008


On 23 mai, 21:40, "Joel Koltner" <zapwireDASHgro... at yahoo.com> wrote:
> How do I get Python to correctly re-load this function definition?
>
> In test.py:
>
> def testFunc():
>     print 'My testFunc!'
>
> I execute...
>
> >>> from test import testFunc
> >>> testFunc()
>
> My testFunc!
>
> Fine... now I change test.py to:
>
> def testFunc():
>     print 'Modified testFunc!'
>
> ...and I'd like to reload testFunc.  How do I do so?  'from test import
> testFunc' keeps the old definition around, and 'reload test' of course doesn't
> work becayse I didn't use 'import test' in the first place.

Import the module and use the fully qualied name. Or use Emacs with
python-mode.



More information about the Python-list mailing list