PyCon 2009 – Namespaces Talk with Jeff Rush

The first PyCon talk I attended was entitled About Python Namespaces (and Code Objects), presented by Jeff Rush. This talk was a little over my head. Be sure to grab the slides and watch the video when and if the PyCon organizers post them. A quick run through is that Rush zipped through how instantiation create various kinds of objects which may have code objects beneath them. He also spoke on how the variables and functions were compiled into those code objects.

Rush also went through the pre and post execution phases of the code objects / namespaces. Pne interesting fact is that generators keep their namespaces longer than a normal locals namespace. What that means in day-to-day coding is less clear to me…but it’s probably important.

His next topic was Closures. Here’s his simple example:

[python]
def salary_above(amt):
def wages_test(person):
return person.salary
return wages_test

Then he went on to Early Binding and Namespaces. Here’s one of his examples:

[python]
# Early binding
names = []
rollcall = names.append
rollcall("John")

He also spoke on delegation and early binding, but as I mentioned above, you’re better off just watching the video along with his slides. I can’t explain it nearly as well as he did.