abusing __builtins__

Vassilis Virvilis vasvir at iit.demokritos.gr
Sat Feb 24 06:54:56 CET 2001


In python 1.5.2 (and possible to any future python) is possible to set a
global variable shared by all modules simply by doing:

setattr(__builtins__, 'GlobalVariable', GlobalVariable)

without the need to import anything.

Not being an experienced python programmer I would like ot hear some
arguments on whether this is considered abuse of the language or not.
Should it be avoided?  Are there any hidden pitfalls? except from the
obvious one that I should not have global variables in the first place.

Thanks in advance...
	.Bill



More information about the Python-list mailing list