list(), tuple() should not place at "Built-in functions" in documentation

Inside fancheyujian at gmail.com
Fri Jul 15 15:53:52 EDT 2011


Why I use assertion,please check this code:
"""
class User(object):pass

class Student(User):pass

class Professional(User):pass

def add(user):
    assert(user, User)

def add(users):
    assert(users, (tuple, list))
    #If necessary I'll also check every obj in the sequence to see whether it's a User.
"""

I just follow some coding rules of me:
1. Controlling "input" strictly.
2. In a function keep doubting on its parameters until they're checked.
3. Let potential errors raise as early as possible.



More information about the Python-list mailing list