[New-bugs-announce] [issue9872] `a.b.my_function is not b.my_function` when `a` and `b` are both on `sys.path`

Ram Rachum report at bugs.python.org
Thu Sep 16 14:28:13 CEST 2010


New submission from Ram Rachum <cool-rr at cool-rr.com>:

Let's say you have this structure:

a\
  __init__.py
  b\
    __init__.py

In `b.__init__` a function called `my_function` is defined.

And assume that `a` and `b` are both on `sys.path`. Then this situation happens:

    >>> import a.b
    >>> import b
    >>> a.b.my_function is b.my_function
    False
    >>> a.b.my_function
    <function my_function at 0x00BC70C0>
    >>> b.my_function
    <function my_function at 0x00BC7108>
    >>> a.b.my_function.__module__
    'a.b'
    >>> b.my_function.__module__
    'b'

It seems that `a.b.my_function` and `b.my_function` are different objects.

----------
messages: 116536
nosy: cool-RR
priority: normal
severity: normal
status: open
title: `a.b.my_function is not b.my_function` when `a` and `b` are both on `sys.path`
type: behavior
versions: Python 2.6, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9872>
_______________________________________


More information about the New-bugs-announce mailing list