Why does get_name_by_addr return '' and org_by_addr return None?
<p>I am currently testing one of my classes which sets variables with the help of pygeoip.</p>

<p><code>org_by_addr</code> returns <code>None</code> when there is nothing found in the database:</p>

<pre><code>seek_org = self._seek_country(ipnum)
if seek_org == self._databaseSegments:
    return None
</code></pre>

<p>While the <code>country_name_by_addr</code> function returns an empty string. </p>

<p>This forces me to check if the return is <code>None</code> and then setting it to <code>''</code> to have the variables uniformly.</p>

<p>Does anybody know, what the reason is to give different returns when there is no entry in the database? </p>

<p>Other than the obvious "variable uniformity", what is the point of changing the NoneType to an empty string? There is a reason why </p>

<pre><code>bool ('') == bool (None) == False
</code></pre>

<p>In my opinion this is a stylistic difference. However, when a package has different return types like this, it can hint several things:</p>

<p>-if the function returns None, you can probably guess that the function would return an instanced object if a match was found in the database.
-if instead of returning None, the function returns an empty string, you can at least expect the output of that function to return a valid string when an entry is found in the database.
-if the function returns 0 instead of None, you can probably guess that the function would return a number of some sort if an entry was found in the database</p>

<p>So really it's mostly about informing the user in some way about what a valid return type would be.</p>

<p>My final suggestion would be to do away with the traditional thought of "types" when using Python. By that I mean the C philosophy of typing. In python there is a reason that you can say:</p>

<pre><code>if result:
    #some code
</code></pre>

<p>And have it be valid across several different "types".</p>

python geoip maxmind