Robert Kern wrote: > Paolino wrote: > >>While it's not so bad we can bind names in the module namespace, (ex >>writing scripts ?) ,writing modules is someway bound to not polluting >>that namespace (really IMO). > > > I'm afraid that I can't parse that sentence.
I show you a piece of code I need to define a function: import string all=string.maketrans('','') badcars=all.translate(all,string.letters+string.digits) table=string.maketrans(badcars,'_'*len(badcars)) def translate(text): return text.translate(table) What I'm needing as a global (in globals() or at the module level or in the module namespace) is 'translate'.The rest of bindings (all,badcars and table) is something which is 'polluting' the module namespace. Now this is the non polluting version : class translate: import string all=string.maketrans('','') badcars=all.translate(all,string.letters+string.digits) @staticmethod def __call__(text,table=string.maketrans(badcars,'_'*len(badcars))): return text.translate(table) translate=translate() I'd like to have some help from the language in binding names this way. Hope I've been clearer :) Paolino ___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it -- http://mail.python.org/mailman/listinfo/python-list