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
4ever911
V2EX  ›  Python

bpython 类似的程序, 能编辑多行吗?

  •  
  •   4ever911 · 2016-07-09 12:40:50 +08:00 · 2372 次点击
    这是一个创建于 2849 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近用 bpython 写代码, 代码提示用的很爽. 可是有一个问题是, 他能不能像文本编辑器那样编辑多行,然后再运行?

    比如, 我前面写了一个函数, 后面想再去编辑一下这个函数, 是不是就没办法?


    我知道 iPython Notebook, PCharme 可以实线这种功能, 但是,感觉用起来没 bpython 爽啊...
    8 条回复    2016-07-12 08:32:40 +08:00
    syslot
        1
    syslot  
       2016-07-09 20:07:56 +08:00
    4ever911
        2
    4ever911  
    OP
       2016-07-10 10:28:47 +08:00
    楼上的可能没明白我的意思, 并不是当前的多行, 而是可以跳过去编辑之前的函数. 类似 VI, 一些 IDE 那样.

    可能反过来说就是 IPython, PyCharm 这些的代码提示都没 bpython 的好用.
    xiahei
        3
    xiahei  
       2016-07-10 11:03:58 +08:00
    - IDLE ,没有提示有补全。可以编辑多行。
    - 试试最新版的 IPython ,提示也很不错了。
    4ever911
        4
    4ever911  
    OP
       2016-07-10 13:42:55 +08:00
    命令行的一行一行解析存在一个问题,

    比如我前面写了一个函数

    def func(a,b):
    print(a)
    print(b)



    后面我也写了一些别的内容,我发现想修改一下这个函数的内容,就很头疼啊.
    syslot
        5
    syslot  
       2016-07-10 14:39:23 +08:00
    @4ever911 这样的话,貌似是需要重新输入代码,如果是这样,推荐还是用 editor 写好脚本,然后在 repl 内部载入脚本
    syslot
        6
    syslot  
       2016-07-10 20:23:35 +08:00
    <img width="1440" alt="screen shot 2016-07-10 at 5 24 08 pm" src="https://cloud.githubusercontent.com/assets/5219942/16712835/77c72e30-46c5-11e6-8c29-f39066ca4d5e.png">
    linhua
        7
    linhua  
       2016-07-11 01:19:23 +08:00
    用 emacs + org-mode org-babel ,, org-mode 里的代码块可以执行,输出在当前文件里。
    literate programming
    https://en.wikipedia.org/wiki/Literate_programming
    http://orgmode.org/worg/org-contrib/babel/
    aec4d
        8
    aec4d  
       2016-07-12 08:32:40 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2994 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:09 · PVG 22:09 · LAX 07:09 · JFK 10:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.