Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89569
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'yet.': 0.04; 'cest': 0.09; 'python:': 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; 'url:github': 0.09; 'python': 0.11; 'def': 0.12; 'enlighten': 0.16; 'iterable': 0.16; 'numpy': 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; 'statement.': 0.16; 'url:py': 0.16; 'values:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'written': 0.21; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'certainly': 0.24; 'sorry,': 0.24; 'wednesday': 0.24; 'compare': 0.26; 'right.': 0.26; '(for': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'errors': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'away.': 0.31; 'anyone': 0.31; 'me?': 0.32; 'run': 0.32; 'community': 0.33; 'bugs': 0.33; 'cases': 0.33; 'limitation': 0.33; 'skip:d 20': 0.34; "i'd": 0.34; 'could': 0.34; 'classes': 0.35; 'case,': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'accessible': 0.36; 'grateful': 0.36; 'interface,': 0.36; 'yield': 0.36; 'useful': 0.36; 'should': 0.36; 'project': 0.37; 'clear': 0.37; 'generic': 0.38; 'writes': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'little': 0.38; 'expect': 0.39; 'moving': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'affect': 0.61; 'ago.': 0.61; 'hardware': 0.61; 'areas': 0.61; 'course': 0.61; 'advanced': 0.63; 'pick': 0.64; 'more': 0.64; 'competition': 0.65; 'caused': 0.69; 'limit': 0.70; '2015': 0.84; 'average.': 0.84; 'float,': 0.84; 'glance': 0.84; 'n):': 0.84; 'url:master': 0.84; 'average': 0.93; 'yours.': 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 | Wed, 29 Apr 2015 21:03:26 +0200 |
| Organization | None |
| References | <87y4lbasvf.fsf@Equus.decebal.nl> <mailman.88.1430324895.3680.python-list@python.org> <87pp6mc100.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.93.1430334242.3680.python-list@python.org> (permalink) |
| Lines | 73 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1430334242 news.xs4all.nl 2967 [2001:888:2000:d::a6]:37388 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:89569 |
Show key headers only | View raw
Cecil Westerhof wrote: > Op Wednesday 29 Apr 2015 18:27 CEST schreef Peter Otten: > >> Cecil Westerhof wrote: >> >>> I have experience with Python, but it has been some time ago. The >>> best way to relearn a language (for me) is just make a lot of code >>> with it. But it would be nice if it was useful at the same time. I >>> started a Python library on GitHub: >>> https://github.com/CecilWesterhof/PythonLibrary >>> >>> Anyone an idea about functions and classes that would be useful for >>> the Python community and could be written by me? >> >> Realistically a Python coder with a little experience will have a >> glance at your code and run away. > > Oops, that is not nice to hear. :'-( Sorry, I did not mean to discourage you or insult you, I just wanted to make it clear that your code is not there yet. > But can you enlighten me? Then I can learn from it. 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 don't see how you cope with error accumulation. Given how generic your code is I don't see why you limit it to just int and float, and I don't expect that limitation to find errors caused by my code using your moving average. And then there's the testing... Compare that to the beast I found in a web search for moving average python: <https://github.com/linsomniac/python-movingaverage/blob/master/movingaverage.py> I'm no numerics expert and it would take me some time to verify that it is a good implementation without bugs or corner cases that affect my use case, but I can pick any three lines from the code and they just look right. If right now I needed an implementation of moving average that is more advanced than the naive one I can churn out >>> def moving_average(values, n): ... values = iter(values) ... d = [] ... for i in range(n-1): ... d.append(next(values)) ... for v in values: ... d.append(v) ... yield sum(d) / n ... del d[0] ... >>> list(moving_average([1,2,3], 2)) [1.5, 2.5] and there is no implementation from a reputable project like numpy I'd certainly use that one rather than yours. To put it into perspective: There are of course many areas where there is not much competition and if someone makes some exotic hardware accessible via Python then I am grateful and will accept that that person writes Python as if it were C and has not yet grokked the exact meaning of the global statement. In other words: useful wins over easy-to-use wins over idiomatic.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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