====== Python Sprachkonstrukte (Klassen, Definitionen, etc.) ====== ==== Besonderheiten der Sprache ==== * [[https://eli.thegreenplace.net/2015/the-scope-of-index-variables-in-pythons-for-loops/|The scope of index variables in Python's for loops]] * [[https://geekflare.com/python-unpacking-operators/|How to Use the Unpacking Operators (*, **) in Python]] ==== Klassen und Methoden ==== * https://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods * http://stackoverflow.com/questions/12632602/class-method-with-no-arguments-produces-typeerror * http://stackoverflow.com/questions/31907122/extend-an-instance-at-runtime * [[https://stackoverflow.com/questions/43807642/why-the-need-for-thread-init-in-a-class|Subclassing erfordert den Aufruf des Konstruktors der SuperClass]] * http://masnun.rocks/2017/04/15/interfaces-in-python-protocols-and-abcs/ ==== Introspection, etc. ==== * http://stackoverflow.com/questions/2705964/how-do-i-extend-a-python-module-python-twitter * http://blog.thedigitalcatonline.com/blog/2014/05/19/method-overriding-in-python/#.WH0yTRRRFjA * http://stackoverflow.com/questions/1006169/how-do-i-look-inside-a-python-object * https://docs.python.org/2/library/inspect.html === Override a method that is called by a module === * http://stackoverflow.com/questions/23646826/python-how-to-override-a-method-defined-in-a-module-of-a-third-party-library * http://stackoverflow.com/questions/5626193/what-is-a-monkey-patch * http://stackoverflow.com/questions/19545982/monkey-patching-a-class-in-another-module-in-python * https://filippo.io/instance-monkey-patching-in-python/ * https://tryolabs.com/blog/2013/07/05/run-time-method-patching-python/ ==== Dicts ==== * [[http://stackoverflow.com/questions/30362391/how-to-find-first-key-in-a-dictionary|find-first-key-in-a-dictionary]] * [[http://stackoverflow.com/questions/40923429/delete-first-item-in-each-key-in-a-dictionary|delete-first-item-in-each-key-in-a-dictionary]] * [[https://codereview.stackexchange.com/questions/85842/a-dictionary-that-allows-multiple-keys-for-one-value/103966|A dictionary that allows multiple keys for one value]] ==== Lists ==== * [[https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search#comment18634157_8653568|Search in a list of dictionaries (such as a JSON representation)]] Liste mit bestimmten Elementen erzeugen: l = [None]*10 # Leere Liste mit 10 Elementen l = list(range(1,11)) # Liste mit Werten von 1-10 # unpacking a range object into a list with the unpack operator (*) r = range(1,11,2) l = [*r] first, *_, last = [1, 2, 3, 5, 7] # first = 1, last = 7 ==== Threads ==== * [[https://stackoverflow.com/questions/11334447/monitor-thread-synchronization-in-python|Monitor thread synchronization]] * [[https://realpython.com/intro-to-python-threading/|An Intro to Threading in Python]] * https://docs.python.org/3/library/threading.html * https://hackernoon.com/synchronization-primitives-in-python-564f89fee732 Let’s Synchronize Threads in Python ==Beispiele== * [[https://www.bogotobogo.com/python/Multithread/python_multithreading_creating_threads.php|Multithreading - Creating Threads]] * [[https://www.bogotobogo.com/python/Multithread/python_multithreading_subclassing_creating_threads.php|Subclassing Thread]] * [[https://dzone.com/articles/python-thread-part-1|Python Thread Tutorial (Part 1)]] * [[https://dzone.com/articles/python-thread-part-2|Python Thread Tutorial (Part 2)]] * https://www.geeksforgeeks.org/start-and-stop-a-thread-in-python/ * https://code-maven.com/slides/python/python-threads * [[https://stackoverflow.com/questions/919897/how-to-obtain-a-thread-id-in-python|How to obtain a Thread id in Python?]] == Synchronisation == * [[https://stackoverflow.com/questions/11334447/monitor-thread-synchronization-in-python|Monitor Thread synchronization mit Lock()]] * https://stackoverflow.com/questions/41441900/how-to-synchronize-python-threads * [[https://pymotw.com/2/Queue/|Queue – A thread-safe FIFO implementation]] ==== Decorators ==== * https://realpython.com/primer-on-python-decorators/