python
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
python [2010/09/06 12:16] – ginko | python [2010/10/06 19:03] – ginko | ||
---|---|---|---|
Line 9: | Line 9: | ||
===== Doc ===== | ===== Doc ===== | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
Line 14: | Line 15: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | |||
===== Basics ===== | ===== Basics ===== | ||
* [[http:// | * [[http:// | ||
Line 19: | Line 21: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | ===== Interactive Shell ===== | ||
+ | Python est livré de base avec un shell interactif très utile. Mais il peut être utile de l' | ||
+ | ==== Objets custom ==== | ||
+ | Il est possible d' | ||
+ | Le namespace du shell contiendra alors tous les objets contenus dans le fichier indiqué. | ||
+ | |||
+ | __Exemple__:< | ||
+ | """ | ||
+ | When ' | ||
+ | if re: | ||
+ | import re | ||
+ | def match(item): | ||
+ | if re.search(pat, | ||
+ | else: return False | ||
+ | else: | ||
+ | def match(item): | ||
+ | if item.find(pat) >= 0: return True | ||
+ | else: return False | ||
+ | |||
+ | for item in list: | ||
+ | if match(item): | ||
+ | print item</ | ||
+ | |||
+ | NB: Ipython ne tient pas compte de '' | ||
+ | ==== Ipython ==== | ||
+ | Ipython est un shell interactif amélioré (coloration syntaxique, historique inter-instances, | ||
+ | === Cygwin === | ||
+ | Pour lancer ipython sur Cygwin, taper simplement '' | ||
+ | |||
+ | La solution la plus simple consiste à préférer '' | ||
+ | === ipythonrc === | ||
+ | Valable pour iptyhon 0.10 | ||
+ | |||
+ | Ipython possède un système de fichiers de configuration à la UNIX. Dans la version 0.10, éditer '' | ||
+ | Pour charger utiliser le '' | ||
+ | <code python> | ||
+ | """ | ||
+ | PYTHONSTARTUP is a environnement variable shared among different python shells.""" | ||
+ | import os | ||
+ | filename = os.environ.get(' | ||
+ | if filename and os.path.isfile(filename): | ||
+ | # execfile(filename) # Can't use builtin execfile function in ipython... | ||
+ | execf(filename)</ | ||
+ | sans oublier d' | ||
===== Unicode ===== | ===== Unicode ===== | ||
* [[http:// | * [[http:// |
python.txt · Last modified: 2014/09/13 14:03 by ginko