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


 
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to