Sessions at PyCon US 2012 on Thursday 8th March in Santa Clara Convention Center

Your current filters are…

Clear
  • Advanced Python I

    by Raymond Hettinger

    Have your Python skills have hit a plateau? Come learn from Python core developer and consultant Raymond Hettinger about the tips and tricks needed to move up to the next level.

    This tutorial will work through a series of real-world examples, showing how an understanding of the tools built into the Python interpreter or included in the standard library can be combined to solve difficult problems clearly and Pythonically. We will also discuss when and how to reach beyond the standard library when needed to address difficult algorithmic and optimization problems. This can be taken as a stand-alone session or in conjunction with the second session; the two sessions will be complementary.

    At 9:00am to 12:20pm, Thursday 8th March

    In D1, Santa Clara Convention Center

    Coverage note

  • Documenting Your Project With Sphinx

    by Brandon Rhodes

    Python projects can succeed or fail because of their documentation. Thanks to Sphinx, Python now has a “documentation framework” with indexing, syntax highlighting, and integration with your code. Students will be given a small undocumented Python package, and during the exercises they will give the package a tutorial and reference manual. Plus: deployment and theming!

    Python projects can succeed or fail based on their documentation. Thanks to Sphinx, Python now has a "documentation framework" that provides convenient indexing and automatic syntax highlighting, and can also integrate your documentation with your code (your documentation can be run as a test, and your class and function docstrings can become your reference documentation). Students will be given an undocumented sample Python package, and be lead through exercises that result, by the end of the tutorial, in their giving the package a full tutorial and reference manual. Deployment and theming will also be taught.

    Besides a 15-minute introduction and 15 minutes for questions and discussion at the end, the tutorial will be organized in six 25-minute sessions which each involve a short lecture and then an interactive exercise that asks the students to apply what they have just learned. Here are the major topics covered by each of the six sessions:

    • The reStructuredText markup language and its syntax; the standard doctools; and the two different conventions that Sphinx can support for laying projects out as directories and files.
    • The Sphinx documentation build process on both Unix and Windows; how to arrange your project documentation in a way that will make sense to novice, experienced, and expert users alike; and how Sphinx supports connections between different pages of documentation.
    • Running code examples in the documentation as doctests; the pros and cons of pulling docstrings from the code as API documentation (and how to do it if it proves necessary); and including non-doctest full code listings in the documentation.
    • Referencing headings in the same document; cross-referencing between documents; making class and method names automatically link to their entry in the API documentation; and how to make code objects appear in the index.
    • Theming with custom HTML and CSS, for students who happen to know web design; plugging in pre-made Sphinx themes; and how to integrate Sphinx into an entire web site for their product.
    • Shipping documentation with your package on PyPI; installing it readthedocs.org; making sure that documentation gets included with a binary install; using a version control source browser to view documentation directly in their project trunk; and deploying Sphinx to a web site.

    The Sphinx approach will be linked to other successful documentation systems in our computing heritage, most notably in the practices it shares in common with the Unix Documenter's Workbench (DWB) of the 1970s.

    At 9:00am to 12:20pm, Thursday 8th March

    In H2, Santa Clara Convention Center

    Coverage video

  • High Performance Python I

    by Ian Ozsvald

    At EuroPython 2011 I ran a very hands-on tutorial for High Performance Python techniques. This updated tutorial will cover profiling, PyPy, Cython, numpy, NumExpr, ShedSkin, multiprocessing, ParallelPython and pyCUDA. Here's a 55 page PDF write-up of the EuroPython material: http://ianozsvald.com/2011/07/25...

    At EuroPython 2011 I ran a very hands-on tutorial for High Performance Python techniques. This updated tutorial will cover:

    • profiling with cProfile, run_snake and line_profiler
    • PyPy
    • Cython
    • numpy with and without vectors
    • NumExpr
    • ShedSkin Py->C++ compiler
    • multiprocessing for multi-core
    • ParallelPython for multi-machine
    • pyCUDA demos

    I plan to expand the original material and to maybe also cover other tools like execnet and PyPy-numpy.

    At 9:00am to 12:20pm, Thursday 8th March

    In D2, Santa Clara Convention Center

  • Introduction to Game Development

    by Richard Jones and Katie Cunningham

    This tutorial will walk the attendees from some introductory game development theory (what makes a good game) and through development of a simple game (how to make a good game) with time left over for some experimentation and exploration of different types of games.

    The tutorial will start with Katie Cunningham giving an introduction to video games, covering the basic components of a game, and some general game genres. Some basic tropes in modern games will be explored, as well as pitfalls to avoid in making a game for a today’s audience. Genres will be paired with inexpensive/free examples that can be explored by the tutorial attendees later.

    The baton will then pass to Richard Jones who will walk through the practicalities of building a simple video game from scratch, starting with presenting one approach to structuring the game code to keep it sane. He will talk about what libraries are available and then focus on the facilities present in the library used in the tutorial.

    We will then walk through the development of a simple game during which the attendees will code the game. Once the game is developed we will talk about potential further development that possibilities and use the remaining tutorial time to encourage and assist attendees in their efforts to do so.

    The game developed will cover the key game-writing skills of controlling what appears on the screen (including animation), loading resources, handling user input and simulating the environment within the game.

    Participants should be familiar with Python, and must have pygame installed. We will not have time to deal with installation and compatibility issues so participants must check their laptops can run pygame applications.

    At 9:00am to 12:20pm, Thursday 8th March

    In H3, Santa Clara Convention Center

    Coverage video

  • Optimize Performance and Scalability with Parallelism and Concurrency

    by Robert Hancock

    From how the operating system handles your requests through design principles on how to use concurrency and parallelism to optimize your program's performance and scalability. We will cover processes, threads, generators, coroutines, non-blocking IO, and the gevent library.

    How processes, threads, coroutines, and non-blocking IO work from the operating system through code implementation and design principles to optimize Python programs. The difference between parallelism and concurrency and when to use each.

    The premise is that to make an informed decision you need to know what is happening under the hood. Once you understand the low level functionality, you can make the correct decision in the design phase.

    The emphasis is on practical application to solve real world problems.

    Outline

    • How the operating system handles traps and interrupts
    • Scheduling
    • Processes
    • Threads
    • The GIL
    • Generators
    • What is a coroutine?
    • What is a Python coroutine?
    • Blocking/Non-blocking I/O.
    • Parallelism versus Concurrency
    • How do these work with CPython, Pypy, and Stackless
    • Greenlets and libevent (gevent)
    • Design principles
    • Example networked application
    • Performance results
    • What are other the other options?

    At 9:00am to 12:20pm, Thursday 8th March

    In F2, Santa Clara Convention Center

  • Plotting with matplotlib

    by Mike Müller

    When it comes to plotting with Python many people think about matplotlib. It is widely used and provides a simple interface for creating a wide variety of plots from very simple diagrams to sophisticated animations. This tutorial is a hands-on introduction that teaches the basics of matplotlib. Students will learn how to create publication-ready plots with just a few lines of Python.

    Target Audience

    This tutorial is for Python users who would like to create nice 2d plots with Python.

    Audience Level

    Students should have a working knowledge of Python. NumPy knowledge is helpful but not required.

    Prerequisites

    Please bring your laptop with the operating system of your choice (Linux, Mac OS X, Windows). In addition to Python 2.6 or 2.7, we need: - a current versions of matplotlib (http://matplotlib.sourceforge.net) - IPython (http://ipython.org) and - NumPy (http://numpy.scipy.org).

    Method

    This is a hands-on course. Students are strongly encouraged to work along with the trainer at the interactive prompt. There will be exercises the students need to do on their own. Experience shows that this active involvement is essential for an effective learning.

    Content

    The library matplotlib provides many different types of diagrams from within Python with only few lines of code. Examples are used to exercise the use of this library. The tutorial provides an overview how to create plots with matplotlib. IPython in combination with pylab from matplotlib provides an interactive environment for fast testing of ideas. We will be using this for most of the tutorial.

    With a simple plot we learn how to add axis labels, titles and a legend. The GUI offers zooming, panning, changing of plot sizes and other interactive ways to modify the plot. We will use Python to change properties of existing plots such as line colors, marker symbols, or line styles. There are several ways how to place text on plots. You will learn about the different coordinate systems relative to the plot, the canvas or the figure. Another topic are ticks, where to put them and how to format them to achieve publication-quality plots. The concepts of figures, subplots, and axes and how they relate to each other will be explained with examples.

    matplotlib offers many different types of plots. The tutorial introduces several of them with an example. A more advanced topic will be creating your own plot types. We will build a stacked plot type. Finally, we will create a small animation to explore the possibilities to visualize changes.

    Outline

    • Introduction (5 min)
    • IPython (5 min)
    • pylab (5 min)
    • Simple plots (20 min)
    • Properties (15 min)
    • Text (20 min)
    • Ticks (25 min)
    • Figures, subplots, and axes (25 min)
    • Other types of plots (10 min)
    • The class library (15 min)
    • Creating New Plot Types (20 min)
    • Animations (15 min)

    At 9:00am to 12:20pm, Thursday 8th March

    In H1, Santa Clara Convention Center

    Coverage video

  • Python Epiphanies

    by Stuart Williams

    This tutorial is for software developers who've been using Python with success for a while but are looking for a deeper understanding of the language. It demystifies a number of language features that are often misunderstood.

    In many ways Python is very similar to other programming languages. However, in a few sometimes subtle ways it is quite different, and many software developers new to Python, after their initial successes, hit a plateau and can't figure out how to get past it. Others don't hit or perceive a plateau, but still find some of Python's features a little mysterious. This tutorial will help deconstruct your incorrect assumptions about Python and pull away the mists of confusion.

    If in your use of Python you sometimes feel like an outsider, like you're missing the inside jokes, or like you have most of the puzzle pieces but they don't quite fit together yet, this may be a good tutorial for you.

    After completing this tutorial you'll have a deeper understanding of many Python features. Here are some of the topics we'll cover:

    • How namespaces really work, after which you'll understand:
    • most of the differences between variables in other languages and Python, including
    • why Python has neither pass-by-value nor pass-by-reference function call semantics, or why sometimes variables passed to a function can be changed by it, and sometimes they cannot.
    • Iterables, iterators, and the iterator protocol, including how to add it to a class
    • How generators can make your code easier to read and understand
    • Creating classes without a class statement in order to better understand how they work
    • Bound versus unbound methods and interesting uses of the former
    • How and why you might want to create or use a partial function
    • Other use-cases of functions as first-class citizens
    • Unpacking and packing arguments with * and ** on function call and definition

    Attendee Requirements

    Bring a laptop computer with a recent version of Python 2.7 or Python 3 installed.

    Prerequisites

    Intermediate ability in Python and little or no fear of iterators, generators, classes, methods, and how to call a function that's stored in a data structure.

    At 9:00am to 12:20pm, Thursday 8th March

    In F1, Santa Clara Convention Center

    Coverage video

  • Social Network Analysis with Python

    by Maksim Tsvetovat

    Social Network data permeates our world -- yet we often don't know what to do with it. In this tutorial, I will introduce both theory and practice of Social Network Analysis -- gathering, analyzing and visualizing data using Python and other open-source tools. I will walk the attendees through an entire project, from gathering and cleaning data to presenting results.

    SNA techniques are derived from sociological and social-psychological theories and take into account the whole network (or, in case of very large networks such as Twitter -- a large segment of the network). Thus, we may arrive at results that may seem counter-intuitive -- e.g. that Justin Bieber (7.5 mil. followers) and Lady Gaga (7.2 mil. followers) have relatively little actual influence despite their celebrity status -- while a middle-of-the-road blogger with 30K followers is able to generate tweets that "go viral" and result in millions of impressions.

    In this tutorial, we will conduct social network analysis of a real dataset, from gathering and cleaning data to analysis and visualization of results. We will use Python and a set of open-source libraries, including NetworkX, NumPy and Matplotlib.

    Outline:

    • Introduction. Why should we do this? What is the data like? Why is this different from other techniques? What can we learn?
    • Centralities: Degree, closeness, betweenness, PageRank, Klout Score
    • Beyond Klout Score: Finding communities of interest, finding clusters in networks
    • Information diffusion in networks -- how do things go viral?

    At 9:00am to 12:20pm, Thursday 8th March

    In D3, Santa Clara Convention Center

    Coverage video

  • Advanced Python II

    by Raymond Hettinger

    Have your Python skills have hit a plateau? Come learn from Python core developer and consultant Raymond Hettinger about the tips and tricks needed to move up to the next level.

    This tutorial will work through a series of real-world examples, showing how an understanding of the tools built into the Python interpreter or included in the standard library can be combined to solve difficult problems clearly and Pythonically. We will also discuss when and how to reach beyond the standard library when needed to address difficult algorithmic and optimization problems. This can be taken as a stand-alone session or in conjunction with the second session; the two sessions will be complementary.

    At 1:20pm to 4:40pm, Thursday 8th March

    In D1, Santa Clara Convention Center

  • Developing custom PyQt widgets and graphical interfaces efficiently.

    by Luis Artola

    Presents techniques and patterns for creating custom PyQt widgets easily. Focus is the separation of layout and logic to produce code that is easy to read and understand, and also inexpensive to maintain and evolve. Encourages and demonstrates the use of layout design applications, code generators and composition over inheritance. Based on PyQt4 but easily applicable to PySide as well.

    Many developers favor the creation of graphical user interfaces by hand-coding the layout of the interface elements. Most often than not, the resulting code is a highly cohesive mix of user interface and business logic that is not easy to maintain. Likewise, the development of custom widgets is often approached by subclassing top-level classes and overriding paint and event-handling methods. While this is the only alterantive for certain types of custom widgets, there is a big percentage that could be more easily created by composition of smaller widgets assembled together to work in as a unit.

    This tutorial aims to share the following with the audience:

    • Make a case for the benefits of using supporting tools for designing the layout portion of graphical user interfaces. In particular, the use of QtDesigner and code generators.
    • Present a pattern and project structure for creating PyQt widgets that can also be used inside QtDesigner.
    • Efficient use of composition over inheritance for assembling elaborate custom widgets more easily.

    All material is based on Python and PyQt4. Audience is expected to have working knowledge of PyQt. Or, at least proficiency developing application in Qt and C++.

    This tutorial is based on PyQt4 but concepts and techniques can be easily transferrable to PySide. Attendees require access to a computer with the following:

    • Qt 4.5.2 or later.
    • PyQt 4.5.4 or later.
    • sip 4.8.2 or later.
    • QtDesigner.
    • Python plugin for QtDesigner.
    • Python 2.5.x, 2.6.x or 2.7.x.

    An easy way to check whether the Python plugin is available or not is to select from QtDesigner's main menu: Help > About Plugins > Loaded Plugins, should show libpythonplugin.so. This is normally installed automatically by the Qt installer.

    At 1:20pm to 4:40pm, Thursday 8th March

    In H1, Santa Clara Convention Center

  • DevOps for Python: Doing More With Less

    by Noah Kantrowitz

    The world of infrastructure as code is becoming far more pervasive and many Python developers are trying to find a way to get started. This class will get you up and running with Chef and Fabric to manage your systems be they in the cloud or under your desk.

    Students must have a laptop with the Chef gem and git installed. Install instructions will sent out before the class.

    Agenda

    • Devops and Chef philosophy
    • Chef basics
    • Basic resources
    • Data bags
    • Environments
    • Intro to Ruby for Chef
    • Fabric

    At 1:20pm to 4:40pm, Thursday 8th March

    In F2, Santa Clara Convention Center

    Coverage video

  • High Performance Python II

    by Travis Oliphant

    In this tutorial, I will cover how to write very fast Python code for data analysis. I will briefly introduce NumPy and illustrate how fast code for Python is written in SciPy using tools like Fwrap / F2py and Cython. I will also describe interesting new approaches to creating fast code that is leading changes to NumPy on a fundamental level.

    In this tutorial, I will cover how to write very fast Python code for data analysis including making use of NumPy and using GPUs. I will largely focus on writing extensions to Python using hand-wrapping and Cython but will touch also on using tools like weave, Instant, ShedSkin and compare them to PyPy. I will also spend the last part of the tutorial on using GPUs with Python and discuss the performance trade-offs of the technology. This will be a high-level overview of the space with deep dives in Cython and GPUs

    Outline:

    • Brief Introduction to NumPy, SciPy and array-oriented computing with Python including exercises (1 hour)
    • Introduction to hand-wrapping and extending Python (1 hour)
    • Detailed description of Cython and how to use it to connect to machine-compiled code (1 hour)
    • Detailed description of GPUs and how to use them best with NumPy (45 minutes)
    • Summary and overview of using Python to write super fast code (15 minutes)

    At 1:20pm to 4:40pm, Thursday 8th March

    In D2, Santa Clara Convention Center

    Coverage video

  • Introduction to Interactive Predictive Analytics in Python with scikit-learn

    by Olivier Grisel

    The goal of this tutorial is to give the attendee a first experience of machine learning tools applied to practical software engineering tasks such as language detection of tweets, topic classification of web pages, sentiment analysis of customer products reviews and facial recognition in pictures from the web or from your own webcam.

    The demand for software engineers with Data Analytics and Machine Learning skills is rapidly growing and Python / Numpy is one of the best environments for quickly prototyping scalable data-centric applications or interactively exploring your data especially thanks to tools such as IPython and Matplotlib.

    scikit-learn is a very active open source project that implements a variety of state-of-the art machine learning algorithms. The goal of this project and tutorial is to take the algorithms out of the academic papers and make them work on a selection of real world tasks to unleash the value of your data.

    We will focus on providing hints to perform the right data preprocessing steps and on how to select algorithms and parameters suitable for the task at hand. We will also introduce tools and methodologies to measure the performance of the trained models as objectively as possible.

    At 1:20pm to 4:40pm, Thursday 8th March

    In F1, Santa Clara Convention Center

    Coverage video

  • Introduction to NLTK

    by Jacob Perkins

    Learn the basics of natural language processing with NLTK, the Natural Language ToolKit. First we'll cover tokenization, stemming and wordnet. Next we'll get into part-of-speech tagging, chunking & named entity recognition. Then we'll close with text classification and sentiment analysis. You'll walk out with new super-powers and an appreciation of the difficulties of analyzing human language.

    This tutorial will be a hands on approach to learning natural language processing using NLTK, the Natural Language ToolKit. We will cover everything from tokenizing sentences to phrase extraction, from splitting words to training your own text classifiers for sentiment analysis. Please come prepared with NLTK already installed so we can dive into the code & data immediately.

    Hour 1: Tokenization, Stemming & Corpora

    Tokenization & familiarity with corpus readers and models are required knowledge before you can get into the more interesting aspects of NLTK. This first hour will include:

    • an overview of modules & data
    • loading pickled models
    • sentence & word tokenization
    • stemming & lemmatization
    • an overview wordnet and other included corpora

    Hour 2: Part-of-Speech Tagging & Chunking/NER

    Using tokenization and a working knowledge of corpus readers & pickled models, we'll dive into part-of-speech tagging and chunking/NER, including:

    • using a part-of-speech tagger
    • an overview of tags and tagged corpora
    • training a custom tagger with nltk-trainer
    • using a chunker for phrase extraction and named entity recognition
    • an overview of chunked corpora
    • training a custom chunker with nltk-trainer

    Hour 3: Text Classification & Sentiment Analysis

    After using classifiers for training part-of-speech taggers and chunkers, this final hour will explain text classification in greater detail with:

    • an overview of classified corpora
    • text feature extraction
    • an overview of classification algorithms & when to use them
    • training a sentiment analysis classifier on movie reviews with nltk-trainer
    • using a classifier for sentiment analysis
    • hierarchical classification for sentiment analysis
    • binary vs multi-label classification

    Wrapping Up

    Now that you know how to use NLTK to process some of the included English corpora, we'll wrap up by covering:

    • non-english corpora included with NLTK
    • other Python libraries for NLP
    • custom corpus creation

    At 1:20pm to 4:40pm, Thursday 8th March

    In D3, Santa Clara Convention Center

  • Making and understanding music with Python and a little bit of Math

    by Pedro Kroger

    Are you interested in learning more about Music but have found most material to be kind of patronizing or to present things magically instead of logically? The good news is that much of music can be understood with programming and math, two things you're already good at! In this hands-on workshop you'll learn some elements of music from a (Python) programmer's perspective.

    There are (many) music operations that can be expressed directly in Math and code. Just to give you a taste, tranposing a set of notes to an interval i is as simple as [(n + i) % 12 for n in notes].

    In this tutorial we'll explore the primitives of Music (notes, intervals, dynamics, articulations, and duration), take a look inside them, the means of combining those primitives (motives, chords, operations such as transposition, retrograde, inversion), and the means of abstraction (phrases, harmonic functions and progressions, and form) using Python and some basic Math. At the end of this tutorial you should have a demysthified understanding of many elements of Music and be able to use Python to create short compositions.

    You can find a list of required libraries and programs, with installation instructions at https://github.com/kroger/learni....

    At 1:20pm to 4:40pm, Thursday 8th March

    In H2, Santa Clara Convention Center

  • Making interactive maps for the web

    by Zain Memon

    This tutorial teaches students how to create beautiful, interactive maps for the web. When asked to display geodata, most developers decide to put some big red markers on an embeddable Google Map and call it a day. If you're interested in creating maps that are more beautiful, more interactive, and more usable, this tutorial is for you.

    Build a light-weight version of Trulia's crime maps from scratch by the end of the tutorial, with a heatmap, source data points on the map, and a custom-styled base layer.

    Prerequisite Knowledge

    A solid understanding of Python, and very basic understanding of map concepts (like knowing what latitudes and longitudes are). A cursory run-through of the GeoDjango Introduction Tutorial would also be helpful.

    Topics Covered

    • Cartography 101
    • What are map projections?
    • Map tiles, and how maps on the web work today
    • Formats for storing and transferring geodata
    • Where to find interesting geodata
    • PostgreSQL + PostGIS
    • How to store geodata
    • Datatypes
    • Geographies vs Geometries
    • GeoDjango
    • Querying data with the ORM
    • Customizing the GeoDjango admin
    • Displaying the data
    • Creating and designing map tiles with TileStache
    • Customizing styles with Polymaps
    • Adding interactivity to maps
    • How to make geodata pretty

    At 1:20pm to 4:40pm, Thursday 8th March

    In H3, Santa Clara Convention Center