ITメモ
Python / パイソン





Warning: file(./WebContents/Data/IT/OS_CentOS/Server_Ftp/List.html): failed to open stream: No such file or directory in /home/server-gena/www/Co/Renoji/WebContents/Function/Make_SiteMap.php on line 52

Warning: count(): Parameter must be an array or an object that implements Countable in /home/server-gena/www/Co/Renoji/WebContents/Function/Make_SiteMap.php on line 54

Warning: count(): Parameter must be an array or an object that implements Countable in /home/server-gena/www/Co/Renoji/WebContents/Function/Make_SiteMap.php on line 54

Warning: filemtime(): stat failed for ./WebContents/Data/IT/OS_CentOS/Server_Ftp/List.html in /home/server-gena/www/Co/Renoji/WebContents/Function/Make_SiteMap.php on line 106

【Python】パッケージとモジュール

【Python】
パッケージとモジュール




モジュール(module)


「Python」は、スクリプトファイルを「import」で読み込んでモジュールとして利用することができる。
読み込んだモジュールの「クラス」「関数」「変数」などは、「モジュール名.識別子」で参照可能。



パッケージ(package)


複数の「モジュール」を、まとめて「パッケージ」いう。
「パッケージ」は、フォルダで管理され、必ず「__init__.py」ファイルを置かなければならない。
パッケージのフォルダ内には、複数のモジュール「.py」 ファイルを持つことができる。
「__init__.py」には、パッケージの初期化処理を記述する。
初期化処理がなければ空でOK。
パッケージ内にパッケージがない方していてもOK。