Chris wrote:
> sin(pi*0.5) is what I expected, but I expected to get 0 for sin(pi).
Computers in general, and Python too, usually use floating point
arithmetic in which all numbers are approximated by rational numbers of
a particular form (see http://en.wikipedia.org/wiki/Floating_point for
detail
Dave Benjamin wrote:
> [EMAIL PROTECTED] wrote:
> > Now suppose I set "expression2 = Sum([a,-a])" and Sum.simplify()
> > recognises that the two terms cancel and the Sum has value 0.
> >
> > Can I make "expression2.simplify()" transform expression2 from an
> > instance of Sum to an instance of Numb
Hello comp.lang.py,
Can you help me with ideas for the following (somewhat newbie) OO
design question in Python? Note, I'm using psuedo-code, not actual
Python for the examples!
Background:
---
I need to represent a small variety of mathematical constructs
symbolically using Python classe
Bruno Desthuilliers wrote:
> You've already got the technical answer. About a possible design
flaw,
> it would seem to me that restricting the join() operation on specific
> subclasses breaks the LSP. OTOH, Python being dynamically typed,
> inheritence is merely an implementation detail, so that m
>Assuming that A is a new-style class then if they have to be
>exactly the same type compare the types
Ah-ha! I didn't know that.
>if the 'other' value can be a subclass of self:
>
> def join(self, other):
> if not isinstance(other, type(self)):
> raise whatever
Simple and neat!
Hi all,
Sorry if the post's title is confusing... I'll explain:
I have a class, called A say, and N>1 subclasses of A, called
A1, A2, A3, ..., AN say.
Instances of each subclass can sensibly be joined together with other
instances of the *same subclass*. The syntax of the join method is
identic