I would like to change the behavior of the list of pythons so that a list
, they list < Produce a sub-class of / code> that I have written. (Note: I do not think this is a good idea; I'm doing this for fun, not real use.)
Here's what I have done:
Old _ list = list class callable list (old_link): def __init __ (self, * args): old_list for arguments in arguments .__ Init __ (self): self Apand (rarg) def __call __ (self, start, end = none): if the end is: return self [start: end] returns self [start] list = callable list
Once done, it gives the third element of the list:
x = list (1, 2, 3) print x (2)
But it still returns an error:
x = [1, 2, 3] print x (2)
The error is very straightforward:
traceback (most recent call final): file "list_test.py", line 23, m & Lt; Module & gt; Print x (2) type error: 'list' object is not worth the corner
I think there is probably no way to do this, but I can not find anything that can Surely any thoughts?
You are on this because the syntax used for the underlying types is trivial to the Chinese. Can not override compiler level Always call Constructor explicitly.
Comments
Post a Comment