compiler-construction

Compiled vs. Interpreted Languages

Compiled vs. Interpreted Languages Question: I’m trying to get a better understanding of the difference. I’ve found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are …

Total answers: 13

assign operator to variable in python?

assign operator to variable in python? Question: Usual method of applying mathematics to variables is a * b Is it able to calculate and manipulate two operands like this? a = input(‘enter a value’) b = input(‘enter a value’) op = raw_input(‘enter a operand’) Then how do i connect op and two variables a and …

Total answers: 5

How to write the Visitor Pattern for Abstract Syntax Tree in Python?

How to write the Visitor Pattern for Abstract Syntax Tree in Python? Question: My collegue suggested me to write a visitor pattern to navigate the AST. Can anyone tell me more how would I start writing it? As far as I understand, each Node in AST would have visit() method (?) that would somehow get …

Total answers: 3

Compiling Python

Compiling Python Question: How can I compile and run a python file (*.py extension)? Asked By: user161004 || Source Answers: python yourfile.py You have to have python installed first. It will automatically compile your file into a .pyc binary, and then run it for you. It will automatically recompile any time your file changes. http://www.python.org/download/ …

Total answers: 8

Why is the compiler package discontinued in Python 3?

Why is the compiler package discontinued in Python 3? Question: I was just pleasantly surprised to came across the documentation of Python’s compiler package, but noticed that it’s gone in Python 3.0, without any clear replacement or explanation. I can’t seem to find any discussion on python-dev about how this decision was made – does …

Total answers: 3

Python's bz2 module not compiled by default

Python's bz2 module not compiled by default Question: It seems that Python 2.6.1 doesn’t compile bz2 library by default from source. I don’t have lib-dynload/bz2.so What’s the quickest way to add it (without installing Python from scratch)? OS is Linux 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686 GNU/Linux IIRC I used only …

Total answers: 4

Parse a .py file, read the AST, modify it, then write back the modified source code

Parse a .py file, read the AST, modify it, then write back the modified source code Question: I want to programmatically edit python source code. Basically I want to read a .py file, generate the AST, and then write back the modified python source code (i.e. another .py file). There are ways to parse/compile python …

Total answers: 13

Is there a need for a "use strict" Python compiler?

Is there a need for a "use strict" Python compiler? Question: There exist static analysis tools for Python, but compile time checks tend to be diametrically opposed to the run-time binding philosophy that Python embraces. It’s possible to wrap the standard Python interpreter with a static analysis tool to enforce some “use strict“-like constraints, but …

Total answers: 10

Online compilers/runtime for Java, C++, Python and ObjC?

Online compilers/runtime for Java, C++, Python and ObjC? Question: Does anyone know of a good online compiler/runtime (for C++, Java, Python, ObjC etc.) that I can access on the web? What I’m looking for is something that would allow me to type in a program in a web form and to run the program and …

Total answers: 9

JavaScript parser in Python

JavaScript parser in Python Question: There is a JavaScript parser at least in C and Java (Mozilla), in JavaScript (Mozilla again) and Ruby. Is there any currently out there for Python? I don’t need a JavaScript interpreter, per se, just a parser that’s up to ECMA-262 standards. A quick google search revealed no immediate answers, …

Total answers: 5