[Zope] convert #var sequence-item to integer?

Jim Fulton jim@digicool.com
Tue, 10 Aug 1999 08:07:05 -0400


Tim Potter wrote:
> 
> Andreas Kostyrka writes:
> 
> > > The error I get is "sequence index must be an integer".  Zope doesn't
> > > seem to be converting the sequence-item variable into an integer
> >
> > Where are you coming from, that you expect a language to convert a string
> > to an integer automatically? *wonder*
> >
> > Try:
> > _.string.atoi(i)
> 
> Are you serious?  There isn't a smiley so I guess so.
> 
> I think my Perl mindset may be what is confusing here.  The following
> two statements bits of perl produce the same result: 43.
> 
> $ perl -e 'print(42 + 1)'
> $ perl -e 'print("42" + "1")'

As do the following:

 $ perl -e 'print("42 monkeys" + "1 snake")'
 $ perl -e 'print("43" + "Hello world")'
 
> Perl automatically converts between strings and integers as the need
> arises

And even when the need does not arise, or would be downright silly.
The overagressive numberification of data was the original
reason I abandoned perl for Python.

> so in my mind, trying to index an array with a string makes
> perfect sense to a Perl programmer. 

I'm sure it does. ;)

> Since DTML expressions are Python
> based and [quickly checks through my copy of Learning Python] Python
> seems to have a stricter typing system than Perl.
> 
> I'm sure people who speak Python as a second language (-: may be
> similarly confused.

It probably depends what their first language was. :)

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.