> If there was some way to make
> @syms x, y
> translate to x, y = syms('x, y') or something like that then that
> would be great. Maybe that doesn't have broad enough use for Python
> the language but I would certainly add something like that if I was
> providing a SymPy UI based on a modified form of Python (e.g. like
> SageMath).
>
>
This actually seems like it would be very helpful to use for some factory
functions as well. If @ could be made to work on variable assignment
similar to how it does on function definition then the following would be
possible and make code a bit more DRY:
# currently: LunchBox = namedtuple("LunchBox", "spam eggs")
@namedtuple("spam", "eggs") LunchBox
LunchBox(eggs=2, spam=4)
# LunchBox(spam=4, eggs=2)
# currently T = TypeVar("T")
@TypeVar T
The variable decorator would be in full control, just like function
decorators so I'm sure some even nicer abstractions could be
created. Perhaps instead of turning
UserID = NewType("UserID", int)
into
@NewType(int) UserID
it could be
@NewType UserID: int
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/4EJVSLXUYEEZU4IF6DMUAPOR6RJ53DST/
Code of Conduct: http://python.org/psf/codeofconduct/