# This is my second attempt writting a class
class Getlist(object):
def __init__(self,list1=[],list2=[]):
self.list1 = list1
self.list2 = list2
def printIt(self):
print self.list1
print self.list2
# This will combine the two lists together
class combineList(Getlist):
def __init__(self):
for i in range(len(getlist.list1)):
print getlist.list1[i],getlist.list2[i]
getlist = Getlist([1,2,3],['a','b','c'])
getlist.printIt()
combineList = combineList()
# result should be
# 1a
# 2 b
# 3 c
# this is a sample I got from the Internet, and i modified it
import csv
portfolio = csv.reader(open("Untitled form.csv", "rb"))
portfolio_list = []
portfolio_list.extend(portfolio)
names = []
idigit = []
for data in portfolio_list:
names.append(data[2])
idigit.append(data[3])
del names[0]
del idigit[0]
k = len(names)
for i in range(len(names)):
print names[i], idigit[i]
I am trying to write a custom class that uses this module CSV
I read this tutorial (the link below), and I tried to work through it
http://www.diveintopython.org/object_oriented_framework/defining_classes.html
class FileInfo(UserDict):
"store file metadata"
def __init__(self, filename=None):
UserDict.__init__(self)
self["name"] = filename
What should I do if I want to incorpate an exisitng module?