Cope 2.5.0
My personal "standard library" of all the generally useful code I've written for various projects over the years
Loading...
Searching...
No Matches
Psuedonym.py
1
2class Psuedonym(str):
3 """ A string that is equal to a bunch of other strings """
4 def __new__(cls, official:str, *psuedonyms:str, caseSensitive=False):
5 obj = str.__new__(cls, official)
6 obj.name = official
7 obj._psuedonyms = psuedonyms
8 obj.caseSensitive = caseSensitive
9 return obj
10
11 def __eq__(self, other):
12 return other == self.name or any([other == i or ((other.lower() == i.lower()) if not self.caseSensitive else False) for i in self._psuedonyms])
A string that is equal to a bunch of other strings.
Definition: Psuedonym.py:2