[Python-ideas] Pre-PEP 2nd draft: adding a statistics module to Python

Ryan rymg19 at gmail.com
Thu Aug 8 18:38:33 CEST 2013


I believe you can also shorten option 1 to:

data = list(data) if data is iter(data) else data

And, wouldn't option 2 change any data structure that isn't a list? Would that be problem or a benefit?

Steven D'Aprano <steve at pearwood.info> wrote:

>On 09/08/13 00:58, Guido van Rossum wrote:
>> --Guido van Rossum (sent from Android phone)
>> On Aug 8, 2013 7:29 AM, "Steven D'Aprano" <steve at pearwood.info>
>wrote:
>>> - one-pass algorithm for variance is deferred until Python 3.5,
>until
>> then, lists are the preferred data structure (iterators will continue
>to
>> work, provided they are small enough to be converted to lists).
>>
>> How do you plan to distinguish between lists and iterators?
>
>
>I haven't yet decided between these two snippets:
>
># option 1
>if data is iter(data):
>     data = list(data)
>
>
># option 2
>if not isinstance(data, collections.Sequence):
>     data = list(data)
>
>
>although I'm currently leaning towards option 1.
>
>
>
>-- 
>Steven
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>http://mail.python.org/mailman/listinfo/python-ideas

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130808/a5993fa6/attachment.html>


More information about the Python-ideas mailing list