推荐学习书目
› 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
rcglight
V2EX  ›  Python

IPython 在 Mac Terminal 下自动缩进问题

  •  
  •   rcglight · Oct 16, 2018 · 3263 views
    This topic created in 2903 days ago, the information mentioned may be changed or developed.
    macOS 下使用 Terminal,发现 IPython 的自动缩进有个比较奇怪的问题,求教一下大家:
    if/for/def 等语句,冒号之后,IPython 会自动换行,缩进一格
    如果再按一次 Enter,这两行代码就自动执行了
    如果想多写几行代码,应该怎么办呢?

    例如我的代码是这样子,输入完毕 print('hello')之后代码块就执行了,没有办法增加一行新的了
    In [10]: def say():
    ...: print(‘ hello ’)
    9 replies  •  2018-10-19 11:02:13 +08:00
    rcglight
        1
    rcglight  
    OP
       Oct 16, 2018
    发现了按 Ctrl-O 时,会再增加一行新的行
    不过这样又有了新问题,就是后面不会再自动缩进了[捂脸]
    rcglight
        2
    rcglight  
    OP
       Oct 16, 2018
    还有一个小问题,是关于 tab 自动补全的,为啥高亮的方法下方都标示了一个<unknown>
    例如
    a = ‘’
    a.<tab>
    弹出的 a.capitalize,a.casefold 这些方法下方都是<unknown>
    Detao
        3
    Detao  
       Oct 16, 2018
    我之前也发现这个问题了, 记得以前是不会直接执行的, 不知道什么时候变得不一样了. 懒得没仔细研究就切去用 jupyter notebook 了.
    rcglight
        4
    rcglight  
    OP
       Oct 17, 2018
    @Detao 多谢,暂时就先这么用用了
    rcglight
        5
    rcglight  
    OP
       Oct 17, 2018
    问题 post 到了 stack overflow 上,目前没人回复。。。
    quinoa42
        6
    quinoa42  
       Oct 17, 2018   ❤️ 1
    推荐一下[ptpython]( https://github.com/jonathanslenders/ptpython),相当于一个 TUI 的 ipython 前端(运行的时候运行 ptipython,ptpython 是 wrap 了 python 的原生 REPL )
    rcglight
        7
    rcglight  
    OP
       Oct 18, 2018
    @quinoa42 多谢多谢~我学习一下!
    Detao
        8
    Detao  
       Oct 18, 2018   ❤️ 1
    https://github.com/ipython/ipython/issues/11334 看样子是个 Bug, 但已经修掉了 ( https://github.com/ipython/ipython/pull/11358). 等 7.1 版本就好了. 或者你可以先装回 6.x 将就着用.
    rcglight
        9
    rcglight  
    OP
       Oct 19, 2018
    @Detao 喔唷 棒棒棒!那我等等!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2530 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:23 · PVG 18:23 · LAX 03:23 · JFK 06:23
    ♥ Do have faith in what you're doing.