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

Andrew Bennetts andrew-pythondev at puzzling.org
Tue Mar 30 06:39:39 EST 2004


On Tue, Mar 30, 2004 at 05:17:31AM -0600, Ka-Ping Yee wrote:
> Someone suggested the following syntax for setting function attributes:
> 
>     def func(arg, arg):
>         .author = 'Guido van Rossum'
>         .version = 42
> 
> Guido replied that he wanted to reserve ".name = value" for use in
> "with" blocks.
> 
> These two uses are not in conflict at all -- in fact, they are
> perfectly compatible and i find the syntactic consistency elegant.

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.

-Andrew




More information about the Python-Dev mailing list