Modifying Element In For List

2010-11-15 Thread octopusgrabbus
My question concerns elementary list and pass by reference:

I've written a function which is passed a list that contains rows read
from a csv file. The function traverses csv_rows, row by row, and
inspects the first element in each row. The function tests for '', and
if true, replaces that with a 0.

I've used the standard Python for syntax for this.

def cleanMeterID(csv_rows, bad_meter_id_count):
d = drIdx()

row_number = 0

for row in csv_rows:
if False == is_number(row[d.MeterID]):
csv_rows[row_number][d.MeterID] = 0
row_number = row_number + 1
bad_meter_id_count[0]= bad_meter_id_count[0] + 1

print("Received ", bad_meter_id_count[0], " bad meter ids")

I believe the logic show above is flawed, because I am not modifying
elements in the original csv_rows list. I would modify this to use an
index to traverse the list like

idx=None
for idx in range(0, len(csv_rows), 1):
if False == is_number(row[d.MeterID]):
csv_rows[row_number][d.MeterID] = 0
row_number = row_number + 1
bad_meter_id_count[0]= bad_meter_id_count[0] + 1

Is this correct?

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re-installing 2.6.6 to build shared library

2011-02-04 Thread octopusgrabbus
In order to accommodate a mod_wsgi build problem, I need to have a
Python shared library. What is the best way to re-install Python to do
this?

Many thanks.
cmn
-- 
http://mail.python.org/mailman/listinfo/python-list


Programmatic Parsing of ps

2011-02-09 Thread octopusgrabbus
I have Python 2.6.6. I would like to get this output

ps -ef | grep 'fglgo csm'

into a list. What is the best way to do that? I've been reading the
documentation, and am lost.

Thank you.
cmn
-- 
http://mail.python.org/mailman/listinfo/python-list