summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorpks <pks@pks.rocks>2022-12-22 10:51:00 +0100
committerpks <pks@pks.rocks>2022-12-22 10:51:00 +0100
commitc8f0cbdd330143c4454b4cda2495d80e9d54c74d (patch)
treeb5d665bb90ef075ec30251ead9fe17c178a1eb65 /python
parente8d6464f5c834b2ea801ac596ee1d31791f2c2fd (diff)
python examples
Diffstat (limited to 'python')
-rw-r--r--python/abstractmethod.py36
-rwxr-xr-xpython/logging.py13
2 files changed, 49 insertions, 0 deletions
diff --git a/python/abstractmethod.py b/python/abstractmethod.py
new file mode 100644
index 0000000..9c2f075
--- /dev/null
+++ b/python/abstractmethod.py
@@ -0,0 +1,36 @@
+from abc import ABC, abstractmethod
+
+class A(ABC):
+ def __init__(self):
+ pass
+
+ def method(self):
+ print("1")
+
+ @abstractmethod
+ def x(self):
+ pass
+
+class B(A):
+ def __init__(self):
+ pass
+
+ def method2(self):
+ print("2")
+
+class C(B):
+ def __init__(self):
+ pass
+
+ def method(self):
+ print("X")
+
+ def method2(self):
+ print("Y")
+
+ def x(self):
+ pass
+
+c = C()
+c.method()
+c.method2()
diff --git a/python/logging.py b/python/logging.py
new file mode 100755
index 0000000..84e2134
--- /dev/null
+++ b/python/logging.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3.9
+
+import logging
+import sys
+
+logging.basicConfig(stream=sys.stdout)
+logger = logging.getLogger()
+logger.warning("test")
+try:
+ a = []
+ a[1] = 2
+except Exception as e:
+ logger.exception(e)