summaryrefslogtreecommitdiffstats
path: root/annotations.py
diff options
context:
space:
mode:
Diffstat (limited to 'annotations.py')
-rw-r--r--annotations.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/annotations.py b/annotations.py
new file mode 100644
index 0000000..fe48791
--- /dev/null
+++ b/annotations.py
@@ -0,0 +1,12 @@
+def f(x: float) -> int:
+ return int(x)
+
+
+print(f.__annotations__['x'])
+print(f.__annotations__['return'])
+
+fname: str = "Kyle"
+print(f"fname variable of content 'Kyle' is of type: {__annotations__}")
+class Vector2:
+ x: float # the ": float" annotates variable/name x to hint e.g. pylint that it ought to be a float
+ y: float \ No newline at end of file