From 06ec17c5e65d03ffd14a60ce89fe71234eb81c8a Mon Sep 17 00:00:00 2001 From: jwansek Date: Mon, 17 Jan 2022 19:47:01 +0000 Subject: added getting class inheritance tree, getting method args nicely, fixed bug with importing too many modules --- ExampleSubmission/animals.py | 22 ++++++++++++++++++++++ ExampleSubmission/example.py | 11 ++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ExampleSubmission/animals.py (limited to 'ExampleSubmission') diff --git a/ExampleSubmission/animals.py b/ExampleSubmission/animals.py new file mode 100644 index 0000000..10c1cb4 --- /dev/null +++ b/ExampleSubmission/animals.py @@ -0,0 +1,22 @@ +import datetime + +class Animal: + def __init__(self): + self.birthday = datetime.datetime.now() + + def move(self): + return "*moves*" + +class Dog(Animal): + def speak(self): + return "woof" + +class Cat(Animal): + def speak(self): + return "meow" + +class Kitten(Cat): + """nyaa~~~ + """ + def speak(self): + return "meow (but cuter)" diff --git a/ExampleSubmission/example.py b/ExampleSubmission/example.py index b64c98d..a226adb 100644 --- a/ExampleSubmission/example.py +++ b/ExampleSubmission/example.py @@ -1,3 +1,6 @@ +# Eden Attenborough +# 12-01-21 + import tkinter as tk class Application(tk.Tk): @@ -8,7 +11,7 @@ class Application(tk.Tk): self.title("Hello World!") - def a_method_with_defaults(self, arg_1 = "hello", arg_2 = "world"): + def a_method_with_defaults(self, n:str, arg_1 = "hello", arg_2 = "world", count:int = 3): """Adds two strings together with a space between them. Args: @@ -32,6 +35,7 @@ class Application(tk.Tk): """ return num1 + num2 +# hello world! def hello_world(times): """Prints 'hello world!' to stdout. Prints it out `times` times. @@ -46,6 +50,11 @@ def hello_world(times): def an_undocumented_function(): return 3.14156 +# kwonlyargs demo +def greet(*names, greeting="Hello"): + for name in names: + print(greeting, name) + if __name__ == "__main__": app = Application() app.mainloop() \ No newline at end of file -- cgit v1.2.3