AndreaCensi / contracts

PyContracts is a Python package that allows to declare constraints on function parameters and return values. Contracts can be specified using Python3 annotations, or inside a docstring. PyContracts supports a basic type system, variables binding, arithmetic constraints, and has several specialized contracts and an extension API.
http://andreacensi.github.io/contracts/
Other
398 stars 62 forks source link

Add 'in' support #37

Open gsemet opened 9 years ago

gsemet commented 9 years ago

Hello. I propose the following syntax to implement

@contract(arg="str,in('a','b','c')")
def function(arg):
  pass

Action: perform the following python code

assert(arg in {'a', 'b', 'c'})