So the other day I thought it'd be a great idea to take a look at the earliest version of Python that I could find. After a few broken links and a lot of time screwing around with Google's webcache, I worked out that the oldest version I was going to (w)get my hands on was this: 0.9.1. Absolutely ISIS*-level hacking, I know.
*International Secret Intelligence Service, for any Archer fans out there.
Just quickly: my system is a Chromebook with Crouton installed. I'm running these commands in a browser tab using CrOSh (or however it's capitalised) to run an Ubuntu 14.04 chroot. My shell is Zsh, because I like the autocomplete more than Bash's default.
After downloading the
.tar.gz file, I unpacked it like so:
cd'd into the directory - yes, I know what 'cd' stands for - I spotted two README's: one looked like the original, and one was clearly a later addition.
Full disclosure: I didn't read either of them before I started building from source. Looking back, the README is a nice helpful note from Guido, and the README.reconstructed has some helpful info I probably should have read. Oh well!
Moving on: the Makefile in the
src directory is gigantic, and pretty unintelligible for the likes of me. I did like this part though: the default Python PATH includes
/ufs/guido/lib/python. Way to add a personal touch, Mr. BDFL!
So what are we waiting for - let's get on and build this thing!
make in the "src" directory.
It doesn't take long, but a whole host of warnings pop up: check out my build output if you're interested.
Most of them are about the C functions
realloc(): defined in
stdlib.h, these functions handle allocating memory, allocating it and then clearing it to zeroes, and reallocating it (respectively). There's "conflicting types", with what looks like an "extern ANY" redefinition. My C-fu isn't really strong enough to speculate as to the precise details of what's going wrong here, but luckily I don't need to: the build succeeds.
(Even if there is a dodgy looking
mv @python python at the end - I'll later discover that the README.reconstructed file mentions this too!)
There's now a "python" executable in my current directory. Let's see what it looks like, and open it up!
Notice that there's no version info, no compiler info, and definitely no friendly welcome message about typing "help" for more information.
So let's try some commands!
Uh, right, sure. I'm a spoiled Python 3.4 baby, let's get rid of those dirty parens.
Wait... what? Is it the exclamation point? The comma? They're both ASCII characters; I can't imagine they'd cause a problem...
So at least we know it hasn't actually regressed to the point where it can't print out ASCII chars.
I played around with this for a few more minutes before I worked it out: it's the quotes. Double quotes, for whatever reason, aren't legal in Python 0.9.1.
Praise the BDFL! I'd say this just about ties with AT&T-syntax assember for my Hardest Ever Hello World trophy (I mean, seriously? Percent signs? I know assembly isn't quite supposed to read like prose, but come on...).
Now let's get on with writing some real code. How about seeing what's currently in scope, to start off with?
Sure, of course
locals isn't, well, in the locals. But
dir() works, right?
Well, good news: there's no unhandled exceptions! I was getting tired of those, weren't you? Weren't you?
*ahem*. There's absolutely nothing locally scoped at the moment. Let's fix that:
Woo! We've got a name in the local namespace. That's a good place to break up the article; Ghost's markdown editor starts running a little slow for larger webpages.
Next installment coming soon to a blog near you!