Advertisement
Guest User

function annotations

a guest
Jun 3rd, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10)
  2. [GCC 4.4.5] on linux2
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> def foo(x: "First operand", y: "Second operand") -> "Sum of operand squares":
  5. ...     return x * x + y * y
  6. ...
  7. >>> foo(3, 4)
  8. 25
  9. >>> print(foo.__annotations__)
  10. {'y': 'Second operand', 'x': 'First operand', 'return': 'Sum of operand squares'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement