Le 01/03/2014 01:22, Mark H. Harris a écrit : > I'll address the second first by asking a question... should an immutable > type (object) be able to hold (contain) mutable objects ... should tuples be > allowed to hold lists? > > lists within a tuple should be converted to tuples. If you want a tuple to > hold a list, make it a list in the first place.
You're perfectly right and that why i've corrected my code to use a list of lists instead of tuple of list. I was hoping Python would prevent me for such a mistake (because such a situation can't be cleary intentional, isn't ?). Now, i will use tuple only with immutable items. IMHO it should be an error to use += with an immutable type and that means not at all. In other words, the list should not even be considered, because we're talking about changing a tuple... which should not be changed (nor should its members be changed). I agree with that too... My error was to first consider the list, then the tuple... I should have considered the tuple first... Anyway, the TypeError should rollback, not commit the mistake. -- https://mail.python.org/mailman/listinfo/python-list