Your current filters are…
Python's metaclasses grant the Python OOP ecosystem all the power of more complex object inheritance systems in other languages, while retaining for most uses the simplicity of the straightforward class structures most developers learn when being introduced to object-oriented programming. This talk is an explanation of metaclasses: first, what they are, and second, how to use them.
All problems have simple, easy-to-understand, logical wrong answers. Subclassing in Python is no exception. Avoid the common pitfalls and learn everything you need to know about making effective use of inheritance in Python.
Avoid the common pitfalls and learn everything you need to know about how subclass in Python.
Classes are great but they are also overused. This talk will describe examples of class overuse taken from real world code and refactor the unnecessary classes, exceptions, and modules out of them.
Classes must be nouns but not every noun must be a class. If your class only has two methods and one of them is init you probably meant to write a function.
MuffinMail recently refactored their API; it went from 20 classes scattered in 22 modules down to 1 class just 15 lines long. It was a welcome change, but we'll further refactor that down to a single function 3 lines long.
The Python stdlib is an example of a namespace that is relatively flat. You won't find packages that consist of a single module defining an exception, and you won't find many exceptions at all - just 165 kinds in 200k lines of code. That's a tiny ratio compared to most projects including Django.
Of course there are things, like containers, that should be classes. As a final example we'll add a Heap type to the heapq module (admit it, you already have one in your utils.py).
by Jeff Rush
Learn the magic of writing programs that monitor, alter and react to the execution of program code by responding to imports, changes to variables, calls to functions and invocations of the builtins. This talk goes beyond the static world of metaclasses and class decorators.
Learn the magic of writing programs that monitor, alter and react to the execution of program code by responding to imports, changes to variables, calls to functions and invocations of the builtins. This talk goes beyond the static world of metaclasses and class decorators.
We'll cover how to slide a class underneath a module to intercept reads/writes, place automatic type checking over your object attributes and use stack peeking to make selected attributes private to their owning class. We'll cover import hacking, metaclasses, descriptors and decorators and graphically describe how they work internally. Source examples and color technical diagrams.
Table-of-Contents
What is Metaprogramming?
Tools At Our Disposal
Orientation Diagram: What is Metaprogramming
First Third of Talk: Import Hooking
Sample Problem #1: Subclassing an Embedded Class
A Solution to #1: Post-Import Hooking
A Solution to #1 (Packaged Up)
Alternate Solution: Pre-Import Hooking
What Does a Subclassed Module Look Like?
Some Benefits of Subclassing Modules
2nd Third of Talk: Metaclasses
Orientation Diagram: Instances, Classes and Metaclasses
Facts About Metaclasses
Example #2: Define a Class from an SQL Table Definition
Example Problem #2 (cont'd)
Metaclasses versus Class Decorators
About Meta-Inheritance
Example #3: Log the Arguments/Return Value of Method Calls
Lull After Metaclasses, Before Descriptors
Last Third of Talk: Descriptors
Python's Mechanism of Attribute Lookup
When to Use Which Lookup Mechanism
Example 4: Overriding getattr
Example 4: Using a Descriptor Instead
Python's Mechanism of Attribute Lookup (descriptors)
So What is a descriptor again?
Where are descriptors used?
Example 5: Caching an Attribute Value
Example 6: Declare an Attribute Private to a Class
Example 7: Tracking Changes in a Value
by Eric Snow
In 2.6, Python introduced the Abstract Base Classes. Before that we had "protocols" (and we still do). In this talk we'll look at how the general concept of interfaces fits into today's Python. We'll also look at some of the alternate proposals of the past, some of the controversies around ABCs, and the direction interfaces might go in the future.
Talk Outline:
For more comprehensive coverage of interfaces in Python, check out this reference: http://readthedocs.org/docs/refe...
Learn how decorators and context managers work, see several popular examples, and get a brief intro to writing your own. Decorators wrap your functions to easily add more functionality. Context managers use the 'with' statement to make indented blocks magical. Both are very powerful parts of the python language; come learn how to use them in your code.
Decorators wrap or modify your functions. They are functions themselves, so you can pass parameters to them. You can wrap a function with multiple decorators too. We'll cover how to use decorators in all those situations and how to write them too. Examples will be demonstrated with:
Context managers wrap a block of code using the 'with' statement to do something on the way into the block and something on the way out. Opening and closing a file is a very common case, but there is a lot more you can do. Examples include:
More about decorators: http://www.python.org/dev/peps/p...
More about context managers: http://www.python.org/dev/peps/p...
http://docs.python.org/library/c...
by Walker Hale
This talk covers the power and metaprogramming features of Python that cater to mad scientists and evil geniuses. This will also be of interest to others who just want to use of Python in a more power (hungry) way. The core concept is that you can synthesize functions, classes and modules without a direct correspondence to source code. You can also mutate third-party objects and apps.
This talk covers the power and metaprogramming features of Python that cater to mad scientists and evil geniuses. This will also be of interest to others who just want to use of Python in a more power (hungry) way.
Users of Python are not limited to the usual model of a one-to-one correspondence between source code and live objects. Python allows you to synthesize functions, classes and modules without a direct correspondence to source code. You can mutate third-party objects, classes, modules and applications through monkey patching -- changing their behavior without altering their source code. You can even "chop-up" third-party objects to create new objects from the pieces. Find out how to unleash your inner Mad Scientist!
Thesis: Python is an ideal language for both:
Although most of the material is presented from the point of view of the Mad Scientist, it is equally useful to the Evil Genius.
Since the Python community prides itself on diversity, I should emphasize that the sane, the non-evil, and "do-gooders" are all welcome.
by glyph
Many - perhaps even most - Python software involves a network, at least a little bit. You've probably written some yourself. But do you really know what happens - to your kernel, to your ethernet card, to Python - when you call socket.send()? Come to this talk and find out: if you dare.
by Taavi Burns
`time`, `datetime`, and `calendar` from the standard library are a bit messy. Find out what to use where and how (particularly when you have users in many timezones), and what extra modules you might want to look into.
by Jonathan Rocher
Analyzing, storing and visualizing time-series efficiently are recurring though difficult tasks in various aspects of scientific data analysis such as meteorological forecasting, financial modeling, ... In this talk we will explore the current Python ecosystem for doing this effectively, comparing options, using only open source packages that are mature yet still under active development.
Python has great Unicode support, but it's still your responsibility to handle it properly. I'll do a quick overview of what Unicode is, but only enough to get your program working properly. I'll describe strategies to make your code work, and keep it working, without getting too far afield in Unicode la-la-land.
Python has great Unicode support, but it's still your responsibility to handle it properly. Even expert programmers get tripped up with the encodings and decodings that can happen implicitly, throwing errors in unexpected places.
This talk will present a quick overview of what Unicode is, why it exists, and how it works, but only enough to get your program working properly. Unicode can be intricate and fascinating, but really, who cares? You just want your code to work without throwing a UnicodeEncodeError every time an accented character sneaks in somehow.
I'll describe strategies to make your code work, and keep it working, without getting too far afield in Unicode la-la-land.
How Unicode is handled is one of the biggest changes in Python 3. I'll touch on what those changes are, and how you can use them to keep even your Python 2 code running smoothly.
Outline
Bytes vs. text
ASCII, 8859-1, etc.
Unicode
Encodings
Python 2: str vs unicode
encode and decode
implicit conversions!!
Python 3: bytes vs str
Everybody's happy!
Datums! Coordinate systems! Map projections! Topologies! Spatial applications are a nebulous, daunting concept to most Pythonistas. This talk is a gentle introduction into the concepts, terminology and tools to demystify the world of the world.
This talk will have multiple parts:
by Zain Memon
Python makes it easy to store, query, and transform geodata. We will run through a handful of useful GIS libraries and patterns that let you do magical things with your maps. If you want to make maps that are more interactive and more interesting, this talk is for you.
This talk will demystify the different parts of a usual map stack, including:
GeoSpatial Datastores (RDBMS & NoSQL)
Map servers (that query the geodata)
Tile servers (that chunk the data into tiles and cache it)
Browser UIs (and the difference between different Javascript slippy maps)
By ensuring consistency and repeatability in setting up the development environments of a team of developers, errors can be avoided (by automating repetitive tasks). It also helps by lowering the entry barrier for new developers, and letting existing developers focus on development tasks without having to worry about infrastructure or process issues.
This talk will show how you can use fabric to standardize the different tasks that are commonly performed during the development process. Such tasks can be grouped into categories like:
bootstrap: initializing the development environment
database: managing the database
testing: running tests
lint: validating the code against different standards
deploy: automating the deployment process
by Paul Smith
Spatial data are often seen as opaque to most developers, and while dealing with them does require a shift in approach from the data types we most regularly handle, they needn’t be the domain of specialists. High-quality Python libraries and Python-based applications exist for operating on and transforming spatial data, and for creating visualizations, including maps for presentation on the web.
This talk will be an overview of the Python libraries and applications available for handling spatial and geospatial data and creating maps for the web. It will cover libraries for open and transforming spatial data formats and representations, spatial operators and predicates for queries and relationships, spatial indexes for efficient queries, and compositing and rendering map tiles, as well as desktop applications extensible with Python that replace much of the functionality of "enterprise" GIS software.
CherryPy was the first web framework to be made available for use with Python 3, and we tried several approaches to support both Python 2 and 3 before settling on one. Learn about the ups and the downs of each approach, and ways you can make your own porting project easier.
The CherryPy project was the first web framework to support Python 3. At the same time, we needed to continue to support and improve the Python 2 implementation. It's taken plenty of time and lots of experimentation to find out the best way. We will explore four different ways to support both Python 2 and 3, commenting on the pros and cons of each.
Intro
Python 3 change highlights
Special concerns for I/O, including WSGI
Approach 1: 2to3
Approach 2: separate branches
Approach 3: setup.py switch
Approach 4: compatibility layer
Q&A
by Erik Rose
If you've ever wanted to get started with parsers, here's your chance for a ground-floor introduction. A harebrained spare-time project gives birth to a whirlwind journey from basic algorithms to Python libraries and, at last, to a parser for one of the craziest syntaxes out there: the MediaWiki grammar that drives Wikipedia.
Some languages were designed to be parsed. The most obvious example is Lisp and its relatives which are practically parsed when they hit the page. However, many others—including most wiki grammars—grow organically and get turned into HTML by sedimentary strata of regular expressions, all backtracking and warring with one another, making it difficult to output other formats or make changes to the language.
We will explore the tools and techniques necessary to attack one of the hairiest lingual challenges out there: MediaWiki syntax. Join me for an introduction to the general classes of parsing algorithms, from the birth of the field to the state of the art. Learn how to pick the right one. Have a comparative look at a dozen different Python parsing toolkits. And finally, learn some optimization tricks to get a grammar going at a reasonable clip.
Search is an increasingly common request in all types of applications as the amount of data all of us deal with continues to grow. The technology/architecture behind search engines is wildly different from what many developers expect. This talk will give a solid grounding in the fundamentals of providing search using Python to flesh out these concepts in a simple library.
by Jeff Elmore
Many of you are probably familiar with NLTK, the wonderful Natural Language Toolkit for Python. You may not be familiar with Linkgrammar, which is a sentence parsing system created at Carnegie Melon university. Linkgrammar is quite robust and works "out of the box" in a way that NLTK does not for sentence parsing.
Abstract
NLTK is a fantastic library with broad capabilities. But often I find that I want something that will just do what I want without my having to figure out all of the details. An example of this is sentence parsing. A quick google search for parsing sentences with NLTK returns a number of articles describing how to write your own grammar and define a parser based on that grammar and parse sentences. This is great for toy problems and education, but if you actually need to parse sentences "from the wild," writing your own grammar is a huge undertaking.
Enter Linkgrammar. Linkgrammar was developed at Carnegie Melon university and is now maintained by the developers of Abiword as the basis for their grammar checking capabilities. It works nicely out of the box and is tolerant of irregularities found in authentic text.