Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: No, there is no problem with Python here.
In your "failing" example, you insert the same object ("new_record") into the dictionary. Right, you modify its content, but it is still the same list object; All values in the dictionary are the same object, and are identical... A list object is said "mutable": if you modify it, you modify all other references to the list. A solution is to *copy* the list before adding it into the dictionary, so that the initial list can be modified without impacting the previous entries. By the way, there are at least two more inconsistencies in your example: 1) record!=''or'\n' does not mean what I think you intended. Python reads this as (record != '') or ('\n') Since the right-hand side is a non-empty string, python will evaluate the condition as True value, always. I think you meant something like: record != '' or record != '\n' which can also be written: record not in ('', '\n') 2) new_record !='\n' always succeed, since new_record is a list... ---------- nosy: +amaury.forgeotdarc resolution: -> invalid status: open -> closed __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2793> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com