Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the Python compiler string programmatically?

Tags:

python

The Python Interpreter Entry Message contains a string that describes the compiler.

For example on my machine, the Entry Message says:

Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32

Where [MSC v.1500 64 bit (AMD64)] is the compiler string.

How can i get this string programmatically?

like image 801
Love and peace - Joe Codeswell Avatar asked Mar 09 '16 15:03

Love and peace - Joe Codeswell


People also ask

How do you compile a string in python?

If the Python code is in string form or is an AST object, and you want to change it to a code object, then you can use compile() method. The code object returned by the compile() method can later be called using methods like: exec() and eval() which will execute dynamically generated Python code.

Can python code be compiled?

For the most part, Python is an interpreted language and not a compiled one, although compilation is a step. Python code, written in . py file is first compiled to what is called bytecode (discussed in detail further) which is stored with a . pyc or .

What is compiler in python with example?

Python is an interpreted programming language and has various execution environments. It has a variety of compilers to execute the Python programs. For example, PyCharm, PyDev, Spyder, Atom, Visual Studio Code, Jupyter Notebook, etc.

Is python interpreted or compiled?

Python is an interpreted language, which means the source code of a Python program is converted into bytecode that is then executed by the Python virtual machine. Python is different from major compiled languages, such as C and C + +, as Python code is not required to be built and linked like code for these languages.


1 Answers

You can get information like this from the platform module, for example:

import platform
platform.python_compiler()

gives me:

'GCC 4.9.2'
like image 78
srowland Avatar answered Sep 28 '22 13:09

srowland