简体   繁体   English

关闭 IPython REPL 中代码的“即时”重新格式化

[英]Turn off "on the fly" reformatting of code in IPython REPL

Starting with IPython 8.0, the code I type in the REPL is reformatted automagically.从 IPython 8.0 开始,我在 REPL 中键入的代码会自动重新格式化。

As it happens (and I realize it's my fault), I am confused by this behavior.当它发生时(我意识到这是我的错),我对这种行为感到困惑。 If I had the choice between getting accustomed to this new experience and turning it off, I'd choose option no.如果我可以在习惯这种新体验和关闭它之间做出选择,我会选择否。 2. 2.

How can I turn off the "on the fly" reformatting in IPython 8.0?如何关闭 IPython 8.0 中的“即时”重新格式化?

IPython supports a couple configuration methods, with profiles being the most common. IPython 支持几种配置方法,其中配置文件是最常见的。 You can create the default profile configuration file by running ipython profile create which will create a ipython_config.py file under .ipython in your home dir.您可以通过运行ipython profile create创建默认配置文件配置文件,这将在您的主目录中的.ipython下创建一个ipython_config.py文件。

In there you can find a commented entry for在那里你可以找到一个评论条目

c.TerminalInteractiveShell.autoformatter = None

either uncomment this, or set it to None yourself and black will no longer be automatically applied to the code.要么取消注释,要么自己将其设置为 None,黑色将不再自动应用于代码。

If modifying the profile's config is not viable the other options are documented here .如果修改配置文件的配置不可行,则此处记录了其他选项。

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

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