ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
Re: [Jython-users] partial imports
by Kevin Butler other posts by this author
Feb 27 2002 10:40PM messages near this date
Re: [Jython-users] partial imports | [Jython-users] How to use the execute() method in javaos
Samuele Pedroni wrote:
>  From: <Matt_Conway@[...].com>
>  > >>> import a
>  > ...NameError...
>  > >>> import a
>  > >>> a.foo

>  Is the BDFL (Guido van Rossum) intended behavior,
>  
>  the point is that, if an import fails somehow, you are on your own,
>  if you know how to cleanup things you can do that explicitly
>  
...
>  the precise rationale is something also Guido continously forget
>  about.

I've found it quite handy helping to debug the problem that caused the error.

import x
<error> 
from x import *
<look at values that led to the failure...> 

It is easy enough to re-execute the failed import with the reload() function:

import x
<error> 
import x
reload( x ) # executes your fixed code, or triggers the failure again.

Standard caveats about Python's non-recursive reload() apply.  :-)

kb

_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:

Samuele Pedroni
Kevin Butler

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved