python3: 'where' keyword

Carlos Ribeiro carribeiro at
Sun Jan 9 03:51:42 EST 2005

On Sun, 09 Jan 2005 15:54:08 +1000, Nick Coghlan <ncoghlan at> wrote:
> Here's another nice one if 'where' is added to compound statements as well:
> @dbc(pre, post)
> def foo():
>    pass
> where:
>    def pre():
>      pass
>    def post():
>      pass

Interesting. It solves some of the issues with chosing a clear syntax
for "design by contract" and other similar features that were being
debated lately. I also thought about his one:

! def foo(x=calculate_default_value()):
!     pass
! where:
!     def calculate_default_value():
!         ...
!         return <something>

Carlos Ribeiro
Consultoria em Projetos
mail: carribeiro at
mail: carribeiro at

More information about the Python-list mailing list