Skip to content

Commit

Permalink
Wrap tokenlist in list if self.resultsName is present (#324)
Browse files Browse the repository at this point in the history
* Wrap tokenlist in list if self.ResulstName is present for Dict

* Use as_dict instead of asDict
  • Loading branch information
busunkim96 committed Oct 29, 2021
1 parent 958d055 commit 8bbc83e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyparsing/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5413,7 +5413,10 @@ def postParse(self, instring, loc, tokenlist):
else:
tokenlist[ikey] = _ParseResultsWithOffset(dictvalue[0], i)

return tokenlist if not self._asPythonDict else tokenlist.as_dict()
if self._asPythonDict:
return tokenlist.as_dict()
else:
return [tokenlist] if self.resultsName else tokenlist


class Suppress(TokenConverter):
Expand Down

0 comments on commit 8bbc83e

Please sign in to comment.