pydstool icon indicating copy to clipboard operation
pydstool copied to clipboard

Uncertainty about hacky module / class name conflicts in __init__

Open robclewley opened this issue 12 years ago • 2 comments

What's the best way to deal with PyDSTool/init.py's

from . import Generator as GenModule from .Generator import Generator as Generator_ from .Generator import * Generator = GenModule from . import Model as ModelModule from .Model import Model as Model_ from .Model import * Model = ModelModule

robclewley avatar Apr 04 '14 22:04 robclewley

To avoid name clashing, I suggest to rename modules to lowercase variants (Points -> points, Generator -> generator, etc), following Python 3 practice. In case someone uses direct imports (from PyDSTool.Points import Points), we can hold simple module wrappers for one or two releases (we need a deprecation policy) which generates deprecation warning, like:

# Points.py
from .points import *

import warnings                                                                                                                                                                                         

warnings.warn(                                                                  
    "Using of capitalized named modules is deprecated",                         
    DeprecationWarning,                                                         
    stacklevel=2                                                                
)   

z2v avatar Apr 10 '14 06:04 z2v

I concur. Let's have a module wrapper with a deprecation for one release cycle (if releasing at around the current rate) or longer if we start releasing more than a couple of times a year.

robclewley avatar Apr 11 '14 19:04 robclewley