myrmepropagandist on Nostr: I have a list of 3 python objects w/ 4 attributes. If exactly 2 are identical (not ...
I have a list of 3 python objects w/ 4 attributes. If exactly 2 are identical (not all 3, not none) I want to return False.
mylist=[ob1, obj2, obj3]
if len(set([x.attribute1 for x in mylist]))==2:
return False
if len(set([x.attribute2 for x in mylist]))==2:
return False
if len(set([x.attribute3 for x in mylist]))==2:
return False
if len(set([x.attribute4 for x in mylist]))==2:
return False
return True
feels clunky. what am i missing?
(can you guess what card game?)
Published at
2024-05-10 15:36:13Event JSON
{
"id": "1fa63515312846b23c56d6f626c6d5f06a3479b73f883dda6fa411e82ca52f26",
"pubkey": "c054144d7615820eaa2322e78ba10e111c44219059482b21ba71e51a9729f40b",
"created_at": 1715355373,
"kind": 1,
"tags": [
[
"content-warning",
"python"
],
[
"proxy",
"https://sauropods.win/users/futurebird/statuses/112417529767920166",
"activitypub"
]
],
"content": "I have a list of 3 python objects w/ 4 attributes. If exactly 2 are identical (not all 3, not none) I want to return False. \n\nmylist=[ob1, obj2, obj3]\n\nif len(set([x.attribute1 for x in mylist]))==2:\n return False\nif len(set([x.attribute2 for x in mylist]))==2:\n return False\nif len(set([x.attribute3 for x in mylist]))==2:\n return False\nif len(set([x.attribute4 for x in mylist]))==2:\n return False\nreturn True\n\nfeels clunky. what am i missing? \n\n(can you guess what card game?)",
"sig": "4c7d70da918b8a8d3571ec00e89c7a0023ae3b76643601829953b669433a0fd1b210fb36e714e2d576008c16c8a7c75dd21de494f288f5c843b8a0e28ebdb183"
}