Comments on my first script?
Chris
cwitts at gmail.com
Fri Jun 13 03:53:20 EDT 2008
On Jun 13, 9:38 am, Phillip B Oldham <phillip.old... at gmail.com> wrote:
> Thanks guys. Those comments are really helpful. The odd semi-colon is
> my PHP background. Will probably be a hard habbit to break, that
> one! ;) If I do accidentally drop a semi-colon at the end of the line,
> will that cause any weird errors?
>
> Also, Chris, can you explain this:
> a, b = line.split(': ')[:2]
>
> I understand the first section, but I've not seen [:2] before.
That's slicing at work. What it is doing is only taking the first two
elements of the list that is built by the line.split.
More information about the Python-list
mailing list