eduardo simioni

Tag: packages

Python, modules and static objects

by on Jan.17, 2014, under python, Uncategorized

There’s this little caveat about python I recently learned that would have helped me understand some of its concepts much more clearly if I was told this earlier on:

A module is a static object.

That means, and please someone correct me if I’m wrong, but maybe with the exception of global variables (which you should avoid anyway), you can treat a module as a static object. So instead of creating a static class for some tool functions you can just group all those functions into a separate .py.

One of the best things in python is how easy and robust is to work with modules, do take your time to get to know how they work. It will help tons to organize your tools and re-use code.

Another thing to remember: __init__.py is used by the python interpreter to treat directories as packages. And a must read literature on the subject is Python documentation on Modules.

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!