SimplePrograms challenge
Steve Howell
showell30 at yahoo.com
Wed Jun 20 12:58:46 EDT 2007
--- Pete Forman <pete.forman at westerngeco.com> wrote:
>
> An empty list raises an IndexError, a non-iterable
> raises TypeError.
> This is correct behavior IMHO, there is nothing to
> fix. Median should
> return an element (or average of two) from its input
> and if that is
> not meaningful returning None or other special value
> is neither
> appropriate nor Pythonic. Only the caller knows how
> to handle such
> exceptional circumstances.
>
> Actually there are some other issues. Should the
> median of an even
> number of integers allow halves? Should median
> insist that its input
> has an odd number of elements? But it's tough
> squeezing all that
> discourse into 13 or 14 lines ;-) BankAccount
> allows arbitrarily
> large withdrawals, is that to be fixed too?
Agreed on all points. I prefer the simplicity of the
current examples, and I think any reasonable reader
will know their limitations.
The BankAccount example is about as small of a
"complete" class example that I could come up with,
even though it's "complete" only a basic level. It
would be good to have a larger class example that
fleshes out the concept a bit more, even if it's just
BankAccount revisited. I have some free time next
time, I'll try my hand at it.
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
More information about the Python-list
mailing list