Lesson 7 Python architecture

4 minutes
Share the link to this page
You need to have access to the item to view this lesson.
One-time Fee
List Price:  $99.99
You save:  $30
List Price:  €92.16
You save:  €27.65
List Price:  £78.48
You save:  £23.54
List Price:  CA$136.70
You save:  CA$41.01
List Price:  A$150.76
You save:  A$45.23
List Price:  S$134.99
You save:  S$40.50
List Price:  HK$780.84
You save:  HK$234.27
CHF 64.08
List Price:  CHF 91.55
You save:  CHF 27.46
NOK kr740.69
List Price:  NOK kr1,058.18
You save:  NOK kr317.48
DKK kr481.62
List Price:  DKK kr688.07
You save:  DKK kr206.44
List Price:  NZ$163.34
You save:  NZ$49
List Price:  د.إ367.26
You save:  د.إ110.19
List Price:  ৳11,714.86
You save:  ৳3,514.80
List Price:  ₹8,305.04
You save:  ₹2,491.76
List Price:  RM470.40
You save:  RM141.13
List Price:  ₦146,115.27
You save:  ₦43,838.96
List Price:  ₨27,783.57
You save:  ₨8,335.90
List Price:  ฿3,658.80
You save:  ฿1,097.75
List Price:  ₺3,220.97
You save:  ₺966.38
List Price:  B$516.65
You save:  B$155.01
List Price:  R1,841.76
You save:  R552.58
List Price:  Лв180.18
You save:  Лв54.05
List Price:  ₩136,656.33
You save:  ₩41,001
List Price:  ₪365.88
You save:  ₪109.77
List Price:  ₱5,819.86
You save:  ₱1,746.13
List Price:  ¥15,692.93
You save:  ¥4,708.35
List Price:  MX$1,669.81
You save:  MX$500.99
List Price:  QR364.18
You save:  QR109.26
List Price:  P1,356.93
You save:  P407.12
List Price:  KSh13,033.20
You save:  KSh3,910.35
List Price:  E£4,712.01
You save:  E£1,413.74
List Price:  ብር5,738.47
You save:  ብር1,721.71
List Price:  Kz84,827.41
You save:  Kz25,450.77
List Price:  CLP$90,653.93
You save:  CLP$27,198.90
List Price:  CN¥710.97
You save:  CN¥213.31
List Price:  RD$5,881.38
You save:  RD$1,764.59
List Price:  DA13,444.25
You save:  DA4,033.68
List Price:  FJ$226.74
You save:  FJ$68.02
List Price:  Q775.80
You save:  Q232.76
List Price:  GY$20,895.31
You save:  GY$6,269.22
ISK kr9,672.61
List Price:  ISK kr13,818.61
You save:  ISK kr4,146
List Price:  DH996.21
You save:  DH298.89
List Price:  L1,771.78
You save:  L531.58
List Price:  ден5,676.40
You save:  ден1,703.09
List Price:  MOP$803.71
You save:  MOP$241.13
List Price:  N$1,835.52
You save:  N$550.71
List Price:  C$3,675.86
You save:  C$1,102.87
List Price:  रु13,281.76
You save:  रु3,984.92
List Price:  S/373.37
You save:  S/112.02
List Price:  K388.13
You save:  K116.45
List Price:  SAR374.94
You save:  SAR112.49
List Price:  ZK2,665.60
You save:  ZK799.76
List Price:  L458.57
You save:  L137.58
List Price:  Kč2,271.01
You save:  Kč681.37
List Price:  Ft35,372.15
You save:  Ft10,612.70
SEK kr746.68
List Price:  SEK kr1,066.73
You save:  SEK kr320.05
List Price:  ARS$89,042.09
You save:  ARS$26,715.29
List Price:  Bs690.12
You save:  Bs207.05
List Price:  COP$386,435.76
You save:  COP$115,942.32
List Price:  ₡51,204.17
You save:  ₡15,362.78
List Price:  L2,468.08
You save:  L740.49
List Price:  ₲751,203.84
You save:  ₲225,383.69
List Price:  $U3,843.53
You save:  $U1,153.17
List Price:  zł391.99
You save:  zł117.60
Already have an account? Log In


Architecture of Python program. And module is a document that can be written on the disk as file under dash name, pi, such as file.pi. Organization of the different constitutes of a program. An independent module promotes code reuse. It also lets you partition that namespace. At the top level is the class.

This uses modules that can be connected with other modules to constitute the standard library model. To import from one input module imports, the entire module called module creates a new namespace that has the name of the module, form two. For module input, attribute one, attribute two, and so on. import the numerated attributes of the module module. The imported attributes are copied to the current namespace from three four Module import inputs, all the attributes of the module module. The imported attributes are copied to the current namespace example, x is equal to one, y is equal to one, comma two.

So we can input the attributes of two two, like example one. First we import the Module Two, two, then when we call it, we get the result of X or Y. Example two, by using from two to import x comma y. You can do the same thing. Input process, find the module file, you can find it in s by s path. compile the code.

This step produces a dot p y c file for all the imported modules, execute code to create objects and associate them with attributes. The module search is done by searching and current program directory paths in Python path directory. Have the standard library. The search continues until a file with the correct name is found. Be careful not to hide the standard modules with your own modules. The path attribute of the SBS module can be queried from a list of paths that will be explored by the module import process.

On my machine, it gives the five path of the Python installation files. the import process transforms the contents of a file into a namespace containing the set of attributes defined in the library. After importing a module foo, all the attributes x y Zed etc. After file to two p y will be called to two dot x to two dot y to two Zed and so on. By putting several files in the same directory, we create a group of modules or package. In Python, we specify a path to get a file by separating directory named with DOD For example, input dir dot mod.

For Python to recognize a directory as a package, it must contain a file name. Double underscore I nit name double underscore dot p y. Typically, this file contains initialization statements for the module group. The file may be empty, but it must still be present. Its content will be executed before importing the first module containing in the group. The group has its own namespace.

Module groups are used to group together modules that work together. And also to avoid file name conflicts to modules with the same name can coexist, provided they belong to different groups. Now an exercise we have created the folder c colon dash text, then the utils package in this folder. In this package, we create a file func dot p y With a function get underscore me underscore your underscore name, def give underscore me underscore your underscore name colon, return hi tech, you can try using our Give me your name function from another module. Variable double underscore name double underscore. This variable double underscore name double underscore is automatically defined for each module file.

If the module is executed directly by the interpreter, then this variable takes the value double underscore main double underscore. On the contrary, if the module is imported, then the variable takes as the value of the module name

Sign Up


Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.