Changeset - 32ffa258953c
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-04-24 23:57:36
chrisjrn@gmail.com
Adds util.all_arguments_optional
1 file changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
registrasion/util.py
Show inline comments
...
 
@@ -14,3 +14,14 @@ def generate_access_code():
 
    chars = string.uppercase + string.digits[1:]
 
    # 4 chars => 35 ** 4 = 1500625 (should be enough for anyone)
 
    return get_random_string(length=length, allowed_chars=chars)
 

	
 

	
 
def all_arguments_optional(ntcls):
 
    ''' Takes a namedtuple derivative and makes all of the arguments optional.
 
    '''
 

	
 
    ntcls.__new__.__defaults__ = (
 
        (None,) * len(ntcls._fields)
 
    )
 

	
 
    return ntcls
0 comments (0 inline, 0 general)