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 a27f9d2

Browse filesBrowse files
committed
Fix minor spelling, grammar, and consistency errors in the Dynamic Typing section.
1 parent 2dd87be commit a27f9d2
Copy full SHA for a27f9d2

File tree

Expand file treeCollapse file tree

1 file changed

+16
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-17
lines changed

‎docs/writing/structure.rst

Copy file name to clipboardExpand all lines: docs/writing/structure.rst
+16-17Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,18 @@ Dynamic typing
290290
Python is said to be dynamically typed, which means that variables
291291
do not have a fixed type. In fact, in Python, variables are very
292292
different from what they are in many other languages, specifically
293-
strongly-typed languages: variables are not a segment of the computer's
294-
memory where some value ir written, they are 'tags' or 'names' pointing
293+
strongly-typed languages. Variables are not a segment of the computer's
294+
memory where some value is written, they are 'tags' or 'names' pointing
295295
to objects. It is therefore possible for the variable 'a' to be set to
296296
the value 1, then to the value 'a string', then to a function.
297297

298-
The dynanic typing of Python is often considered as a weakness, and indeed
299-
it can lead to complexities and to hard-to-debug code, where something
298+
The dynamic typing of Python is often considered to be a weakness, and indeed
299+
it can lead to complexities and hard-to-debug code. Something
300300
named 'a' can be set to many different things, and the developer or the
301-
maintainer need to track this name in the code to make sure it has not
301+
maintainer needs to track this name in the code to make sure it has not
302302
been set to a completely unrelated object.
303303

304-
Some guidelines allow to avoid this issue:
304+
Some guidelines help to avoid this issue:
305305

306306
- Avoid using variables for different things.
307307

@@ -323,9 +323,8 @@ Some guidelines allow to avoid this issue:
323323
def func()
324324
pass # Do something
325325
326-
Using short functions or methods helps writing good code for many
327-
reasons, one being that their local scope is clearer, and the risk
328-
of using the same name for two unrelated things is lowered.
326+
Using short functions or methods helps reduce the risk
327+
of using the same name for two unrelated things.
329328

330329
It is better to use different names even for things that are related,
331330
when they have a different type:
@@ -340,14 +339,14 @@ when they have a different type:
340339
341340
There is no efficiency gain when reusing names: the assignments
342341
will have to create new objects anyway. However, when the complexity
343-
grows are each assignment are separated by other lines of code, including
344-
'if' branches and loops, it becomes harder to acertain which type is the
345-
variable at hand.
346-
347-
Some coding practices, like functional programming, even recommend to never re-assign a variable, which
348-
is done in Java with the keyword final. Python do not have such a keyword,
349-
and it would be against its philosophy anyway, but it may be a good
350-
discipline to avoid setting more than once any variable, and it helps
342+
grows and each assignment is separated by other lines of code, including
343+
'if' branches and loops, it becomes harder to ascertain what a given
344+
variable's type is.
345+
346+
Some coding practices, like functional programming, recommend never reassigning a variable.
347+
In Java this is done with the `final` keyword. Python does not have a `final` keyword
348+
and it would be against its philosophy anyway. However, it may be a good
349+
discipline to avoid assigning to a variable more than once, and it helps
351350
in grasping the concept of mutable and immutable types.
352351

353352
Mutable and immutable types

0 commit comments

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