{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Encoding\n", "\n", "## Goals\n", "\n", " - A string is more than a sequence of bytes\n", " - A string is a couple (bytes, encoding)\n", " - Use unicode_literals in python2\n", " - Manage differently encoded filenames\n", " - A string is not a sequence of bytes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Modules" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os\n", "import os.path\n", "import glob" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from os.path import isdir\n", "basedir = \"/tmp/course\"\n", "if not isdir(basedir):\n", " os.makedirs(basedir) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Song of Childhood\n", "\n", "
\n", "Als das Kind Kind war,\n", "ging es mit hängenden Armen,\n", "wollte der Bach sei ein Fluß,\n", "der Fluß sei ein Strom,\n", "und diese Pfütze das Meer.\n", "\n", "Als das Kind Kind war,\n", "wußte es nicht, daß es Kind war,\n", "alles war ihm beseelt,\n", "und alle Seelen waren eins.\n", "\n", " | \n", "\n",
"
\n", "characters were bytes, and \n", "strings list of bytes.\"\n", " | \n",
"\n", "When the child was a child\n", "It walked with its arms swinging,\n", "wanted the brook to be a river,\n", "the river to be a torrent,\n", "and this puddle to be the sea.\n", "\n", "When the child was a child,\n", "it didn’t know that it was a child,\n", "everything was soulful,\n", "and all souls were one.\n", "\n", " | \n", "