Skip to Content
Python APIEinführungPython-Code-Stilrichtlinie

Python-Code-Stilrichtlinie

Stilrichtlinie für Python-Code

Style guidelines are intended to improve the readability of code and make it consistent across the wide spectrum of Python code. The PEP 8 - Style Guide for Python Code: https://peps.python.org/pep-0008/ is the most widely used style guide at the moment.

FASTSUITE-Code verwendet hauptsächlich den CapitalizedWords- (oder CapWords- bzw. CamelCase-) Benennungsstil, daher wird empfohlen, diesen Stil in allen Kundenprojekten zu verwenden.

Allgemeine CENIT-Stilempfehlungen

Klassen- und Funktionsnamen

  • Klassen- und Funktionsnamen sollten normalerweise die CapWords-Konvention verwenden, zum Beispiel MyFirstClass oder MyFirstFunction.

Variablennamen

  • Lokale Variablen: lokaleVariable
  • Globale Variablen innerhalb eines Moduls: GlobalVariable
  • Konstanten: CONSTANT_VARIABLE
  • Private Variablen: _semiPrivat und __superPrivat

Kommentare und Beschreibungen

Please use autoDocstring extension (see Recommended VS Code extensions).

  • Klassen und Funktionen sollten mit dreifachen Anführungszeichen dokumentiert werden, zum Beispiel """Beschreibung"""
  • Hashtags sollten nur für Inline-Code-Kommentare verwendet werden: # Kommentar

Codebeispiel

  • Please see one of the cenpylib classes as an example.
Was this page helpful?