推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
simple2025
0D
V2EX  ›  Python

在 Python 里面怎么处理非常多的 import 的情况吗?

  •  
  •   simple2025 · Apr 12, 2020 · 4428 views
    This topic created in 2400 days ago, the information mentioned may be changed or developed.

    不想再手动 import 了

    17 replies  •  2020-04-17 10:08:13 +08:00
    zhuangzhuang1988
    zhuangzhuang1988
    Apr 12, 2020
    1
    pycharm 啊
    自动 import 的
    不要用各种 magic 方法 维护的人(很可能是自己)倒霉
    simple2025
    simple2025
    OP
    Apr 12, 2020
    2
    @zhuangzhuang1988 我现在是 vscode 了,为了 remote
    heart4lor
    heart4lor
    Apr 12, 2020
    3
    pycharm 也可以 remote 啊
    Juszoe
    Juszoe
    Apr 12, 2020
    4
    pycharm remote 调试提示样样全,不过只有专业版支持
    gwy15
    gwy15
    Apr 12, 2020
    5
    非要做的话,可以这样:
    # prelude.py
    import requests
    import json

    # main.py
    from prelude import *
    chevalier
    chevalier
    Apr 12, 2020
    6
    @Juszoe 请教一些,公司登录测试 /线上环境都要通过跳板机,pycharm remote 可以支持么?
    gjquoiai
    gjquoiai
    Apr 12, 2020
    7
    ms 的 language server 已经支持自动 import 了,虽然还是有很多问题不过还算勉强能用了。。试试更新一下,或者换到更快的更新频道上
    laike9m
    laike9m
    Apr 12, 2020 via Android
    8
    首先我觉得 import 多不是特别大的问题,至少我见到的 Java 的 import 一般都多得多。其次,如果真的多到难以接受,你可能要考虑一下模块拆分,以保证模块是单一职责的。
    Juszoe
    Juszoe
    Apr 12, 2020
    9
    @chevalier #6 他是走的 ssh 协议的,有跳板应该问题不大,做好转发即可
    noparking188
    noparking188
    Apr 13, 2020
    10
    那你真的懒
    luhuisicnu
    luhuisicnu
    Apr 13, 2020
    11
    估计是代码架构的问题,到处 import 很多模块
    exip
    exip
    Apr 13, 2020 via Android
    12
    pyforest
    延迟导入所有流行的 Python 数据科学库。 停止一遍又一遍地写相同的导入。
    ytmsdy
    ytmsdy
    Apr 13, 2020
    13
    @gwy15 大兄弟,尽量不要 import * ,当出现函数名相同的时候,就 SB 了。
    Harlaus
    Harlaus
    Apr 14, 2020
    14
    __all__ = ['a', 'b']
    from . import *
    arthurire
    arthurire
    Apr 14, 2020
    15
    snippet?
    cominghome
    cominghome
    Apr 16, 2020
    16
    没研究过,但是总感觉怪怪的。就好比问“有没有别的办法处理生存问题,不想手动吃饭了”
    guhuisec
    guhuisec
    Apr 17, 2020
    17
    大神,希望转载您的 flask 教程,详情已经发您 163 的邮箱了,能否抽空回复下,谢了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   920 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 18:03 · PVG 02:03 · LAX 10:03 · JFK 13:03
    ♥ Do have faith in what you're doing.