[Tutor] 'Common' mistake ... for other newbies
David Broadwell
dbroadwell at mindspring.com
Mon Apr 12 19:02:25 EDT 2004
> Thank you David for this clear message.
Glad I decided to send anyway ... but it seeded a shame to waste the thought
on it.
> Are they here people who think that such a so-called "mistake"
> is not a mistake ?
Not in though but;
> That David programmed the way he (and we, humans should and
> that the error lies in language, not in his brain ?
I DID have an error, I was going the long way around of getting a random
item from a list.
The function for that is;
random.choice([someindexibleitem])
instead of;
someindexibleitem[random.randint(0,len(someindexibleitem)-1)]
Which are computationally equivalent in effect. Can't answer about speed,
In that situation, I should never have been wasting my personal runtime on
numerical indexes, is not python a 'very' high level language after all?
> Why are indexes based on 0 instead of 1 ?
Tradition. And having done basic logic circuits, I should have known better.
Call it a mistake from a 6 month lapse in coding.
Wasting my brain time is in fact WHY I started programming at all. I hate
doing things twice. Especially typing them twice. I hit a case of repetitive
copying and pasting of text files 425 of them into a new format and decided
it was time to code a routine. Other commentary of why one started
programming?
> [PS : if you're interested in such a way of reflexion, like "ameliorating
> python", or "the ideal programming language", I would really welcome your
> ideas -- outside the list]
I kind of think there is no perfect language, so far python (my first
language grok) is the closest that has trained the ability to be functional
as well as close.
--
Programmer's mantra; Observe, Brainstorm, Prototype, Repeat
David Broadwell
More information about the Tutor
mailing list