Objects in Python

shaun shaun.wiseman91 at gmail.com
Wed Aug 22 11:25:36 EDT 2012


Here is some code: 
//////////////////////////This is the object I want to create:
#!/usr/bin/python
import cx_Oracle
import sys
import time
import datetime


class batchParam:

	def __init__(self,array):
		self.array=array


	def breakuparray(self):
		for row in self.array:
			mer = row[0].ljust(25, ' ')
			merc = row[1].ljust(13, ' ')
			mertype = row[2]
			merloc = row[3]
			mercount = row[4]
			mersec = row[5]
			acq = row[6]
		
	
	
	def returnBatch(self):
		self.breakuparray()
		return "\x01001\x0251.%s%s%s%s%s%s%s%s\x03"  % (mer, merc, mertype, merloc, mercount, mersec, acq);


//////////////////////////////////////Here is the script I want to run the object in:


#!/usr/bin/python
import cx_Oracle
import sys
import time
import datetime
sys.path.append("C:\\Documents and Settings\\swiseman\\Desktop")
from batchParam import batchParam

term = sys.argv[1]
batch = sys.argv[2]

con = cx_Oracle.connect('databaseInfo')


cur = con.cursor()
cur.execute("SELECT * FROM SOME_TABLE))

results = cur.fetchall()

batchParam(results)
Batch=batchParam.returnBatch

print Batch

cur.close()

//////////////////////////////////////

Thanks,
Shaun



More information about the Python-list mailing list