Return class.

Satish ML satishmlwizpro at gmail.com
Sat Jul 26 21:04:32 CEST 2014


Which line of code is printing [4] and [4, 5, 6, 7] in the output?

from tracer import Tracer
@Tracer
class MyList(list):
    def __init__(self, *args):
        print("INSIDE MyList")
        print(*args)
x = MyList([1, 2, 3])
x.append(4)
print(x.wrapped)
WrapList = Tracer(list)
x = WrapList([4, 5, 6])
x.append(7)
print(x.wrapped)

OUTPUT:

CARST
Trace: display
1
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!
[1]
Trace: name
1
Bob
Trace: pay
2
2000

Trace: name
1
Sue
Trace: pay
2
6000
Trace: name
3
Bob
Trace: pay
4
2000
[4, 2]
INSIDE MyList
[1, 2, 3]
Trace: append
1
[4]
Trace: append
1
[4, 5, 6, 7]



More information about the Python-list mailing list