OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Class for proxy objects that delegate to a specified function to evaluate
the actual object. 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: Inherited from Inherited from
Home
Trees
Indices
Help
Documentation Index
Class LazyProxy
object --+
|
LazyProxy
>>> 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!)'
>>> greetings = [
... LazyProxy(greeting, 'world'),
... LazyProxy(greeting, 'Joe'),
... LazyProxy(greeting, 'universe'),
... ]
>>> greetings.sort()
>>> for greeting in greetings:
... print greeting
Hello, Joe!
Hello, universe!
Hello, world!
Instance Methods
__init__(self,
func,
*args,
**kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__contains__(self,
key)
__nonzero__(self)
__dir__(self)
__iter__(self)
__len__(self)
__str__(self)
str(x)
__unicode__(self)
__add__(self,
other)
__radd__(self,
other)
__mod__(self,
other)
__rmod__(self,
other)
__mul__(self,
other)
__rmul__(self,
other)
__call__(self,
*args,
**kwargs)
__lt__(self,
other)
__le__(self,
other)
__eq__(self,
other)
__ne__(self,
other)
__gt__(self,
other)
__ge__(self,
other)
__delattr__(self,
name)
x.__delattr__('name') <==> del x.name
__getattr__(self,
name)
__setattr__(self,
name,
value)
x.__setattr__('name', value) <==> x.name = value
__delitem__(self,
key)
__getitem__(self,
key)
__setitem__(self,
key,
value)
object:
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__repr__,
__sizeof__,
__subclasshook__
Properties
value
object:
__class__
Method Details
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__init__(self,
func,
*args,
**kwargs)
(Constructor)
str(x)
__str__(self)
(Informal representation operator)
x.__delattr__('name') <==> del x.name
__delattr__(self,
name)
x.__setattr__('name', value) <==> x.name = value
__setattr__(self,
name,
value)
Property Details
value
Home
Trees
Indices
Help
Documentation Index
Generated by Epydoc 3.0.1 on Thu Mar 17 15:12:45 2011
http://epydoc.sourceforge.net