[Python-Dev] relative import circular problem

Cameron Simpson cs at zip.com.au
Thu Apr 4 23:45:36 CEST 2013

On 03Apr2013 12:12, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
| 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, [...]
| 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'.

+0 from me (I'd have been +0.5 but for Guido's explaination about
"import X" generally letting you use "X" exactly as phrased in the

| Another would be
| to always require an 'as' clause in this case, so that you
| would have to write'
|    import .foo as foo

And a big +1 for this.

Cameron Simpson <cs at zip.com.au>

The Force. It surrounds us; It enfolds us; It gets us dates on Saturday
Nights. - Obi Wan Kenobi, Famous Jedi Knight and Party Animal.

More information about the Python-Dev mailing list