[Python-Dev] relative import circular problem (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 3 01:12:34 CEST 2013
- Previous message: [Python-Dev] relative import circular problem
- Next message: [Python-Dev] relative import circular problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Kristján Valur Jónsson wrote:
However, relative imports can only be performed using the "from X import Y syntax"
This seems like a legitimate complaint on its own, regardless of the circular import issue. The principle of least surprise suggests that relative imports should be possible using either syntax.
I'm guessing the reason that 'import' doesn't support relative imports is that it's not clear what name to bind the imported module to.
There are a couple of ways that this could be resolved. One would be to use the name resulting from stripping off the leading dots, so that
import .foo
would bind the module to the name 'foo'. Another would be to always require an 'as' clause in this case, so that you would have to write'
import .foo as foo
-- Greg
- Previous message: [Python-Dev] relative import circular problem
- Next message: [Python-Dev] relative import circular problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]