Re: [web2py] Re: try: for-loop

2012-05-31 Thread Doug Philips
BTW: Take a look at the Style Guide for Python Code (PEP-8) for lots of really helpful tips. The empty collections (of which list is one) can be found under Programming Recommendations of PEP-8: http://www.python.org/dev/peps/pep-0008/#programming-recommendations --Doug On Wed, May 30,

[web2py] Re: try: for-loop

2012-05-30 Thread Niphlod
didn't test it, but I spot a missing : after for x in db.test Il giorno mercoledì 30 maggio 2012 16:08:10 UTC+2, BlueShadow ha scritto: Hi I like to put a for-loop in a try except clause in an html file. My problem is that the pass from the for loop terminates the try block. {{try:}} {{for

[web2py] Re: try: for-loop

2012-05-30 Thread Niphlod
btw, this works perfectly as intended trying to do 1/0 {{try:}} {{for a in range(15):}} {{=1/0}} {{pass}} {{except:}} can't divide by 0 {{pass}} Il giorno mercoledì 30 maggio 2012 16:15:10 UTC+2, Niphlod ha scritto: didn't test it, but I spot a missing : after for x in db.test

[web2py] Re: try: for-loop

2012-05-30 Thread BlueShadow
I tried it too and for some weird reason it works. The missing doublepoint you spotted is in my complete code on my server^^ what I really want to do is: diyplaying a database entry in a table. this entry varies from no entries to about 10. I didn't account for the no entries part but I got a

[web2py] Re: try: for-loop

2012-05-30 Thread BlueShadow
OK I did some further testing and I'm pretty stupid some basic understanding of python would tell me that the for loop finishes without a problem if there are no elements in it. {{try:}} {{print articlesformovie[0]}} {{noarticles=0}} {{except:}} {{noarticles=1}} TRTD/TDTDEs sind

[web2py] Re: try: for-loop

2012-05-30 Thread Niphlod
you're overcomplicating a small issue {{if articles and len(articles)0:}} display whatever you want in a for loop {{else:}} display your static message {{pass}} Il giorno mercoledì 30 maggio 2012 16:44:22 UTC+2, BlueShadow ha scritto: I tried it too and for some weird reason it works.

[web2py] Re: try: for-loop

2012-05-30 Thread BlueShadow
OK it obviously has nothing to do with the for loop in try except because the for loop finishes when there are no entries in articles. But some basic understanding of python should have told me the solution^^ thats what works if anyone is interested: {{try:}} {{print article[0].title}}

Re: [web2py] Re: try: for-loop

2012-05-30 Thread Bruno Rocha
len(articles) is not necessary {{if articles:}} display whatever you want in a for loop {{else:}} display your static message {{pass}} On Wed, May 30, 2012 at 12:04 PM, Niphlod niph...@gmail.com wrote: {{if articles and len(articles)0:}} display whatever you want in a for loop {{else:}}

[web2py] Re: try: for-loop

2012-05-30 Thread BlueShadow
thats even more elegant^^ Am Mittwoch, 30. Mai 2012 17:04:16 UTC+2 schrieb Niphlod: you're overcomplicating a small issue {{if articles and len(articles)0:}} display whatever you want in a for loop {{else:}} display your static message {{pass}} Il giorno mercoledì 30 maggio 2012

Re: [web2py] Re: try: for-loop

2012-05-30 Thread Niphlod
uhm, depends if he uses lists and articles is = [], there will be a problem. Anyway, under some circumstances you're right. Il giorno mercoledì 30 maggio 2012 17:11:33 UTC+2, rochacbruno ha scritto: len(articles) is not necessary {{if articles:}} display whatever you want in a for

Re: [web2py] Re: try: for-loop

2012-05-30 Thread Anthony
On Wednesday, May 30, 2012 11:59:13 AM UTC-4, Niphlod wrote: uhm, depends if he uses lists and articles is = [], there will be a problem. What problem? An empty list evaluates to False. Anthony

Re: [web2py] Re: try: for-loop

2012-05-30 Thread Niphlod
I am astonished... I missed this in almost 3 years of python development :D I genuinely repent and knee before you, Anthony Niphlod Il giorno mercoledì 30 maggio 2012 18:11:32 UTC+2, Anthony ha scritto: On Wednesday, May 30, 2012 11:59:13 AM UTC-4, Niphlod wrote: uhm, depends if he