On 05/09/2017 03:14 PM, John H Palmieri wrote: > Sage's developer's guide says: "Every function must have a docstring" > which must include "An EXAMPLES block for examples. This is not > optional." What is meant by "function"? Here is an example, taken from > ticket #21399: > > | > importsys > > ifsys.platform ==X: > defauxiliary_function(...): > ... > elifsys.platform ==Y: > defauxiliary_function(...): > ... > else: > defauxiliary_function(...): > ... > > defmain_function(...): > returnauxiliary_function(...) > | > > What needs a docstring here? What needs doctests? >
You can write this in a way that lets you doctest everything... def auxiliary_function_X: ... def auxiliary_function_Y: ... def auxiliary_function_default: ... def main_function(platform = None): if platform is None: platform = sys.platform if platform == X: return auxiliary_function_X() elif platform == Y: return auxiliary_function_Y() else: return auxiliary_function_default() Now you can test/comment both the auxiliary functions and the main function easily. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.