Pulling arrays from database for plotting

2009-08-12 Thread Kurt Schwehr
Hi all, What's the best way to pull arrays from a database for plotting? Right now, this is what I do, but can it be done simpler / more efficiently? ipython -pylab import sqlite3 cx = sqlite3.connect('20080407.decimated.db3') a = array( [tuple(row) for row in cx.execute('SELECT cg_offset, delta_

Re: A superclass using a child classes' methods

2009-06-24 Thread Kurt Schwehr
Jean-Michel, Thanks for the excellent response setting me straight. Now to figure out what dumb thing I did to make my code not work... -kurt On Jun 24, 12:23 pm, Jean-Michel Pichavant wrote: > Kurt Schwehr wrote: > > I'm trying to build an OO system for encoding and decoding &

A superclass using a child classes' methods

2009-06-24 Thread Kurt Schwehr
I'm trying to build an OO system for encoding and decoding datapackets. I'd like the parent class to have an encode function that uses each of the child classes' packing methods. It appears that this works for attributes of children accessed by the parent, but not for methods. Is that right? Fo

Re: pysqlite2 fetching from select different than pysqlite?

2006-07-27 Thread schwehr
Dennis Lee Bieber wrote: > cursor.description -- after an .execute() has selected data. Thanks Dennis, The desciription works, but gives some funky results, but with python it is not a big deal. cu.description (('activity_id', None, None, None, None, None, None), ('case_id', None, None

Re: pysqlite2 fetching from select different than pysqlite?

2006-07-27 Thread schwehr
Perfect. Thanks much! -kurt > > from pysqlite2 import dbapi2 as sqlite > > db = sqlite.connect (":memory:") > db.row_factory = sqlite.Row > > db.execute ("CREATE TABLE x (i INTEGER, code VARCHAR (10), name VARCHAR > (60))") > > for row in db.execute ("PRAGMA TABLE_INFO ('x')"): > print row['n

Re: pysqlite2 fetching from select different than pysqlite?

2006-07-27 Thread schwehr
Thanks Tim! That works well. As a followup, is there a standard compliant way to ask what fields are in the table? -kurt Tim Golden wrote: > | I have some old pysqlite 1.x code that uses a pattern like this: > | > | cu.execute('SELECT weight FROM weights WHERE samplename="foo") > | row = cu.fe

pysqlite2 fetching from select different than pysqlite?

2006-07-27 Thread schwehr
Hi All, I have some old pysqlite 1.x code that uses a pattern like this: cu.execute('SELECT weight FROM weights WHERE samplename="foo") row = cu.fetchone() weight=row['weight'] It seems like lookups by name are no longer supported in pysqlite2. Is that true? And if not, and I want to do a SELE

Re: Detecting socket connection failure

2006-07-19 Thread schwehr
Hi Dieter, Thanks for the feedback. Were you also using mac osx? I am wondering at what level this bug is occuring. -kurt Dieter Maurer wrote: > [EMAIL PROTECTED] writes on 10 Jul 2006 08:42:11 -0700: > > I've tried to RTFM this and am having no luck.First off, I am using > > Mac OSX 10.4.

Detecting socket connection failure

2006-07-10 Thread schwehr
Hi All, I've tried to RTFM this and am having no luck.First off, I am using Mac OSX 10.4.7 with python 2.4.2 from fink. I am trying to connect to a server that should be rejecting connections and I was surprised when it did not throw an exception or do something otherwise equally nasty. It ju

Re: += append class operator

2006-04-19 Thread schwehr
Awesome. Thanks! -kurt -- http://mail.python.org/mailman/listinfo/python-list

+= append class operator

2006-04-19 Thread schwehr
Hi All, This is probably a FAQ, but is there an operator mapping for += for classes? Or does a += b get converted to a = a + b? I would like to make this operator faster for the BitVector class, but I don't see += in http://docs.python.org/lib/operator-map.html I could always create an append m

Re: packaging question - documentation

2006-04-01 Thread schwehr
Sorry about not being clear. I have been downloading quite a few packages for examples, but have not found a good example of man page building from optparse. seismic-py - setup.py - seismic - __init.py__ - bulk of the code *.py - scripts - programs that go in bin/

packaging question - documentation

2006-03-31 Thread schwehr
; [AUTHOR] Kurt Schwehr [SEE ALSO] segysql.py [DESCRIPTION] .PP The --coord-unit option is designed to allow use of databases that exclude the CoordUnit field. This field is probably the same for all traces in the majority of SEGY data files, so most segy-py drivers will want to exclude coordunit from

Building files within a package

2006-03-23 Thread schwehr
Hi All, I am creating a python package that contains a whole pile of functions that build lookup tables. Since these lookup tables will not be changing, I would like to have setup.py create a lut_static.py fie from the lookup table code (lut.py). What is the best way to do this so that when I in

Re: passing artibrary strings into a database

2005-11-27 Thread schwehr
Thanks! Looks like I need to get a newer version of pysqlite into the fink package tree since pysqlite 1.0.1 does not appear support that -- http://mail.python.org/mailman/listinfo/python-list

passing artibrary strings into a database

2005-11-27 Thread schwehr
Hi All, I was wondering if there is a helper library out there that will nicely encode artibrary text so that I can put in into a TEXT field in a database and then retrieve it without getting into trouble with ',",new lines or other such things that would foul the sql insert call and or be a secu

Re: Math markup in code documentation?

2005-10-25 Thread schwehr
Awesome!!! When did doxygen start supporting python? I was really into doxygen last year, but stopped using it when I started doing a lot of coding in python. Thanks -kurt -- http://mail.python.org/mailman/listinfo/python-list

Math markup in code documentation?

2005-10-25 Thread schwehr
Done any one have a way (and examples) of how to do math markups in the docstrings of function and class definitions such that the equations get typeset in the generated html documentation? I'll take any markup system that'll do the job... MathML or LaTeX possible? I'd like to start doing a bette

keeping unit test info out of pydoc -w?

2005-10-16 Thread schwehr
Hi All, Is there an easy way to keep the unittest stuff out of the documentation that gets generated by pydoc -w? I just want to exclude the "Methods inherited from unittest.TestCase:" section. Thanks! -kurt -- http://mail.python.org/mailman/listinfo/python-list

latex/bibtex python paper?

2005-07-06 Thread schwehr
Hi All, Does anyone have a good template that I might use for writing a python paper in latex/bibtex? I've got the paper mostly done, but am having issues with the references. I am definitely not an expert at latex/bibtex. Right now, I have references defined like this: @article{imp, title =