On Sun, 12 Jun 2005 14:40:26 +0000, Chris Spencer wrote: > Being an untyped language, Python does not require you to enforce types. > However, for those that require such functionality, you can get away > with using the "assert" statement.
Assuming that Python isn't executed with the optimize switch, which disables assert. $ python -O Python 2.3.3 (#1, May 7 2004, 10:31:40) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. py> py> py> def tester(x): ... assert type(x) == type(0) ... print "%s is an integer." % x ... py> tester(3) '3 is an integer' py> tester("hello") 'hello is an integer' -- http://mail.python.org/mailman/listinfo/python-list