[Tutor] changing list index start

Rance Hall ranceh at gmail.com
Sat Sep 11 18:05:48 CEST 2010

On Sat, Sep 11, 2010 at 10:40 AM, Joel Goldstick
<joel.goldstick at gmail.com> wrote:


> I think the first message in the original post is instructive:
> "I'm using the following function style I found on the net to create
> menus for a command line python script:"
> I (sometimes!) love looking at other peoples code to learn.  However taking
> some code and
> using it in your application demands that you understand it, or it will bite
> you later.  In this case,
> the code might have been appropriate to the original author, but not for its
> new use.

I agree completely and I did understand what this code snippet was
doing, and I also understood why the first menu item was labeled 0

My question revolves around the theme of "this is the idea I want to
use, it does this, I like what it does, but I'd like to alter it
slightly, how do I turn this into what I want?

> Using index starting with 1 sounds to me idiomatic of BASIC programming.
> While I'm too inexperienced
> with Python to consider myself good at it, I think the key to using python
> is to 'get it' as to the fundamental
> data types in python and how they make things easier to solve problems.
> One of the earliest programming
> books I read was 'Algorithms + Data Structures = Programs' by Niklaus
> Wirth.  The book used Pascal, which I think
> the author wrote.  But no matter the language, learn what data structures it
> offers, and why and then your algorithms
> will become simpler and more elegant.  If you find yourself doing weird
> things with your code, see if you can rethink
> how you organize your data

Yea, it does a little bit, doesn't it.  (at least reminding of BASIC)

I can't disagree with you on the rest of your comments either

I can't say that I thought my original idea was weird at all,  BASIC,
PHP and probably other languages allow you to approach the problem in
the same way I thought of.
But this is python and not any other language, so for me I'm finding
that the biggest issue on my plate now is not "What is this?" but more
of "Why is this better or worse than that?"

Steven reply in an example of what I'm talking about, Steven said "You
*think* its a good idea"

In some ways python is a very flexible flowing language.  In other
ways its very restrictive.  For example: I *like* how whitespace
matters in python, it forces you to structure your code.correctly.
Other languages don't care about the whitespace, you dont have to
indent your code (which is a disaster to read I know)

This is the stuff I need to learn, where is python rigid and where is
it flexible.  This gives me a framework to use for evaluating tasks.

I think my original question has been answered and I'm glad I wasn't
barking up the wrong tree.

As to the philosophical stuff maybe its time to start a new thread.

More information about the Tutor mailing list