John Machin schrieb:
Rephrasing for clarity: Don't use a data structure that is more complicated than that indicated by your requirements.
Could you please define "complicated" in this context? In terms of characters to type and reading, the dict is surely simpler. But I suppose that under the hood, it is "less work" for Python to deal with a list of tuples than a dict?
Judging which of two structures is "simpler" should not be independent of those requirements. I don't see a role for intuition in this process.
Maybe I should have said "upon first sight" / "judging from the outer appearance" instead of "intuition".
Please see my belated response in your "My first Python program -- a lexer" thread.
(See my answer there.) I think I should definitely read up a bit on the implementation details of those data structures in Python. (As it was suggested earlier in my lexer thread.)
Greetings, Thomas -- Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison! (Coluche) -- http://mail.python.org/mailman/listinfo/python-list