Should it be If i< lrows-1 ?
[1,2,3] has a length of 3 but the last comma would be after i = 1 since counting starts at 0. -tom On Jan 6, 4:12 pm, Andre Smit <freevryh...@gmail.com> wrote: > This has me stumped. I'm trying to apply the function as posted and trying > to get rid of the trailing comma to ensure valid json. The > following doesn't work: > > def GET(self): > web.header('Content', 'text/json') > rows = db.select('foo') > lrows = len(rows) > yield '[' > for i,row in enumerate(rows): > if i < lrows: > yield json.dumps(row) + ', ' > else: > yield json.dumps(row) > yield ']' > any suggestions on how to handle the trailing comma? > TIA -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to webpy@googlegroups.com. To unsubscribe from this group, send email to webpy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.