【问题标题】:What is the correct indention for pep8 on long lines with argument list and assignment带有参数列表和赋值的长行中 pep8 的正确缩进是什么
【发布时间】:2016-04-23 22:14:08
【问题描述】:

这个场景的正确缩进是什么:

class StorageType(models.Model):
    """ Defining a general typ of storage """

    name = models.CharField(
            max_length=50,
            help_text=_("The name for a storage type. Should be unique")
        )

pep8 抱怨

../models.py:68:13: E126 continuation line over-indented for hanging indent
../models.py:70:9: E121 continuation line under-indented for hanging indent

【问题讨论】:

  • 为什么不自己咨询PEP 8?请注意,pep8 程序(顺便说一下,没有得到官方 Python 开发人员的认可)比实际的 PEP 8 指南更加严格。
  • 事实上我做到了,但以上是我理解的摘录。所以我不得不承认我有一些潜力——至少在阅读/理解它时。

标签: python django pep8


【解决方案1】:

这是一个正确的缩进:

class StorageType(models.Model):
    """ Defining a general typ of storage """

    name = models.CharField(
        max_length=50,
        help_text=_("The name for a storage type. Should be unique")
        )

【讨论】:

    【解决方案2】:

    我不知道“正确的”,但这是我最喜欢的通过pep8检查:

    name = models.CharField(
        max_length=50,
        help_text=_("The name for a storage type. Should be unique")
    )
    

    【讨论】:

      猜你喜欢
      • 2013-03-20
      • 2020-02-23
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 2011-01-18
      相关资源
      最近更新 更多