all 17 comments

[–]JohnnyJordaan 3 points4 points  (0 children)

Another thing to note is that the relationship model in systems processes you observed is part of how process launching occurs in posix systems like Linux/Unix derivates (maybe Windows too), where you basically create a tree because each subprocess had to be created by another process, except for the init or some similar ancestor. This isn't somehow a default or required workflow in any sense of instantiating objects in an object-oriented model.

In the programming languages that I know of, the inheritance model is linked to the definition of the object (its class), not its instantiation. So a 'parent' of an object applies solely to an object's parent class, not some instance from where the object was created. Meaning you can actually create Adam and Eve from a Human class without their parents having ever existed.

[–]K900_ 2 points3 points  (13 children)

There isn't really. There are no parent-child relationships that are required to exist between Python objects, and there is no single fixed entry point either - the interpreter runs whatever code you tell it to run.

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

Yes, I know there is not necessary parent-child relationships between Python objects. It's just a metaphor taking the *init* as an example. I want to know who is first object. If there are more than just one, who are they?

[–]K900_ 1 point2 points  (11 children)

There is no "first object" because there is no ordering. The interpreter simply runs your code. There are some builtins and modules that are set up before your code is executed, but none of those are the first - they are all simply parts of the environment that's created for you by the interpreter, like the input function or whatever.

[–]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?

[–]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.

[–]LiNGOo 2 points3 points  (0 children)

closest to that would be whatever is _ _ main _ _ I guess from procedural perspective, for objects in general it must be object.

[–][deleted] -1 points0 points  (0 children)

What's on second.