Michael Sparks wrote:
On Monday 04 Jul 2005 03:10, Phillip J. Eby wrote:
At 03:41 PM 7/3/2005 -0400, Raymond Hettinger wrote:
This is possible. I just wanted to expand everyone's minds :)
The mechanism is more general than resourcemanagement.
Expand your mind. :) "Resource" can include whatever objects you want it to -- or no objects at all.
Is printing HTML and guaranteeing ending tags a resource ? I've been reading this thread, and been thinking that Holger Kregel's XPython hack could be implemented using the new with statement.
with some_encoding: with html: with body: with h1: print "Some heading" with p: print "This is paragraph 1" with p: print "This is paragraph 2" with h2: print "Another heading"
The enter/exit for html would be to print <html> </html> respectively and so on. (Though "p" would be special cased, etc)
Phillip's 'context' terminology, on the other hand, applies beautifully:
- encoding context - HTML context - HTML body context - HTML heading 1 context - HTML paragraph context
I think we have a winner. . .