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


Groups > comp.lang.python > #89581

Re: Useful module to be written by a newbie

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'yet.': 0.04; 'cest': 0.09; 'explanation': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'iterable': 0.16; 'iterator': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; 'acquired': 0.19; 'value.': 0.19; 'thanks.': 0.20; 'example': 0.22; 'header:User-Agent:1': 0.23; 'wednesday': 0.24; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'possibility': 0.29; "doesn't": 0.30; 'especially': 0.30; 'probably': 0.32; 'moment': 0.34; 'something': 0.35; 'but': 0.35; 'really': 0.36; 'interface,': 0.36; 'should': 0.36; 'list': 0.37; 'feed': 0.38; 'to:addr:python-list': 0.38; 'moving': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'new': 0.61; 'more': 0.64; '2015': 0.84; 'average.': 0.84; 'beside': 0.84; 'excursion': 0.84; 'newbie,': 0.84; 'average': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Useful module to be written by a newbie
Date Thu, 30 Apr 2015 00:00:54 +0200
Organization None
References <87y4lbasvf.fsf@Equus.decebal.nl> <mailman.88.1430324895.3680.python-list@python.org> <87pp6mc100.fsf@Equus.decebal.nl> <mailman.93.1430334242.3680.python-list@python.org> <87h9rybr0w.fsf@Equus.decebal.nl>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd8d27.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.101.1430344867.3680.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430344867 news.xs4all.nl 2944 [2001:888:2000:d::a6]:60619
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3789
X-Received-Body-CRC 1929040466
Xref csiph.com comp.lang.python:89581

Show key headers only | View raw


Cecil Westerhof wrote:

> Op Wednesday 29 Apr 2015 21:03 CEST schreef Peter Otten:

>> I was judging from the look of your MovingAverage.
>>
>> I don't like the interface, it really should take an iterable so
>> that you can write
>>
>>>>> list(moving_average([1,2,3], 2))
>> [1.5, 2.5]
> 
> I should probably document it better. The idea is that you do not have
> the data yet. At certain intervals data is acquired and at that moment
> you want the moving average with the new data. But it would not hurt
> to have the possibility to feed it a list of values, beside single
> value. Something to better the function. Thanks.

With that explanation and especially Ian's motivational excursion it makes 
more sense. My conclusion "ah newbie, doesn't know/shuns iterator protocol" 
may be wrong. However, it may be better to follow Ian's example and decouple 
adding a new value and reading the current average.

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


Thread

Useful module to be written by a newbie Cecil Westerhof <Cecil@decebal.nl> - 2015-04-29 16:53 +0200
  Re: Useful module to be written by a newbie Peter Otten <__peter__@web.de> - 2015-04-29 18:27 +0200
    Re: Useful module to be written by a newbie Cecil Westerhof <Cecil@decebal.nl> - 2015-04-29 19:12 +0200
      Re: Useful module to be written by a newbie Peter Otten <__peter__@web.de> - 2015-04-29 21:03 +0200
        Re: Useful module to be written by a newbie Cecil Westerhof <Cecil@decebal.nl> - 2015-04-29 22:47 +0200
          Re: Useful module to be written by a newbie Peter Otten <__peter__@web.de> - 2015-04-30 00:00 +0200
          Re: Useful module to be written by a newbie Michael Welle <mwe012008@gmx.net> - 2015-05-09 08:10 +0200
            Re: Useful module to be written by a newbie Cecil Westerhof <Cecil@decebal.nl> - 2015-05-09 10:28 +0200
              Re: Useful module to be written by a newbie Michael Welle <mwe012008@gmx.net> - 2015-05-09 11:43 +0200
      Re: Useful module to be written by a newbie Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-29 13:40 -0600

csiph-web