Excerpts from Inside's message of Sat Jul 16 01:40:21 -0400 2011:
> Supplement:
> The assertion will not be handled anyway.
> I want AssertionError raise as early as possible.(mentinoed before)

An AssertionError is pretty useless, there are much better exceptions
that you could (and should!) use, depending on the context. If you
need a sequence, just use it like it is. If it's not a sequence a 
TypeError will be raised anyway:

>>> class Foo(object): pass
... 
>>> f = Foo()
>>> for i in f: pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Foo' object is not iterable
>>> 

Which is tons more useful than

>>> assert isinstance(f, (list, tuple))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
>>> 
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
     -- Abraham Lincoln

Attachment: signature.asc
Description: PGP signature

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

Reply via email to