[Python-ideas] Attribute Docstrings and Annotations

Tony Lownds tony at PageDNA.com
Fri Jun 1 18:19:22 CEST 2007

On May 31, 2007, at 6:15 AM, Ali Sabil wrote:

> Hello all,
> I was looking into function annotations, that are to be introduced  
> in Python3k, and I found this old message sent to this mailing  
> list : http://mail.python.org/pipermail/python-ideas/2007-January/ 
> 000037.html
> I would like to restart the discussion of attribute annotation,  
> because in my opinion it can be a very powerful feature. I  
> personally think about using it for SOAP message serialization, or  
> any kind of XML serialization, the Idea would be to annotate  
> various object attribues to be either marshaled as XML Elements or  
> XML Attributes of the current Node that reflects the Object.

Hi Ali,

I'm afraid the PEP deadline has passed, restarting the discussion would
not change that.

Your use case sounds interesting. I know there are a lot of other use  
cases for
attribute meta-data. However there are lots of ways to achieve  
attribute meta data

# Via naming convention
class A:
   attr = 1
   f_attr = int

# Via decorators
class A:
   attr = annotated_value(1, int)

# Via a separate class
class A:
   class meta:
     attr = int
   attr = 1

# Compare to attribute annotation syntax
class A:
   attr: int = 1

Each of the existing idioms I have seen or used has issues, mostly  
minor. I suspect that because
the existing ways don't have glaring deficiencies, even if it were  
before the PEP deadline, a renewed
push on the proposal would have encountered a lot more resistance.

I still think the syntax is elegant in symmetry and provides a  
unified and improved idiom for
a common use case.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070601/a73dd473/attachment.html>

More information about the Python-ideas mailing list