Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:

FWIW, the new_child() and parents() part of the API was modeled after contexts 
in ANLTR where they are needed to overcome the limitations of Django's push/pop 
style which precludes a context from having multiple, independent children at 
the same time.  The module docstring in the 
http://code.activestate.com/recipes/577434/ recipe shows how new_child() can be 
used to easily model both dynamic scoping and nested scoping.

The other advantage of the new_child/parents API over the push/pop API is that 
it overcomes the occasional templating need to keep two copies of the context 
(before a push and after a push).

In some ways, it is more difficult to keep track of a mutating chain that is 
being continuously pushed and popped.  It is simpler to assign a chain to a 
variable and always know that it is associated with a given template and not 
have to worry about whether some utility function pushed a new context and 
failed to pop it when it was done.  A push/pop style introduces the same 
problems as matching matching malloc() with free() in C.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11297>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to