top | item 4404984

(no title)

erikrose | 13 years ago

Deferring the setup is first a matter of politeness, an artifact of my opinion that importing a module shouldn't have (possibly surprising) side effects on the environment.

As for hanging everything off the Terminal instance, the motivation is that there's significant state on it that you might want to customize. Things like type (ANSI, vt100, etc.) and whether to suppress or force styling affect the result of formatting methods. See http://packages.python.org/blessings/#blessings.Terminal.__i.... I've several times benefitted by making a formatting-suppressed Terminal and passing it around.

I fully endorse you saying...

    term = Terminal()
...at the top level of some module and referencing it there. Then you get the init-on-import behavior you want, but it's not forced on anybody who'd rather not have it.

Cheers!

discuss

order

ciupicri|13 years ago

Or as The Zen of Pythons says, explicit is better than implicit. Thanks for clearing things up for me.