Пример #1
0
def list():
    users = User.all()
    print_bool = lambda boolean: 'Yes' if boolean else 'No'
    data = [['Username', 'Email', 'Created At', 'Verified', 'Enabled']]
    for user in users:
        data.append([user.username, 
                     user.email,
                     user.created_at.strftime('%A %B %d %Y'),
                     print_bool(user.verified),
                     print_bool(user.enabled)])

    col_width = max(len(word) for row in data for word in row) + 2 # padding
    print '\n'
    for row in data:
        print "".join(word.ljust(col_width) for word in row)