Eight days have passed since we’ve had hot water. I signed a work order last Wednesday but TransGlobe says they received it this past Monday. Those two dates are “a world apart” (I love making fun of that slogan of their’s). TransGlobe says that a maintenance person probably won’t be able to take a look at our water heater until the end of this week or beginning of next week. I definitely think it’s time Dena and I starting looking for a house. Renting and sharing walls with others has become tiresome after nine years (5 years in university and 4 years in this apartment).
On a lighter note, here’s another chronicle of my love affair with Python. I’m a crazy looping fool. Most of the work I do during the day involves writing parsers. Be it parsing text or CNC code, I’m a parsing fool with parsing on my mind and I eat sleep and dream loops. I have a love/hate relationship with FOR loops; functional but they’re ever so constrictive. “Do this this many times and then stop. Good boy”. In every C-like language, FOR loops look like this:
String[] arrTPB = {"Ricky", "Bubbles", "Julian", "Corey", "Trevor"};
for (int i = 0; i < arrTPB.length; i++)
{
System.out.print(arrTPB[i] + "\n");
}
That was Java, but it would look similar in C, C++, C#, JavaScript, PHP, Perl, etc. Ok, I'll tighten it up a smidge since there's only one line of instruction in this FOR loop:
String[] arrTPB = {"Ricky", "Bubbles", "Julian", "Corey", "Trevor"}; for (int i = 0; i < arrTPB.length; i++) System.out.print(arrTPB[i] + "\n"); |
How about Visual Basic? That’s not C-like:
Dim i As Integer Dim arrTPB() As String ' Chris' cheesy work-around to quickly init VB6 string arrays arrTPB() = Split("Ricky~Bubbles~Julian~Corey~Trevor", "~") For i = 0 To UBound(arrTPB) MsgBox (arrTPB(i)) Next |
Still nasty. Now be in awe at the utter smoothness of Python:
arrTPB = ['Ricky', 'Bubbles', 'Julian', 'Corey', 'Trevor'] print "\n".join(arrTPB) |
The join() function concatenates elements together with a delimiter (I used a newline character in this case). I didn’t even need a FOR loop to display all of the elements. How kewl is that? 🙂 If I wanted to, I could use a FOR loop in Python:
arrTPB = ['Ricky', 'Bubbles', 'Julian', 'Corey', 'Trevor'] for strBoy in arrTPB: print strBoy |
But I didn’t have to 🙂 I’m still undecided about how classes in Python are used, but I’ll save that for another time…perhaps after a hot shower 😉