Threader Slash wrote:
Hello Everybody,

My doubt is about matrix data manipulation in python - I hope someone can point me some direction.

I googled around, but there is not much good examples about playing with matrix in python on internet. My following function works pretty well, and gives me the outup from my MySQL db:

* Code:
def employee(self, verifyName): runQuery= """.... = %s"""
        self.cursor.execute(runQuery,(verifyName,))
        for row in self.cursor.fetchall():
print row print "Number of lines returned: %d" % self.cursor.rowcount print "tell column numbers: %d" % len(row)

* output

('John', 'Plumber')
('Bill', 'Driver')
('Mark', 'Lawyer')
Number of lines returned: 3
tell column numbers: 2

Now, how can I transfer this output to provide a matrix with a content like this:

my_array = [['John','Plumber'],
['Bill','Driver'],
['Mark','Lawyer']]

All comments and suggestions are highly appreciated!
my_array = [list(row) for row in self.cursor.fetchall()]
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to