I would like to change the behavior of the list of pythons so that a Here's what I have done: Once done, it gives the third element of the list: But it still returns an error: The error is very straightforward: I think there is probably no way to do this, but I can not find anything that can Surely any thoughts? 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.)
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
x = list (1, 2, 3) print x (2)
x = [1, 2, 3] print x (2)
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
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