I would like to use let instead of def.
I am looking for sane way of changing syntax of own code in this way.
basically in c it would be
#define let def
How to make the same in python?
I would like to use let instead of def.
I am looking for sane way of changing syntax of own code in this way.
basically in c it would be
#define let def
How to make the same in python?
def
is a keyword in python, so it can't be changed to anything else.
From the docs:
The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:
and del from not while as elif
global or with assert else if pass yield
break except import print class exec in
raise continue finally is return def for lambda
try
#define let def
That would work in C because it is a pre-processor command. Here you are not tricking C, you are tricking the person reading your code.
To achieve the same in Python you need a pre-processor. Like C, you would not be tricking Python you would only be tricking the reader.
So you could write a preprocessor that would be used to launch your program. Like C, you would produce an intermediate file which the "real" python compiler would then use.
I'm not alone in thinking this is not a good idea. This is a support nightmare. You have this preference, but what about everyone who comes after you? How could anyone else maintain this code if you start messing with keywords?