Creating Class Objects in Loop

2008-03-30 Thread Fish
Hello Folks,
I am reading a CSV file and based on that I am creating TestCase(my
own defined class) objects in a for loop. The problem is each time I
create a new TestCase object in loop, previous objects data is already
copied in that object.

e.g. my sample CSV file is
# -
hello.pcap, 123, 231
test.pcap, 90, 899
hello2.pcap, 81, 18
# ---

When I print the TestCase elements from returned list I get

(Pdb) print tcLstOrig[0]
Pcap Path: hello.pcap
Sid List: 123, 231, 90, 899, 81, 18,

(Pdb) print tcLstOrig[1]
Pcap Path: test.pcap
Sid List: 123, 231, 90, 899, 81, 18,

(Pdb) print tcLstOrig[2]
Pcap Path: hello2.pcap
Sid List: 123, 231, 90, 899, 81, 18,


Kindly guys advise me on this thing. Function snippet and Class
definition are provided below.

Regards,
Fish

=== Problem Code

The function snippet reading CSV and creating TestCase objects is
[code]
tcLst = []
# CSV file is read in variable 'lines'
def returnTcLst(path):
  fp = open(path)
  lines = fp.readlines()

  for line in lines:
tc = TestCase()
i = line.find(",")
tc.setPcap(line[:i].strip())
line = line[i+1:]
line = line + ","
i = line.find(",")
while i != -1:
sid = line[:i].strip()
tc.appendSid(sid)
line = line[i+1:]
i = line.find(",")

tcLst.append(tc)
del tc
  return tcLst
[/code]

My TestCase Class is defined as
[code]
class TestCase(object):
def __init__(self, pcap = None, sids = []):
self.__Pcap = pcap
self.__lstSid = sids

def setPcap(self, path):
self.__Pcap = path

def appendSid(self, sid):
self.__lstSid.append(sid)

def __str__(self):
text = "Pcap Path: " + self.__Pcap + "\n"
text += "Sid List: "
for sid in self.__lstSid:
text += sid + ", "
text += "\n"
return text
[/code]
-- 
http://mail.python.org/mailman/listinfo/python-list


prototpye wtp released

2008-10-11 Thread javascript fish
from:http://www.googlemother.com/wpblogs/?p=7281";>prototype
wtp
Prototype WTP 0.2 released,this release for Prototype 1.6.0

Prototype

Prototype is a JavaScript Framework that aims to ease development of
dynamic web applications. Featuring a unique, easy-to-use toolkit for
class-driven development and the nicest Ajax library around, Prototype
is quickly becoming the codebase of choice for web application
developers everywhere.
Eclipse WTP support javascript code content assistance,but does not
support prototype js.
prototypeWTP is a tool make Eclipse WTP support prototype js code
content assistance.
PDT(PHP Development Tools framework for the Eclipse platform) is based
on WTP,so the plug-in also support PDT.

prototypeWTP also support other tools based on WTP,such as MyEclipse
--
http://mail.python.org/mailman/listinfo/python-list