Added more test files from lectures.

This commit is contained in:
cheezedoodle2
2023-04-06 17:03:21 -07:00
parent c610762522
commit 0dd1348601
13 changed files with 311 additions and 7 deletions
+46
View File
@@ -0,0 +1,46 @@
class Test:
a = [1,2,3,4,5]
a1 = 1
def __init__(self) -> None:
pass
def sentiment(self):
pass
def __getattr__(self, str):
print(f"DEBUG: attempt to access attr {str}")
if int(str[1]) > 0 and int(str[1]) < 6:
return self.a[int(str[1])]
def c():
print(f"DEBUG: {c.__self__=}")
def i(self):
pass
#print(f"DEBUG: {i.__self__=}")
class ChildTest(Test):
pass
if __name__ == '__main__':
def whoami(who):
if isinstance(Test.c(), Test):
print("It's a Test!")
if isinstance(ChildTest.c(), ChildTest):
print("It's a ChildTest!")
test = Test()
childtest = ChildTest()
test.sentiment
whoami(test)
whoami(childtest)
print(f"{test.a1}")
print(f"{hasattr(test, 'sentiment')}")
print(f"{test.c=}")
print(f"{childtest.c=}")
test.i()
#print(test['1099'][2019][3])
#print(test.1099_2019_3)