Swiss Python Summit

This notebook is part of a poster session at #SPS17. Code snippets affixed to the poster were encoded, computed, and the results shared here. Visit our forum for background.

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=2017,centers=99)
plt.scatter(X[:, 0], X[:, 1], c=y, s=50, cmap='rainbow')
<matplotlib.collections.PathCollection at 0x7f8aa0555b70>


In [2]:

Easter eggs

In [3]:
import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
In [5]:
import antigravity 
# in Python 3, opens a browser pointing to

Python hacks

Not sure what the intent here was?

In [16]:
  File "<ipython-input-16-a60b254ebb24>", line 1
SyntaxError: can use starred expression only as assignment target
In [18]:
In [26]:
# I gather at this point we should be seeing something interesting..
False + True

Self referencing

Data below collected using this script.

In [66]:
self_references_in_docs = {
    'Bottle':  {'refs': 6962,   'size': 54583}, 
    'Django':  {'refs': 14941,  'size': 136397}, 
    'Flask':   {'refs': 1306,   'size': 13667}, 
    'Pyramid': {'refs': 5207,   'size': 73288}, 
    'Scrapy':  {'refs': 1760,   'size': 17627}, 
    'Tornado': {'refs': 928,    'size': 6348}, 
    'Twisted': {'refs': 5242,   'size': 75888}, 
    'WebPy':   {'refs': 9,      'size': 1164}, 
for t in self_references_in_docs.keys():
    o = self_references_in_docs[t]
    o['avg'] = o['refs']/o['size']
In [65]:
import numpy as np
X = np.arange(len(self_references_in_docs))
Y = [t['avg'] for t in self_references_in_docs.values()], Y, width=0.5)
plt.xticks(X, self_references_in_docs.keys())

Clowning around

In [1]:
fn main() {
    loop {
        println!("Rust is awesome!");
  File "<ipython-input-1-b6d5c13fafdd>", line 1
    fn main() {
SyntaxError: invalid syntax

This raises the question of how to add Rust code to Jupyter notebooks, something this project attempts to answer:

For a survey of supported languages see: