Al Sweigart's tumblr

Short blog posts on my random ideas and thoughts.

Feb 25

A poem

I love my kitty,

My kitty loves me,

Together we’re so happy,

And always carefree.

Though my head has suspicions,

That I keep under my hat,

Of what might happen,

If I shrank to the size of a rat.

Yeah. 

I’m pretty sure my cat would eat me.


Aug 16

Suggestions for programming book title?

Aside from the encryption book, I’m also working on another programming book for young adults that features graphical games made in Python with the Pygame library. It’s aimed at an intermediate audience (basically a sequel of the first book) so the more basic programming concepts aren’t explained. It’s mostly the source code for 11 different games (about 200 to 500 lines of code each), and explaining more higher level programming & game design concepts.

I’d like to come up with a title that:

* Has the words Python and Pygame in it.

* Emphasizes the “making video games” aspect.

So far I have the following:

“11 Game Projects with Python & Pygame”

“Making Games with Python & Pygame”

Any other suggestions?


May 31

“Become a Code Breaker with Python” Outline

I’m writing a new book that teaches programming (in Python) to kids and adult beginners. The programs it covers are all cryptography and code breaking programs rather than games. Here’s the outline:

  • Chapter 1 – How Encryption Works: Making a Cipher Wheel
  • Chapter 2 – Downloading and Installing Python
  • Chapter 3 – The Interactive Shell
  • Chapter 4 – Strings
  • Chapter 5 – Functions
  • Chapter 6 – The Caesar Cipher
  • Chapter 7 – Breaking the Caesar Cipher with the Brute Force Technique
  • Chapter 8 – Designing Programs with Flow Charts
  • Chapter 9 – Using the Debugger
  • Chapter 10 - The Transpositional Cipher
  • Chapter 11 - Symbols, Encodings, and Data
  • Chapter 12 – Detecting English Programmatically
  • Chapter 13 - Breaking the Transpositional Cipher
  • Chapter 14 - The Simple Substitution Cipher
  • Chapter 15 - Breaking the Simple Substitution Cipher
  • Chapter 16 – A Simple Substitution Cracker Tool
  • Chapter 17 - The Vigenere Cipher
  • Chapter 18 - Frequency Analysis
  • Chapter 19 - Breaking the Vigenere Cipher

Here’s the source code for the programs (except for the Vigenere breaker, I haven’t completed it yet.) http://inventwithpython.com/codebreaker_src.zip


Mar 31

Glob Annoyance

This is something I noticed with the Windows dir command. If you have a file called “foobar” and type “dir foo?ar” it will find the file. The question mark wildcard will correctly mean “any character match”.

The question mark is like the regular expression syntax’s period, where it can stand for one (and only one) character. It isn’t optional. So if you type “dir foo?bar” then the “foobar” file will not be found.

However, this is not the case if the question mark goes at the end of the filename. If you type “dir foobar?” then the “foobar” file is found.

So, the question mark really means, “One and only one character unless it is at the end in which case zero or one characters.”

ಠ_ಠ


Mar 21

Command line idea: “up”

I had an idea for a piece of software that would be useful to have on the command line. Several times I’ve wanted to jump up several directories from my current working directory, for example: from C:\mgmt\framework\src\lib\python\scripts to C:\mgmt\framework\src

Ordinarily, this would require using “cd ../../..” but that’s a lot to type out. I’d rather just type “up 3”. So I’ve also come up with some other shortcuts that this “up” command could have:

> up

This would be the equivalent of “cd ..”

> up 3

This would be the equivalent of “cd ../../..”

> up bin

This would keep jumping up directories until it found a directory that had a directory named “bin” (or started with “bin”) in it. For example, from c:\foo\bar\bazz to c:\foo\bin. (Or possibly, from c:\zap\blam\foo to c:\zap\binaries)

If there was some ambiguity as to which directory to go in, then it would go into the directory named exactly “bin”. Otherwise, it would display the multiple directory names (just like tab completion does.)

> up bin\lib

This would do the same jumping up until it found a directory named (or began with) “bin”, but furthermore had a directory named (or began with) lib inside of it.

> up 2 bin

This would jump up two directories before starting to look for a directory named (or beginning with) “bin”. For example, if you were in c:\foo\bar\fizz and there was a c:\bin and a c:\foo\bin, it would go to c:\bin. (However, just “up bin” would have resulted in changing directories to c:\foo\bin)

> up bin*ies?

In this case, the command can use the standard * and ? glob pattern matching.

What do you think? Does a command like this already exist? It would be fairly simple to create portable ANSI C code that does this. Would this command even be useful?