Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 13865ee

Browse filesBrowse files
committed
Fix minor spelling, grammar, and consistency errors in the Modules section.
1 parent 947bdef commit 13865ee
Copy full SHA for 13865ee

File tree

Expand file treeCollapse file tree

1 file changed

+23
-23
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-23
lines changed

‎docs/writing/structure.rst

Copy file name to clipboardExpand all lines: docs/writing/structure.rst
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,53 +60,53 @@ include:
6060
Modules
6161
-------
6262

63-
Python modules are one of the main abstraction layer available and probably the
63+
Python modules are one of the main abstraction layers available and probably the
6464
most natural one. Abstraction layers allow separating code into parts holding
65-
related data and functionalities.
65+
related data and functionality.
6666

6767
For example, a layer of a project can handle interfacing with user actions,
6868
while another would handle low-level manipulation of data. The most natural way
69-
to separate these two layers is to regroup all interfacing functionalities
69+
to separate these two layers is to regroup all interfacing functionality
7070
in one file, and all low-level operations in another file. In this case,
71-
the interface file need to import the low-level file. This is done with the
71+
the interface file needs to import the low-level file. This is done with the
7272
`import` and `from ... import` statements.
7373

74-
As soon as you use `import` statements you use modules, either builtin modules
75-
such as `os` and `sys`, or third-party modules you have installed in your
76-
environment, or project's internal modules.
74+
As soon as you use `import` statements you use modules. These can be either built-in
75+
modules such as `os` and `sys`, third-party modules you have installed in your
76+
environment, or your project's internal modules.
7777

7878
Nothing special is required for a Python file to be a module, but the import
79-
mechanism need to be understood in order to use this concept properly and avoid
79+
mechanism needs to be understood in order to use this concept properly and avoid
8080
some issues.
8181

8282
Concretely, the `import modu` statement will look for the proper file, which is
8383
`modu.py` in the same directory as the caller if it exists. If it is not
84-
found, the Python interpreter with search for `modu.py` in the "path"
84+
found, the Python interpreter will search for `modu.py` in the "path"
8585
recursively and raise an ImportError exception if it is not found.
8686

8787
Once `modu.py` is found, the Python interpreter will execute the module in an
8888
isolated scope. Any top-level statement in `modu.py` will be executed,
89-
including other imports if any. Function and classes definitions are stored in
89+
including other imports if any. Function and class definitions are stored in
9090
the module's dictionary.
9191

92-
Then modules variables, functions and classes will be available to the caller
92+
Then, the module's variables, functions, and classes will be available to the caller
9393
through the module's namespace, a central concept in programming that is
9494
particularly helpful and powerful in Python.
9595

96-
In many languages, a `include file` directive is used by the preprocessor to
97-
take all code found in the file and 'copy' it in the caller's code. It is
96+
In many languages, an `include file` directive is used by the preprocessor to
97+
take all code found in the file and 'copy' it into the caller's code. It is
9898
different in Python: the included code is isolated in a module namespace, which
9999
means that you generally don't have to worry that the included code could have
100-
unwanted effect, eg override an existing function with the same name.
100+
unwanted effects, e.g. override an existing function with the same name.
101101

102102
It is possible to simulate the more standard behavior by using a special syntax
103103
of the import statement: `from modu import *`. This is generally considered bad
104-
practice, **using import * makes code harder to read and dependencies less
105-
compartimented**.
104+
practice. **Using `import *` makes code harder to read and makes dependencies less
105+
compartmentalized**.
106106

107107
Using `from modu import func` is a way to pinpoint the function you want to
108-
import and put it is the global namespace. While much less harmful than `import
109-
*` because it shows explicitely what is imported in the global namespace, it's
108+
import and put it in the global namespace. While much less harmful than `import
109+
*` because it shows explicitly what is imported in the global namespace, its
110110
advantage over a simpler `import modu` is only that it will save some typing.
111111

112112
**Very bad**
@@ -134,13 +134,13 @@ advantage over a simpler `import modu` is only that it will save some typing.
134134
[...]
135135
x = modu.sqrt(4) # sqrt is visibly part of modu's namespace
136136
137-
As said in the section about style, readability is one of the main feature of
137+
As said in the section about style, readability is one of the main features of
138138
Python. Readability means to avoid useless boilerplate text and clutter,
139139
therefore some efforts are spent trying to achieve a certain level of brevity.
140-
But terseness and obscurity are the limits where brevity should stop: being
141-
able to tell immediately from where comes a class or a function, as in the
142-
`modu.func` idiom, improves greatly code readability and understandability in
143-
most cases but the simplest single file projects.
140+
But terseness and obscurity are the limits where brevity should stop. Being
141+
able to tell immediately where a class or function comes from, as in the
142+
`modu.func` idiom, greatly improves code readability and understandability in
143+
all but the simplest single file projects.
144144

145145

146146
Packages

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.