original_docstring: Convert string representation of m-by-n matrix into a single
      string, assuming a nested comma-delimited list representation in
      the input, and outputting a dictionary of the sub-lists, indexed
      by the ordered list of names specvars (specified as an
      argument).
docstring: Convert string representation of m-by-n matrix into a single
  string, assuming a nested comma-delimited list representation in
  the input, and outputting a dictionary of the sub-lists, indexed
  by the ordered list of names specvars (specified as an
  argument).
docstring_tokens: Convert string representation of m - by - n matrix into a single string assuming a nested comma - delimited list representation in the input and outputting a dictionary of the sub - lists indexed by the ordered list of names specvars ( specified as an argument ) .
code: def parseMatrixStrToDictStr(specstr, specvars, m=0):
      """Convert string representation of m-by-n matrix into a single
      string, assuming a nested comma-delimited list representation in
      the input, and outputting a dictionary of the sub-lists, indexed
      by the ordered list of names specvars (specified as an
      argument)."""
  
      specdict = {}
      # matrix is n by m
      n = len(specvars)
      if n == 0:
          raise ValueError("parseMatrixStrToDictStr: specvars was empty")
      if m == 0:
          # assume square matrix
          m = len(specvars)
      # strip leading and trailing whitespace
      spectemp1 = specstr.strip()
      assert spectemp1[0] == '[' and spectemp1[-1] == ']', \
          ("Matrix must be supplied as a Python matrix, using [ and ] syntax")
      # strip first [ and last ] and then all whitespace and \n
      spectemp2 = spectemp1[1:-1].replace(' ','').replace('\n','')
      splitdone = False
      entrycount = 0
      startpos = 0
      try:
          while not splitdone:
              nextrbrace = findEndBrace(spectemp2[startpos:],
                                         '[', ']') + startpos
              if nextrbrace is None:
                  raise ValueError("Mismatched braces before end of string")
              specdict[specvars[entrycount]] = \
                                  spectemp2[startpos:nextrbrace+1]
              entrycount += 1
              if entrycount < n:
                  nextcomma = spectemp2.find(',', nextrbrace)
                  if nextcomma > 0:
                      nextlbrace = spectemp2.find('[', nextcomma)
                      if nextlbrace > 0:
                          startpos = nextlbrace
                      else:
                          raise ValueError("Not enough comma-delimited entries")
                  else:
                      raise ValueError("Not enough comma-delimited entries")
              else:
                  splitdone = True
      except:
          print("Error in matrix specification")
          raise
      return specdict
code_tokens: def parseMatrixStrToDictStr ( specstr , specvars , m = 0 ) : specdict = { } n = len ( specvars ) if n == 0 : raise ValueError ( "parseMatrixStrToDictStr: specvars was empty" ) if m == 0 : m = len ( specvars ) spectemp1 = specstr . strip ( ) assert spectemp1 [ 0 ] == '[' and spectemp1 [ - 1 ] == ']' , ( "Matrix must be supplied as a Python matrix, using [ and ] syntax" ) spectemp2 = spectemp1 [ 1 : - 1 ] . replace ( ' ' , '' ) . replace ( '\n' , '' ) splitdone = False entrycount = 0 startpos = 0 try : while not splitdone : nextrbrace = findEndBrace ( spectemp2 [ startpos : ] , '[' , ']' ) + startpos if nextrbrace is None : raise ValueError ( "Mismatched braces before end of string" ) specdict [ specvars [ entrycount ] ] = spectemp2 [ startpos : nextrbrace + 1 ] entrycount += 1 if entrycount < n : nextcomma = spectemp2 . find ( ',' , nextrbrace ) if nextcomma > 0 : nextlbrace = spectemp2 . find ( '[' , nextcomma ) if nextlbrace > 0 : startpos = nextlbrace else : raise ValueError ( "Not enough comma-delimited entries" ) else : raise ValueError ( "Not enough comma-delimited entries" ) else : splitdone = True except : print ( "Error in matrix specification" ) raise return specdict
short_docstring: Convert string representation of m-by-n matrix into a single
  string, assuming a nested comma-delimited list representation in
  the input, and outputting a dictionary of the sub-lists, indexed
  by the ordered list of names specvars (specified as an
  argument).
short_docstring_tokens: Convert string representation of m - by - n matrix into a single string assuming a nested comma - delimited list representation in the input and outputting a dictionary of the sub - lists indexed by the ordered list of names specvars ( specified as an argument ) .
comment: """Convert string representation of m-by-n matrix into a single
      string, assuming a nested comma-delimited list representation in
      the input, and outputting a dictionary of the sub-lists, indexed
      by the ordered list of names specvars (specified as an
      argument)."""$SEP$# matrix is n by m$SEP$# assume square matrix$SEP$# strip leading and trailing whitespace$SEP$# strip first [ and last ] and then all whitespace and \n