python-2.1 function attributes

Carel Fellinger cfelling at iae.nl
Thu Jan 25 11:34:48 EST 2001


Paul Prescod <paulp at activestate.com> wrote:
> Mike Romberg wrote:
...
>> def spam():
>>     """The doc string."""
>>     { 'attribute1' : 'val1', 'attribute2' : val2 }
>>     pass

> I proposed a similar syntax to Guido a couple of years ago and he
> pointed out that it is unclear whether "val2" should be evaluated in the
> runtime context of spam() or in the global context. The former is what
> the syntax suggests but the latter is the only way to have the feature
> work properly.

That's why I proposed

    def spam()   # no trailing : here!, so we didn't really enter spam scope
        with:    # buth first the `with' scope to define spam's attributes
            statements to initialise f's dict with full python power
        suite

On the other hand, the current practice of having the first string-statement
be converted compile time into spam's docstring has always struck my as odd.
-- 
groetjes, carel



More information about the Python-list mailing list