[Tutor] Project tree

Wiktor Matuszewski pywkm at wukaem.pl
Mon Nov 10 19:20:53 CET 2014

let's assume I have this project tree:

  |  |- __init__.py
  |  |- moda.py
  |  '- modb.py
  '- start.py

And individual files contain:

----- modb.py: -----
def hello(txt):
     return "Hello " + txt + "!"

def plus1(num):
     return num + 1

----- moda.py: -----
import modb

def hello_world():
     return modb.hello("World")

----- start.py: -----
from src import moda, modb


__init__.py is empty

(it's project for my purpose - I don't want to distribute it with pypi, 
I pulled out start.py form src folder to just run everything without 
opening src folder)

Ok, so now executing start.py works in Python 2.7(*), but doesn't work 
in Python 3.4(**). Can someone, please, explain me why? What changed 
between 2.x and 3.x versions?

*) - gives output:
Hello World!

**) - gives error message:
Traceback (most recent call last):
   File "E:\tests\project_name\start.py", line 1, in <module>
     from src import moda
   File "E:\tests\project_name\src\moda.py", line 1, in <module>
     import modb
ImportError: No module named 'modb'

Best regards,
Wiktor Matuszewski

More information about the Tutor mailing list