Skip to content

Instantly share code, notes, and snippets.

@geekKeen
Created July 8, 2017 14:49
Show Gist options
  • Save geekKeen/d6bb9e2c181bd7fd06a3065ade46bcd8 to your computer and use it in GitHub Desktop.
Save geekKeen/d6bb9e2c181bd7fd06a3065ade46bcd8 to your computer and use it in GitHub Desktop.
Python absolute import
```
file sqlalchemy/orm/mapper.py
```
from __future__ import absoute_import
from collections import deque
@geekKeen
Copy link
Author

geekKeen commented Jul 8, 2017

file system
sqlalchemy/
...
orm/
init.py
mapper.py
...
在 mapper.py 中导入 collections 将会出现模糊,
是导入项目中的还是Python 标准库,
此时用 future 模块将会使用绝对导入,会从sys中选择

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment