Skip to content

Commit

Permalink
Add slides
Browse files Browse the repository at this point in the history
  • Loading branch information
funsim committed Sep 22, 2015
0 parents commit b6c6ecd
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 0 deletions.
Binary file added 03_python_summary-beamer-handouts2x3.pdf
Binary file not shown.
Binary file added 03_python_summary-beamer.pdf
Binary file not shown.
Binary file added 06_encoding-beamer-handouts2x3.pdf
Binary file not shown.
Binary file added 06_encoding-beamer.pdf
Binary file not shown.
Binary file added 06_peer_review-beamer-handouts2x3.pdf
Binary file not shown.
Binary file added 06_peer_review-beamer.pdf
Binary file not shown.
182 changes: 182 additions & 0 deletions Unicode in Python.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Lets read in a UTF-8 file"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'Bokm\\xc3\\xa5l'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# -*- coding: utf-8 -*- \n",
" \n",
"# wget http://fil.nrk.no/yr/viktigestader/noreg.txt \n",
" \n",
"f = open(\"noreg.txt\", \"r\") \n",
" \n",
"s_utf8 = f.readline().split(\"\\t\")[12] \n",
"s_utf8"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7\n"
]
}
],
"source": [
"print len(s_utf8)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<type 'unicode'>\n"
]
},
{
"data": {
"text/plain": [
"u'Bokm\\xe5l'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s_unicode = s_utf8.decode(\"utf-8\")\n",
"print type(s_unicode)\n",
"s_unicode"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6\n"
]
}
],
"source": [
"print len(s_unicode)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<type 'str'>\n",
"<type 'unicode'>\n"
]
}
],
"source": [
"print type(\"Bokmål\") \n",
"print type(u\"Bokmål\") "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"False\n",
"True\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python2.7/dist-packages/IPython/kernel/__main__.py:2: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal\n",
" from IPython.kernel.zmq import kernelapp as app\n"
]
}
],
"source": [
"print s_unicode == u\"Bokmål\" \n",
"print s_unicode == \"Bokmål\" \n",
"print s_unicode.encode(\"utf-8\") == \"Bokmål\" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit b6c6ecd

Please sign in to comment.