dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23212
[Bug 783463] Re: dolfin.common.time overrides standard library time
On Monday May 16 2011 07:19:48 Martin Sandve Alnæs wrote:
> This affects all python modules in FEniCS, so we probably don't want
> to fix it now.
I can fix this together with some other bugs I am up for.
[snip]
> > I did some digging and testing. My understanding is that since
> > dolfin/common/__init__.py does not define __all__, the submodules
> > under common are part of dolfin.common.*.
> >
> > Which means that this code will have the same issue:
> >
> > import math
> > from dolfin import *
> > # math is now dolfin.common.math
> >
> >
> > It can be fixed by doing this in common/__init__.py:
> >
> > """The common module of dolfin"""
> > import globalparameters
> > import constants
> > import plot
> > import time
> > import memory
> > import math
> >
> > __all__ = []
> > __all__ += globalparameters.__all__
> > __all__ += constants.__all__
> > __all__ += plot.__all__
> > __all__ += time.__all__
> > __all__ += memory.__all__
> > __all__ += math.__all__
> >
> > from globalparameters import *
> > from constants import *
> > from plot import *
> > from time import *
> > from memory import *
> > from math import *
Sounds good.
I am responsible for this import ambiguity. I hoped it was not nessesary to
define __all__ in the mid packages (dolfin.foo), as __all__ is defined in all
leaf modules (dolfin.foo.bar). But I did not anticipate the modules poluting
the namespace...
Johan
> >> Anders
> >>
> >> --
> >> You received this bug notification because you are a direct subscriber
> >> of the bug.
> >> https://bugs.launchpad.net/bugs/783463
> >>
> >> Title:
> >> dolfin.common.time overrides standard library time
> >>
> >> Status in DOLFIN:
> >> New
> >>
> >> Bug description:
> >> When doing
> >> from dolfin import *
> >> the module dolfin.common.time is imported. There is a module called
> >> time in the standard library, and this can cause confusion.
> >>
> >> A distilled version of the code I had problems with:
> >> import time
> >> from dolfin import *
> >> print time.localtime()
> >>
> >> Does dolfin.common.time need to be imported in the global namespace?
> >> Can it be renamed?
> >>
> >> To unsubscribe from this bug, go to:
> >> https://bugs.launchpad.net/dolfin/+bug/783463/+subscribe
** Changed in: dolfin
Importance: Undecided => Low
** Changed in: dolfin
Status: New => Confirmed
** Changed in: dolfin
Assignee: (unassigned) => Johan Hake (johan-hake)
--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/783463
Title:
dolfin.common.time overrides standard library time
Status in DOLFIN:
Confirmed
Bug description:
When doing
from dolfin import *
the module dolfin.common.time is imported. There is a module called time in the standard library, and this can cause confusion.
A distilled version of the code I had problems with:
import time
from dolfin import *
print time.localtime()
Does dolfin.common.time need to be imported in the global namespace?
Can it be renamed?
References