a = 2
b = 3
a_list[a, b] = 4
I found some code like above in a python source file. I looked around in the source file, but found nothing about the definition of using turple as a list index. While I tried to intercept i in UserList.__getiterm__(self, i) : to check if i is a tuple, then do something. It really works. I want to know if intercepting parameter is the standard way to use tuple as list index.
UPDATE: I think it is a user-defined list, while I didn't find the definition.
I don't think that's a list. In your code, a_list is probably a dictionary. And yes, it's completely valid.
Example:
>>> c ={}
>>> c[2,3] = 4
>>> c
{(2,3):4)}
Another posibility is that this is a numpy array.
Hope this helps!
More on dictionaries: http://docs.python.org/2/tutorial/datastructures.html#dictionaries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With