V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-10-16 13:37:17 +08:00 · 2055 次点击
    这是一个创建于 2012 天前的主题,其中的信息可能已经有所发展或是发生改变。
    macOS 下使用 Terminal,发现 IPython 的自动缩进有个比较奇怪的问题,求教一下大家:
    if/for/def 等语句,冒号之后,IPython 会自动换行,缩进一格
    如果再按一次 Enter,这两行代码就自动执行了
    如果想多写几行代码,应该怎么办呢?

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