how to get the ordinal number in list

Rustom Mody rustompmody at gmail.com
Sun Aug 10 23:35:24 EDT 2014


On Monday, August 11, 2014 3:31:08 AM UTC+5:30, Roy Smith wrote:

>  Mark Lawrence wrote:

> > On 10/08/2014 19:26, Rustom Mody wrote:
> > > Its when we have variables that are assigned in multiple places that
> > > we start seeing mathematical abominations like
> > > x = x+1
> > I'm not bothered about it being a mathematical or any other type of 
> > abomination.  It works, practically beats purity, so if it ain't broke, 
> > please don't fix it, for some definition of fix.

> I'm with Mark.  This isn't math, it's programming.  Sure, the 
> intersection of the two is non-null, but they are different things.  
> I'll often do things like:

> for line in input:
>    line = line.strip()
>    # do more stuff

So would I

> Sure, I could invent some other variable name to avoid re-using the same 
> name, but does:

> for line in input:
>    stripped_line = line.strip()
>    # do more stuff

> really make this any easier to read or understand?  I think not.

You are switching between software-engineer and teacher hat.

As a software engineer you (and I and possibly most reasonable people)
would do things like that.

As a teacher when you introduce problematic concepts you have to answer
questions -- possibly embarrassing -- about them.

Just as parents need to talk of 'birds-and-bees' to their children
sometime but also need good sense and judgement as to when, likewise
teachers should deliver maturity-building easier stuff before
maturity-needing harder ideas.

Assignment is definitely in the latter category because we have to
talk of time, environments and so on.  When one explicates (and not
handwaves) these pre-requisites -- as happens in denotational
semantics or in any language implementation -- then assignment is seen
to be as higher-order a concept as any other 2 level lambda expression.



More information about the Python-list mailing list