首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python.el错误地处理了文档字符串上的my缩进

Python.el错误地处理了文档字符串上的my缩进
EN

Stack Overflow用户
提问于 2014-05-20 17:02:37
回答 1查看 377关注 0票数 4

给定函数

代码语言:javascript
复制
def foo():
  """
  etc
  stuff
  """
  pass

当我在文档字符串上运行M到段落时,emacs (24.3.1,python.el)会像这样重新格式化foo:

代码语言:javascript
复制
def foo():
  """etc
  stuff
  """
  pass

我该如何告诉python.el不要管它呢?(我知道这种行为是新的,在另一台计算机(我无法访问)上的老emacs没有这样做)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-20 17:38:52

python.el正在做的实际上是Python约定(尽管在第一行之后没有空行)-参见PEP-0257的示例:

代码语言:javascript
复制
def complex(real=0.0, imag=0.0):
    """Form a complex number.

    Keyword arguments:
    real -- the real part (default 0.0)
    imag -- the imaginary part (default 0.0)
    """
    if imag == 0.0 and real == 0.0:
        return complex_zero

看看python.el,改变这种行为的参数是'python-fill-docstring-style',它默认为pep-257,但提供了一些替代方案:

代码语言:javascript
复制
:type '(choice
          (const :tag "Don't format docstrings" nil)
          (const :tag "Django's coding standards style." django)
          (const :tag "One newline and start and Two at end style." onetwo)
          (const :tag "PEP-257 with 2 newlines at end of string." pep-257)
          (const :tag "PEP-257 with 1 newline at end of string." pep-257-nn)
          (const :tag "Symmetric style." symmetric))
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23765887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档