On 08/29/2012 11:43 AM, Aaron Gallagher wrote:
So, if you're going to put code in __init__.py, make it imports and not
definitions.

That's a good rule of thumb, but even imports in this scenario can get clobbered if the names collide. For example:

test.py
--------

import foo
foo.print_stuff() # Outputs: <built-in function log>
import foo.log
foo.print_stuff() # <module 'foo.log' from '.../foo/log.py'>


foo/__init__.py
---------------

from math import log

def print_stuff():
    print log


foo/log.py
----------

def log_stuff():
    pass

Reply via email to