In python how do you add an attribute to a list to perform an operation?
Suppose you have a class like:
class TestClass:
def __init__(self, lst):
self.lst = lst
def test(self, lst):
"""
>>> t1 = TestClass([1,2,3,4])
>>> t1.test(self.lst).size
4
"""
if you attach the attribute size to the function test it will return the length of self.lst. So, return len(self.lst)
return len(self.lst)- and what's that otherlstintest? What exactly are you trying to do - I suspect it isn't making function attributes...