Ryan Ryan - 1 year ago 81
Python Question

Python namespaced class module directory layout

I want to create a

module which is namespaced
, and currently use the directory structure

example\__init__.py (Empty file)
example\user.py (Define the class `User`)

And in other file I import via

from example.user import User

It works, but I want to double check if it is the the Pythonic Way to do it.

Answer Source


Your approach is good and 100% Pythonic. Just make sure that you have proper comments in the modules you make.

You can refer this link for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download