Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Behind the scenes activity on python prompt load-up

Tags:

python

What happens behind the scenes when we invoke the python prompt?

I am more interested in understanding how do the methods/functions like print, import and the likes load up in the interpreter?

EDIT: Some clarification on my question:
When we type python on our unix prompt/windows console and Hit enter, what are the libraries that get loaded. My specific interest is as to how the keywords like print and import are made available to the user.

like image 591
sidhshar Avatar asked Jan 19 '11 12:01

sidhshar


Video Answer


2 Answers

Like you , I am very interested by the underlying mechanisms of Python. I think you'll love this series: http://tech.blog.aknin.name/category/my-projects/pythons-innards/

like image 107
eyquem Avatar answered Sep 20 '22 00:09

eyquem


There are too many levels to that question. Here's a very rough sketch.

There's the whole C-level interpreter initialization, a bunch of in-the-interpreter tasks, reading the environment and options, customization of the interpreter session. All that defines what you see when you run python.

I know there's a good description of the whole process somewhere.

like image 26
TryPyPy Avatar answered Sep 24 '22 00:09

TryPyPy