parameters: (formula)
return_statement: return "".join(out)
docstring: Translate a formula containing fancy cell names to valid Python code.
  
      Examples:
          B4 -> cell(2, 4)
          B4:Z100 -> cells(2, 4, 26, 100)
docstring_summary: Translate a formula containing fancy cell names to valid Python code.
docstring_tokens: Translate a formula containing fancy cell names to valid Python code .
function: def translate(formula):
      """Translate a formula containing fancy cell names to valid Python code.
  
      Examples:
          B4 -> cell(2, 4)
          B4:Z100 -> cells(2, 4, 26, 100)
      """
      out = []
      for part in re.split(r"(\w+(?::\w+)?)", formula):
          m = re.match(r"^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$", part)
          if m is None:
              out.append(part)
          else:
              x1, y1, x2, y2 = m.groups()
              x1 = colname2num(x1)
              if x2 is None:
                  s = "cell(%s, %s)" % (x1, y1)
              else:
                  x2 = colname2num(x2)
                  s = "cells(%s, %s, %s, %s)" % (x1, y1, x2, y2)
              out.append(s)
      return "".join(out)
function_tokens: def translate ( formula ) : out = [ ] for part in re . split ( r"(\w+(?::\w+)?)" , formula ) : m = re . match ( r"^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$" , part ) if m is None : out . append ( part ) else : x1 , y1 , x2 , y2 = m . groups ( ) x1 = colname2num ( x1 ) if x2 is None : s = "cell(%s, %s)" % ( x1 , y1 ) else : x2 = colname2num ( x2 ) s = "cells(%s, %s, %s, %s)" % ( x1 , y1 , x2 , y2 ) out . append ( s ) return "" . join ( out )