Python naming request

When I speak,

>>>radius = 2

Inside, a new object by name radiusis created in the global frame of the module __main__, and this object has a class int. A reference variable is also created by a name radiusthat points to this object.

When I speak,

>>>from math import sqrt

Inside, a new object by name sqrtis created in the global frame of the module __main__, and this object has a class function. A reference variable is also created by a name sqrtthat points to this type object function.

when I speak,

>>>def square(x):
         return mul(x,x)

Inside, a new object by name squareis created in the global frame of the module __main__, and this object has a class function. A reference variable is also created by a name squarethat points to this type object function.

My question is:

Do I understand correctly?

or

Whether objects are created radiusand sqrtand the squareoutside __main__of the module frame and the global reference variable ( radius sqrt square) sitting within the __main__module frame a global point of these objects?

CS61A Fall 2012, , , python.

program environment in memory

+4
2

, , , . 200 OK , - , , . ( , ), .

, , . - - , - sys.modules dict. , , ; .

+2

radius __main__, int.

() . radius = 2 ...

  • 2, ( CPython , ),
  • radius (), .

, import import . math , . sqrt , math. , , , . , . , .

def , , .

0

Source: https://habr.com/ru/post/1547005/


All Articles