class documentation

class LazyProxy(object):

View In Hierarchy

Class for proxy objects that delegate to a specified function to evaluate the actual object.

>>> def greeting(name='world'):
...     return 'Hello, %s!' % name
>>> lazy_greeting = LazyProxy(greeting, name='Joe')
>>> print(lazy_greeting)
Hello, Joe!
>>> u'  ' + lazy_greeting
u'  Hello, Joe!'
>>> u'(%s)' % lazy_greeting
u'(Hello, Joe!)'

This can be used, for example, to implement lazy translation functions that delay the actual translation until the string is actually used. The rationale for such behavior is that the locale of the user may not always be available. In web applications, you only know the locale when processing a request.

The proxy implementation attempts to be as complete as possible, so that the lazy objects should mostly work as expected, for example for sorting:

>>> greetings = [
...     LazyProxy(greeting, 'world'),
...     LazyProxy(greeting, 'Joe'),
...     LazyProxy(greeting, 'universe'),
... ]
>>> greetings.sort()
>>> for greeting in greetings:
...     print(greeting)
Hello, Joe!
Hello, universe!
Hello, world!
Method __add__ Undocumented
Method __call__ Undocumented
Method __contains__ Undocumented
Method __copy__ Undocumented
Method __deepcopy__ Undocumented
Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method __dir__ Undocumented
Method __eq__ Undocumented
Method __ge__ Undocumented
Method __getattr__ Undocumented
Method __getitem__ Undocumented
Method __gt__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method __le__ Undocumented
Method __len__ Undocumented
Method __lt__ Undocumented
Method __mod__ Undocumented
Method __mul__ Undocumented
Method __ne__ Undocumented
Method __nonzero__ Undocumented
Method __radd__ Undocumented
Method __rmod__ Undocumented
Method __rmul__ Undocumented
Method __setattr__ Undocumented
Method __setitem__ Undocumented
Method __str__ Undocumented
Method __unicode__ Undocumented
Class Variable __slots__ Undocumented
Property value Undocumented
def __add__(self, other):

Undocumented

def __call__(self, *args, **kwargs):

Undocumented

def __contains__(self, key):

Undocumented

def __copy__(self):

Undocumented

def __deepcopy__(self, memo):

Undocumented

def __delattr__(self, name):

Undocumented

def __delitem__(self, key):

Undocumented

def __dir__(self):

Undocumented

def __eq__(self, other):

Undocumented

def __ge__(self, other):

Undocumented

def __getattr__(self, name):

Undocumented

def __getitem__(self, key):

Undocumented

def __gt__(self, other):

Undocumented

def __init__(self, func, *args, **kwargs):

Undocumented

def __iter__(self):

Undocumented

def __le__(self, other):

Undocumented

def __len__(self):

Undocumented

def __lt__(self, other):

Undocumented

def __mod__(self, other):

Undocumented

def __mul__(self, other):

Undocumented

def __ne__(self, other):

Undocumented

def __nonzero__(self):

Undocumented

def __radd__(self, other):

Undocumented

def __rmod__(self, other):

Undocumented

def __rmul__(self, other):

Undocumented

def __setattr__(self, name, value):

Undocumented

def __setitem__(self, key, value):

Undocumented

def __str__(self):

Undocumented

def __unicode__(self):

Undocumented

__slots__: list[str] =

Undocumented

@property
value =

Undocumented