assertions to validate function parameters

Matthew Wilson matt at
Thu Jan 25 17:54:05 CET 2007

Lately, I've been writing functions like this:

def f(a, b):

    assert a in [1, 2, 3]
    assert b in [4, 5, 6]

The point is that I'm checking the type and the values of the

I'm curious how this does or doesn't fit into python's duck-typing

I find that when I detect invalid parameters overtly, I spend less time

Are other people doing things like this?  Any related commentary is


A better way of running series of SAS programs:

More information about the Python-list mailing list