How do the points in python?

Do I understand correctly that when I see this design:
pygame.display.set_mode((800, 600))

It implies this:
class Person():
 b = lambda x: x**2

class Student():
 a = Person

print(Student.a.b(12)) # 144


Do not understand that in this case, it means pygame, and display set_mode((800, 600)) and how it works.
April 4th 20 at 00:43
3 answers
April 4th 20 at 00:45
Solution
Analyze pygame.display.set_mode((800, 600)):
  • pygame is the name of the module. Modules can contain classes, functions, variables. You can read for example here
  • display (pygame.display) - class of module pygame. Normal class in some module file. Like your example about the Person and Student
  • set_mode (pygame.display.set_mode) function in this class

For example, create a file test.py:
class Person(): # analogue display
 b = lambda x: x**2
 def count(a): # analogue set_mode
 return 3 * a

Then the following construction is correct (for any file in the same directory):
import test
print( test.Person.count(2) ) # will print 6


So it's not working as you suggested.
set_mode is a function, not a class function in the class display.
April 4th 20 at 00:47
When the module is imported, Python executes all the code in it. When importing a package, Python executes the code in the package file __init__.py, if available. All of the objects defined in a module or __init__.py become available importing.
April 4th 20 at 00:49
Entry pygame.display.set_mode((800, 600))
means call function set_mode in as argument a tuple (800, 600). Point how would asking the path of this function (the object to which it belongs).

Analogy in Windows is:
imagine that you run the program ะก:\pygame\display\set_mode.exe c dimension (800, 600)
In Python you have dots instead of backslashes.

Jigsaw:
what is the record ' '.join(('one', 'two', 'three'))
?

Find more questions by tags Python