Hi.
From: <Matt_Conway@...>
> This might be more of a python question, but here goes anyway. If I
> import a module that has an error in it, the import correctly fails. But
> if I then import the same module again, the import succeeds, and the only
> attributes on that module are those that were processed before the failure
> was hit. Is this correct behavior? It seems very dangerous.
> e.g.
>
> <a.py>
> foo='foo'
> errorhere
> bar='bar'
>
> <interactive>
> >>> import a
> ...NameError...
> >>> import a
> >>> a.foo
> 'foo'
> >>> a.bar
> .. AttributeError...
>
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
OTOH the interpreter does not try to illude you to have
properly cleaned up things, because there is no general notion
of what that means ...
the precise rationale is something also Guido continously forget
about.
regards, Samuele Pedroni.
|