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

From Peter Otten <__peter__@web.de>
Subject Re: Useful module to be written by a newbie
Date 2015-04-30 00:00 +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>
Newsgroups comp.lang.python
Message-ID <mailman.101.1430344867.3680.python-list@python.org> (permalink)

Show all headers | 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