2009/3/10 Martijn Pieters <m...@zopatista.com>:
> On Mon, Mar 9, 2009 at 22:20, Dan Korostelev <nad...@gmail.com> wrote:
>> As you may know, python 3 introduced the concept of annotations for
>> callable objects. That annotations store information about arguments
>> and return values, which is kinda nice language feature that will
>> allow us to do interesting things.
>>
>> But there's a problem: those annotations will be stored in object's
>> __annotations__ attribute, which is also used by zope.annotation's
>> AttributeAnnotation implementation, so they will conflict.
>
> I don't think they are, according to PEP 3107 they are stored in the
> func_annotations attribute of the function.

No, they are stored in __annotations__. Look here:
http://docs.python.org/3.0/whatsnew/3.0.html#new-syntax

Also:

n...@seasaw:~$ python3
Python 3.0.1+ (r301:69556, Feb 24 2009, 13:51:44)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> def hello(who:'name') -> None:
...     print('Hello, {0}!'.format(who))
...
>>> hello.__annotations__
{'who': 'name', 'return': None}


> Note that even if the name *where* the same, attribute annotations
> only work on classes and instances, while function annotations only
> apply to functions, not?

Good point. Looks like it is added automatically only for functions/methods. :)

However, we can't be sure there won't be annotations for any callable
object, because even PEP says that ``we say function, we mean callable
object``, so one day we certainly will conflict with something. Also,
as Gary pointed out, we mis-use the __*__ name pattern that is now
intended for defining special names that have special meaning for
python interpreter. And we'll certainly will mis-use the
__annotations__ name as it's clearly defined in python 3k.

So, after Gary reminded about __*__ names, I think we shoud use
something like "_z_annotations".

-- 
WBR, Dan Korostelev
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to