Usage of main()

Ben Finney ben+python at
Fri Sep 4 14:55:55 CEST 2009

"Jan Kaliszewski" <zuo at> writes:

> I understand you name global scope as 'main'. But (independently of
> using the __main__ idiom and so on) it is still good idea not to place
> to much code in the global scope but to place your app-logic code in
> functions -- because, as we noted:
> * in practice it is considerably faster,
> * it helps you with using functions & class browsers.

* having a module that can be imported without side effects helps select
  pieces of the module's functionality

* any module should be importable without side effects to make it easier
  to run unit tests for that module

 \        “The number of UNIX installations has grown to 10, with more |
  `\         expected.” —Unix Programmer's Manual, 2nd Ed., 1972-06-12 |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list