I mean everything in python is a function. I'm not positive what you mean by JavaScript's function construct. But.
In python you can effectively make classes by just embedding function definitions.
You can generate functions programmatically by just modifying the global namespace (it's gross but you can do it, so use only when needed). You can get funky JavaScript like function definitions
Such as:
const sum = new Function('a', 'b', 'return a + b');
by using eval though you shouldn't, because that's gross even in JavaScript and evalis generally a bad idea.
The concept of what Eval does has been around for 50 years or more. E.g. the mainframe language Rexx had an Eval statement. For me, I wouldn't ever say eval is a bad idea as ultimately it's a pseudo run time compiler transforming strings into executable statements. This ability in the right hands is really powerful.
There are rare problems where use of Eval like constructs are true lifesavers.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes but it's function construct is a true first class citizen. Does python have that?
I mean everything in python is a function. I'm not positive what you mean by JavaScript's function construct. But.
In python you can effectively make classes by just embedding function definitions.
You can generate functions programmatically by just modifying the global namespace (it's gross but you can do it, so use only when needed). You can get funky JavaScript like function definitions
Such as:
const sum = new Function('a', 'b', 'return a + b');
by using
eval
though you shouldn't, because that's gross even in JavaScript andeval
is generally a bad idea.Nice.
The concept of what Eval does has been around for 50 years or more. E.g. the mainframe language Rexx had an Eval statement. For me, I wouldn't ever say eval is a bad idea as ultimately it's a pseudo run time compiler transforming strings into executable statements. This ability in the right hands is really powerful.
There are rare problems where use of Eval like constructs are true lifesavers.