|
|
Zeile 5: |
Zeile 5: |
| Ausführlichere Informationen gibt es hier (english):<br> | | Ausführlichere Informationen gibt es hier (english):<br> |
| https://martinxpn.medium.com/how-modules-actually-work-in-python-and-how-to-create-your-own-custom-module-81-100-days-of-d1a84fead104<br> | | https://martinxpn.medium.com/how-modules-actually-work-in-python-and-how-to-create-your-own-custom-module-81-100-days-of-d1a84fead104<br> |
− |
| |
− | == Was ist in einem Modul drin ?==
| |
− | dir(modulname)
| |
− | zeigt den Inhalt eines Moduls an.
| |
− | <pre>
| |
− | >>> dir(time)
| |
− | ['__class__', '__name__', 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us',
| |
− | 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time']
| |
− | </pre>
| |
− | == Was sind Biblitheken ?==
| |
− | https://www.notion.so/Python-Modules-and-Libraries-deutsch-1e7010e7e964472484e90675efc2b717
| |
− | <br>
| |
− | https://pytechacademy.medium.com/structuring-your-python-projects-harnessing-the-power-of-modules-and-packages-7143c95a6f34
| |
− | <br>
| |
| | | |
| == Module benutzen== | | == Module benutzen== |
| Module müssen importiert werden bevor man die Funktionen daraus nutzen kann.<br> | | Module müssen importiert werden bevor man die Funktionen daraus nutzen kann.<br> |
− | Üblicherweise werden die Importanweisungen ziemlich am Anfang des Scriptes stehen.<br> | + | Üblicherweise sollen die Importanweisungen am Anfang des Scriptes stehen.<br> |
| ==== Es gibt 4 Möglichkeiten Module zu importieren:==== | | ==== Es gibt 4 Möglichkeiten Module zu importieren:==== |
| | | |
Zeile 53: |
Zeile 39: |
| *: <pre>aliasname_der_funktion()</pre> | | *: <pre>aliasname_der_funktion()</pre> |
| | | |
| + | == Was ist in einem Modul drin ?== |
| + | dir(modulname) |
| + | zeigt den Inhalt eines Moduls an. |
| + | <pre> |
| + | >>> dir(time) |
| + | ['__class__', '__name__', 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us', |
| + | 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time'] |
| + | </pre> |
| == Module selber schreiben == | | == Module selber schreiben == |
| https://python.plainenglish.io/init-files-in-python-how-to-organize-your-code-into-logical-and-reusable-units-1f4c7c31d4f7 | | https://python.plainenglish.io/init-files-in-python-how-to-organize-your-code-into-logical-and-reusable-units-1f4c7c31d4f7 |
Version vom 27. September 2023, 13:42 Uhr
Was sind Module ?
Module sind Sammlungen von Funktionen, die in einer Datei zusammen gefasst sind.
In anderen Programmiersprachen werden sie Bibliotheken genannt.
Bibliotheken sind in Phython die Zusammenfassung mehrerer Module
Ausführlichere Informationen gibt es hier (english):
https://martinxpn.medium.com/how-modules-actually-work-in-python-and-how-to-create-your-own-custom-module-81-100-days-of-d1a84fead104
Module benutzen
Module müssen importiert werden bevor man die Funktionen daraus nutzen kann.
Üblicherweise sollen die Importanweisungen am Anfang des Scriptes stehen.
Es gibt 4 Möglichkeiten Module zu importieren:
Was ist in einem Modul drin ?
dir(modulname)
zeigt den Inhalt eines Moduls an.
>>> dir(time)
['__class__', '__name__', 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us',
'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time']
Module selber schreiben
https://python.plainenglish.io/init-files-in-python-how-to-organize-your-code-into-logical-and-reusable-units-1f4c7c31d4f7
Module mit mip laden
Navigation
Zurück zu Micropython Kurs 2023 - Teil 1
Zurück zur "Micropython Kurs 2023" Startseite
Zurück zur Programmieren Startseite
Zurück zur Wiki Startseite