On Fri, 05 Feb 2010 16:52:19 +0100, mk wrote:

> assert isinstance(cmd, basestring) or cmd is None, "cmd should be string
> or None"

Do not use assertions for input validation. That's not what they're for.

assert is compiled away when you run your code with the -O switch, which 
means that the test may never be made at all. You should limit assertions 
for testing "this can never happen" situations, verifying pre- and post-
conditions, checking the internal logic of your code, and similar.


See also:

http://nedbatchelder.com/text/assert.html


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to