On Mon, Oct 7, 2013 at 11:33 AM, Joachim Durchholz <[email protected]> wrote: > I'm currently running into problems with imports. > > Problem 1: Relative imports don't work in 2.6. > "from .module import blah" works, but "from ..module import blah" does not.
Really? I don't see any mention of this in the docs. I did a little test of this and it seems to work for me. So are you sure you weren't really running into another issue. Unfortunately, when it comes to imports, Python's error messages are really bad (e.g., when there is a circular import problem, it will just say "ImportError: could not import x", which is the exact same error message you get when x never existed in the first place). > > That's really a pity, I'd be all for doing all imports in a relative > fashion, but if 2.6 doesn't support it, I'd suggest going back to absolute > imports. > > SUGGESTION: > Postpone using relative imports until we drop the last Python version that > does not support them fully. > > > Problem 2: Most Sympy modules do most of their imports through > "from sympy import blah", and don't care what those modules come from. > > This is fragile because whether a "from sympy" import will work depends on > whether you're inside an __init__ module or not, and if there, whether the > code of the module defining "blah" has already run or not. > I.e. you can't reorder import statements freely due to implementation > details inside the imported modules. > > SUGGESTION: > Eliminate the use of "from sympy import" /inside SymPy itself/. > User code and example code should still use "from sympy import". I agree, if this helps avoid circular imports, though it's less convenient to write, and annoying when you want to move functions around. I also agree that we should keep user code as "from sympy import", because although we do consider importable names as part of the API, their locations are implementation details (i.e., I don't want to create a deprecation warning every time we want to refactor some submodules). Aaron Meurer > > > Voices? Opinions? > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
