python_cheat_sheet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| python_cheat_sheet [2010/06/18 18:26] – ginko | python_cheat_sheet [2015/01/02 13:03] (current) – ginko | ||
|---|---|---|---|
| Line 9: | Line 9: | ||
| * Argv: (nécessite l' | * Argv: (nécessite l' | ||
| * Il existe aussi une implémentation de getopt (//cf//. [[http:// | * Il existe aussi une implémentation de getopt (//cf//. [[http:// | ||
| + | ===== Packaging ===== | ||
| + | * Encapsulation pour librairie autonome <code python> | ||
| + | main()</ | ||
| ===== Variables ===== | ===== Variables ===== | ||
| * Listes (mutable)< | * Listes (mutable)< | ||
| Line 35: | Line 37: | ||
| ===== IO ===== | ===== IO ===== | ||
| * Ouvrir un fichier <code python>#' | * Ouvrir un fichier <code python>#' | ||
| - | fichier=open('/ | + | fichier=open('/ |
| + | # il faut alors fermer le fichier | ||
| + | # une métode qui referme le fichier proprement: | ||
| + | with open('/ | ||
| + | </ | ||
| * '' | * '' | ||
| * Sortie vers le shell: <code python> | * Sortie vers le shell: <code python> | ||
| * Prompt au shell: <code python> | * Prompt au shell: <code python> | ||
| + | Pour travavailler avec les chemins de fichiers : '' | ||
| ===== Structure de code ===== | ===== Structure de code ===== | ||
| * Boucle '' | * Boucle '' | ||
| Line 82: | Line 89: | ||
| kwargs = {' | kwargs = {' | ||
| function_name(**kwargs)</ | function_name(**kwargs)</ | ||
| + | * Fonction anonyme (jettable, pour usage unique):< | ||
| * Test: <code python> | * Test: <code python> | ||
python_cheat_sheet.1276878419.txt.gz · Last modified: 2010/06/18 18:26 by ginko
