pythonscripting-language

Proposal for python syntax - what would go into implemention?


I would like to use certain keywords and unary/binary operators as functions. For example:

_not = lambda a: not a
_plus = lambda a, b: a + b
_or = lambda a, b: a | b

I think there is an opportunity for a simpler syntax, which would look nicer in some functional settings:

_not = (not)
_plus = (+)
_or = (|)

The expressions on the right hand side are invalid anyway, so why not have them be those functions. I think it would also be nice to an identity lambda, maybe (:), as in (:) = lambda x: x.

So to make a question out of this: what would it take, broadly speaking, to implement these changes on my local installation of python and/or why is this a terrible idea?

Cheers


Solution

  • What you are trying to do here is to override the built in scope, enter image description here

    If you are really interested by following through with your question I think you should check functional programming langues like LISP, or try having a look at a python module called textX with which you can create your own language however you wanted to be like and then test if the idea is as good as you might think it is.