使用SublimeREPL和Sublime Text 2将文本发送到REPL [英] Send Text to REPL Using SublimeREPL and Sublime Text 2

查看:169
本文介绍了使用SublimeREPL和Sublime Text 2将文本发送到REPL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开始使用SublimeREPL时遇到麻烦.我有一个python程序,可以在SublimeText2内部启动python解释器.

I'm having trouble getting started with SublimeREPL. I have a python program, and can start a python interpreter inside of SublimeText2.

但是,我想使用在副本中评估"和转移到副本"功能,但它们似乎无能为力.我如何将一个repl与我的崇高文字2中的文件相关联,以便它们可以正常工作?

However, I would like to use either the Eval In Repl and Transfer to Repl features, but they don't seem to do anything. How do I associate a repl with my file in sublime text 2 so these will work?

推荐答案

历史记录

说实话,对于python而言,eval从来没有可靠地工作过.它受到奇怪的编译错误(主要是由空格/空白行引起)的困扰,并且在评估过程中出现了许多不必要的">>>"提示.

History

To be honest eval for python never worked reliably. It was plagued with strange compilation errors (mainly caused by whitespace/blank lines) and dozens of unnecessary ">>> " prompts showing up during evaluation.

我使用临时文件修复它的尝试仅获得了一定程度的成功,并且由于能够通过ssh运行远程Python而彻底失败: http://www.youtube.com/watch?v=zodAqBvKQm0

My attempt to fix it using temporary files was only moderately successful and broke down completely with the ability to run remote Pythons over ssh: http://www.youtube.com/watch?v=zodAqBvKQm0

但是,看来我终于破解了它:)(一个令人惊讶的简短解决方案,让人感觉很棘手,但AFAICT应该比上一个更可靠,请好奇链接:

However it seems that I've finally cracked it :) (with a surprisingly short solution that feels hacky but AFAICT should be orders of magnitude more reliable than the previous one, link for the curious: https://github.com/wuub/SublimeREPL/blob/master/text_transfer.py#L43)

  1. 安装SublimeREPL 1.2.0(在10分钟前发布)
  2. 运行Python REPL(任意一个,不带virtualenv)
  3. 关注您要评估的文件
  4. Tools -> SublimeREPL -> Eval in REPL -> File[Ctrl+, f]
  5. 使用其他选项(行评估应该很有用,您希望评估的每一行只需要一个光标,请尝试[Ctrl+Alt+<down-arrow>])
  6. ...
  7. 利润! :)
  1. Install SublimeREPL 1.2.0 (released +- 10 minutes ago)
  2. Run Python REPL (any one you wish, w/ or w/o virtualenv)
  3. Focus a file you wish to evaluate
  4. Tools -> SublimeREPL -> Eval in REPL -> File or [Ctrl+, f]
  5. Play with other options (line evaluation should be useful, you only need one cursor in each line you wish to eval, try [Ctrl+Alt+<down-arrow>])
  6. ...
  7. Profit! :)

这篇关于使用SublimeREPL和Sublime Text 2将文本发送到REPL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