import, from and reload
ramen at lackingtalent.com
Thu Mar 2 22:48:07 CET 2006
On Thu, 2 Mar 2006, John Salerno wrote:
> Dave Benjamin wrote:
>> In general, "from X import *" should be avoided anyway, for reasons that
>> have been discussed many times in the past. The annoyance with reloading is
>> just one more reason. Better to just use "import X" in the first place.
> Thanks. I kind of figured it's better to use import instead of from anyway,
> but I was following along with some examples that use from (despite the fact
> that earlier in the book they even say that from is problematic and you
> should use import instead!) :)
No problem. I stand by my original advice, but there is one semi-oneliner
that you might find useful:
reload(__import__('X')); from X import *
You could keep that in your clipboard and paste it into the interpreter
when you need to reload.
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
"one man's constant is another man's variable" - alan perlis
More information about the Python-list