Python: Override __eq__ to allow comparison of strings #73

Closed
opened 2026-10-05 03:57:17 +02:00 by adam · 0 comments
Owner

Example usage

nick == "kylef"
channel == "#znc"
user == "kylef"
network == "efnet"
message == "foo" # CPyRetString

How to implement in Python

def __eq__(self, other):
    if str(other) == str(self):
        return True

    return id(self) == id(other)
### Example usage ``` nick == "kylef" channel == "#znc" user == "kylef" network == "efnet" message == "foo" # CPyRetString ``` ### How to implement in Python ``` def __eq__(self, other): if str(other) == str(self): return True return id(self) == id(other) ``` <!-- github-sync-id:3364103 -->
adam closed this issue 2026-10-05 03:57:17 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#73