[Python-Dev] PEP 318: Set attribs with .name = value

Nick Coghlan ncoghlan at email.com
Tue Mar 30 21:02:17 EST 2004


Quoting Andrew Bennetts <andrew-pythondev at puzzling.org>:

> Although this would not (I hope) be a common use-case, what would this code
> mean:
> 
>     with foo:
>         def func(arg):
>             .attrib = value
>             pass
>             
> ?
> 
> I'm not entirely sure it's safe to say they don't conflict, although I don't
> see this case as a serious problem.

The proposal would basically be that the above becomes equivalent to:

  with foo:
    def func(arg):
      with func:
        .attrib = value

(except that the above wouldn't actually work, as 'func' isn't bound to 
anything in it's own body)

Personally, I'd prefer to see function attributes made possible by allowing 
references to the name of the function from within the definition of the 
function.Eg:

    def func(arg):
      func.attrib = value

Then a 'function attribute block' can easily be delimited by using a with block 
as I do above. However, I don't know if this idea has been considered and 
discarded in the past.

Cheers,
Nick
-- 
Nick Coghlan
Brisbane, Australia



More information about the Python-Dev mailing list