@@ -290,18 +290,18 @@ Dynamic typing
290290Python is said to be dynamically typed, which means that variables
291291do not have a fixed type. In fact, in Python, variables are very
292292different 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
295295to objects. It is therefore possible for the variable 'a' to be set to
296296the 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
300300named '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
302302been 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
330329It is better to use different names even for things that are related,
331330when 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
342341will 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
351350in grasping the concept of mutable and immutable types.
352351
353352Mutable and immutable types
0 commit comments