Patty wrote:
This is very interesting to me - the below excerpt is something I was
trying to do for one of my programs and gave up on it:
A fifth approach, common in some other languages, is to return some
arbitrary value, and set an error flag. The caller then has to write
code like this:
I think I understand, I will have to reread this a couple times! But I do
consider myself a C programmer so that probably explains why I was trying
to write code that way. And you are right 'you must inspect the global
after each call, before making the next call'. I *was* setting up the
On Tue, Nov 30, 2010 at 13:23, Steven D'Aprano st...@pearwood.info wrote:
Richard D. Moores wrote:
Please take a look at 2 functions I just wrote to calculate the
harmonic and geometric means of lists of positive numbers:
http://tutoree7.pastebin.com/VhUnZcma.
Both Hlist and Glist must
Richard D. Moores wrote:
[...]
def harmonic_mean(data):
try:
m = mean(1.0/x for x in data)
except ZeroDivisionError:
return 0.0
if m == 0.0:
return math.copysign(float('inf'), m)
return 1/m
math.copysign! Didn't know about that one. But mean? It's not a
On Tue, Nov 30, 2010 at 13:23, Steven D'Aprano st...@pearwood.info wrote:
For what it's worth, I have a module of statistics functions (shameless
plug: http://pypi.python.org/pypi/stats and
http://code.google.com/p/pycalcstats -- feedback and bug reports welcome)
Your readme says:
On Thu, Dec 2, 2010 at 10:27 AM, Richard D. Moores rdmoo...@gmail.com wrote:
Could I have put stats-0.1.1a anywhere, CD-ed to that anywhere, and
then run the command?
Yes.
python setup.py install essentially instructs
distutils (or setuptools or distribute - whichever is being used)
to install
On Wed, Dec 1, 2010 at 16:41, James Mills prolo...@shortcircuit.net.au wrote:
On Thu, Dec 2, 2010 at 10:27 AM, Richard D. Moores rdmoo...@gmail.com wrote:
Could I have put stats-0.1.1a anywhere, CD-ed to that anywhere, and
then run the command?
Yes.
Thanks, James. Did that.
Thought I'd
On Tue, Nov 30, 2010 at 3:00 PM, Richard D. Moores rdmoo...@gmail.com wrote:
Both Hlist and Glist must contain only positive numbers, so I really
need to test for this inside each function. But is there a good way to
do this? What should the functions return should a non-positive number
be
Richard D. Moores wrote:
Please take a look at 2 functions I just wrote to calculate the
harmonic and geometric means of lists of positive numbers:
http://tutoree7.pastebin.com/VhUnZcma.
Both Hlist and Glist must contain only positive numbers, so I really
need to test for this inside each
...@pearwood.info
To: tutor@python.org
Sent: Tuesday, November 30, 2010 1:23 PM
Subject: Re: [Tutor] How to handle exceptions raised inside a function?
Richard D. Moores wrote:
Please take a look at 2 functions I just wrote to calculate the
harmonic and geometric means of lists of positive
10 matches
Mail list logo