Try it here
Subscribe
Documentation interlude

Docstring in Python

docstring_in_python

A docstring is a unique text that happens to be the first statement in the following Python constructs:

Module, Function, Class, or Method definition.

A docstring gets added to the __doc__ attribute of the string object.

This Documentation(docstring is accessible by __doc__ within the module or help() function outside the module.

There should be only one Documentation of an object and should be written before any executable statement.

Example :

>>> import oracle_to_python.nulls
>>> help(oracle_to_python.nulls)
Help on module oracle_to_python.nulls in oracle_to_python:

NAME
    oracle_to_python.nulls

FUNCTIONS
    coalesce(list_of_values)
        The coalesce function returns the first non-None or none-blank or non-false value in list.
        If all expressions are None it returns None. The following would return '5'.
        
        coalesce([None, None, '5'])
    
    nullif(value1, value2)
        The nullif function returns a None value if both parameters are equal in value.
        If the parameters are not equal, it returns the value of the first parameter.
        
        nullif(1,1) will retun None and
        
        nullif(1,2) will return 1
    
    nvl(value, replace_if_value_is_null)
        nvl function Converts NULL value to actual value.
        
        nvl(None,5) will return 5
    
    nvl2(expr1, value_if_expr1_not_null, value_if_expr1_null)
        If expr1 is not None, nvl2 returns expr2. If expr1 is None, nvl2 returns expr3
        
        nvl2(None,5,7) will return 7 and
        
        nvl2('dEexams',5,7) will return 5

Writer profile pic

Anmol on Jun 21, 2020 at 12:04 am


This article is contributed by Anmol. If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.



Post Comment

Comments( 0)

WEB TECHNOLOGY

Articles

×

Forgot Password

Please enter your email address below and we will send you information to change your password.