hangman/guessword/templatetags/range_tag.py
def do_range(parser, token):
    """
    Work much like forloop with a range.
    Takes both variables and constant integers.

    Syntax:
    {% range end as i %}
      {{ i }}
    {% endrange %}
    {% range start:end as i %}
      {{ i }}
    {% endrange %}
    {% range start:step:end as i %}
      {{ i }}
    {% endrange %}

    """

    bits = token.split_contents()
    if len(bits) != 4 or bits[2] != 'as':
        raise template.TemplateSyntaxError(
            "%r expected format is '[start:][step:]end as <iter>'" % bits[0]
        )

    var_name = bits[3]

    rangebits = bits[1].split(':')
    if len(rangebits) == 1:
        start = 0
        end = rangebits[0]
        step = 1
    elif len(rangebits) == 2:
        start = rangebits[0]
        end = rangebits[1]
        step = 1
    elif len(rangebits) == 3:
        start = rangebits[0]
        step = rangebits[1]
        end = rangebits[2]
    else:
        start, step, end = 0, 0, 0

    nodelist = parser.parse(('endrange',))
    parser.delete_first_token()
    return RangeNode(var_name, start, end, step, nodelist)

    Work much like forloop with a range.
    Takes both variables and constant integers.

    Syntax:
    {% range end as i %}
      {{ i }}
    {% endrange %}
    {% range start:end as i %}
      {{ i }}
    {% endrange %}
    {% range start:step:end as i %}
      {{ i }}
    {% endrange %}

    
Work much like forloop with a range.
Takes both variables and constant integers.


Work much like forloop with a range . Takes both variables and constant integers .
def do_range(parser, token):
    bits = token.split_contents()
    if len(bits) != 4 or bits[2] != 'as':
        raise template.TemplateSyntaxError(
            "%r expected format is '[start:][step:]end as <iter>'" % bits[0]
        )
    var_name = bits[3]
    rangebits = bits[1].split(':')
    if len(rangebits) == 1:
        start = 0
        end = rangebits[0]
        step = 1
    elif len(rangebits) == 2:
        start = rangebits[0]
        end = rangebits[1]
        step = 1
    elif len(rangebits) == 3:
        start = rangebits[0]
        step = rangebits[1]
        end = rangebits[2]
    else:
        start, step, end = 0, 0, 0
    nodelist = parser.parse(('endrange',))
    parser.delete_first_token()
    return RangeNode(var_name, start, end, step, nodelist)
def do_range ( parser , token ) : bits = token . split_contents ( ) if len ( bits ) != 4 or bits [ 2 ] != 'as' : raise template . TemplateSyntaxError ( "%r expected format is '[start:][step:]end as <iter>'" % bits [ 0 ] ) var_name = bits [ 3 ] rangebits = bits [ 1 ] . split ( ':' ) if len ( rangebits ) == 1 : start = 0 end = rangebits [ 0 ] step = 1 elif len ( rangebits ) == 2 : start = rangebits [ 0 ] end = rangebits [ 1 ] step = 1 elif len ( rangebits ) == 3 : start = rangebits [ 0 ] step = rangebits [ 1 ] end = rangebits [ 2 ] else : start , step , end = 0 , 0 , 0 nodelist = parser . parse ( ( 'endrange' , ) ) parser . delete_first_token ( ) return RangeNode ( var_name , start , end , step , nodelist )
Work much like forloop with a range.
Work much like forloop with a range .
"""
    Work much like forloop with a range.
    Takes both variables and constant integers.

    Syntax:
    {% range end as i %}
      {{ i }}
    {% endrange %}
    {% range start:end as i %}
      {{ i }}
    {% endrange %}
    {% range start:step:end as i %}
      {{ i }}
    {% endrange %}

    """
parser
token