However I've learned Python several times now, used it for whatever project I've needed it for, and then mostly forgotten most of what I knew about it afterwards. But with the release of Google's App Engine however, I think it's time to dust my Python off and pick it up again for a third time. Which is why I'm sitting in "Python in 3 Hours" given by Steve Holden. Steve has put his slides online, but it looks like his hosting provider isn't holding up that well...
Update: The main principle in Python is "Keep it simple stupid", as opposed to Perl's "There is more than one way to do things". That basically sums up the difference between the two languages. It looks like Twitter is over capacity again, the fail whale is very much in evidence.
Update: One of the things that people coming from the C world find difficult is that while Python is a strongly typed language the type is associated with the value, not with the variable. Well that and the mandatory indenting.
Steve is really emphasising the presence of the interactive interpreter, which is something that Python talk about a lot. As a Perl person, it's not something we really have, and I've not felt that lack. Trying to get my head around why Python people feel it's important.
Update: Steve is talking about the different implementations of Python. Also not something we've had with Perl, at least until Perl 6 came along...
Update: That's interesting. Since Python 2.5 integers are unbounded, and since Python 3.0 diving two integers no longer does integer division, you end up with a floating point number. Oh, and strings are going to become Unicode by default.
Update: Now here is something I've always wanted in Perl, and it doesn't have because of its admittedly quite odd object model, default methods on strings;
s.strip()and the like. Of course since strings are immutable, they don't do an in place operation.
Having things like strings and tuples, and dictionary keys, as immutable is one of the things I've always had problems with in Python, and yes I know it means it's all thread-safe. Guess I've been working with Perl's threading model too long as well...
Update: Interesting, if obvious, admission from Steve,
We're talking about a Turing complete language, so there is always more than one way of doing things...when talking about there being only one way of doing things in Python.
Update: Time for morning coffee, back after these short messages...
Update: ...and we're back, and Steve has moved on to defining functions, where Python is actually a lot different than most other languages. In Python
defis an executable statement. The interpreter reads and compiles the indented body and the resulting function object is bound to the function name in current namespace.
Update: After working with Perl for so long I've never liked the way Python handles variable parameter lists,
Some functions can take an indefinite number of positional and keyword arguments. These are caught with a special parameter syntax;which is only sort of like the way Perl does things...
*namebecomes a tuple of "extra" positional arguments to a call
**namebecomes a dict of "extra" keyword arguments to a call:
Update: Pointer to PEP8, the "Style Guide to Python". I guess Perl people just have "Perl Best Practices" by Damian?
Update: Must admit I'm starting to drift here...
I'm trying to figure out whether Python is more strict and complicated than Perl, or whether I'm just thinking in Perl, and Python is just as slack and easy to use as Perl but in a different way? Anyone got any opinions on that one?
Update: I didn't realise the Python interpreter implicitly provides a
$selfwhen using an instance. That's interesting...
Update: Steve just said,
Five minutes left to cover formatting and I/O...That's not good. Nor is the fact that it's only in "modern" Python that you can iterate over a file and don't have to read it in all at once. Hmm...
Update: ...and we're done, or at least I am. Time for lunch.