[Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?
Steven D'Aprano
steve at pearwood.info
Thu May 23 19:59:39 EDT 2019
On Thu, May 23, 2019 at 06:23:31PM +0200, Yanghao Hua wrote:
> Is this (<== and ==>) something can be made into CPython?
If it goes into CPython, eventually every other Python needs to do the
same.
Of course it *could* be put into Python, but you haven't given
sufficient justification for why it *should* be put into Python.
Why does your DSL need a seperate assignment operator? How is it
different from regular assignment?
Could you use __setitem__ instead?
Instead of this:
variable <== thing # magic happens here
can you write this?
obj.variable = thing # magic happens here
If your DSL is so different from Python that it needs new operators,
perhaps you should write an interpreter for your language and run that
seperately.
code = """
any syntax you like <- thing
"""
result = interpret(code)
--
Steven
More information about the Python-ideas
mailing list