Python coding practice : Return None vs Return same datatype with empty value?
<p>Shall same datatypes be used to return from functions, or assign default values ? or None ? What is a better coding practice, and why ?</p>

<p>eg. Some pseudo  codes in python :</p>

<p>/1</p>

<pre><code>def my_position():   # returns a positive integer if found
    if(object is present):
          position = get_position()
          return position # eg 2,3,4,6
    else: 
          return None     # or return -1 or 0 ??
</code></pre>

<p>/2</p>

<pre><code>def get_database_rows():    
    do query to whatever database
    if(rows are found):
       return [list of rows]
    else:
       return None  # or return empty list []  ?
</code></pre>

<p>/3</p>

<pre><code>the_dictionary = {'a' : 'john','b':'mike','c': 'robert' }  # values are names i.e. non empty string
my_new_var = the_dictionary.get('z', None)  # or the_dictionary.get('z','')  ?
</code></pre>
