class SomeClass(object):
def __init__(self, key_text_pairs = None):
.....
for key, text in key_text_pairs:
......
......
x = SomeClass([(1, "abc",), (2, "fff",)])
The value of key_text_pairs inside the init is None even if I pass a list as in the above statement. Why is it so??
I want to write a generic init which can take all iterator objects...
Thanks
Edit: oops.. I wanted to pass key value pair in the form of tuple... I was just trying to create a toy example.. I am still seeing the same behavior
dictsyntax on a listkey_text_pairsis adict, and you wanted to loop over it, usefor key, text in key_text_pairs.items():. That said, you say "I want to write a generic init which can take all iterator objects," but you seem to mean "I want to write a generic__init__which can take all iterables which yield a 2-tuple at a time." Is this true, or are there other things you want to accept?