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   
 19  __docformat__ = "restructuredtext en" 
 20   
 21   
22 -def foo(var1, var2, long_var_name='hi') :
23 """One-line summary or signature. 24 25 Several sentences providing an extended description. You can put 26 text in mono-spaced type like so: ``var``. 27 28 *Parameters*: 29 30 var1 : {array_like} 31 Array_like means all those objects -- lists, nested lists, etc. -- 32 that can be converted to an array. 33 var2 : {integer} 34 Write out the full type 35 long_variable_name : {'hi', 'ho'}, optional 36 Choices in brackets, default first when optional. 37 38 *Returns*: 39 40 named : {type} 41 Explanation 42 list 43 Explanation 44 of 45 Explanation 46 outputs 47 even more explaining 48 49 *Other Parameters*: 50 51 only_seldom_used_keywords : type 52 Explanation 53 common_parametrs_listed_above : type 54 Explanation 55 56 *See Also*: 57 58 `otherfunc` : relationship (optional) 59 60 `newfunc` : relationship (optional) 61 62 *Notes* 63 64 Notes about the implementation algorithm (if needed). 65 66 This can have multiple paragraphs as can all sections. 67 68 *Examples* 69 70 examples in doctest format 71 72 >>> a=[1,2,3] 73 >>> [x + 3 for x in a] 74 [4, 5, 6] 75 76 """ 77 78 pass
79 80
81 -def newfunc() :
82 """Do nothing. 83 84 I never saw a purple cow. 85 86 """ 87 88 pass
89 90
91 -def otherfunc() :
92 """Do nothing. 93 94 I never hope to see one. 95 96 """ 97 98 pass
99