Module example
[hide private]
[frames] | no frames]

Source Code for Module example

 1  """This is the docstring for the example.py module.  Modules names should 
 2  have short, all-lowercase names.  The module name may have underscores if 
 3  this improves readability. 
 4   
 5  Every module should have a docstring at the very top of the file.  The 
 6  module's docstring may extend over multiple lines.  If your docstring does 
 7  extend over multiple lines, the closing three quotation marks must be on 
 8  a line by itself, preferably preceeded by a blank line. 
 9   
10  """ 
11   
12  import os                      # standard library imports first 
13   
14  import numpy as np             # related third party imports next 
15  import scipy as sp             # imports should be at the top of the module 
16  import matplotlib as mpl       # imports should usually be on separate lines 
17   
18 -def foo(var1, var2, long_var_name='hi') :
19 """One-line summary or signature. 20 21 Several sentences providing an extended description. You can put 22 text in mono-spaced type like so: ``var``. 23 24 Parameters 25 ---------- 26 var1 : array_like 27 Array_like means all those objects -- lists, nested lists, etc. -- 28 that can be converted to an array. 29 var2 : integer 30 Write out the full type 31 long_variable_name : {'hi', 'ho'}, optional 32 Choices in brackets, default first when optional. 33 34 Returns 35 ------- 36 named : type 37 Explanation 38 list 39 Explanation 40 of 41 Explanation 42 outputs 43 even more explaining 44 45 Other Parameters 46 ---------------- 47 only_seldom_used_keywords : type 48 Explanation 49 common_parametrs_listed_above : type 50 Explanation 51 52 See Also 53 -------- 54 otherfunc : relationship (optional) 55 newfunc : relationship (optional) 56 57 Notes 58 ----- 59 Notes about the implementation algorithm (if needed). 60 61 This can have multiple paragraphs as can all sections. 62 63 Examples 64 -------- 65 66 examples in doctest format 67 68 >>> a=[1,2,3] 69 >>> [x + 3 for x in a] 70 [4, 5, 6] 71 72 """ 73 74 pass
75 76
77 -def newfunc() :
78 """Do nothing. 79 80 I never saw a purple cow. 81 82 """ 83 84 pass
85 86
87 -def otherfunc() :
88 """Do nothing. 89 90 I never hope to see one. 91 92 """ 93 94 pass
95