Source code for sdss_install.main

# encoding: utf-8
#
# @Author: José Sánchez-Gallego
# @Date: Oct 12, 2017
# @Filename: main.py
# @License: BSD 3-Clause
# @Copyright: José Sánchez-Gallego


from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals

import operator


__all__ = ('math', 'MyClass')


[docs]def math(arg1, arg2, arith_operator='+'): """Performs an arithmetic operation. This function accepts to numbers and performs an arithmetic operation with them. The arithmetic operation can be passed as a string. By default, the addition operator is assumed. Parameters: arg1,arg2 (float): The numbers that we will sub/subtract/multiply/divide. arith_operator ({'+', '-', '*', '/'}): A string indicating the arithmetic operation to perform. Returns: result (float): The result of the arithmetic operation. Example: >>> math(2, 2, arith_operator='*') >>> 4 """ str_to_operator = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv} return str_to_operator[arith_operator](arg1, arg2)
[docs]class MyClass(object): """A description of the class. The top docstring in a class describes the class in general, and the parameters to be passed to the class ``__init__``. Parameters: arg1 (float): The first argument. arg2 (int): The second argument. kwarg1 (str): A keyword argument. Attributes: name (str): A description of what names gives acces to. """ def __init__(self, arg1, arg2, kwarg1='a'): self.name = arg1
[docs] def do_something(self): """A description of what this method does.""" pass
[docs] def do_something_else(self, param): """A description of what this method does. If the class only has one or two arguments, you can describe them inline. ``param`` is the parameter that we use to do something else. """ pass