I'm trying to understand how __builtin__
works in Python. My code is as follows:
import __builtin__
class MyList(list):
pass
__builtin__.list = MyList
a = [1,2,3,4,5]
b = list([1,2,3,4,5])
print 'A: ', type(a)
print 'B: ', type(b)
When I print the types of both of the lists, I get:
A: <type 'list'>
B: <class '__main__.MyList'>
Why aren't both lists of type MyList
and how can I achieve that []
syntax would also be of type MyList
?