Search code examples
pythonobjectinitializationbrackets

Python: what does putting [square] brackets around an object do?


I'm translating code from Python to Lua, but I can't figure out what this line of code does:

results = [node]

To provide context, this is in the parser for a Pascal interpreter. I'm translating this code from a tutorial to try to wrap my head around interpreters. node is an object that represents a node in an abstract syntax tree. I'm not sure what the brackets do.

Here is the full code for the interpreter at this point in the tutorial. The line I'm looking at is 255.


Solution

  • That creates a list of one element with just the node object. Presumably results is expected to be a list.