SORU
10 EKİM 2010, Pazar


Standart kütüphane biçimi Python nedir?

Python, orada bir resmi docstrings yazı birkaç farklı stilleri görmüş ya da "mutabık kalınan" tarzı?

CEVAP
13 Kasım 2011, Pazar


Google style guide Python mükemmel bir stil kılavuzu içerir. KEP-257 daha iyi kılavuz sunar conventions for readable docstring syntax içerir. Örneğin:

def square_root(n):
    """Calculate the square root of a number.

    Args:
        n: the number to get the square root of.
    Returns:
        the square root of n.
    Raises:
        TypeError: if n is not a number.
        ValueError: if n is negative.

    """
    pass

Bu Sphinx documentation tutorial bu tarif aynı zamanda bağımsız tür bilgi vardır, genişletmek için seviyorum. Örneğin:

def add_value(self, value):
    """Add a new value.

       Args:
           value (str): the value to add.
    """
    pass

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Hak5DarrensVlog

    Hak5DarrensV

    11 EYLÜL 2009
  • UrAvgConsumer

    UrAvgConsume

    1 Ocak 2012
  • Virtual Riot

    Virtual Riot

    19 Mayıs 2011