0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PEP8の命名規則

Posted at

PEP8の命名規則

PythonにはPEP8というコーディング規約があります。
変数名や関数を考える時に毎回調べるのが面倒なので、良く使うルールをメモ書きしておきます。

参考資料

よく使うルール

内容
変数名 スネークケース(すべて小文字で区切りはアンダースコア) my_value
関数名 スネークケース(すべて小文字で区切りはアンダースコア) my_func()
クラス名 キャメルケース(先頭は大文字で区切りは大文字) MyClass
定数 コンスタンスコース(すべて大文字で区切りはアンダースコア) MY_CONSTANT
パッケージ名 全て小文字の短い名前にすべき mypackage
モジュール名 全て小文字の短い名前、アンダースコアは非推奨 mypackage

docstring

docstringのスタイルガイドに PEP257 がありますが、reStructuredTextスタイルの方が直観的に読みやすかったです。

def my_func(value1=0.0, value2=0.0):
    """
    この関数はvalue1とvalue2を加算して返します。

    :param value1: 加算する一つ目の値
    :param value2: 加算する二つ目の値
    :return: 加算結果
    """
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?