Created
May 12, 2021 12:28
-
-
Save emadflash/63a006c5f7041eeccb89a8285c7eb380 to your computer and use it in GitHub Desktop.
You can access Class object stuffs with python list like thingy
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
class Poon: | |
def __init__(self, ip, port): | |
self.ip = ip | |
self.port = port | |
def __getitem__(self, index): | |
return self.__dict__[index] | |
p = Poon('192.168.0.1', '8080') | |
print(p['ip']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment