Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. testapp/
  2. ├── __init__.py
  3. ├── api
  4. │   ├── __init__.py
  5. │   └── utils.py
  6. └── utils.py
  7.  
  8. from testapp import utils
  9.  
  10. print "a", utils
  11.  
  12. from testapp.api.utils import x
  13.  
  14. print "b", utils
  15.  
  16. x = 1
  17.  
  18. $ export PYTHONPATH=$PYTHONPATH:.
  19. $ python -c "import testapp.api"
  20. a <module 'testapp.utils' from 'testapp/utils.pyc'>
  21. b <module 'testapp.api.utils' from 'testapp/api/utils.pyc'>
  22.  
  23. >>> from os.path import abspath
  24. >>> path
  25. Traceback (most recent call last):
  26. File "<stdin>", line 1, in <module>
  27. NameError: name 'path' is not defined
  28.  
  29. spam/
  30. __init__.py
  31. foo.py
  32. bar.py
  33.  
  34. from .foo import Foo
  35. from .bar import Bar
  36.  
  37. >>> import spam
  38. >>> spam.foo
  39. <module 'spam.foo' from '/tmp/imports/spam/foo.py'>
  40. >>> spam.bar
  41. <module 'spam.bar' from '/tmp/imports/spam/bar.py'>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement