Changeset 26
- Timestamp:
- 10/12/08 14:44:00 (2 years ago)
- Files:
-
- 1 modified
-
procyon/util.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
procyon/util.py
r13 r26 107 107 yield delim 108 108 yield x 109 110 111 def maybe(value, f, default=None): 112 """ 113 Maybe apply C{f} to C{value} otherwise return C{default}. 114 115 If C{value} is None then C{default} is returned, otherwise C{f} is applied 116 to C{value} and the result returned. 117 118 @type f: C{callable} 119 @param f: A callable that is passed one argument, C{value}, the result of 120 which is then returned 121 """ 122 if value is None: 123 return default 124 return f(value) 125 126
