{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "[prev: *String Services*](stdlib-string-services.ipynb) | [home](../index.ipynb) | [next: *Numeric tools*](stdlib-numeric-tools.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# *Data Types*\n", "Modules introduisant des types de données spécifiques." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Module *collections* \n", "*collections* proposent 5 nouveaux conteneurs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "``` python\n", "import collections\n", "\n", "collections.namedtuple # factory function for creating tuple subclasses with named fields\n", "collections.deque # list-like container with fast appends and pops on either end\n", "collections.Counter # dict subclass for counting hashable objects\n", "collections.OrderedDict # dict subclass that remembers the order entries were added\n", "collections.defaultdict # dict subclass that calls a factory function to supply missing values\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercices" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Aidé du module `collections`, réécrire une fonction `compte_occurences()`." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.2" } }, "nbformat": 4, "nbformat_minor": 1 }