Created
September 9, 2022 10:24
-
-
Save Glutexo/2ca8ffd15d3f0c0622c327866d397fa5 to your computer and use it in GitHub Desktop.
__getitem__ example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unicodedata import name | |
ANIMALS = ( | |
"๐ถ๐ฑ๐ญ๐น๐ฐ๐ฆ๐ป๐ผ๐ป๐จ๐ฏ๐ฆ๐ฎ๐ท๐ฝ๐ธ๐ต๐๐๐๐๐๐ง๐ฆ๐ค๐ฃ๐ฅ๐ฆ๐ฆ ๐ฆ๐ฆ๐บ๐๐ด๐ฆ๐๐ชฑ๐๐ฆ๐๐๐๐ชฐ๐ชฒ๐ชณ๐ฆ๐ฆ๐ท๐ธ๐ฆ๐ข๐๐ฆ๐ฆ๐ฆ๐๐ฆ๐ฆ๐ฆ๐ฆ๐ก๐ ๐๐ฌ๐ณ๐๐ฆ๐ฆญ๐" | |
"๐ ๐๐ฆ๐ฆ๐ฆง๐ฆฃ๐๐ฆ๐ฆ๐ช๐ซ๐ฆ๐ฆ๐ฆฌ๐๐๐๐๐๐๐๐ฆ๐๐ฆ๐๐ฉ๐ฆฎ๐๐ชถ๐๐ฆ๐ฆค๐ฆ๐ฆ๐ฆข๐ฆฉ๐๐๐ฆ๐ฆจ๐ฆก๐ฆซ๐ฆฆ๐ฆฅ๐๐๐ฟ๐ฆ๐พ๐๐ฒ" | |
) | |
class Emoticons: | |
def __init__(self, chars): | |
self.chars = chars | |
def __getitem__(self, item): | |
return [char for char in self.chars if item in name(char)] | |
if __name__ == "__main__": | |
animals = Emoticons(ANIMALS) | |
print(animals["MOUSE"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment