Send Text to REPL Using SublimeREPL and Sublime Text 2

谁说我不能喝 提交于 2019-12-04 09:41:06

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.

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

Now

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)

Howto

  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! :)

I had the same problem, namely SublimeREPL wouldn't evaluate a file or selected lines. Amazingly this worked:

  1. Remove REPL (Preferences-> Package Control -> Remove package)
  2. Quit and restart Sublime Text
  3. Install REPL (Preferences-> Package Control -> Install package)
  4. Quit and restart Sublime Text

Voila!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!