Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65775

Re: imperative mood in docstrings

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kwpolska@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'example:': 0.03; 'utf-8': 0.07; 'if,': 0.09; 'logic': 0.09; 'pep': 0.09; '\xe2\x80\x94': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'books': 0.15; 'dictionary.': 0.16; 'docstring': 0.16; 'docstrings': 0.16; "function's": 0.16; "method's": 0.16; 'roy': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'command': 0.22; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'quickly': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'documenting': 0.31; 'such.': 0.31; 'class': 0.32; 'sense': 0.34; 'could': 0.34; 'received:google.com': 0.35; 'described': 0.36; 'words,': 0.36; 'should': 0.36; 'behind': 0.37; 'so,': 0.37; 'pm,': 0.38; 'does': 0.39; 'new': 0.61; 'from:charset:utf-8': 0.61; 'act': 0.63; 'skip:\xe2 10': 0.65; 'air': 0.66; 'american': 0.66; 'smith': 0.68; '8bit%:43': 0.74; 'article': 0.77; 'url:search': 0.81; '257': 0.84; 'action.': 0.84; 'air.': 0.84; 'performs.': 0.84; 'hand,': 0.93; 'url:tk': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Ezi9Y+s7/jikPHN5C2z1JcMQRrZnstDNkmiJnxeNox4=; b=FgV/K1QNUKEmcOMH40mtn499ytF/nZmBS0MXhcR1d3h9ZOpauHx1QidayRFo7U3xYY nID5Z8Mvmp0ABIzwlaSM3z7vvQ4oZIK0SwMMIG4q8HH6aYPKuSl+9wlAXLCkggK3ppNn AB0SSBk1hCcoYFxDBT1g00J5oYNZ95EBA9HLN5BwSdfGfzDFQhKVD7jCQ4RaXW6FZFAf KyTiLAzZCnlF+QK6UDEgGKYvXFbvupuBGzp0CR8x0GYXwevLsPPkjgv6zRZ9oDXgoIbc iUA+wMkdtdI8VOONy3klK/rfTZZ6kTvSEp6upUZqk1dpBFDNvi4lOaIoxn8iz6ylm1Wi YaiA==
MIME-Version 1.0
X-Received by 10.220.58.202 with SMTP id i10mr286153vch.23.1391967993523; Sun, 09 Feb 2014 09:46:33 -0800 (PST)
In-Reply-To <roy-94D93E.11521509022014@news.panix.com>
References <mailman.6584.1391950328.18130.python-list@python.org> <roy-94D93E.11521509022014@news.panix.com>
Date Sun, 9 Feb 2014 18:46:33 +0100
Subject Re: imperative mood in docstrings
From Chris “Kwpolska” Warrick <kwpolska@gmail.com>
To Roy Smith <roy@panix.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6597.1391968001.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391968001 news.xs4all.nl 2871 [2001:888:2000:d::a6]:38343
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65775

Show key headers only | View raw


On Sun, Feb 9, 2014 at 5:52 PM, Roy Smith <roy@panix.com> wrote:
> In article <mailman.6584.1391950328.18130.python-list@python.org>,
>  bagrat lazaryan <bagratte@live.com> wrote:
>
>> pep 257 -- docstring conventions, as well as a myriad of books and other
>> resources, recommend documenting a function's or method's effect as a command
>> ("do this", "return that"), not as a description ("does this", "returns
>> that"). what's the logic behind this recommendation?
>>
>> bagratte
>
> Methods are verbs, and should be described as such.  If I had:
>
> class Sheep:
>    def fly(self):
>       "Plummet to the ground."
>
> I'm defining the action the verb performs.  If, on the other hand, I had:
>
> class Sheep:
>    def fly(self):
>       "Plummets to the ground"
>
> I'm no longer describing the action of flying, I'm describing what the
> sheep does when it attempts to perform that action.

This can also be seen with a (monolingual) dictionary.  For example:
https://www.google.com/search?q=define+fly (that’s actually from the
New Oxford American Dictionary):

fly, verb: 1. move through the air under control. 2. move or be hurled
quickly through the air.

Those could be valid docstrings (if sheep could fly, of course…) — so,
in other words, act as if you were writing a dictionary and not Python
code.

-- 
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

imperative mood in docstrings bagrat lazaryan <bagratte@live.com> - 2014-02-09 16:05 +0400
  Re: imperative mood in docstrings Roy Smith <roy@panix.com> - 2014-02-09 11:52 -0500
    Re: imperative mood in docstrings Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-02-09 18:46 +0100
    Re: imperative mood in docstrings Ethan Furman <ethan@stoneleaf.us> - 2014-02-09 09:53 -0800
    Re: imperative mood in docstrings Chris Angelico <rosuav@gmail.com> - 2014-02-10 09:12 +1100
  Re: imperative mood in docstrings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-09 23:01 +0000

csiph-web