← Back to team overview

dolfin team mailing list archive

Re: [Bug 783463] [NEW] dolfin.common.time overrides standard library time

 

On 16 May 2011 15:32, Anders Logg <logg@xxxxxxxxx> wrote:
> On Mon, May 16, 2011 at 12:59:49PM -0000, Martin Sandve Alnæs wrote:
>> Public bug reported:
>>
>> 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?
>>
>> ** Affects: dolfin
>>      Importance: Undecided
>>          Status: New
>
> Hmm... I can't find where this is imported. site-packages/dolfin/common/time.py
> defines __all__ which does not include time.

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 *


> 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
>

-- 
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:
  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?



Follow ups

References