Namespaces are one honking great idea
carlosjosepita at gmail.com
carlosjosepita at gmail.com
Sat Jul 9 10:05:28 EDT 2016
Hi all,
although it doesn't fit the bill 100%, I sometimes use this extremely simple function as a decorator:
def new(call):
return call()
For example:
@new
class MySingleton:
x = 2
y = 2
def sum(self, x, y):
return x + y
@new
def my_obj():
x = 2
y = 2
def sum(x, y):
return x + y
return Bundle(locals())
where Bundle is a simple subclass of dict implementing __xxxattr__ dunder methods.
Cheers
--
Carlos
More information about the Python-list
mailing list