Missing exceptions in PEP 3107

Duncan Booth duncan.booth at invalid.invalid
Sun Aug 10 13:31:58 CEST 2008

Christoph Zwerschke <cito at online.de> wrote:

> That would be possible. But I still think it makes sense to separate 
> them, like so:
> def foo(a: "a info", b: "b info") -> "ret info" raise "exc info":
>      return "hello world"
> And then the annotation dictionary would contain another key "raise" 
> containing the exc info. This cannot conflict with the name of any other 
> parameter either.

If you really want this then you can use a decorator to insert a 'raise' 
key into the annotations:

@raises("exc info")
def foo(a: "a info", b: "b info") -> "ret info":
	return "hello world"

> I don't know how determined the "->" syntax is already.

Consider the syntax set in concrete. The meaning of the annotations on the 
other hand is completely up for grabs.

More information about the Python-list mailing list