Constructing an Abstract Syntax Tree with a list of Tokens

The fundamental trick is to recognize that parsing, however accomplished, happens in incremental steps, including the reading of the tokens one by one. At each incremental step, there is an opportunity to build part of the AST by combining AST fragments built by other incremental steps. This is a recursive idea, and it bottoms out … Read more

Is it possible to have multiple PyPlot windows? Or am I limited to subplots?

Sure, just open a new figure: import matplotlib.pyplot as plt plt.plot(range(10)) plt.figure() plt.plot(range(10), ‘ro-‘) plt.figure(), plt.plot(…) plt.show() # only do this once, at the end If you’re running this in the default python interpreter, this won’t work, as each figure needs to enter the gui’s mainloop. If you want to run things in an interactive … Read more

Python Compilation/Interpretation Process

The bytecode is not actually interpreted to machine code, unless you are using some exotic implementation such as pypy. Other than that, you have the description correct. The bytecode is loaded into the Python runtime and interpreted by a virtual machine, which is a piece of code that reads each instruction in the bytecode and … Read more

Compiler vs Interpreter vs Transpiler

Compiler – compiles code to a lower level code. Example: “Developer code” -> “Machine code” PHP -> C Java -> bytecode Transpiler – compiles code to same level of code/abstraction. Example: “Developer code” -> “Another developer code or version” JavaScript ES2015+ -> JavaScript ES5 Interpreter – interprets code, not really in the same class/league/context with … Read more

Assigning a value to single underscore _ in Python/IPython interpreter

The Python interpreter assigns the last expression value to _. This behaviour is limited to the REPL interpreter only, and is intended to assist in interactive coding sessions: >>> import math >>> math.pow(3.0, 5) 243.0 >>> result = _ >>> result 243.0 The standard Python interpreter goes to some length to not trample on user-defined … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)