PEP 359: The "make" Statement

Duncan Booth duncan.booth at invalid.invalid
Fri Apr 14 04:05:12 EDT 2006


Steven Bethard wrote:

> Should users of the make statement be able to determine in which dict
> object the code is executed?  The make statement could look for a
> ``__make_dict__`` attribute and call it to allow things like::
> 
>      make Element html:
>          make Element body:
>              make Element h1:
>                  '''First heading text'''
>              make Element h1:
>                  '''Second heading text'''

I'm concerned about the magic implied here for __doc__:

   make Element p:
       '''This is '''
       make Element strong:
          '''not'''
       '''going to work'''


There is another effect which should be considered here. If you allow 
Element to create an object to be used as the namespace, then as well as 
doing special tracking when values are set in the namespace it can also 
pre-seed it with names which magically appear in scope within the make.

e.g.

make Element html:
    make Element body:
        make Element p:
            text('But this ')
            make Element strong:
                 text('could')
            text(' be made to work')

or even:

   make Element p:
        text('This would ')
        strong('also')
        text(' work')

where text and strong are readable in the Element namespace (there doesn't 
actually have to be any relationship between the names you can access and 
the names you set).



More information about the Python-list mailing list