Hi: How i can repeat a string n times. For example in perl i can do: "*" x $score ($score is a integer) and if $score=10 i have ********** . I tried use it for make histograms. For example: Student_ID Score ------------------------------------------ 1030 ***************** 1031 ******************* 1032 ************ 1033 ************************ __________________________________________ Mean **************** ------------------------------------------- -- +----------------------------------------------------------------------+ | Jorge Magalhães Email: jmagalhaes@eng.uminho.pt | | Quinta do Calvário, bloco 14 Telemóvel: 966172200 | | 2º Direito Trás Fax: + 351 253 516007 | | 5400 Chaves Phone: + 351 276 333008 | | Portugal Email: jorgemagalhaes@clix.pt | +----------------------------------------------------------------------+
Jorge Magalhaes wrote:
Hi:
How i can repeat a string n times. For example in perl i can do:
"*" x $score ($score is a integer)
In python it'd be: '*' * score Or, in DTML-land: <dtml-var "'*' * score"> I've found the Python tutorial to be a good place to find these kinds of answers: http://www.python.org/doc/current/tut/tut.html -CJ
"*" x $score ($score is a integer) in python (which is zope, in a way) you do: 'x'*10, which will produce 'xxxxxxxxxx' and in zope you do: <dtml-var "'x'*10"> which will also produce 'xxxxxxxxxx' -Morten
----- Original Message ----- From: "Jorge Magalhaes" <root@predict.telepac.pt> To: <zope@zope.org> Sent: Tuesday, April 25, 2000 9:47 AM Subject: [Zope] string n times
How i can repeat a string n times. For example in perl i can do:
"*" x $score ($score is a integer)
and if $score=10 i have ********** .
In python, you can just do '*' * score (The standard multiplication operator works with strings). In DTML, you can do <dtml-var "'*' * score"> Kevin
If score is equal to 8 then <dtml-var "'*' * score"> will give you ******** ----- Original Message ----- From: Jorge Magalhaes <root@predict.telepac.pt> To: <zope@zope.org> Sent: Tuesday, April 25, 2000 8:47 AM Subject: [Zope] string n times Hi: How i can repeat a string n times. For example in perl i can do: "*" x $score ($score is a integer) and if $score=10 i have ********** . I tried use it for make histograms. For example: Student_ID Score ------------------------------------------ 1030 ***************** 1031 ******************* 1032 ************ 1033 ************************ __________________________________________ Mean **************** ------------------------------------------- -- +----------------------------------------------------------------------+ | Jorge Magalhães Email: jmagalhaes@eng.uminho.pt | | Quinta do Calvário, bloco 14 Telemóvel: 966172200 | | 2º Direito Trás Fax: + 351 253 516007 | | 5400 Chaves Phone: + 351 276 333008 | | Portugal Email: jorgemagalhaes@clix.pt | +----------------------------------------------------------------------+ _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Jim, Jim Sanford wrote:
If score is equal to 8 then <dtml-var "'*' * score"> will give you ********
----- Original Message ----- From: Jorge Magalhaes <root@predict.telepac.pt> To: <zope@zope.org> Sent: Tuesday, April 25, 2000 8:47 AM Subject: [Zope] string n times
Hi:
How i can repeat a string n times. For example in perl i can do:
(Yeah, again, where is the dammed questionmark? ;-)
"*" x $score ($score is a integer)
(shown already)
For example:
Student_ID Score ------------------------------------------ 1030 ***************** 1031 ******************* 1032 ************ 1033 ************************ __________________________________________ Mean **************** ------------------------------------------- Easy as hell:
<dtml-in database_query_over_students_score> <dtml-if sequence-start> <table border=0> <tr> <td>Student_ID</td><td>Score</td> </tr> <tr> <td colspan="2"><hr></td> </tr> </dtml-if> <tr> <td><dtml-var Student_ID></td> <td><dtml-var "'*' * Score"></td> </tr> <dtml-if sequence-end> <tr> <td colspan="2"><hr></td> </tr> <tr> <td>Mean</td> <td><dtml-var "'*' * _.int(_['mean-Score'])"></td> </tr> <tr> <td colspan="2"><hr></td> </tr> </table> </dtml-in> </dtml-if> <dtml-var
participants (6)
-
Christopher J. Kucera -
Jim Sanford -
Jorge Magalhaes -
Kevin Dangoor -
Morten W. Petersen -
Tino Wildenhain