[Tutor] A couple beginner questions.

Lloyd Kvam lkvam@venix.com
Wed, 26 Sep 2001 07:59:57 -0400


The book "Python Programming on Win32" by Hammond & Robinson includes some sample classes for processing data. (Chapter 13 on databases.)  While the sample code includes windows paths and windows ODBC config info, it is actually quite portable.

They use a class, DataSet which loads data from an sql database as a list of rows.  The fieldnames are stored as a seperate list.  They provide sample methods for manipulating DataSet's.

I have found this a very useful starting point for my statistical processing.  The sample code is here:
http://starship.python.net/crew/mhammond/ppw32/index.html

If you are working in a Windows environment, this book is EXTREMELY helpful.

Eric Henry wrote:
> 
> Sean 'Shaleh' Perry wrote:
> 
> > this one is straight from the tutorials.
> >
> > [1,2,3] is a list in python.  There are two handy functions in python for
> > lists:
> >
> > map(func,list) -- every item in list is passed to func() as an argument this is
> > equivalent to 'for i in list: func(i)'
> >
> > reduce(func, list) -- starting with the first two elements, pass two elements
> > to func and keep a cumalitive result.  This is the same as 'total =
> 
> Ah, ok.  Thanks, that was exactly what I needed.  :)
> 
> > Hmmm, sounds like a homework problem (-:  Consider making the middle element
> > the key and the each list the data.  So dict[3] -> [1,3,4].  Of course this
> > only works when the keys are not dups.
> 
> Hmm.  I'm not sure that will do what I need.  I'm not always gonna know
> what the number in the middle column is.  Sometimes I'll need to give it
> the number in the first column, and get the value from the second
> column, other times the value in the third column, and get back both the
> first and second column values.
> 
> Oh, and actually it's not homework.  :)  I'm a sociology student, just
> trying to learn a bit about programming by doing some stuff to solve
> some problems I come across a lot, basically just statistics related
> stuff.  Usually I just open up SPSS and do it, but I needed something to
> work on while I'm learning, so I'm duplicating a bunch of stuff.
> Probably pretty badly too.  ;)
> 
> Thanks again.
> 
> Eric Henry
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582