How to control EOL and leading spaces in Mako?

216
April 29, 2017, at 03:08 AM

With the following, I would like to control the EOL:

<%!
    import sqlite3
    def data():
        return [(1,2,3,4,5), (1,2,3,4,5)]
%>
/**
 * Header file
 */
#define foo bar
% for row in data():
    { \
    % for col in row:
        ${col}, \
    % endfor
    }
% endfor

The goal is to print:

{1,2,3,4,5},
{1,2,3,4,5}    

I've tried to do something like:

% for row in data():
    {<%for i, col in enumerate(row):%>${','*bool(i)}${col}<%endfor%>},
% endfor
READ ALSO
How to search for a variable in a list of strings

How to search for a variable in a list of strings

I have very basic python knowledgeThis is my code so far: when i run this code the error UnboundLocalError: local variable 'response' referenced before assignment on line 7 displays

248
Trying to wrap my head around python property decorator [duplicate]

Trying to wrap my head around python property decorator [duplicate]

This question already has an answer here:

234
How to recognize Chinese or English name using python [on hold]

How to recognize Chinese or English name using python [on hold]

Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chinese namesFor example, Bruce Lee, Lee is a Chinese last name, so we regard...

464
Elasticsearch: Data too large, data for [_uid] would be larger than limit of [1267571097/1.1gb]]

Elasticsearch: Data too large, data for [_uid] would be larger than limit of [1267571097/1.1gb]]

I'm trying to query elasticsearch to retrieve some document that got the keyword #test in their documentsThe all_hateful_ids is a list of id

550