Project

General

Profile

« Previous | Next » 

Revision 836

util.py: Added cast() to cast a value while passing None through

View differences:

lib/util.py
15 15
        ValueError.__init__(self, str(value)+' must satisfy constraint '
16 16
            +check_func.__name__)
17 17

  
18
def cast(type_, val):
19
    '''Passes None through'''
20
    if val != None: val = type_(val)
21
    return val
22

  
18 23
def is_str(val): return isinstance(val, basestring)
19 24

  
20 25
#### Iterables

Also available in: Unified diff