matrix class
DarrenWeber
Darren.Weber at radiology.ucsf.edu
Tue Jun 12 21:56:52 EDT 2007
More information about the Python-list mailing list
Tue Jun 12 21:56:52 EDT 2007
- Previous message (by thread): Why can't easy_install Django
- Next message (by thread): matrix class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Jun 12, 6:20 pm, Dan Bishop <danb... at yahoo.com> wrote: > On Jun 12, 7:31 pm, DarrenWeber <Darren.We... at radiology.ucsf.edu> > wrote: > > > > > Below is a module (matrix.py) with a class to implement some basic > > matrix operations on a 2D list. Some things puzzle me about the best > > way to do this (please don't refer to scipy, numpy and numeric because > > this is a personal programming exercise for me in creating an > > operational class in pure python for some *basic* matrix operations). > > > 1. Please take a look at the __init__ function and comment on the > > initialization of the list data with respect to unique memory > > allocation. > > > 2. In the operator overloading of __add__, __sub__, etc., the > > statement isinstance(q, Matrix) raises exceptions every time. This > > statement works fine outside of the class definition, but not during > > the operator evaluation. What is going here? > ... > > > def __add__(self, q): > > 'matrix addition: m3 = m1 + m2' > > # if isinstance(q, Matrix): > > # arg = ("q is not a matrix instance", q) > > # raise TypeError, arg > > Wouldn't it make more sense to raise an exception if q is NOT an > instance of Matrix? Duh, yea! I don't recommend programming and sleep deprivation ;-)
- Previous message (by thread): Why can't easy_install Django
- Next message (by thread): matrix class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list