Pythonにモジュールをサブフォルダーにインポートさせることができないようです。インポートされたモジュールからクラスのインスタンスを作成しようとするとエラーが発生しますが、インポート自体は成功します。これが私のディレクトリ構造です:
Server
-server.py
-Models
--user.py
server.pyの内容は次のとおりです。
from sys import path
from os import getcwd
path.append(getcwd() + "\\models") #Yes, i'm on windows
print path
import user
u=user.User() #error on this line
そしてuser.py:
class User(Entity):
using_options(tablename='users')
username = Field(String(15))
password = Field(String(64))
email = Field(String(50))
status = Field(Integer)
created = Field(DateTime)
エラーは次のとおりです:AttributeError: 'module' object has no attribute 'User'