module_3.py (622B)
1 """ 2 This is the docstring for ./subpkg_2/module_3.py. This module provides one 3 function `baz`. Example usage is: 4 5 >>> baz(0) 6 0 7 """ 8 9 10 def baz(x): 11 """ 12 Return the input x if it is an int or float. 13 14 Parameters 15 ---------- 16 x : input argument 17 18 Returns 19 ------- 20 x : If it is of type int or float 21 22 Examples 23 -------- 24 >>> baz(0) 25 0 26 27 >>> baz(0.0) 28 0.0 29 30 >>> baz('a string') 31 Traceback (most recent call last): 32 ... 33 ValueError: x must be int or float 34 """ 35 if not isinstance(x, (int, float)): 36 raise ValueError('x must be int or float') 37 return x