简体   繁体   English

迭代和交互地编写和测试python代码

[英]iteratively and interactively writing and testing python code

I'd like to iteratively write and test my python code in the Python console. 我想在Python控制台中迭代编写和测试我的python代码。 I can't find a way to easily load what i've got written in the editor (somefile.py) into the Python console in Pycharm. 我找不到一种方法可以轻松地将我在编辑器(somefile.py)中编写的内容加载到Pycharm的Python控制台中。 Is there a trick to doing so? 这样做有技巧吗?

Pycharm will let me run the entire script but that's not useful because i want to build up my state in the shell by experimenting with the functions and data i've got in the environment (kind of like how a lisp programmer would use a REPL). Pycharm可以让我运行整个脚本,但这没什么用,因为我想通过试验环境中的功能和数据来在外壳中建立状态(就像Lisp程序员将如何使用REPL)。 。

Pycharm have this alt-shift-E option . Pycharm具有此alt-shift-E选项

This way you can write in the editor, select the lines you want to run and run them by alt-shift-E. 这样,您可以在编辑器中编写代码,选择要运行的行,然后通过alt-shift-E来运行它们。

I use it all the time, although I find a lot of people not fameliar with this option. 我一直使用它,尽管我发现很多人对此选项并不满意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM