[Python-3000] Type annotations: annotating generators

Collin Winter collinw at gmail.com
Fri May 19 22:50:19 CEST 2006


On 5/19/06, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 5/19/06, Collin Winter <collinw at gmail.com> wrote:
> > On 5/19/06, Jim Jewett <jimjjewett at gmail.com> wrote:
> > > (1)  Just use a tuple, and put the smarts in your decorator if you
> > > need to actually do something with the information.
>
> > >     @decorator_which_handles_tuples
> > >     def f(a: (int, str)):
>
> > How do you differentiate between this and wanting to assert that 'a'
> > is a 2-tuple with a first element of type int and a second element of
> > type str?
>
> The decorator knows.  The human only knows by convention.  (But that's
> true anyhow; a sneaky decorator could replace the entire function with
> something having an unrelated signature.)
>
> I expect that there would be other decorators using a tuple to say
> "must meet all", rather than "must meet at least one".

And what if I want to use several decorators at the same time, all of
which stake a claim to tuples?

Collin Winter


More information about the Python-3000 mailing list