@register.tag
@blocktag
def ifneatnumber(context, nodelist, rid):
 if ((rid is None) or (rid < 1000)):
  return u''
 ridstr = six.text_type(rid)
 interesting = False
 context.push()
 context[u'milestone'] = False
 context[u'palindrome'] = False
 if (rid >= 1000):
  trailing = ridstr[1:]
  if (trailing == (u'0' * len(trailing))):
   context[u'milestone'] = True
   interesting = True
 if (not interesting):
  if (ridstr == u''.join(reversed(ridstr))):
   context[u'palindrome'] = True
   interesting = True
 if (not interesting):
  context.pop()
  return u''
 s = nodelist.render(context)
 context.pop()
 return s

@ register . tag @ blocktag def ifneatnumber ( context , nodelist , rid ) : if ( ( rid is None ) or ( rid < 1000 ) ) : return u'' ridstr = six . text_type ( rid ) interesting = False context . push ( ) context [ u'milestone' ] = False context [ u'palindrome' ] = False if ( rid >= 1000 ) : trailing = ridstr [ 1 : ] if ( trailing == ( u'0' * len ( trailing ) ) ) : context [ u'milestone' ] = True interesting = True if ( not interesting ) : if ( ridstr == u'' . join ( reversed ( ridstr ) ) ) : context [ u'palindrome' ] = True interesting = True if ( not interesting ) : context . pop ( ) return u'' s = nodelist . render ( context ) context . pop ( ) return s
returns whether or not the specified number is a "neat" number .