2010/05/08 10:20: Started the Python tutorial. It's nice that you don't need to install anything extra. Hello world is simple but there are no parentheses. Interesting.
2010/05/08 11:00: And no braces either. Everything is whitespace. It's easy to do the examples from the book, but once I try to do something myself it goes wrong.
2010/05/08 12:00: Strings don't have a length property! Well, I'll write a function to get the length. That should be fairly basic.
2010/05/08 13:00: Loops are confusing in Python, since you can only loop through a sequence. But it seems strings are sequences. My length() function works!
[note: function was:
def length(string):
a = 0;
for i in string:
a = a + 1;
return a;]2010/05/08 13:15: I miswrote it as len(a) instead of length(a) and it still worked! Does Python automatically correct things?
2010/05/08 13:20: Damn. len() is a built-in function, which does the same thing as mine does. I didn't need to write that after all.
2010/05/08 17:00: Wrote a simple calculator which can handle big numbers (more than 14 digits).
2010/05/08 17:30: And it seems that Python's math can do this too. Much faster than mine. I asked it for 2**1,000,000 and it calculated it in about ten seconds! I've got to google things before I do them in Python, chances are it's there already.
2010/05/08 18:00: That's it! I'll write a Python program that googles something!
2010/05/08 19:00: Why can't I add a number to a string?
2010/05/08 19:30: Sooo...Python is an interpreted language but it's picky about type.
2010/05/08 20:00: urllib2 is surprisingly easy to parse. The HTML page that Google returns, however, is not. Something about '</scr'+'ipt>' in the JavaScript. I'll give this one another try tomorrow.
No comments:
Post a Comment