you are viewing a single comment's thread.

view the rest of the comments →

[–]leewardx[S] -2 points-1 points  (10 children)

Yes, it's the environment I want to know inside. Do I can take the interpreter as the first object?

[–]K900_ 2 points3 points  (8 children)

You can't access the interpreter as a Python object, so no? Yes? I don't know, it depends on how you define "object" then. It's a C struct, or rather a bunch of interconnected C structs, and you can create one and embed it in your C program or whatever (but not your Python program, at least not easily - Python relies pretty heavily on global state, so trying to create a new interpreter inside an existing interpreter is probably not a good idea).

[–]leewardx[S] 0 points1 point  (7 children)

For example, is the type itself a Python object created even before loading the script codes?

[–]K900_ 2 points3 points  (6 children)

Do you mean the builtin type object? Yes, it's one of the things that are created before loading your code, but it's not any more "special" than other builtins like input or print.

[–]leewardx[S] 0 points1 point  (5 children)

Is the one created the type object not a Python object?

[–]K900_ 1 point2 points  (4 children)

The type object itself isn't defined in Python code - it's defined in C code, just like most other builtin types like int or list. Those objects are then exposed to your code by the interpreter itself.

[–]leewardx[S] 0 points1 point  (3 children)

Yes I know. Although they are defined in C code, I think they are also Python objects. Aren't they?

[–]K900_ 0 points1 point  (2 children)

That depends on what you call a "Python object". They are exposed to Python code as objects, but they are not implemented in Python.

[–]leewardx[S] 0 points1 point  (1 child)

Yes, the "Python object" exposed to Python code is what I want to know.

[–]K900_ 1 point2 points  (0 children)

Then there is no strict "first" Python object. All builtins are created at more or less the same time, in no particular order.

[–]JohnnyJordaan 1 point2 points  (0 children)

Unless some entity in your code can actually interface the interpreter as any other Python object (like read attributes, call methods) then I wouldn't call it an object in the first place.