Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin3!goblin.stu.neva.ru!newsfeed2.funet.fi!newsfeeds.funet.fi!85.12.40.130.MISMATCH!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'static': 0.04; 'argument': 0.05; 'classes,': 0.05; 'explicitly': 0.05; 'subject:Python': 0.06; 'attribute': 0.07; 'class,': 0.07; 'though:': 0.07; 'string': 0.09; 'attributes': 0.09; 'constructor': 0.09; 'function,': 0.09; 'ide': 0.09; 'occasionally': 0.09; 'subject:using': 0.09; '>>': 0.16; 'attributes.': 0.16; 'email addr:udel.edu>': 0.16; 'email name:<tjreedy': 0.16; 'evaluates': 0.16; 'exist.': 0.16; 'function?': 0.16; 'ides': 0.16; 'iterable': 0.16; 'likewise': 0.16; 'reedy': 0.16; 'values:': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; '>>>': 0.22; 'import': 0.22; '>>>': 0.24; 'alternate': 0.24; 'string,': 0.24; 'test.': 0.24; 'versions': 0.24; '>': 0.26; 'mention': 0.26; 'right.': 0.26; 'least': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'point': 0.28; 'function': 0.29; 'am,': 0.29; 'points': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '4.0': 0.31; 'doc': 0.31; 'existence': 0.31; 'invoke': 0.31; 'prints': 0.31; 'lists': 0.32; 'skip:s 30': 0.35; 'point.': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'two': 0.37; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; '8bit%:6': 0.40; 'chain': 0.60; 'middle': 0.60; 'simply': 0.61; 'complete': 0.62; '8bit%:10': 0.64; 'taking': 0.65; 'frustrated': 0.68; 'surprise': 0.74; 'completion': 0.78; 'dict.': 0.84; 'median': 0.84; 'usage.': 0.84; 'average': 0.93 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 :content-type; bh=tJsyR1yD07gg0gs6LapEf0jZ/12YkbhJcTRNzLkXx9c=; b=oCdDZNhvUOc3pTqUp/ppnfZ7E1pMqOg3emZBkZulbx7Sogh0M/33vw3hvvBcsbCMUY HyBEJHOyiPi8UPPMT3z6RYKdXV9u108Qqqwb8hqOUknskUfyj+wy6B+t2tzsapfp28Cx QYCnz2xrl5NlIDbHL3Gd1dTBKbZ2SRfeFfp45nL5dOxRQGHLEeaiT8tFBXKBDRax0w+B kDOuoqv8JdtjIYU/GSp5MitS8vujxvdEy5JMFo0RyA3mckBULEFVPHddkZWECC+lf0JS BqZecKwyR3yILhTEJbeiRZD0fM865dGUxvxcYYIB1nnjGE1dggU+OxvJ18U5dvz/JDZT xqQg== X-Received: by 10.70.26.100 with SMTP id k4mr10179338pdg.101.1418243588875; Wed, 10 Dec 2014 12:33:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <004e01d01173$e1641c10$a42c5430$@gmail.com> <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> <54866372$0$12991$c3e8da3$5496439d@news.astraweb.com> <54878f8a$0$13010$c3e8da3$5496439d@news.astraweb.com> <54881159$0$2817$c3e8da3$76491128@news.astraweb.com> From: Ian Kelly Date: Wed, 10 Dec 2014 13:32:28 -0700 Subject: Re: Python Iterables struggling using map() built-in To: Python Content-Type: multipart/alternative; boundary=047d7bd6bd9251f17c0509e29112 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 100 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418243599 news.xs4all.nl 2941 [2001:888:2000:d::a6]:49359 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 9773 X-Received-Body-CRC: 4163713483 Xref: csiph.com comp.lang.python:82309 --047d7bd6bd9251f17c0509e29112 Content-Type: text/plain; charset=UTF-8 On Wed, Dec 10, 2014 at 10:48 AM, Terry Reedy wrote: >> Likewise the generated help for the help() function, >> unless care is taken to explicitly mention the existence of those >> functions in either the doc string for the module > > > help(it.chain) lists > | from_iterable(...) from builtins.type > | chain.from_iterable(iterable) --> chain object > | > | Alternate chain() contructor taking a single iterable argument > | that evaluates lazily. As you point out, chain is a class, not a function. When you invoke help() on a function, it lists the members, of which a static alternate constructor would be one. Try it with a function, though: >>> import statistics >>> statistics.median.low = statistics.median_low >>> help(statistics.median) Help on function median in module statistics: median(data) Return the median (middle value) of numeric data. When the number of data points is odd, return the middle data point. When the number of data points is even, the median is interpolated by taking the average of the two middle values: >>> median([1, 3, 5]) 3 >>> median([1, 3, 5, 7]) 4.0 It only prints out the doc string, nothing about the attributes. So the doc string for median would need to explicitly document the existence of median.low and median.high in addition to its own usage. >> Thirdly, IDEs with code completion features may simply fail to >> notice that these alternate versions of the function exist. > > I don't know what you mean here. In Idle > >>> it.chain. --> completion box with from_iterable > >>> dict. --> completion box that includes fromkeys So Idle gets it right. At least for static methods of classes, which isn't very surprising. Does it complete a function attribute of a function? I don't have it installed to test. Having used Komodo IDE for a number of years and been occasionally frustrated by its code completion, it would not surprise me in the least if it failed to pull attributes of functions into its completion database. --047d7bd6bd9251f17c0509e29112 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Wed, Dec 10, 2014 at 10:48 AM, Terry Reedy <tjreedy@udel.edu> wrote:
>> Li= kewise the generated help for the help() function,
>> unless care = is taken to explicitly mention the existence of those
>> functions= in either the doc string for the module
>
>
> help(it.ch= ain) lists
> =C2=A0| =C2=A0from_iterable(...) from builtins.type
&= gt; =C2=A0| =C2=A0 =C2=A0 =C2=A0chain.from_iterable(iterable) --> chain = object
> =C2=A0|
> =C2=A0| =C2=A0 =C2=A0 =C2=A0Alternate chain(= ) contructor taking a single iterable argument
> =C2=A0| =C2=A0 =C2= =A0 =C2=A0that evaluates lazily.

