)]}'
{"neutron/tests/tools.py":[{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"3f59060d1623eaa7b9c0bd1b00b90debc840b8fc","unresolved":false,"context_lines":[{"line_number":114,"context_line":"    def __eq__(self, other):"},{"line_number":115,"context_line":"        if not isinstance(other, list):"},{"line_number":116,"context_line":"            return False"},{"line_number":117,"context_line":"        # One cannot write \"sorted(list_of_dict)\", since dicts cannot be"},{"line_number":118,"context_line":"        # ordered (at least in Python 3). So, when we have to handle list of"},{"line_number":119,"context_line":"        # dictionaries, we need to use the \"key\" parameter."},{"line_number":120,"context_line":"        if ((len(other) \u003e 0 and isinstance(other[0], dict)) or"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a50d1a3_66473f4c","line":117,"updated":"2015-07-23 23:27:20.000000000","message":"it seems you can do:\n\n return sorted(self, key\u003dsafe_hash) \u003d\u003d sorted(other, key\u003dsafe_hash)\n\nwith safe_hash defined in https://review.openstack.org/#/c/204792/4/neutron/tests/tools.py\n\nIf needed, safe_hash can extended to support more mutable types (set, list).\n\nThoughts?","commit_id":"9712958e4c8e0de5b3cd5aac8cde1c1502e12709"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"56c30f38e7ae519c36ff6a0e172ab903ce266981","unresolved":false,"context_lines":[{"line_number":117,"context_line":"        # One cannot write \"sorted(list_of_dict)\", since dicts cannot be"},{"line_number":118,"context_line":"        # ordered (at least in Python 3). So, when we have to handle list of"},{"line_number":119,"context_line":"        # dictionaries, we need to use the \"key\" parameter."},{"line_number":120,"context_line":"        if ((len(other) \u003e 0 and isinstance(other[0], dict)) or"},{"line_number":121,"context_line":"            (len(self) \u003e 0 and isinstance(self[0], dict))):"},{"line_number":122,"context_line":"            return (sorted(self, key\u003dlambda x: list(x.items())) \u003d\u003d"},{"line_number":123,"context_line":"                    sorted(other, key\u003dlambda x: list(x.items())))"}],"source_content_type":"text/x-python","patch_set":1,"id":"3a50d1a3_17297189","line":120,"updated":"2015-07-27 08:01:26.000000000","message":"\"if len(other) \u003e 0\" can be written \"if other\".\n\nI don\u0027t like the isinstance(other[0], dict)? What if other[0] is an int, and other[1] is a dict?\n\nWrite a key function which support any type. Example:\n\ndef sort_key(obj):\n    if isinstance(obj, dict):\n        return sorted(x.items())\n    return obj","commit_id":"9712958e4c8e0de5b3cd5aac8cde1c1502e12709"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"56c30f38e7ae519c36ff6a0e172ab903ce266981","unresolved":false,"context_lines":[{"line_number":119,"context_line":"        # dictionaries, we need to use the \"key\" parameter."},{"line_number":120,"context_line":"        if ((len(other) \u003e 0 and isinstance(other[0], dict)) or"},{"line_number":121,"context_line":"            (len(self) \u003e 0 and isinstance(self[0], dict))):"},{"line_number":122,"context_line":"            return (sorted(self, key\u003dlambda x: list(x.items())) \u003d\u003d"},{"line_number":123,"context_line":"                    sorted(other, key\u003dlambda x: list(x.items())))"},{"line_number":124,"context_line":"        return sorted(self) \u003d\u003d sorted(other)"},{"line_number":125,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"3a50d1a3_dc14904e","line":122,"updated":"2015-07-27 08:01:26.000000000","message":"The key function doesn\u0027t work: you should sort items. Use: key\u003dlambda x: sorted(x.items()).","commit_id":"9712958e4c8e0de5b3cd5aac8cde1c1502e12709"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"64f01cd52cec4a9e07e3643ff163d9b5a49e00d2","unresolved":false,"context_lines":[{"line_number":119,"context_line":"        # dictionaries, we need to use the \"key\" parameter."},{"line_number":120,"context_line":"        if ((len(other) \u003e 0 and isinstance(other[0], dict)) or"},{"line_number":121,"context_line":"            (len(self) \u003e 0 and isinstance(self[0], dict))):"},{"line_number":122,"context_line":"            return (sorted(self, key\u003dlambda x: list(x.items())) \u003d\u003d"},{"line_number":123,"context_line":"                    sorted(other, key\u003dlambda x: list(x.items())))"},{"line_number":124,"context_line":"        return sorted(self) \u003d\u003d sorted(other)"},{"line_number":125,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"3a50d1a3_41007066","line":122,"in_reply_to":"3a50d1a3_dc14904e","updated":"2015-07-27 21:31:18.000000000","message":"It would be safer not to assume a list beginning with a dict is a list of dicts","commit_id":"9712958e4c8e0de5b3cd5aac8cde1c1502e12709"}]}
