At 12:05 PM 4/13/2006 -0600, Steven Bethard wrote:
>On 4/13/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > Steven Bethard wrote:
> > > I know 2.5's not out yet, but since I now have a PEP number, I'm going
> > > to go ahead and post this for discussion.  Currently, the target
> > > version is Python 2.6.  You can also see the PEP at:
> > >     http://www.python.org/dev/peps/pep-0359/
> > >
> > > Thanks in advance for the feedback!
> >
>[snip]
> >
> > Would it be possible/useful to have a pre-block hook to the callable,
> > which would provide the dictionary; this dictionary might not be
> > a proper dictionary (but only some mapping), or it might be 
> pre-initialized.
>
>Yeah, something along these lines came up in dicussing using the make
>statement for XML generation.  You might want to write something like:
>
>     make Element html:
>         make Element head:
>             ...
>         make Element body:
>             ...
>
>however, this doesn't work with the current semantics because:
>
>(1) dict's are unordered
>(2) dict's can't have the same name (key) twice

Why not just use 'with' statements for this?  The context gets invoked 
before and after, so it can track any local bindings that occur -- 
including the 'as' binding.

    with maker(...) as foo:
        blah blah

While it's true that frame-locals hacking isn't especially portable, you 
can at least use it to develop your actual use cases for this stuff, and 
then show why the syntax is awkward or doesn't support something.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to