As you point out, chain is a c= lass, not a function. When you invoke help() on a function, it lists the me= mbers, of which a static alternate constructor would be one. Try it with a = function, though:

>>> import statist= ics
>>> statistics.median.low =3D statistics.median_low<= /div>
>>> help(statistics.median)
Help on function m= edian in module statistics:

median(data)
=C2=A0 =C2=A0 Return the median (middle value) of numeric data.
= =C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 When the number of data points = is odd, return the middle data point.
=C2=A0 =C2=A0 When the numb= er of data points is even, the median is interpolated by
=C2=A0 = =C2=A0 taking the average of the two middle values:
=C2=A0 =C2=A0= =C2=A0
=C2=A0 =C2=A0 >>> median([1, 3, 5])
=C2= =A0 =C2=A0 3
=C2=A0 =C2=A0 >>> median([1, 3, 5, 7])
=C2=A0 =C2=A0 4.0

It only prints out t= he doc string, nothing about the attributes. So the doc string for median w= ould need to explicitly document the existence of median.low and median.hig= h in addition to its own usage.

>> Thirdly, = IDEs with code completion features may simply fail to
>> notice th= at these alternate versions of the function exist.
>
> I don= 9;t know what you mean here.=C2=A0 In Idle
> >>> it.chain. = =C2=A0--> completion box with from_iterable
> >>> dict. = =C2=A0 --> completion box that includes fromkeys

So Id= le gets it right. At least for static methods of classes, which isn't v= ery surprising. Does it complete a function attribute of a function? I don&= #39;t have it installed to test.

Having used Komod= o IDE for a number of years and been occasionally frustrated by its code co= mpletion, it would not surprise me in the least if it failed to pull attrib= utes of functions into its completion database.
--047d7bd6bd9251f17c0509e29112--