(Excerpted from my forthcoming book Learn to Program Humans with Python, not to be confused with the 1978 Lawrence Block and Robert Silverberg classic Learn to Program Humans with Pythons, which is a very different sort of book.)
As a beginning human programmer, it's important to start simple. In most languages, we start with a program called "Hello World," but your prototype human will not be capable of running that program until you've done some basic installation and training, and let it run for several months. Human programming is not for the impatient!
Instead we start with a very simple, single conditional:
if this.is_boob():
grab(this)
This isn't just the basic program for humans, it's the basic program for all mammals. Remember this if you acquire a prototype rhinoceros, muskrat, or polar bear! If your human does not learn this it will likely fail to progress far enough to run more complex programs.
While you may have to run this program manually a few times until the human gains abilities, before long you will be able to introduce the concept of loops. Most managers of prototype humans attempt this simple "for"-style loop:
for boob in mom:
grab(boob)
However, prototype humans have a tendency to develop emergent properties, and the end program often looks more like:
for boob in any_woman_available:
grab(boob)
or even
for boob in any_woman_available:
grab(boob)
else:
grab(manboob)
Truly precocious prototype humans will progress beyond "for" loops into the "while 1" loop used to keep a program running at all times, and implement:
while 1:
if this.is_boob():
grab(this)
This is a particularly dangerous program, especially as it may persist into adulthood. If it does, your prototype human is at risk of being committed to the git repository and spending the rest of his life doing pull requests. Thus it's important to break him of this habit early, by liberal disciplinary usage of the "break" statement to end the loop.
while 1:
if this.is_boob():
grab(this)
if this.is_not_yours():
break
As your prototype human matures, you'll begin to use Python libraries to train it, and one of the most important libraries is the "consent" library.
from consent import explicit_permission
while 1:
if this.is_boob():
if explicit_permission(this):
grab(this)
else:
continue
while 1:
if this.is_butt():
if location == "state fair":
grab(this)
This production human naturally had to be taken off-line immediately. Don't let this happen to your production human! Keep your consent library updated!
Error checking is also mandatory, especially when you are preparing to remove your access permissions from your prototype human and allow it into production. Python error checking is done with a "try-except" structure:
while 1:
try:
if this.is_boob():
grab(this)
except:
print insincere_apology
continue
The above is the most common error-checking routine in current production humans, but is now generally considered poor programming practice, and has been deprecated in favor of the consent library. However, even with the consent library corruption can occur:
while 1:
if anyone.is_looking():
get_consent()
else:
grab(boob)
Therefore, error checking is still appropriate:
while 1:
try:
get_consent()
grab(boob)
except:
print gracious_acceptance_of_no
break
Always stick to good programming practices, lest your human end up here: in the Git Repository.
By © User:Colin / Wikimedia Commons, CC BY-SA 4.0, Link
Please pre-order the book if you would like to read the rest of the chapter, about Ball Python.