Skip to content
Advertisement

Run function from the command line

I have this code:

JavaScript

How would I run this directly from the command line?

Advertisement

Answer

With the -c (command) argument (assuming your file is named foo.py):

JavaScript

Alternatively, if you don’t care about namespace pollution:

JavaScript

And the middle ground:

JavaScript
Advertisement