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.