[Tutor] Not Really Questions
Hugo González Monteverde
hugonz-lists at h-lab.net
Sun Jun 4 22:54:36 CEST 2006
John Connors wrote:
>
> The first one is lists... I can't for the life of me understand why a list
> starts at zero. In everything else in life other than programming the 1st
> item in a list is always 1.
Hi,
Exactly, everything else other than programming. Zero indexed arrays are
the norm in everything but moronic old VB. I guess it's just a defacto
standard now.
>
> The next thing I don't understand is why the last number in a range is not
> used...
>
> For a in range(1,6):
> print a,
>
> 1 2 3 4 5
>
This relates to the previous issue. This comes from the fact that
range(3) = [0, 1, 2]
This is extremely useful for iterating indices, and I can suppose that
when range() was first extended, it had to remain consistent.
> The 3rd whinge is object oriented programming. I think I understand the
> principle behind OOP but in practise, to me, it just makes programs jumbled,
> unreadable and bloated. Just about every summary I have read on Python says
> it is designed to have a simple syntax and is easy to learn. As a beginner I
> can look at Python code and have a very good idea of what is happening and
> why unless it's written in OOP style in which case I have no idea.
>
OOP is a rare beast to me: it makes suitable problems very very easy
(think about GUI programming without OOP) and unsuitable problems
extremely convoluted. I guess it's just the fact that it is a paradigm
and not just a programming technique.
Fortunately, unless other languages which *force* you to use OOP (think
Java), Python allows you to use at least 3 different paradigms (OOP,
functional(like Lisp et al) and structured(like Pascal and C))
Just my 2 cents,
Hugo
More information about the Tutor
mailing list