On 5/24/21 6:36 PM, micro codery wrote:

> Variable decorators have been suggested here before, as have new statements
> that could also achieve the same level of access to the binding name. However
> I propose a much more restricted syntax that would make for less edge cases
> where what is actually passed to the decorator callable may be ambiguous.

> #instead of GREEN = "GREEN"
> @str GREEN

> #instead of Point = namedtuple("Point", "x y z")
> @namedtuple("x y z") Point

> #instead of Point = make_dataclass("Point", [("x", int), ("y", int), ("z", 
int)])
> @make_dataclass([("x", int), ("y", int), ("z", int)]) Point

> #instead of Colors = Enum("Colors", "RED GREEN BLUE")
> @Enum("RED GREEN BLUE") Colors

> class Colors(Enum):
>      @str RED
>      @str GREEN
>      @str BLUE

> #instead of UUIDType = NewType("UUIDType", str)
> @NewType UUIDType: str

I think that looks very interesting.

--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CFFC2TCFTGCR3BY6U5JY5KHB6QB46U6P/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to