python_cheat_sheet
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
python_cheat_sheet [2010/04/29 12:40] – ginko | python_cheat_sheet [2014/04/01 16:25] – 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)< | ||
+ | * Sets (mutable) fournit une interface implémentant les ensembles mathématiques (union, réunion, intersection, | ||
* Ajouter un élément en fin de liste: <code python> | * Ajouter un élément en fin de liste: <code python> | ||
* Tuple (immutable, mais plus performant) <code python> | * Tuple (immutable, mais plus performant) <code python> | ||
+ | * Matrices: installer et importer numpy ([[http:// | ||
* Casts | * Casts | ||
* String <code python> | * String <code python> | ||
Line 33: | 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> | ||
Line 76: | Line 84: | ||
* Classe: <code python> | * Classe: <code python> | ||
* Fonction: <code python> | * Fonction: <code python> | ||
+ | * Expansion des arguments dans un appel de fonction:< | ||
+ | function_name(*args) | ||
+ | kwargs = {' | ||
+ | function_name(**kwargs)</ | ||
+ | * Fonction anonyme (jettable, pour usage unique):< | ||
* Test: <code python> | * Test: <code python> | ||
python_cheat_sheet.txt · Last modified: 2015/01/02 13:03 by ginko