Let me share a secret.
I do not like Python.
It is not a programmer's programming language.
It is a getting-things-done language.
60's Brutalist architecture in Moscow in the 90's.
It is not just ugly, the heating doesn't work.
Oh, and Winter is on the way.
As with every unfashionable city quarter, we can some interesting artsy things without paying too much in rent.
But before we get started, let's setup our workspace.
Install the Python programming language on your system.
Google the previous sentence for instructions.
Second let's create and run a Python script.
Create a text file called
Open it in a text editor and type,
a = lambda: 42
The 'i' stands for interactive. We will split our time between the iPython interactive shell and the text editor.
cd to the appropriate directory on your command line and run
Assuming our iPython shell started in the same directory as our
foo.py file, we can import it
import foo as f
here we have given foo the alias
Let's test our code.
In (1): f.a()
When we tweak our code, it's best if iPython refreshes automatically, rather than running the import manually.
Find the iPython configuration file.
On my Linux machine it is located here:
Search for these variables and set up 'autoreload'
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
c.InteractiveShellApp.extensions = [ 'autoreload' ]
foo.py again. Try
f.a() change it to 43 and call
f.a() again, it should show
What have we done?
We have created a 'lambda' function or 'mathematical' function, if you prefer, set it to 42 and named it 'a'.
We have begin to use Python's flavour of Lambda calculus.
If you are used to Python, Lambdas are terribly frustrating, because as a Python programmer you are undisciplined.
Lambdas are a lot of things, but most importantly, during our katas they will help us remain disciplined.