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


Groups > comp.lang.python > #55297

Re: python function parameters, debugging, comments, etc.

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'languages.': 0.04; 'encoding': 0.05; 'explicitly': 0.05; 'interpreter': 0.05; 'binary': 0.07; 'purpose.': 0.07; 'string': 0.09; 'arguments': 0.09; 'integers': 0.09; 'strings.': 0.09; 'typed': 0.09; 'cc:addr :python-list': 0.11; "(it's": 0.16; 'cc:name:python list': 0.16; 'clear.': 0.16; 'expects': 0.16; 'format?': 0.16; 'integer.': 0.16; 'subject:etc.': 0.16; 'subject:parameters': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; "python's": 0.19; 'cc:addr:python.org': 0.22; 'error': 0.23; 'char': 0.24; 'integer': 0.24; 'replace': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'characters': 0.30; 'nature': 0.30; 'returned': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'decimal': 0.31; 'relies': 0.31; 'text': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'representing': 0.36; 'should': 0.36; 'list': 0.37; 'clear': 0.37; 'represent': 0.38; 'does': 0.39; 'even': 0.60; 'numbers': 0.61; "you've": 0.63; 'information': 0.63; 'name': 0.63; 'kind': 0.63; 'different': 0.65; 'gain': 0.79; 'oscar': 0.84; 'upside': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=WEODsZc4arDDQzGK1kC8KQEJ1UJLaEyIk8KgmBwh1SA=; b=B8Pf4bM/+Qh9q58840KXTiemYg0dS+xzhpK8et6Cfr+b5XKsmULabLzrTrImlgSfDL kN9XIv5sM5WRoTKJj1OEYea2hR9pxygK6ui7DEVqqGErspdMUdESfAAhUvIrsLruRJ+0 B3fCO+Tsc9FF3E8Y+iUFrts45WBZcH39fbEdK+ms8l9+NnfkfnZCRCsTopF/XIzBGUCF ohBUs0+d05hCoxP6vxexpCvU+3l2iGEUagCtSdCh0qhvhomIBr9XTpkbDq1/zsSTE4rN YjWLOM0E7wB8nqNTZlJyPf6/wwR8xsM5M77GWrMDlER7C/ZL/lE0rq0zJDD2lwQ8s9Q3 /42Q==
X-Received by 10.52.161.231 with SMTP id xv7mr1078056vdb.1.1380708923833; Wed, 02 Oct 2013 03:15:23 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <l2fmrk$4ti$1@dont-email.me>
References <mailman.576.1380668112.18130.python-list@python.org> <l2fmrk$4ti$1@dont-email.me>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Wed, 2 Oct 2013 11:15:03 +0100
Subject Re: python function parameters, debugging, comments, etc.
To Rotwang <sg552@hotmail.co.uk>
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <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.605.1380708933.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380708933 news.xs4all.nl 15938 [2001:888:2000:d::a6]:33057
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55297

Show key headers only | View raw


On 2 October 2013 00:45, Rotwang <sg552@hotmail.co.uk> wrote:
>
> So the upside of duck-typing is clear. But as you've already discovered, so
> is the downside: Python's dynamic nature means that there's no way for the
> interpreter to know what kind of arguments a function will accept, and so a
> user of any function relies on the function having clear documentation.

It is still necessary to document the arguments of functions in
explicitly typed languages. Knowing that you need a list of strings
does not mean that you know what the function expects of the values of
the strings and what it will try to do with them.

When you see something like
    int atoi (const char * str);
you know that it takes a string and returns an integer. However the
function name does not clearly indicate any purpose. What kind of
string should I pass in? Is the returned value an error code or a
value generated from the string (it's actually both). Even if you know
that the function parses strings representing integers there are still
many different formats for representing numbers as strings. Should the
string be in a locale-dependent format? What kind of text encoding is
it using (utf-8 maybe)? Should the characters represent an integer in
decimal format or hex, octal, binary or something else?

Inspecting types can be a quick way to gain information about the
meaning of arguments and return values but it is not something that
you should be relying on to replace documentation.


Oscar

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


Thread

python function parameters, debugging, comments, etc. Chris Friesen <cbf123@mail.usask.ca> - 2013-10-01 16:54 -0600
  Re: python function parameters, debugging, comments, etc. Rotwang <sg552@hotmail.co.uk> - 2013-10-02 00:45 +0100
    Re: python function parameters, debugging, comments, etc. Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-02 11:15 +0100
      Re: python function parameters, debugging, comments, etc. Rotwang <sg552@hotmail.co.uk> - 2013-10-02 14:52 +0100

csiph-web