[Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

Ricky Teachey ricky at teachey.org
Wed May 29 10:51:02 EDT 2019


 Another approach is to abandon the idea of HDL namespace parent class, and
just create a HDL (or hdl) decorator:

@hdl  # decorator adds a custom __setattr__
class C: ...

The decorator would modify the __setatrr__ method of the class so that
members of the class have signal behavior. You could even write the
decorator so that you specify which attributes have signal behavior, and
the remainders don't:

@hdl(list('xyz'))
class C:
    def __init__(self, **kwargs):
        for k,v in kwargs.items():
            setattr(self, k, v)

c = C(x=1, a=2)  # x is a signal, a is not
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190529/a941cdc1/attachment.html>


More information about the Python-ideas mailing list