[Zope-dev] Re: [Zope] sequence of numbers
Shaw, Howard
ShawH@STHS.org
Sat, 13 Mar 1999 11:54:11 -0600
Perhaps if you added a python function which performed range checking
and constrained the command to generating between 1 and 100 numbers,
etc, DC might be willing to integrate the patch, since this would not
leave open the hole DC feared (i.e. ask Python to generate several
billion length range). If the range was insufficient for anyone, they
could easily modify that code snippet... Thus the Zopist could tune the
function to be useful.
I am sure DC didn't spend a lot of time on _. functions. They have much
else to do, but I expect if you create a wrapper that can make a
pythonic function safely available and provide a patch they will
probably consider integrating it.
Howard C. Shaw III
Programmer, SysAdmin
St. Thomas High School, Houston, Texas
<disclaimer>My opinions are not those of my employer nor am I
representing my employer in an official capacity</disclaimer>
----------
From: Bill Randle [SMTP:billr@coinet.com]
Sent: Saturday, March 13, 1999 10:37 AM
To: Paul Everitt
Cc: zope-dev@zope.org
Subject: [Zope-dev] Re: [Zope] sequence of numbers
Paul,
Thanks for the suggestion. I had thought of something like that,
and my
sequence is short, but the problem is I don't know how long it
is ahead
of time. The actual sequence length is stored in a property. I
guess I
could brute force it like this:
<!--#if "slen == 2"-->
<!--#call "REQUEST.set('foo'.['1','2'])"-->
<!--#elif "slen == 3"-->
<!--#call "REQUEST.set('foo','['1','2','3'])"-->
...
<!--#/if-->
Before I finished writing this followup, I did some browsing
thru the Python
book (definite newbie here, also) and found exactly what I was
looking for:
range(start?, end, step?)
So, what I want to do is:
<!--#in "range(slen)"-->
// some stuff
<!--/#in-->
I notice that range() is not in the list of attributes for '_'.
Is there any
special reason for this? If it was there, I could do this:
<!--#in "_.range(slen)"-->
Will it work to add "range" to the list of built-ins in line 185
of
lib/python/DocumentTemplate/DT_Util.py (line number matches
version 1.50)?
I've redirected this followup to Zope-dev, as I think I'm
talking more about
development issues now, than a simple language quesiton.
-Bill Randle
Central Oregon Internet
billr@coinet.com
On Mar 13, 9:29am, Paul Everitt wrote:
} Subject: RE: [Zope] sequence of numbers
}
} Bill wrote:
} > What I want to do is given a limit number, iterate over a
sequence of
} > DTML commands. This would be an obvious use for #in (which
I'm using
} > elsewhere for other things) except I don't have a sequence -
just the
} > number of items in the sequence, as it were.
}
} Here's a brute-force way to do it, as long as the list of
items was
} short:
}
} <!--#call "REQUEST.set('foo',['1',
} '2','3','4','5'])"-->
}
} <!--#in foo-->
} <!--#var sequence-item--><br>
} <!--#/in-->
}
} --Paul
_______________________________________________
Zope-Dev maillist - Zope-Dev@zope.org
http://www.zope.org/mailman/listinfo/zope-dev
(For non-developer, user-level issues, use the companion list,
zope@zope.org, http://www.zope.org/mailman/listinfo/zope )