type() of an old-style class

types.ClassType

added 2012-06-02T19:58:07Z by anders

__metaclass__

We can provide a custom metaclass by setting __metaclass__ in a class definition to any callable that takes the same arguments as type.

added 2012-06-02T19:58:07Z by anders

type(name, bases, dict) creates a new type

When the Python interpreter executes a class statement […], it calls type with the following arguments:

  • The name of the class as a string
  • A tuple of base classes - for our example this is the ‘one-pl’ 1
  • A dictionary containing members of the class (class attributes, methods, etc) mapped by their names

added 2012-06-02T19:58:07Z by anders

descriptor definition

a descriptor is an object attribute with “binding behavior”, one whose attribute access has been overridden by methods in the descriptor protocol.

added 2012-06-01T23:02:12Z by anders

non-data descriptor defnition

Descriptors that only define get are called non-data descriptors (they are typically used for methods but other uses are possible).

added 2012-06-01T23:02:12Z by anders

data descriptor definition

If an object defines both __get__ and __set__, it is considered a data descriptor.

added 2012-06-01T23:02:12Z by anders

descriptors are invoked by the __getattribute__ method

overriding __getattribute__ prevents automatic descriptor calls

added 2012-06-01T23:02:12Z by anders

descriptor precedence rules

If an instance’s dictionary has an entry with the same name as a data descriptor, the data descriptor takes precedence. If an instance’s dictionary has an entry with the same name as a non-data descriptor, the dictionary entry takes precedence.

added 2012-06-01T23:02:12Z by anders

virtualenv will be included in a future Python release

In about two minutes, discussion on PEP 405 came and went. Carl Meyer mentioned that a reference implementation is available and is working pretty well.

added 2012-03-14T14:15:14Z by anders

Django and Python 3

Django 1.5 will begin to experimentally support Python 3. Python 2.6 will be the minimum requirement.

added 2012-03-13T23:59:23Z by anders

@cache_control decorator for django

very handy for preventing back button issues.

from django.views.decorators.cache import cache_control

Source: stackoverflow
added 2012-03-12T17:17:57Z by anders