[Python-ideas] Make-statement [Re: Different interface for namedtuple?]

Nick Coghlan ncoghlan at gmail.com
Mon Mar 7 08:28:06 CET 2011


On Mon, Mar 7, 2011 at 4:06 PM, Bruce Leban <bruce at leapyear.org> wrote:
> On Sun, Mar 6, 2011 at 7:11 PM, Guido van Rossum <guido at python.org> wrote:
>> On Sat, Mar 5, 2011 at 10:27 PM, Carl M. Johnson
>> <cmjohnson.mailinglist at gmail.com> wrote:> With a little searching, you can
>> find similar examples of abuse that
>> > are centered around the with statement rather than metaclasses. People
>> > have made the with statement into an XML generator
>> >
>> > <http://langexplr.blogspot.com/2009/02/writing-xml-with-ironpython-xmlwriter.html>
>> > or an anonymous block handler
>> > <http://code.google.com/p/ouspg/wiki/AnonymousBlocksInPython>.
>>
>> TBH I find such abuse of 'with' much more troubling.
>
> I'm curious if you are troubled by both of these or one more than the other.
> Personally, the xml writer seems like a reasonable use to me. While I really
> don't like the anonymous block hack (either the use or the implementation).

The XML example is fine, since it is just another application of
"before-and-after" coding that the with statement was designed (that
kind of thing was mentioned explicitly in the PEP 343 discussions,
although never elaborated to anything like that degree).

The bytecode hackery involved in AnonymousBlocksInPython and the
withhacks module makes for fun toys to play with, but nothing that
should even be remotely contemplated for a production system.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list