Reuse of existing module name



examples/pitfalls/random.py

import random

print(random.random())
$ python examples/pitfalls/random.py

Traceback (most recent call last):
  File "examples/pitfalls/random.py", line 1, in <module>
    import random
  File ".../examples/pitfalls/random.py", line 3, in <module>
    print(random.random())
TypeError: 'module' object is not callable


  • Write an example to use random number and call your example number.py
  • Same with any other module name.
  • Lack of multi-level namespaces
  • Solution: user longer names. Maybe with project specific names.