File/module structure in Python

Posted by keithjgrant on Stack Overflow See other posts from Stack Overflow or by keithjgrant
Published on 2011-01-13T18:49:22Z Indexed on 2011/01/13 18:53 UTC
Read the original article Hit count: 179

Filed under:
|
|

So I'm just getting started with Python, and currently working my way through diveintopython.org. The code examples are nice, but the vast majority of them are little four-line snippets, and I want to see a little more of the big picture.

As I understand it--and correct me if I'm wrong--each '.py' file becomes a "module", and a group of modules in a directory becomes a "package" (at least, it does if I create a __init__.py file in that directory). What is it if I don't have a __init__.py file?

So what does each "module" file look like? Do I generally define only one class in the file? Does anything else go in that file besides the class definition and maybe a handful of import commands?

© Stack Overflow or respective owner

Related posts about python

Related posts about module