{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Assert" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "assert 1 == 1" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " \n" ] } ], "source": [ "try:\n", " assert 1 == 2\n", "except Exception as e:\n", " print(type(e), e)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Object Oriented Programming" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "i = 666" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "print(type(i))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "s = 'mississippi'" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "print(type(s))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s.count('ss')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s.find('ss')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "str_mit_666 = str(666)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "666\n" ] } ], "source": [ "print(str_mit_666)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The ``id()`` function" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "l1 = [1, 2, 3]\n", "l2 = l1" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l2" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "l1.append(4)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l2" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240419976192" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(l1)" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240419976192" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(l2)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(l1) == id(l2)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1 is l2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ``class Person``" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "class Person:\n", " def __init__(self, firstname, lastname):\n", " print('Person.__init__(): ', id(self))\n", " self.firstname = firstname\n", " self.lastname = lastname" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Person.__init__(): 140240419593568\n" ] } ], "source": [ "joerg = Person('Joerg', 'Faschingbauer')" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "id von joerg: 140240419593568\n" ] } ], "source": [ "print('id von joerg:', id(joerg))" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "print(type(joerg))" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Joerg'" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joerg.firstname" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Faschingbauer'" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joerg.lastname" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Functions That Do Not Return Anything" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "def f():\n", " pass" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "wert = f()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n" ] } ], "source": [ "print(wert)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Classes, Attributes, und so (Dictionaries Everywhere!)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "class AClass {\n", " public:\n", " int i;\n", "};\n", " " ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "class Empty:\n", " pass" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "e = Empty()" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.Empty" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(e)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "class AlmostEmpty:\n", " def do_something(self, msg):\n", " self.beenthere = msg" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "a = AlmostEmpty()" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 'AlmostEmpty' object has no attribute 'beenthere'\n" ] } ], "source": [ "try:\n", " a.beenthere\n", "except Exception as e:\n", " print(type(e), e)" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hasattr(a, 'beenthere')" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "a.do_something('yay!!!')" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hasattr(a, 'beenthere')" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'yay!!!'" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.beenthere" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'beenthere': 'yay!!!'}" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.__dict__" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "a.__dict__['kuckucksei'] = 'chirp'" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'chirp'" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.kuckucksei" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.AlmostEmpty" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(a) " ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "isinstance(a, AlmostEmpty)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "a.do_something('yay!!!')" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "def some_bullshit(o, msg):\n", " o.bad_thing_happened = 'JESSAS '+msg+'!!!!!!!'\n", " print('some_bullshit called')" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "AlmostEmpty.do_some_bullshit = some_bullshit" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.AlmostEmpty" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.__class__" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "mappingproxy({'__module__': '__main__',\n", " 'do_something': ,\n", " '__dict__': ,\n", " '__weakref__': ,\n", " '__doc__': None,\n", " 'do_some_bullshit': })" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "AlmostEmpty.__dict__" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "some_bullshit called\n" ] } ], "source": [ "a.do_some_bullshit('boah!')" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'beenthere': 'yay!!!',\n", " 'kuckucksei': 'chirp',\n", " 'bad_thing_happened': 'JESSAS boah!!!!!!!!'}" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.__dict__" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__.AlmostEmpty" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.__class__" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "mappingproxy({'__module__': '__main__',\n", " 'do_something': ,\n", " '__dict__': ,\n", " '__weakref__': ,\n", " '__doc__': None,\n", " 'do_some_bullshit': })" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.__class__.__dict__" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "a.do_something('hallo')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ``exec()``" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n" ] } ], "source": [ "for i in range(3): print(i)" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "python_code = 'for i in range(3): print(i)'" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "str" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(python_code)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n" ] } ], "source": [ "exec(python_code)" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [], "source": [ "python_code = 'a_global_variable = 666'\n", "exec(python_code)" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "666" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a_global_variable" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [], "source": [ "del a_global_variable" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [], "source": [ "context = {}\n", "exec(python_code, context)" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "666" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "context['a_global_variable']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Globale, lokale, und Class Variablen" ] }, { "cell_type": "code", "execution_count": 64, "metadata": {}, "outputs": [], "source": [ "globale_variable = 666\n", "def f():\n", " globale_variable = 42" ] }, { "cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [], "source": [ "f()" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "666" ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "globale_variable" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [], "source": [ "globale_variable = 666\n", "def f():\n", " global globale_variable\n", " globale_variable = 42" ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "42" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f()\n", "globale_variable" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Mutable vs. Immutable" ] }, { "cell_type": "code", "execution_count": 69, "metadata": {}, "outputs": [], "source": [ "a = 42\n", "b = a" ] }, { "cell_type": "code", "execution_count": 70, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240513015376" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(a)" ] }, { "cell_type": "code", "execution_count": 71, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240513015376" ] }, "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(b)" ] }, { "cell_type": "code", "execution_count": 72, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 72, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a is b" ] }, { "cell_type": "code", "execution_count": 73, "metadata": {}, "outputs": [], "source": [ "b = 7" ] }, { "cell_type": "code", "execution_count": 74, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "42" ] }, "execution_count": 74, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240513015376" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(a)" ] }, { "cell_type": "code", "execution_count": 76, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240513014256" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id(b)" ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240513014256" ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = 7\n", "id(a)" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240419270768" ] }, "execution_count": 78, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = 10**10\n", "id(a)" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240419271792" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b = 10**10\n", "id(b)" ] }, { "cell_type": "code", "execution_count": 80, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b == a" ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b is a " ] }, { "cell_type": "code", "execution_count": 82, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "140240419270768" ] }, "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b = a\n", "id(b)" ] }, { "cell_type": "code", "execution_count": 83, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b is a" ] }, { "cell_type": "code", "execution_count": 84, "metadata": {}, "outputs": [], "source": [ "a += 1" ] }, { "cell_type": "code", "execution_count": 85, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a is b" ] }, { "cell_type": "code", "execution_count": 86, "metadata": {}, "outputs": [], "source": [ "class StoresAnIntegerAndModifiesIt:\n", " def __init__(self, i):\n", " self.the_int = i\n", " def increment(self):\n", " self.the_int += 1" ] }, { "cell_type": "code", "execution_count": 87, "metadata": {}, "outputs": [], "source": [ "my_int = 666\n", "saiami = StoresAnIntegerAndModifiesIt(my_int)" ] }, { "cell_type": "code", "execution_count": 88, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 88, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_int is saiami.the_int" ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [], "source": [ "saiami.increment()" ] }, { "cell_type": "code", "execution_count": 90, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "666" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_int" ] }, { "cell_type": "code", "execution_count": 91, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "667" ] }, "execution_count": 91, "metadata": {}, "output_type": "execute_result" } ], "source": [ "saiami.the_int" ] }, { "cell_type": "code", "execution_count": 92, "metadata": {}, "outputs": [], "source": [ "class StoresAListAndModifiesIt:\n", " def __init__(self, l):\n", " self.the_list = l\n", " def append_something(self, something):\n", " self.the_list.append(something)" ] }, { "cell_type": "code", "execution_count": 93, "metadata": {}, "outputs": [], "source": [ "my_list = ['hallo', 'suesser']\n", "salami = StoresAListAndModifiesIt(my_list)" ] }, { "cell_type": "code", "execution_count": 94, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_list is salami.the_list" ] }, { "cell_type": "code", "execution_count": 95, "metadata": {}, "outputs": [], "source": [ "salami.append_something('du!')" ] }, { "cell_type": "code", "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['hallo', 'suesser', 'du!']" ] }, "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_list" ] }, { "cell_type": "code", "execution_count": 97, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "my_list is salami.the_list" ] }, { "cell_type": "code", "execution_count": 98, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['hallo', 'suesser', 'du!']" ] }, "execution_count": 98, "metadata": {}, "output_type": "execute_result" } ], "source": [ "salami.the_list" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [], "source": [ "l1 = [1, ['a', 'b'], 2]\n", "l2 = l1[:]" ] }, { "cell_type": "code", "execution_count": 100, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1 is l2" ] }, { "cell_type": "code", "execution_count": 101, "metadata": {}, "outputs": [], "source": [ "l2[1].append('c')" ] }, { "cell_type": "code", "execution_count": 102, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 102, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1 is l2" ] }, { "cell_type": "code", "execution_count": 103, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 103, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1[1] is l2[1]" ] }, { "cell_type": "code", "execution_count": 104, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, ['a', 'b', 'c'], 2]" ] }, "execution_count": 104, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l1" ] }, { "cell_type": "code", "execution_count": 105, "metadata": {}, "outputs": [], "source": [ "del l1\n", "del l2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Exceptions" ] }, { "cell_type": "code", "execution_count": 134, "metadata": {}, "outputs": [], "source": [ "def compute_square(param):\n", " '''Compute the square of param and return it\n", " (only 666 is an exception which refuses a square to be computed)'''\n", " if param == 666:\n", " e = ValueError('Geht net: '+str(param))\n", " raise e\n", " else:\n", " return param**2" ] }, { "cell_type": "code", "execution_count": 113, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "25\n" ] } ], "source": [ "result = compute_square(5)\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Catch exception *by type only*:" ] }, { "cell_type": "code", "execution_count": 129, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "jessas, da ist was nicht gegangen\n" ] } ], "source": [ "try:\n", " result = compute_square(666)\n", "except Exception:\n", " print('jessas, da ist was nicht gegangen')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Catch Exception by type, plus the exception object " ] }, { "cell_type": "code", "execution_count": 135, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "jessas, da ist was nicht gegangen: Geht net: 666\n" ] } ], "source": [ "try:\n", " result = compute_square(666)\n", "except Exception as e:\n", " print('jessas, da ist was nicht gegangen:', e)" ] }, { "cell_type": "code", "execution_count": 137, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "jessas, da ist was nicht gegangen: Geht net: 666\n" ] } ], "source": [ "try:\n", " result = compute_square(666)\n", "except ValueError as e:\n", " print('jessas, da ist was nicht gegangen:', e)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Defining my Own Exceptions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "``SatanicError`` **is-a** ``Exception``" ] }, { "cell_type": "code", "execution_count": 140, "metadata": {}, "outputs": [], "source": [ "class SatanicError(Exception):\n", " pass" ] }, { "cell_type": "code", "execution_count": 141, "metadata": {}, "outputs": [], "source": [ "def compute_square(param):\n", " '''Compute the square of param and return it\n", " (only 666 is an exception which refuses a square to be computed)'''\n", " if param == 666:\n", " e = SatanicError('Geht net: '+str(param))\n", " raise e\n", " else:\n", " return param**2" ] }, { "cell_type": "code", "execution_count": 143, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "jesses: Geht net: 666\n" ] } ], "source": [ "try:\n", " result = compute_square(666)\n", "except SatanicError as e:\n", " print('jesses:', e)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dictionary Lookup, ``keys()`` etc." ] }, { "cell_type": "code", "execution_count": 144, "metadata": {}, "outputs": [], "source": [ "db = {\n", " '1037190666': ('Joerg', 'Faschingbauer'),\n", " '1234250497': ('Caro', 'Faschingbauer'),\n", "}" ] }, { "cell_type": "code", "execution_count": 145, "metadata": {}, "outputs": [], "source": [ "svnr = '1037190666'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following is **sequential search**:" ] }, { "cell_type": "code", "execution_count": 146, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ja\n" ] } ], "source": [ "if svnr in db.keys():\n", " print('ja')\n", "else:\n", " print('nein')" ] }, { "cell_type": "code", "execution_count": 148, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['1037190666', '1234250497'])" ] }, "execution_count": 148, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db.keys()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "... much like this ... (the ``in`` operator on a list does its job, but is suboptimal)" ] }, { "cell_type": "code", "execution_count": 149, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 149, "metadata": {}, "output_type": "execute_result" } ], "source": [ "10 in [1,2,3,4,5,6,7,8,9,10]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Better ask the dictionary, directly:" ] }, { "cell_type": "code", "execution_count": 150, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 150, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svnr in db" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is just as fast:" ] }, { "cell_type": "code", "execution_count": 151, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ja\n" ] } ], "source": [ "if db.get(svnr) is None:\n", " print('nein')\n", "else:\n", " print('ja')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Integers, Strings, und so" ] }, { "cell_type": "code", "execution_count": 153, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "str" ] }, "execution_count": 153, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s = '1037190666'\n", "type(s)" ] }, { "cell_type": "code", "execution_count": 155, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1037190666" ] }, "execution_count": 155, "metadata": {}, "output_type": "execute_result" } ], "source": [ "int(s)" ] }, { "cell_type": "code", "execution_count": 158, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " abc ist keine SVNR\n" ] } ], "source": [ "class InvalidSVNR(Exception):\n", " pass\n", "\n", "try:\n", " s = 'abc'\n", " try:\n", " int(s)\n", " except ValueError:\n", " raise InvalidSVNR(s+' ist keine SVNR')\n", "except Exception as e:\n", " print(type(e), e)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Regular Expressions" ] }, { "cell_type": "code", "execution_count": 168, "metadata": {}, "outputs": [], "source": [ "line = ' \\t 1037190666 | Joerg|Faschingbauer '" ] }, { "cell_type": "code", "execution_count": 169, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[' \\t 1037190666 ', ' Joerg', 'Faschingbauer ']" ] }, "execution_count": 169, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fields = line.split('|')\n", "fields" ] }, { "cell_type": "code", "execution_count": 171, "metadata": {}, "outputs": [], "source": [ "svnr = fields[0].strip()\n", "firstname = fields[1].strip()\n", "lastname = fields[2].strip()" ] }, { "cell_type": "code", "execution_count": 172, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('1037190666', 'Joerg', 'Faschingbauer')" ] }, "execution_count": 172, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svnr, firstname, lastname" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Enter regex" ] }, { "cell_type": "code", "execution_count": 174, "metadata": {}, "outputs": [], "source": [ "import re" ] }, { "cell_type": "code", "execution_count": 178, "metadata": {}, "outputs": [], "source": [ "rex_line = re.compile(r'^\\s*(\\S+)\\s*\\|\\s*(\\S+)\\s*\\|\\s*(\\S+)\\s*$')" ] }, { "cell_type": "code", "execution_count": 179, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "]" ] }, "execution_count": 198, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAh90lEQVR4nO3deXyU5b3+8c+XkABhSVjCFgig7LIkEMG1rYA9etxwqXVDVBTbY117qmh7jm2Pban12NqfdUFRWRS0CIpLPe5rKxIIgoAiO4QAAZIQyJ58f39krGijDEkmT2ZyvV8vXjPzZCbP5UAun9zzPPdt7o6IiESfFkEHEBGRulGBi4hEKRW4iEiUUoGLiEQpFbiISJRq2Zg769Kli/ft27cxdykiEvWWLVu2x91Tvr69UQu8b9++ZGVlNeYuRUSinpltqW27hlBERKKUClxEJEqpwEVEopQKXEQkSqnARUSilApcRCRKqcBFRKKUClxEJIL2Hijj1y+soaS8qsG/d1gFbmY3m9lqM/vEzOaZWWsz62dmS8xsvZk9bWYJDZ5ORCSKlVdW8+Mnl/Pkki1s2nOwwb//YQvczFKBG4BMdx8GxAEXAb8H/uju/YF8YEqDpxMRiWK/fnE1H23ax90XjGBozw4N/v3DHUJpCbQxs5ZAIpALjAMWhL4+C5jY4OlERKLUk0u2MPfDrVz73aM4Jz01Ivs4bIG7ew5wD7CVmuIuBJYBBe5eGXradqDWhGY21cyyz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c6+73Bp0naO5+u7v3cve+1Py7eNPdY+4oK1zuvhPYZmaDQpvGA2sCjBSkrcBxZpYY+rkZTwx+oFuvNTEbgxZP/ooTgUnAKjNbEdp2R2htUhGA64EnQwc7G4ErA84TCHdfYmYLgOXUnL2VTQxeUq9L6UVEolQ0DKGIiEgtVOAiIlFKBS4iEqVU4CIiUUoFLiISpVTgIiJRSgUuIhKl/j9JXvIu6LG7fwAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "plt.plot(x, y)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" } }, "nbformat": 4, "nbformat_minor": 4 }