13.07.2015 Views

Initiation `a Python par l'exemple - Bienvenue sur le portail du ...

Initiation `a Python par l'exemple - Bienvenue sur le portail du ...

Initiation `a Python par l'exemple - Bienvenue sur le portail du ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 TABLE DES MATIÈRES2.2.3 Le mo<strong>du</strong><strong>le</strong> re . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.2.4 Le mo<strong>du</strong><strong>le</strong> os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.2.5 Le mo<strong>du</strong><strong>le</strong> os.path . . . . . . . . . . . . . . . . . . . . . . . . . . . 352.2.6 Les mo<strong>du</strong><strong>le</strong>s glob et fnmatch . . . . . . . . . . . . . . . . . . . . . 352.2.7 Le mo<strong>du</strong><strong>le</strong> getpass . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.3 Built-in en <strong>Python</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.3.1 Les fichiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.3.2 Conversions de type . . . . . . . . . . . . . . . . . . . . . . . . . . 382.3.3 Evaluation dynamique . . . . . . . . . . . . . . . . . . . . . . . . . 382.3.4 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392.4 Exercices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392.4.1 Utilitaire de sauvegarde . . . . . . . . . . . . . . . . . . . . . . . . 392.4.2 Extraction de données . . . . . . . . . . . . . . . . . . . . . . . . . 403 Plongeon dans <strong>le</strong>s objets 413.1 Des objets, que des objets . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.1.1 Rappels des principes de base de POO . . . . . . . . . . . . . . . . 413.1.2 Objets et références . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.1.3 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.1.4 Héritage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.1.5 Introspection simp<strong>le</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . 443.1.6 Classes et attributs . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.1.7 Un peu de réf<strong>le</strong>xion . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.1.8 Un peu plus de réf<strong>le</strong>xion avec inspect . . . . . . . . . . . . . . . . 473.1.9 Classes vs mo<strong>du</strong><strong>le</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.2 Les exceptions en python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.2.1 Définition et lancement . . . . . . . . . . . . . . . . . . . . . . . . . 493.2.2 Traitement des exceptions . . . . . . . . . . . . . . . . . . . . . . . 503.2.3 Traitement d’exceptions et héritage . . . . . . . . . . . . . . . . . . 523.3 Exercices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.3.1 Premières classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.3.2 Design pattern état . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 <strong>Python</strong> et XML 554.1 XML, avec une vision DOM . . . . . . . . . . . . . . . . . . . . . . . . . . 554.1.1 Langages de balises . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.1.2 XML, quels outils ? . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.1.3 DOM, petit rappel . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.1.4 Exemp<strong>le</strong> <strong>du</strong> chapitre . . . . . . . . . . . . . . . . . . . . . . . . . . 564.2 Naviguer dans un arbre DOM . . . . . . . . . . . . . . . . . . . . . . . . . 574.2.1 minidom «il fait <strong>le</strong> maximum» . . . . . . . . . . . . . . . . . . . . . 574.2.2 Parser un document XML . . . . . . . . . . . . . . . . . . . . . . . 574.2.3 Parcourir un arbre DOM . . . . . . . . . . . . . . . . . . . . . . . . 57c○2003-2005, Raphaël Marvie

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!