From eb79ed95d65e837b50575808e40536a83b090a49 Mon Sep 17 00:00:00 2001 From: Beau Date: Sat, 16 Jul 2016 13:09:05 -0500 Subject: [PATCH 01/14] Cleaned up the english a bit --- Chapter1/Chapter1_Introduction.ipynb | 32 +++++++++--------- Chapter2/Chapter2_Syntax.ipynb | 12 +++---- Chapter3/Chapter3_Control_flow.ipynb | 2 +- Chapter4/Chapter4_Loops.ipynb | 4 +-- Chapter5/Chapter5_Types.ipynb | 48 +++++++++++++-------------- Chapter6/Chapter6_Functions.ipynb | 18 +++++----- Chapter7/Chapter7_Documentation.ipynb | 10 +++--- ExercisesI/ExercisesI.ipynb | 14 ++++---- 8 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Chapter1/Chapter1_Introduction.ipynb b/Chapter1/Chapter1_Introduction.ipynb index a2eefb9..ffa0e50 100644 --- a/Chapter1/Chapter1_Introduction.ipynb +++ b/Chapter1/Chapter1_Introduction.ipynb @@ -28,13 +28,13 @@ "---------------\n", "Python has a clear and concise syntax, which favors the readability of source code, and makes the language more productive.\n", "\n", - "The language includes several high-level structures (lists, dictionaries, date / time, complex numbers and others) and a vast collection of modules ready for use, plus third-party frameworks that can be added. It also has features found in other modern languages, such as generators, introspection, persistence, metaclasses and unity tests. Multiparadigm, the language supports modular, functional, and object-oriented programming. Even the basic types in Python are objects. The language is interpreted through bytecode by the Python virtual machine, making the code portable. This makes it possible to build applications on one platform and run on other systems or run direct from the source.\n", + "The language includes several high-level structures (lists, dictionaries, date / time, complex numbers and others) and a vast collection of modules ready for use, plus third-party frameworks that can be added. It also has features found in other modern languages, such as generators, introspection, persistence, metaclasses and unity tests. Multiparadigm, the language supports modular, functional, and object-oriented programming. Even the basic types in Python are objects. The language is interpreted through bytecode by the Python virtual machine, making the code portable. This makes it possible to build applications on one platform and run them on other systems or direct from the source.\n", "\n", - "Python is an open source software (with license compatible with the *General Public License (GPL)*, but less restrictive, allowing Python to be even incorporated into proprietary products). The language specification is maintained by [Python Software Foundation](http://www.python.org/psf/) (PSF).\n", + "Python is open source software (with license compatible with the *General Public License (GPL)*, but less restrictive, allowing Python to be even incorporated into proprietary products). The language specification is maintained by the [Python Software Foundation](http://www.python.org/psf/) (PSF).\n", "\n", - "Besides being used as the main language in the development of systems, Python is also used as a *script* language in various software, enabling you to automate tasks and add new features, among them: LibreOffice.org, PostgreSQL, Blender, GIMP and Inkscape.\n", + "Besides being used as the main language in the development of systems, Python is also used as a *scripting* language in various pieces of software, enabling you to automate tasks and add new features, among them: LibreOffice.org, PostgreSQL, Blender, GIMP and Inkscape.\n", "\n", - "It is possible to integrate Python with other languages such as C and Fortran languages. In general terms, the language has many similarities with other dynamic languages such as Perl and Ruby.\n", + "It is possible to integrate Python with other languages such as C and Fortran. In general terms, the language has many similarities with other dynamic languages such as Perl and Ruby.\n", "\n", "History\n", "---------\n", @@ -102,7 +102,7 @@ "\n", "`python apl.py`\n", "\n", - "Thus `apl.py` will run. On Windows, the file extensions\u00a0\".py\", \". pyw\", \". pyc\" and \". pyo\" are associated with the Python automatically during installation, then just click on the file to run. The \". pyw\" files run with an alternate version of the interpreter that does not open the console window.\n", + "Thus `apl.py` will run. On Windows, the file extensions\u00a0\".py\", \". pyw\", \". pyc\" and \". pyo\" are associated with Python automatically during installation, so just click a the file to run it. The \". pyw\" files run with an alternate version of the interpreter that does not open the console window.\n", "\n", "Dynamic Typing\n", "----------------\n", @@ -116,9 +116,9 @@ "\n", "![Compilation, interpretation and packing](files/bpyfd_diags1.png)\n", "\n", - "By default, the parser compiles the code and stores the bytecode on disk, so the next time you run it, there is no need to recompile the program, reducing the load time on execution. If the source files are changed, the interpreter will be responsible for regenerating the bytecode automatically, even using the *interactive shell*. When a program or a module is invoked, the interpreter performs the analysis of the code, converting to symbols, compiles (if there is no updated bytecode on disk) and runs it on Python virtual machine.\n", + "By default, the parser compiles the code and stores the bytecode on disk, so the next time you run it, there is no need to recompile the program, reducing the load time of execution. If the source files are changed, the interpreter will be responsible for regenerating the bytecode automatically, even using the *interactive shell*. When a program or a module is invoked, the interpreter performs the analysis of the code, converts to symbols, compiles (if there is no updated bytecode on disk) and runs it in the Python virtual machine.\n", "\n", - "The bytecode is stored in files with extension \". pyc\" (normal bytecode) or \". pyo\" (optimized bytecode). The bytecode can also be packaged along with an executable interpreter, to facilitate the distribution of the application, eliminating the need to install Python on each computer.\n", + "The bytecode is stored in files with the extension \". pyc\" (normal bytecode) or \". pyo\" (optimized bytecode). The bytecode can also be packaged along with an executable interpreter, to facilitate the distribution of the application, eliminating the need to install Python on each computer.\n", "\n", "Interactive Mode\n", "----------------\n", @@ -135,16 +135,16 @@ "\n", "On Windows, the interactive mode is also available via the icon \"Python (command line)\".\n", "\n", - "The interactive mode is a distinguishing feature of the language, as it is possible to test and modify code snippets code before inclusion in programs, to extract and convert data or even analyze the state of the objects in memory, among other possibilities.\n", + "The interactive mode is a distinguishing feature of the language, as it is possible to test and modify code snippets before inclusion in programs, to extract and convert data or even analyze the state of the objects in memory, among other possibilities.\n", "\n", - "Besides traditional interactive mode of Python, there are other programs that act as alternatives to more sophisticated interfaces (such as PyCrust):\n", + "Besides the traditional interactive mode of Python, there are other programs that act as alternatives to more sophisticated interfaces (such as PyCrust):\n", "![PyCrust](files/pycrust.png)\n", "\n", "Tools\n", "-----------\n", "There are many development tools for Python, such as IDEs, editors and shells (that take advantage of the interactive capabilities of Python).\n", "\n", - "*Integrated Development Environments* (IDEs) are software packages that integrate various development tools in an environment consistent with the goal of increasing developer productivity. Generally, IDEs include such features as syntax highlight (colorized source code according to the syntax of the language), source browsers, integrated shell and *code completion* (the editor presents possible ways to complete the text it can identify while typing).\n", + "*Integrated Development Environments* (IDEs) are software packages that integrate various development tools in an environment consistent with the goal of increasing developer productivity. Generally, IDEs include such features as syntax highlighting (colorized source code according to the syntax of the language), source browsers, integrated shell and *code completion* (the editor presents possible ways to complete the text it can identify while typing).\n", "Among Python IDEs, there are:\n", "\n", "+ [PyScripter](http://code.google.com/p/pyscripter/)\n", @@ -156,14 +156,14 @@ "\n", "There are also text editors specialized in programming code, which have features like syntax colorization, export to other formats and convert text encoding.\n", "\n", - "These editors support multiple programming languages\u200b\u200b, among them Python:\n", + "These editors support multiple programming languages\u200b\u200b, Python among them:\n", "\n", "+ [SciTE](http://www.scintilla.org/SciTE.html)\n", "+ [Notepad++](http://notepad-plus.sourceforge.net/br/site.htm)\n", "\n", "*Shell* is the name given to interactive environments for executing commands that can be used to test small pieces of code and for activities like data crunching (extraction of information of interest in masses of data and subsequent translation to other formats).\n", "\n", - "Beyond standard Python *Shell*, there are others available:\n", + "Beyond the standard Python *Shell*, there are others available:\n", "\n", "+ PyCrust \n", "+ IPython \n", @@ -177,7 +177,7 @@ "\n", "*Frameworks* are collections of software components (libraries, utilities and others) that have been designed to be used by other systems.\n", "\n", - "Some of the most known *frameworks* availbles:\n", + "Some of the most known *frameworks* availble are:\n", "\n", "+ Web: Django, TurboGears, Zope and web2py.\n", "+ Graphic interface: wxPython, PyGTK and PyQt.\n", @@ -189,9 +189,9 @@ "\n", "Culture\n", "-------\n", - "The name Python was taken by Guido van Rossum from british TV program *Monty Python Flying Circus*, and there are many references to the show in language documentation. For instance, Python oficial package repository was called Cheese Shop, the name of one of the frames of the programa. Currently, the repository name is [Python Package Index](http://pypi.python.org/pypi) (PYPI).\n", + "The name Python was taken by Guido van Rossum from british TV program *Monty Python's Flying Circus*, and there are many references to the show in its documentation. For instance, Python's oficial package repository was called Cheese Shop, the name of one of the frames of the program. Currently, the repository name is [Python Package Index](http://pypi.python.org/pypi) (PYPI).\n", "\n", - "The goals of the project were summarized by Tim Peters in a text called *Zen of Python* , which is available in Python itself using the command:" + "The goals of the project was summarized by Tim Peters in a text called *Zen of Python*, which is available in Python itself using the command:" ] }, { @@ -241,7 +241,7 @@ "\n", "Proposals for improving the language are called PEPs *(Python Enhancement Proposals)*, which also serve as a reference for new features to be implemented in the language.\n", "\n", - "In addition to the official website, other good source of information about language is: [Python Cookbook](http://aspn.activestate.com/ASPN/Python/Cookbook/) site that stores \"recipes\": small portions of code to accomplish specific tasks." + "In addition to the official website, other good source of information about the language are: [Python Cookbook](http://aspn.activestate.com/ASPN/Python/Cookbook/) site that stores \"recipes\": small portions of code to accomplish specific tasks." ] }, { diff --git a/Chapter2/Chapter2_Syntax.ipynb b/Chapter2/Chapter2_Syntax.ipynb index ae9d5b2..ee84708 100644 --- a/Chapter2/Chapter2_Syntax.ipynb +++ b/Chapter2/Chapter2_Syntax.ipynb @@ -19,13 +19,13 @@ "Chapter 2: Syntax\n", "===================\n", "___________________\n", - "A program written in Python consists of lines, which may continue in the following lines, by using the backslash character (`\\`) at the end of the line or parentheses, brackets or braces in expressions that use such characters.\n", + "A program written in Python consists of lines, which may continue on the following lines, by using the backslash character (`\\`) at the end of the line or parentheses, brackets or braces in expressions that use such characters.\n", "\n", "The character `#` marks the beginning of a comment. Any text after the `#` will be ignored until the end of the line, with the exception of functional comments.\n", "\n", - "Functional comments are used for:\n", + "Functional comments are used to:\n", "\n", - "+ change the encoding of the source file of the program by adding a comment with the text `# - * - coding: - # -` at the beginning of the file, in which ` ` is the file encoding (usually latin1 or utf-8). Change encoding is required to support characters that are not part of the English language, in the source code of the program.\n", + "+ change the encoding of the source file of the program by adding a comment with the text `# - * - coding: - # -` at the beginning of the file, in which ` ` is the file encoding (usually latin1 or utf-8). Changing encoding is required to support characters that are not part of the English language, in the source code of the program.\n", "+ define the interpreter that will be used to run the program on UNIX systems, through a comment starting with `#!` at the beginning of the file, which indicates the path to the interpreter (usually the comment line will be something like` #! / usr / bin / env python` ).\n", "\n", "Example of functional comments:" @@ -96,15 +96,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The command `print` inserts spaces between expressions that are received as a parameter, and a newline character at the end, unless he receives a comma at the end of the parameter list.\n", + "The command `print` inserts spaces between expressions that are received as a parameter, and a newline character at the end, unless it receives a comma at the end of the parameter list.\n", "\n", "Blocks\n", "------\n", - "In Python, code blocks are defined by the use of indentation, which should be constant in the code block, but it is considered good practice to maintain consistency throughout the project and avoid mixing tabs and spaces.\n", + "In Python, code blocks are defined by the use of indentation, which should be constant in the code block, but it is considered good practice to maintain consistency throughout the project and avoid mixing tabs and spaces.\n", "\n", "The line before the block always ends with a colon (:) and is a control structure of the language or a statement of a new structure (a function, for example).\n", "\n", - "![Estrutura de um programa](files/bpyfd_diags2.png)\n", + "![Program structure](files/bpyfd_diags2.png)\n", "\n", "Example:" ] diff --git a/Chapter3/Chapter3_Control_flow.ipynb b/Chapter3/Chapter3_Control_flow.ipynb index 22db97d..5026717 100644 --- a/Chapter3/Chapter3_Control_flow.ipynb +++ b/Chapter3/Chapter3_Control_flow.ipynb @@ -38,7 +38,7 @@ "+ ``: sequence of command lines.\n", "+ The clauses `elif` and `else` are optional and\u00a0 several `elifs` for the `if` may be used but only\u00a0 one `else` at the end.\n", "+ Parentheses are only required to avoid ambiguity.\n", - "Exemplo:" + "Example:" ] }, { diff --git a/Chapter4/Chapter4_Loops.ipynb b/Chapter4/Chapter4_Loops.ipynb index 1b0c942..a09605c 100644 --- a/Chapter4/Chapter4_Loops.ipynb +++ b/Chapter4/Chapter4_Loops.ipynb @@ -23,11 +23,11 @@ "\n", "For\n", "---\n", - "It is the repetition structure most often used in the Python. The statement accepts not only static\u00a0sequences, but also sequences generated by iterators. Iterators are structures that allow iterations, ie access to items of a collection of elements, sequentially.\n", + "It is the repetition structure most often used in Python. The statement accepts not only static\u00a0sequences, but also sequences generated by iterators. Iterators are structures that allow iterations, i.e. access to items of a collection of elements, sequentially.\n", "\n", "![Loop Example](files/bpyfd_diags3.png)\n", "\n", - "During the execution of a *for* loop , the reference points to an element in the sequence. At each iteration, the reference is updated, in order to the *for* code block to process the corresponding element.\n", + "During the execution of a *for* loop, the reference points to an element in the sequence. At each iteration, the reference is updated, in order for the *for* code block to process the corresponding element.\n", "\n", "The clause *break*\u00a0stops the loop and *continue* passes it to the next iteration. The code inside the `else` is executed at the end of the loop, except if the loop has been interrupted by *break*.\n", "\n", diff --git a/Chapter5/Chapter5_Types.ipynb b/Chapter5/Chapter5_Types.ipynb index ae43b41..165394c 100644 --- a/Chapter5/Chapter5_Types.ipynb +++ b/Chapter5/Chapter5_Types.ipynb @@ -21,9 +21,9 @@ "_____________________________\n", "Variables in the Python interpreter are created by assignment and destroyed by the garbage collector, when there are no more references to them.\n", "\n", - "Variable names must start with letter or underscore (`_`) and be followed by letters, digits or underscores (`_`).\u00a0 Uppercase and lowercase letters are considered different.\n", + "Variable names must start with a letter or underscore (`_`) and be followed by letters, digits or underscores (`_`).\u00a0 Uppercase and lowercase letters are considered different.\n", "\n", - "There are several pre-defined simple types of data in the Python, such as:\n", + "There are several pre-defined simple types of data in Python, such as:\n", "\n", "+ Numbers (integer, real, complex, ... )\n", "+ Text\n", @@ -41,7 +41,7 @@ "\n", "In Python, variable names are references that can be changed at execution time.\n", "\n", - "The most common types and routines are implemented in the form of *builtins*, ie, they are always available at runtime, without the need to import any library.\n", + "The most common types and routines are implemented in the form of *builtins*, i.e. they are always available at runtime, without the need to import any library.\n", "\n", "Numbers\n", "-------\n", @@ -117,7 +117,7 @@ "+ Division (/): between two integers the result is equal to the integer division. In other cases, the result is real.\n", "+ Integer Division (//): the result is truncated to the next lower integer, even when applied to real numbers, but in this case the result type is real too.\n", "+ Module (%): returns the remainder of the division.\n", - "+ Power (**): can be used to calculate the root, through fractional exponents (eg `100 ** 0.5`).\n", + "+ Power (\*\*): can be used to calculate the root, through fractional exponents (eg `100 \*\* 0.5`).\n", "+ Positive (+)\n", "+ Negative (-)\n", "\n", @@ -145,7 +145,7 @@ "\n", "Text\n", "-----\n", - "The *strings* are Python *builtins* for handling text. As they are immutable, you can not add, remove or change any character in a *string*. To perform these operations, Python needs to create a new *string*.\n", + "*Strings* are Python *builtins* for handling text. As they are immutable, you can not add, remove or change any character in a *string*. To perform these operations, Python needs to create a new *string*.\n", "\n", "Types:\n", "\n", @@ -154,10 +154,10 @@ "\n", "The standard *string* can be converted to *unicode* by using the function `unicode()`.\n", "\n", - "String Inicialization can be made:\n", + "String initializations can be made:\n", "\n", "+ With single or double quotes.\n", - "+ In several consecutive lines, provided that it done between three single or double quotes.\n", + "+ On several consecutive lines, provided that it's between three single or double quotes.\n", "+ Without expansion characters (example: `s = r '\\ n'`, where `s` will contain the characters `\\` and `n`).\n", "\n", "String Operations:" @@ -170,7 +170,7 @@ "s = 'Camel'\n", "\n", "# Concatenation\n", - "print 'The ' + s + ' run away!'\n", + "print 'The ' + s + ' ran away!'\n", "\n", "# Interpolation\n", "print 'Size of %s => %d' % (s, len(s))\n", @@ -259,7 +259,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Since version 2.6, is available in addition to interpolation operator `%`, the string method and function `format()`.\n", + "Since version 2.6, in addition to interpolation operator `%`, the string method and function `format()` is available.\n", "Examples:" ] }, @@ -430,7 +430,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "It is possible to use *mutable* strings in the Python through UserString *module*, which defines the *MutableString* type" + "It is possible to use *mutable* strings in Python through the UserString *module*, which defines the *MutableString* type" ] }, { @@ -462,7 +462,7 @@ "metadata": {}, "source": [ "Mutable *Strings* are less efficient than immutable *strings*, as they are more complex (in terms of the structure), which is reflected in increased consumption of resources (CPU and memory).\n", - "The *unicode* strings can converted to conventional strings through the `decode()` method and the reverse path can be done by the method `encode()`.\n", + "The *unicode* strings can be converted to conventional strings through the `decode()` method and the reverse path can be done by the method `encode()`.\n", "Example:" ] }, @@ -506,7 +506,7 @@ "------\n", "Lists are collections of heterogeneous objects, which can be of any type, including other lists.\n", "\n", - "Lists in the Python are mutable and can be changed at any time. Lists can be sliced \u200b\u200bin the same way that the *strings*, but as the lists are mutable, it is possible to make assignments to the list items.\n", + "Lists in the Python are mutable and can be changed at any time. Lists can be sliced \u200b\u200bin the same way as *strings*, but as the lists are mutable, it is possible to make assignments to the list items.\n", "\n", "Syntax:\n", "\n", @@ -573,7 +573,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The function `enumerate()` returns a tuple of two elements in each iteration: a sequence number an item from the corresponding sequence.\n", + "The function `enumerate()` returns a tuple of two elements in each iteration: a sequence number and an item from the corresponding sequence.\n", "\n", "The list has a `pop()` method that helps the implementation of queues and stacks:" ] @@ -628,7 +628,7 @@ "\n", "Tuples\n", "------\n", - "Similar to lists, but immutable: its not possible to append, delete or make assignments to the items.\n", + "Similar to lists, but immutable: it's not possible to append, delete or make assignments to the items.\n", "\n", "Syntax:\n", "\n", @@ -666,11 +666,11 @@ " TypeError: object does not support item assignment\n", " >>>\n", "\n", - "Tuples are more efficient than conventional lists, as they consume less computing resources (memory)\u00a0because they are simpler structures the same way *immutable* strings are in relation to the *mutable* strings.\n", + "Tuples are more efficient than conventional lists, as they consume less computing resources (memory)\u00a0because they are simpler structures the same way *immutable* strings are in relation to *mutable* strings.\n", "\n", "Other types of sequences\n", "--------------------------\n", - "Python provides also in the *builtins*:\n", + "Also in the *builtins*, Python provides:\n", "\n", "+ *set*: mutable sequence univocal (without repetitions) unordered.\n", "+ *frozenset*: immutable sequence univocal unordered.\n", @@ -736,13 +736,13 @@ "source": [ "When one list is converted to a *set*, the repetitions are discarded.\n", "\n", - "In version 2.6, it is also available a *builtin* type for mutable characters list, called *bytearray*.\n", + "In version 2.6, a *builtin* type for mutable characters list, called *bytearray* is also available.\n", "\n", "Dictionaries\n", "-----------\n", "A dictionary is a list of associations composed by a unique key and corresponding structures. Dictionaries are mutable, like lists.\n", "\n", - "The key must be an immutable type, usually strings, but can also be tuples or numeric types. On the other hand the items of dictionaries can be either mutable as immutable. The Python dictionary provides no guarantee that the keys are ordered.\n", + "The key must be an immutable type, usually strings, but can also be tuples or numeric types. On the other hand the items of dictionaries can be either mutable or immutable. The Python dictionary provides no guarantee that the keys are ordered.\n", "\n", "Syntax:\n", "\n", @@ -752,7 +752,7 @@ "\n", "![Structure of a dictionary](files/bpyfd_diags5.png)\n", "\n", - "Example of dictionary:\n", + "Example of a dictionary:\n", "\n", " dic = {'name': 'Shirley Manson', 'band': 'Garbage'}\n", "\n", @@ -764,11 +764,11 @@ "\n", " dic['album'] = 'Version 2.0'\n", "\n", - "Removing one elemento from dictionary:\n", + "Removing one elemento from a dictionary:\n", "\n", " del dic['album']\n", "\n", - "Getting the itens, keys and values:\n", + "Getting the items, keys and values:\n", "\n", " items = dic.items()\n", " keys = dic.keys()\n", @@ -930,11 +930,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The sparse matrix is a good solution for processing structures in which most of the items remain empty as spreadsheets, for example.\n", + "The sparse matrix is a good solution for processing structures in which most of the items remain empty, like spreadsheets for example.\n", "\n", "True, False and Null\n", "------------------------\n", - "In Python, the boolean type (*bool*) is a specialization of the integer type (*int*). The *True* value is equal to 1, while the *False* values is equal to zero.\n", + "In Python, the boolean type (*bool*) is a specialization of the integer type (*int*). The *True* value is equal to 1, while the *False* value is equal to zero.\n", "\n", "The following values \u200b\u200bare considered false:\n", "\n", @@ -1009,7 +1009,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Besides boolean operators, thre are the functions `all()`, which returns true when all of the items in the sequence passed as parameter are true, and `any()`, which returns true if any item is true." + "Besides boolean operators, there are the functions `all()`, which returns true when all of the items in the sequence passed as parameters are true, and `any()`, which returns true if any item is true." ] }, { diff --git a/Chapter6/Chapter6_Functions.ipynb b/Chapter6/Chapter6_Functions.ipynb index 72ce913..8644942 100644 --- a/Chapter6/Chapter6_Functions.ipynb +++ b/Chapter6/Chapter6_Functions.ipynb @@ -21,16 +21,16 @@ "_____________________________\n", "Functions are blocks of code identified by a name, which can receive predetermined parameters.\n", "\n", - "In Python, the functions:\n", + "In Python, functions:\n", "\n", "+ Can return objects or not.\n", - "+ Accepted *Doc Strings*.\n", - "+ Accepts optional parameters (with *defaults* ). If no parameter is passed, it will be equal to the *default* defined in the function.\n", + "+ Accept *Doc Strings*.\n", + "+ Accept optional parameters (with *defaults* ). If no parameter is passed, it will be equal to the *default* defined in the function.\n", "+ Accepts parameters to be passed by name. In this case, the order in which the parameters were passed does not matter.\n", "+ Have their own namespace (local scope), and therefore may obscure definitions of global scope.\n", "+ Can have their properties changed (usually by decorators).\n", "\n", - "*Doc Strings* are strings that are attached to a\u00a0Python structure . In the functions, *Doc strings* are placed within the body of the function, usually at the beginning. The goal of *Doc Strings* is to be used as documentation for this structure.\n", + "*Doc Strings* are strings that are attached to a\u00a0Python structure. In functions, *Doc strings* are placed within the body of the function, usually at the beginning. The goal of *Doc Strings* is to be used as documentation for this structure.\n", "\n", "Syntax:\n", "\n", @@ -246,9 +246,9 @@ "source": [ "Observations:\n", "\n", - "+ The\u00a0 arguments with default value must come at last, after the non-default arguments.\n", + "+ The\u00a0 arguments with default value must come last, after the non-default arguments.\n", "+ The default value for a parameter is calculated when the function is defined.\n", - "+ The arguments passed without identifier are received by the function in the form of a list.\n", + "+ The arguments passed without an identifier are received by the function in the form of a list.\n", "+ The arguments passed to the function with an identifier are received in the form of a dictionary.\n", "+ The parameters passed to the function with an identifier should come at the end of the parameter list.\n", "\n", @@ -286,7 +286,7 @@ "source": [ "In the example, `kargs` will receive the named arguments and `args` will receive the others.\n", "\n", - "The interpreter has some *builtin* functions defined, including `sorted()`, which orders sequences, and `cmp()`, which makes comparisons between two arguments and returns -1 if the first element is greater, 0 (zero) if they are equal or 1 if the latter is higher. This function is used by the routine of ordering, a behavior that can be modified.\n", + "The interpreter has some *builtin* functions defined, including `sorted()`, which orders sequences, and `cmp()`, which makes comparisons between two arguments and returns -1 if the first element is greater, 0 (zero) if they are equal, or 1 if the latter is higher. This function is used by the routine of ordering, a behavior that can be modified.\n", "\n", "Example:" ] @@ -322,7 +322,7 @@ { "cell_type": "markdown", "source": [ - "Python has also as *builtin* the function `eval()`, which evaluates code (source or object) returning the value.\n", + "Python also has a *builtin* function `eval()`, which evaluates code (source or object) and returns the value.\n", "\n", "Example:" ] @@ -348,7 +348,7 @@ { "cell_type": "markdown", "source": [ - "With that is possible to mount code to be passed to the interpreter during the execution of a program. This feature should be used with caution because code assembled from system inputs open up security holes." + "With that it's possible to mount code to be passed to the interpreter during the execution of a program. This feature should be used with caution because code assembled from system inputs open up security holes." ] }, { diff --git a/Chapter7/Chapter7_Documentation.ipynb b/Chapter7/Chapter7_Documentation.ipynb index bb19cc2..7c5b136 100644 --- a/Chapter7/Chapter7_Documentation.ipynb +++ b/Chapter7/Chapter7_Documentation.ipynb @@ -19,26 +19,26 @@ "Chapter 7: Documentation\n", "=============================\n", "_____________________________\n", - "PyDOC is a documentation tool of Python. It can be used both for access to the documentation of the modules that come with Python, as the documentation of third party modules.\n", + "PyDOC is a documentation tool for Python. It can be used both to access to the documentation of the modules that come with Python, and the documentation of third party modules.\n", "\n", - "In Windows, go to the icon \"Module Docs\" documentation of the standard library and \"Python Manuals\" to view the tutorial, referrals and other more extensive documentation.\n", + "In Windows, go to the icon \"Module Docs\" documentation of the standard library and \"Python Manuals\" to view the tutorial, referrals, and other more extensive documentation.\n", "\n", "To use PyDOC in Linux:\n", "\n", " pydoc ./modulo.py\n", "\n", - "To show the documentation of `modulo.py` in current directory.\n", + "To show the documentation of `modulo.py` in the current directory.\n", "\n", "In Linux, the documentation of libraries can be seen throught the *browser* by using:\n", "\n", " pydoc -p 8000\n", "\n", - "In the address http://localhost:8000/.\n", + "At the address http://localhost:8000/.\n", "To run the graphical version of PyDOC type:\n", "\n", " pydoc -g\n", "\n", - "PyDOC uses modules *Doc Strings* to generate the documentation.\n", + "PyDOC uses the module *Doc Strings* to generate the documentation.\n", "\n", "Besides that, it is also possible to consult the documentation on the interpreter itself, with the function `help()`.\n", "\n", diff --git a/ExercisesI/ExercisesI.ipynb b/ExercisesI/ExercisesI.ipynb index 40a96e0..5175546 100644 --- a/ExercisesI/ExercisesI.ipynb +++ b/ExercisesI/ExercisesI.ipynb @@ -21,8 +21,8 @@ "_____________________________\n", "1\\. Implement the two functions:\n", "\n", - "+ One that converts temperature in *Celsius* degrees to *Fahrenheit*.\n", - "+ Anthoer that converts temperature in *Fahrenheit* degrees to *Celsius*.\n", + "+ One that converts temperature in degrees *Celsius* to degrees *Fahrenheit*.\n", + "+ Anthoer that converts temperature in degrees *Fahrenheit* to degrees *Celsius*.\n", "\n", "Keep in mind that:\n", "\n", @@ -32,16 +32,16 @@ "\n", "3\\. Implement a function that takes a list of lists of any length and returns a list of one dimension.\n", "\n", - "4\\. Implement a function that takes a dictionary and return the sum, average and range of its values\u200b\u200b.\n", + "4\\. Implement a function that takes a dictionary and returns the sum, average and range of its values\u200b\u200b.\n", "\n", "5\\. Write a function that:\n", - "Get a phrase as a parameter.\n", - "Return a new sentence with each word with the letters reversed.\n", + "Gets a phrase as a parameter.\n", + "Returns a new sentence with each word with the letters reversed.\n", "\n", "6\\. Create a function that:\n", "\n", - "+ Get a list of tuples (data), an integer (key, by default equal to zero) and a boolean (reverse, false by default).\n", - "+ Return data sorted by item indicated by key in descending order and if reverse is true." + "+ Gets a list of tuples (data), an integer (key, by default equal to zero) and a boolean (reverse, false by default).\n", + "+ Returns data sorted by item indicated by key in descending order and if reverse is true." ] }, { From ecacee9ef542e53e0decbb8f3d340d4a89016bc6 Mon Sep 17 00:00:00 2001 From: Beau Date: Tue, 26 Jul 2016 18:01:42 -0500 Subject: [PATCH 02/14] Fixed up the language a bit --- Chapter10/Chapter10_Packages.ipynb | 2 +- Chapter11/Chapter11_Standard_library.ipynb | 49 ++++++------------- .../Chapter12_Third_Party_Libraries.ipynb | 16 +++--- Chapter13/Chapter13_Exceptions.ipynb | 8 +-- Chapter14/Chapter14_Introspection.ipynb | 8 +-- Chapter8/Chapter8_Modules.ipynb | 14 +++--- Chapter9/Chapter9_Scope_of_names.ipynb | 4 +- 7 files changed, 42 insertions(+), 59 deletions(-) diff --git a/Chapter10/Chapter10_Packages.ipynb b/Chapter10/Chapter10_Packages.ipynb index 03b3838..9d1cc84 100644 --- a/Chapter10/Chapter10_Packages.ipynb +++ b/Chapter10/Chapter10_Packages.ipynb @@ -19,7 +19,7 @@ "Chapter 10: Packages\n", "=============================\n", "_____________________________\n", - "Packages are folders that are identified by the interpreter by the presence of a file named `__init__.py`. Packages work as collections to organize hierarchically modules.\n", + "Packages are folders that are identified by the interpreter by the presence of a file named `__init__.py`. Packages work as collections to organize modules hierarchically.\n", "\n", "![Package](files/bpyfd_diags8.png)\n", "\n", diff --git a/Chapter11/Chapter11_Standard_library.ipynb b/Chapter11/Chapter11_Standard_library.ipynb index 25812f1..098d2de 100644 --- a/Chapter11/Chapter11_Standard_library.ipynb +++ b/Chapter11/Chapter11_Standard_library.ipynb @@ -34,11 +34,11 @@ "\n", "Maths\n", "----------\n", - "In addition to the *builtin* numeric types interpreter in the Python standard library there are several modules devoted to implement other types and mathematical operations.\n", + "In addition to the *builtin* numeric types in the Python standard library, there are several modules devoted to implementing other types and mathematical operations.\n", "\n", - "The *math* module defines logarithmic, exponentiation, trigonometric, hyperbolic functions and angular conversions, among others. The *cmath* module, implements similar functions, but made to handle complex numbers.\n", + "The *math* module defines logarithmic, exponentiation, trigonometric, and hyperbolic functions, as well as angular conversions and more. The *cmath* module implements similar functions, but can handle complex numbers.\n", "\n", - "example:" + "Example:" ] }, { @@ -52,7 +52,7 @@ "# Complex\n", "for cpx in [3j, 1.5 + 1j, -2 - 2j]:\n", "\n", - " # Polar coordinates convertion\n", + " # Polar coordinate conversion\n", " plr = cmath.polar(cpx)\n", " print 'Complex:', cpx\n", " print 'Polar:', plr, '(in radians)'\n", @@ -105,7 +105,7 @@ "# Choose a number from 1 to 10\n", "print random.randrange(1, 11)\n", "\n", - "# Escolha um float no intervalo de 0 a 1\n", + "# Choose a float from 0 to 1\n", "print random.random()" ], "language": "python", @@ -129,7 +129,7 @@ "source": [ "In the standard library there is the decimal module that defines operations with real numbers with fixed precision.\n", "\n", - "example:" + "Example:" ] }, { @@ -172,7 +172,7 @@ "\n", "In version 2.6, the module *fractions*, which deals with rational numbers, is also available.\n", "\n", - "example:" + "Example:" ] }, { @@ -214,11 +214,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Fractions can be initialized in several ways: as a *string*, as a pair of integer or as a real number. The module also has a function called `gcd ()` which calculates the greatest common divisor (gcd) of two integers.\n", + "Fractions can be initialized in several ways: as a *string*, as a pair of integers, or as a real number. The module also has a function called `gcd()` which calculates the greatest common divisor (gcd) of two integers.\n", "\n", "Files and I/O\n", "--------------\n", - "Files in Python are represented by objects of type *file*, which offer various methods for file operations. Files can be opened for reading ('r', which is the default), write ('w') or addition ('a'), in text or binary ('b') mode.\n", + "Files in Python are represented by objects of type *file*, which offer various methods for file operations. Files can be opened for reading ('r', which is the default), writing ('w'), or appending ('a'), in text or binary ('b') mode.\n", "\n", "In Python:\n", "\n", @@ -240,7 +240,7 @@ "# Create an object of type file\n", "temp = open('temp.txt', 'w')\n", "\n", - "# Writing output\n", + "# Write output\n", "for i in range(20):\n", " temp.write('%03d\\n' % i)\n", "\n", @@ -376,7 +376,7 @@ "source": [ "The objects of type file also have the method `seek()`, which allow going to any position in the file.\n", "\n", - "In version 2.6, it is available the module *io*, which implements separately the file operations and the text manipulation routines.\n", + "In version 2.6 the module *io* is available, which implements file operations and text manipulation routines separately.\n", "\n", "File Systems\n", "-------------------\n", @@ -389,7 +389,7 @@ "+ `os.path.exists()`: returns *True* if the path exists or *False* otherwise.\n", "+ `os.path.getsize()`: returns the size of the file in *bytes*.\n", "\n", - "*glob* is another module related with the file system:" + "*glob* is another module related to the file system:" ] }, { @@ -413,7 +413,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The *glob.glob()* function returns a list of filenames that meet the criteria passed as a parameter in a similar way to `ls` command available on UNIX systems.\n", + "The *glob.glob()* function returns a list of filenames that meet the criteria passed as a parameter in a similar way to the `ls` command available on UNIX systems.\n", "\n", "Temporary files\n", "--------------------\n", @@ -465,14 +465,6 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Existe tamb\u00e9m a fun\u00e7\u00e3o `tempnam()`, que retorna um nome v\u00e1lido para arquivo tempor\u00e1rio, incluindo um caminho que respeite as conven\u00e7\u00f5es do sistema operacional. Por\u00e9m, fica por conta do desenvolvedor garantir que a rotina seja usada de forma a n\u00e3o comprometer a seguran\u00e7a da aplica\u00e7\u00e3o.\n", - "\n", - "Arquivos compactados\n", - "--------------------\n", - "O Python possui m\u00f3dulos para trabalhar com v\u00e1rios formatos de arquivos compactados.\n", - "\n", - "Exemplo de grava\u00e7\u00e3o de um arquivo \u201c.zip\u201d:\n", - "\n", "There is also the `tempnam()` function, which returns a valid name for temporary file, including a path that respects the conventions of the operating system. However, it is up to the developer to ensure that the routine is used so as not to compromise the security of the application.\n", "\n", "Compressed files\n", @@ -642,22 +634,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "O formato CSV \u00e9 aceito pela maioria das planilhas e sistemas de banco de dados para importa\u00e7\u00e3o e exporta\u00e7\u00e3o de informa\u00e7\u00f5es.\n", - "\n", - "Sistema operacional\n", - "-------------------\n", - "Al\u00e9m do sistema de arquivos, os m\u00f3dulos da biblioteca padr\u00e3o tamb\u00e9m fornecem acesso a outros servi\u00e7os providos pelo sistema operacional.\n", - "\n", - "Exemplo:\n", - "\n", - "\n", "The CSV format is supported by most spreadsheet and databases for data import and export.\n", "\n", "Operating System\n", "-------------------\n", "Apart from the file system, the modules of the standard library also provides access to other services provided by the operating system.\n", "\n", - "example:" + "Example:" ] }, { @@ -864,7 +847,7 @@ "+ *time*: just time.\n", "+ *timedelta*: time diference.\n", "\n", - "Exemple:" + "Example:" ] }, { @@ -994,7 +977,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The behaviour of the functions of this module can be changed by options, to tread strings as *unicode*, for instance." + "The behaviour of the functions of this module can be changed by options, to treat strings as *unicode*, for instance." ] }, { diff --git a/Chapter12/Chapter12_Third_Party_Libraries.ipynb b/Chapter12/Chapter12_Third_Party_Libraries.ipynb index 8e0a15d..994448e 100644 --- a/Chapter12/Chapter12_Third_Party_Libraries.ipynb +++ b/Chapter12/Chapter12_Third_Party_Libraries.ipynb @@ -19,28 +19,28 @@ "Chapter 12 : Third Party Libraries\n", "=============================\n", "_____________________________\n", - "There are many libraries written by others available for Python, consisting of packages or modules, that implement many features beyond the standard library .\n", + "There are many libraries written by others available for Python, consisting of packages or modules, that implement many features beyond the standard library.\n", "\n", - "Generally, the libraries are distributed in the following ways :\n", + "Generally, the libraries are distributed in the following ways:\n", "\n", "+ *distutils* packages.\n", "+ Package managers from operating system.\n", "+ Installers.\n", "+ Python Eggs.\n", "\n", - "Packages using *distutils* module, which is distributed with Python, are very popular. The packages are distributed in compressed files (usually \".tar.gz\" , \".tar.bz2\" or \".zip \" ). To install , you must unzip the file , go into the folder that was unzipped , and to execute the command:\n", + "Packages using *distutils* module, which is distributed with Python, are very popular. The packages are distributed in compressed files (usually \".tar.gz\" , \".tar.bz2\" or \".zip \" ). To install, you must unzip the file, go into the folder that was unzipped, and to execute the command:\n", "\n", " python setup.py install\n", "\n", - "The package will be installed in \"site-packages\" folder in Python .\n", + "The package will be installed in \"site-packages\" folder in Python.\n", "\n", - "Package managers from operating System, usually work with their own packet formats, like \".deb\" (Debian Linux) or \".rpm\" (RedHat Linux). How to install the packages depends on the manager. The big advantage is that the package manager takes care of dependencies and updates.\n", + "Package managers from operating System usually work with their own packet formats, like \".deb\" (Debian Linux) or \".rpm\" (RedHat Linux). How to install the packages depends on the manager. The big advantage is that the package manager takes care of dependencies and updates.\n", "\n", - "Installer programs are nothing more than executables that install the library. They are generally used in Windows environment and can be uninstalled from the Control Panel.\n", + "Installer programs are nothing more than executables that install the library. They are generally used in Windows environments and can be uninstalled from the Control Panel.\n", "\n", - "Egg is a Python package format (with the extension \".egg\") which is administered by easy_install utility, which is part of the project [setuptools](http://peak.telecommunity.com/DevCenter/setuptools/). Similar to some tools found in other languages such as Ruby Gems, is gradually becoming the de facto standard for distributing libraries in Python .\n", + "Egg is a Python package format (with the extension \".egg\") which is administered by the easy_install utility, which is part of the project [setuptools](http://peak.telecommunity.com/DevCenter/setuptools/). Similar to some tools found in other languages such as Ruby Gems, it is gradually becoming the de facto standard for distributing libraries in Python.\n", "\n", - "The program finds the newest version of the package in [PYPI](http://pypi.python.org/pypi) (*Python Package Index*), the Python package repository, and also tries to install dependencies as needed .\n", + "The program finds the newest version of the package in [PYPI](http://pypi.python.org/pypi) (*Python Package Index*), the Python package repository, and also tries to install dependencies as needed.\n", "\n", "Python Egg packages can be installed via the command:\n", "\n", diff --git a/Chapter13/Chapter13_Exceptions.ipynb b/Chapter13/Chapter13_Exceptions.ipynb index de4a0e2..01d3151 100644 --- a/Chapter13/Chapter13_Exceptions.ipynb +++ b/Chapter13/Chapter13_Exceptions.ipynb @@ -48,7 +48,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The *try* instruction allows exception handling in Python. If an exception occur in a block marked by *try*, it is possible to tread the exception through the instruction *except*. It is possible to have many *except* blocks for the same *try* block." + "The *try* instruction allows exception handling in Python. If an exception occurs in a block marked by *try*, it is possible to handle the exception through the instruction *except*. It is possible to have many *except* blocks for the same *try* block." ] }, { @@ -77,7 +77,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If *except* receives the name of an exception, only that exception will be handled. If no exception name is passed as parameter, all exceptions will be handled.\n", + "If *except* receives the name of an exception, only that exception will be handled. If no exception name is passed as a parameter, all exceptions will be handled.\n", "\n", "Example:" ] @@ -157,9 +157,9 @@ "source": [ "The module *traceback* offers functions for dealing with error messages. The function format_exc() returns the output of the last exception formatted in a *string*.\n", "\n", - "The handling of exceptions may have an *else* block, which will be executed when no exception occur and a *finally* block, which will be executed anyway, exception occurred or not. New types of exceptions may be defined through inheritance of the class *Exception*.\n", + "The handling of exceptions may have an *else* block, which will be executed when no exception occurs and a *finally* block, which will be executed anyway, whether an exception occurred or not. New types of exceptions may be defined through inheritance of the class *Exception*.\n", "\n", - "Since version 2.6, it is available the instruction *with*, that may substitute the combination *try / finally* in many situations. It is possible to define an object that will be used during the *with* block execution. The object will support context management protocol, which means that it will need to have an `__enter__()` method, which will be executed on the beginning of the block, and another called `__exit__()`, which will be called at the end of the block.\n", + "Since version 2.6, the instruction *with* is available, that may replace the combination of *try / finally* in many situations. It is possible to define an object that will be used during the *with* block execution. The object will support the context management protocol, which means that it will need to have an `__enter__()` method, which will be executed at the beginning of the block, and another called `__exit__()`, which will be called at the end of the block.\n", "\n", "Example:" ] diff --git a/Chapter14/Chapter14_Introspection.ipynb b/Chapter14/Chapter14_Introspection.ipynb index a4a0b7b..6fc3a0a 100644 --- a/Chapter14/Chapter14_Introspection.ipynb +++ b/Chapter14/Chapter14_Introspection.ipynb @@ -73,7 +73,7 @@ " \n", "\n", "\n", - "The object identifier is an unique number that is used by the interpreter for identifying the objects internally.\n", + "The object identifier is a unique number that is used by the interpreter for identifying the objects internally.\n", "\n", " Example:" ] @@ -469,7 +469,7 @@ "source": [ "Python also has a module called *types*, which has the definitions of the basic types of the interpreter.\n", "\n", - "example:" + "Example:" ] }, { @@ -503,9 +503,9 @@ "\n", "Inspect\n", "-------\n", - "The module *inspect* provides a set of high-level functions that allow for introspection investigate types, collection items, classes, functions, source code and the runtime stack of the interpreter.\n", + "The module *inspect* provides a set of high-level functions that allow for introspection to investigate types, collection items, classes, functions, source code and the runtime stack of the interpreter.\n", "\n", - "example:" + "Example:" ] }, { diff --git a/Chapter8/Chapter8_Modules.ipynb b/Chapter8/Chapter8_Modules.ipynb index 92e9831..51aac29 100644 --- a/Chapter8/Chapter8_Modules.ipynb +++ b/Chapter8/Chapter8_Modules.ipynb @@ -19,7 +19,7 @@ "Chapter 8: Modules\n", "=============================\n", "_____________________________\n", - "For Python, modules are source files that can be imported into a program. They can contain any Python structure and run when imported. They are compiled when first imported and stored in file (with file extension \".pyc\" or \".pyo\"), have their own *namespaces* and support *Doc Strings*. They are singleton objects (only one instance is loaded into memory, which is available globally for the program).\n", + "For Python, modules are source files that can be imported into a program. They can contain any Python structure and run when imported. They are compiled when first imported and stored in a file (with the extension \".pyc\" or \".pyo\"), have their own *namespaces* and support *Doc Strings*. They are singleton objects (only one instance is loaded into memory, which is available globally for the program).\n", "\n", "![Modules](files/bpyfd_diags6.png)\n", "\n", @@ -79,7 +79,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "By avoiding problems such as variable obfuscation, the absolute import is considered a better programming practice than the relative import.\n", + "To avoid problems such as variable obfuscation, the absolute import is considered a better programming practice than the relative import.\n", "\n", "Example of module:" ] @@ -103,7 +103,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Exemple of module usage:" + "Example of module usage:" ] }, { @@ -116,7 +116,7 @@ "l = [23, 54, 31, 77, 12, 34]\n", "\n", "# Calls the function defined in calc\n", - "print calc.media(l)" + "print calc.average(l)" ], "language": "python", "metadata": {}, @@ -143,7 +143,7 @@ "collapsed": false, "input": [ "if __name__ == \"__main__\":\n", - " # Code here will only be runned \n", + " # Code here will only be run \n", " # if it is the main module\n", " # and not when it is imported by another program\n", " pass" @@ -197,7 +197,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Exemplo de uso do m\u00f3dulo:" + "Example module use:" ] }, { @@ -237,7 +237,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Splitting programs into modules makes it easy to reuse and locating faults in the code." + "Splitting programs into modules makes it easy to reuse and locate faults in the code." ] }, { diff --git a/Chapter9/Chapter9_Scope_of_names.ipynb b/Chapter9/Chapter9_Scope_of_names.ipynb index 883fd85..40d44e3 100644 --- a/Chapter9/Chapter9_Scope_of_names.ipynb +++ b/Chapter9/Chapter9_Scope_of_names.ipynb @@ -20,7 +20,7 @@ "=============================\n", "_____________________________\n", "\n", - "The scope of names in Python is maintained by *Namespaces*, which are dictionaries that list the names of the objects (references) and the objects themselves.\n", + "The scope of names in Python are maintained by *Namespaces*, which are dictionaries that list the names of the objects (references) and the objects themselves.\n", "\n", "Normally, the names are defined in two dictionaries, which can be accessed through the functions `locals()` and `globals()`. These dictionaries are updated dynamically at runtime.\n", "\n", @@ -70,7 +70,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Using global variables is not considered a good development practice, as they make the system harder to understand, so it is better to avoid its use. The same applies to overshadowing variables." + "Using global variables is not considered a good development practice, as they make the system harder to understand, so it is better to avoid their use. The same applies to overshadowing variables." ] }, { From 4539639740ac73f659f820c18fd8ae90be0757c9 Mon Sep 17 00:00:00 2001 From: Valery Kharitonov Date: Tue, 2 Aug 2016 16:45:46 +0300 Subject: [PATCH 03/14] Fixed Markdown in Chapter 5 --- Chapter5/Chapter5_Types.ipynb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Chapter5/Chapter5_Types.ipynb b/Chapter5/Chapter5_Types.ipynb index 165394c..11ebf80 100644 --- a/Chapter5/Chapter5_Types.ipynb +++ b/Chapter5/Chapter5_Types.ipynb @@ -113,11 +113,11 @@ "\n", "+ Sum (+)\n", "+ Difference (-)\n", - "+ Multiplication (*)\n", + "+ Multiplication (*)\n", "+ Division (/): between two integers the result is equal to the integer division. In other cases, the result is real.\n", "+ Integer Division (//): the result is truncated to the next lower integer, even when applied to real numbers, but in this case the result type is real too.\n", "+ Module (%): returns the remainder of the division.\n", - "+ Power (\*\*): can be used to calculate the root, through fractional exponents (eg `100 \*\* 0.5`).\n", + "+ Power (**): can be used to calculate the root, through fractional exponents (eg `100 ** 0.5`).\n", "+ Positive (+)\n", "+ Negative (-)\n", "\n", @@ -1098,4 +1098,5 @@ "metadata": {} } ] -} \ No newline at end of file +} + From 9cd31f601ecfde9c798dddfb6ad9ff4d37429513 Mon Sep 17 00:00:00 2001 From: ethanj Date: Sat, 3 Jun 2017 00:32:13 -0700 Subject: [PATCH 04/14] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11c1d42..ca9b7a9 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ Several factors contributed to this change, such as the internet, open source so Among the dynamic languages, Python stands out as one of the most popular and powerful. There is a lively community of language users in the world, and this is reflected in active mailing lists and many tools available in open source. -Learning a new programming language means learning to think differently. And learn a dynamic language represents a paradigm shift even harder for those people who have spent years developing in static languages. +Learning a new programming language means learning to think differently. And learning a dynamic language represents an even harder paradigm shift for those people who have spent years developing in static languages. -The e-book "Python para Desenvolvedores" ("Python for Developers") aimed to fill a gap, which was the lack of free courseware in Portuguese about the Python programming language. The work was adopted as a support material for several universities in Brazil, served as a reference for academic papers and has been downloaded over 100,000 times from its official website. +The e-book "Python para Desenvolvedores" ("Python for Developers") aimed to fill a gap, which was the lack of free courseware in Portuguese about the Python programming language. The work was adopted as support material for several universities in Brazil, served as a reference for academic papers and has been downloaded over 100,000 times from its official website. -This e-book was originally written in Portuguese and was translated by a small group of volunteers who do not speak English natively, so we ask for help from those who know better the English language, to refine the work, which we believe is a meaningful contribution to the Python users around the world. +This e-book was originally written in Portuguese and was translated by a small group of volunteers who do not speak English natively, so we ask for help from those who know the English language better, to refine the work, which we believe is a meaningful contribution to the Python users around the world. Visit the e-book website: [http://ricardoduarte.github.io/python-for-developers/](http://ricardoduarte.github.io/python-for-developers/) From 9fd1b2cc88078c4adae118f6f09e3f93998a8ddf Mon Sep 17 00:00:00 2001 From: ethanj Date: Sat, 3 Jun 2017 00:46:14 -0700 Subject: [PATCH 05/14] Update Chapter14_Introspection.ipynb --- Chapter14/Chapter14_Introspection.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Chapter14/Chapter14_Introspection.ipynb b/Chapter14/Chapter14_Introspection.ipynb index 6fc3a0a..b952dd6 100644 --- a/Chapter14/Chapter14_Introspection.ipynb +++ b/Chapter14/Chapter14_Introspection.ipynb @@ -19,7 +19,7 @@ "Chapter 14: Introspection\n", "=============================\n", "_____________________________\n", - "Introspection or reflection is the ability of software to identify and report their own internal structures, such as types, variable scope, methods and attributes.\n", + "Introspection or reflection is the ability of software to identify and report its own internal structures, such as types, variable scope, methods and attributes.\n", "\n", "Native interpreter functions for introspection:\n", "\n", @@ -89,7 +89,7 @@ "\n", "def info(n_obj):\n", "\n", - " # Create a refer\u00eance to the object\n", + " # Create a reference to the object\n", " obj = globals()[n_obj]\n", "\n", " # Show object information \n", @@ -644,4 +644,4 @@ "metadata": {} } ] -} \ No newline at end of file +} From d14a92a86b1fde1e4a70168ecdbe07ad1b49bf06 Mon Sep 17 00:00:00 2001 From: ethanj Date: Sat, 3 Jun 2017 00:51:45 -0700 Subject: [PATCH 06/14] Update Chapter15_Generators.ipynb --- Chapter15/Chapter15_Generators.ipynb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Chapter15/Chapter15_Generators.ipynb b/Chapter15/Chapter15_Generators.ipynb index 2722ebe..5140d95 100644 --- a/Chapter15/Chapter15_Generators.ipynb +++ b/Chapter15/Chapter15_Generators.ipynb @@ -19,16 +19,15 @@ "Chapter 15: Generators\n", "=============================\n", "_____________________________\n", - "tentativa\n", - "The functions generally follow the conventional process flow, return values \u200b\u200band quit. Generators work similarly, but remember the state of the processing between calls, staying in memory and returning the next item expected when activated.\n", + "Functions generally follow the conventional process flow, return values and quit. Generators work similarly, but remember the state of the processing between calls, staying in memory and returning the next item expected when activated.\n", "\n", - "The generators have several advantages over conventional functions:\n", + "Generators have several advantages over conventional functions:\n", "\n", "+ *Lazy Evaluation*: generators are only processed when it is really needed, saving processing resources. \n", "+ They reduce the need to create lists.\n", - "+ They allow to work with unlimited sequences of elements.\n", + "+ They allow working with unlimited sequences of elements.\n", "\n", - "Generators are usually called through a *for* loop. The syntax is similar to the traditional function, just the *yield* instruction substitutes *return*. In each new iteraction, *yield* returns the next value.\n", + "Generators are usually called through a *for* loop. The syntax is similar to the traditional function, but with the *yield* instruction substituting for *return*. In each new iteraction, *yield* returns the next value.\n", "\n", "Exemplo:" ] @@ -123,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There are many generators that are builtin to the lanaguage, like xrange(). Moreover, in the module *itertools*, many useful generators are defined.\n", + "There are many generators that are built in to the lanaguage, like xrange(). Moreover, in the module *itertools*, many useful generators are defined.\n", "\n", "To convert the output of a generator into a list:\n", "\n", @@ -218,4 +217,4 @@ "metadata": {} } ] -} \ No newline at end of file +} From f9858551da9faf841b157876e8093d6d186b8250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Thu, 17 Aug 2017 20:22:55 +0200 Subject: [PATCH 07/14] Added Dockerfile It is much easier to deploy with this. --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..481085f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# build with `docker build -t dockername:tag .` +# run with `docker run -p 8888:8888 dockername:tag` +# open http://localhost:8888 in browser +FROM debian + +RUN apt-get update && apt-get install -y python python-pip +RUN pip install jupyter + +RUN mkdir /var/www +COPY . /var/www +WORKDIR /var/www + +# config to run without authentication +RUN mkdir /root/.jupyter +RUN echo "c.NotebookApp.token = u''" >> /root/.jupyter/jupyter_notebook_config.py + +CMD ["jupyter-notebook", "--no-browser", "--ip=0.0.0.0", "--allow-root"] # to prevent listening on IPv6 + From 972bc9a37a6878a04588563f2457f2a0b5cbcb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Fri, 18 Aug 2017 09:47:07 +0200 Subject: [PATCH 08/14] Installed python2 in jupyter/base-notebook It is now available in the notebook, but still has to be selected. Should be made default, or python3 should be removed. Removing should be done by the rm -rfv line in the Dockerfile, but appearantly it does not work. Hints, I've read: - https://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook - https://stackoverflow.com/questions/42635310/remove-kernel-on-jupyter-notebook --- Dockerfile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 481085f..c7074a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,17 @@ # build with `docker build -t dockername:tag .` # run with `docker run -p 8888:8888 dockername:tag` # open http://localhost:8888 in browser -FROM debian +FROM jupyter/base-notebook -RUN apt-get update && apt-get install -y python python-pip -RUN pip install jupyter +USER root +RUN /bin/bash -c "conda create --yes -n py27 python=2.7; source activate py27; conda install --yes notebook ipykernel; ipython kernel install" +RUN rm -rfv /opt/conda/share/jupyter/kernels/python3/ -RUN mkdir /var/www -COPY . /var/www -WORKDIR /var/www +COPY . /home/jovyan +RUN chown -R jovyan:users /home/jovyan # config to run without authentication -RUN mkdir /root/.jupyter -RUN echo "c.NotebookApp.token = u''" >> /root/.jupyter/jupyter_notebook_config.py - -CMD ["jupyter-notebook", "--no-browser", "--ip=0.0.0.0", "--allow-root"] # to prevent listening on IPv6 +USER jovyan +RUN mkdir /home/jovyan/.jupyter >> /dev/null || echo "" +RUN echo "c.NotebookApp.token = u''" >> /home/jovyan/.jupyter/jupyter_notebook_config.py From 253578d68fcb84e11805f6c4e3a07c5ed63dcf54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Fri, 18 Aug 2017 13:48:13 +0200 Subject: [PATCH 09/14] Specify source image tag It is supposed to prevent deprecation. If they update to newer packages, this build file will still work. It will be necessary to be updated manually. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c7074a4..d55c7f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # build with `docker build -t dockername:tag .` # run with `docker run -p 8888:8888 dockername:tag` # open http://localhost:8888 in browser -FROM jupyter/base-notebook +FROM jupyter/base-notebook:37af02395694 USER root RUN /bin/bash -c "conda create --yes -n py27 python=2.7; source activate py27; conda install --yes notebook ipykernel; ipython kernel install" From 9edd6c05984fcec51c8cdc143a2eb9e45cf5a315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Fri, 18 Aug 2017 13:52:20 +0200 Subject: [PATCH 10/14] Python2 kernel made default --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d55c7f3..d766a8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,14 @@ FROM jupyter/base-notebook:37af02395694 USER root RUN /bin/bash -c "conda create --yes -n py27 python=2.7; source activate py27; conda install --yes notebook ipykernel; ipython kernel install" -RUN rm -rfv /opt/conda/share/jupyter/kernels/python3/ COPY . /home/jovyan RUN chown -R jovyan:users /home/jovyan +RUN echo 'PATH="$PATH:/opt/conda/bin"' >> .bashrc # config to run without authentication USER jovyan RUN mkdir /home/jovyan/.jupyter >> /dev/null || echo "" RUN echo "c.NotebookApp.token = u''" >> /home/jovyan/.jupyter/jupyter_notebook_config.py +CMD /bin/bash -c "source activate py27; start-notebook.sh" From ca9c5c2a9923ce7a591e187b89e1b1f0879d2240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Mon, 21 Aug 2017 21:25:29 +0200 Subject: [PATCH 11/14] Invalid type errors repaired --- Chapter1/Chapter1_Introduction.ipynb | 4 ++-- Chapter5/Chapter5_Types.ipynb | 18 +++++++++--------- Chapter6/Chapter6_Functions.ipynb | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Chapter1/Chapter1_Introduction.ipynb b/Chapter1/Chapter1_Introduction.ipynb index ffa0e50..6a41ce5 100644 --- a/Chapter1/Chapter1_Introduction.ipynb +++ b/Chapter1/Chapter1_Introduction.ipynb @@ -90,7 +90,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 5 }, { "cell_type": "markdown", @@ -330,4 +330,4 @@ "metadata": {} } ] -} \ No newline at end of file +} diff --git a/Chapter5/Chapter5_Types.ipynb b/Chapter5/Chapter5_Types.ipynb index 11ebf80..178a368 100644 --- a/Chapter5/Chapter5_Types.ipynb +++ b/Chapter5/Chapter5_Types.ipynb @@ -99,7 +99,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 2 }, { "cell_type": "markdown", @@ -204,7 +204,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 3 }, { "cell_type": "markdown", @@ -253,7 +253,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 4 }, { "cell_type": "markdown", @@ -298,7 +298,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 5 }, { "cell_type": "markdown", @@ -385,7 +385,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 7 }, { "cell_type": "markdown", @@ -424,7 +424,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 8 }, { "cell_type": "markdown", @@ -618,7 +618,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 12 }, { "cell_type": "markdown", @@ -728,7 +728,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 13 }, { "cell_type": "markdown", @@ -924,7 +924,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 18 }, { "cell_type": "markdown", diff --git a/Chapter6/Chapter6_Functions.ipynb b/Chapter6/Chapter6_Functions.ipynb index 8644942..61a8c83 100644 --- a/Chapter6/Chapter6_Functions.ipynb +++ b/Chapter6/Chapter6_Functions.ipynb @@ -279,7 +279,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 7 }, { "cell_type": "markdown", @@ -317,7 +317,7 @@ ] } ], - "prompt_number": "*" + "prompt_number": 8 }, { "cell_type": "markdown", @@ -435,4 +435,4 @@ ] } ] -} \ No newline at end of file +} From d8f71ad5baf40713a524d6bd5316ddd6c4829118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Mon, 21 Aug 2017 21:27:59 +0200 Subject: [PATCH 12/14] Typo --- Chapter6/Chapter6_Functions.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter6/Chapter6_Functions.ipynb b/Chapter6/Chapter6_Functions.ipynb index 61a8c83..8f5b226 100644 --- a/Chapter6/Chapter6_Functions.ipynb +++ b/Chapter6/Chapter6_Functions.ipynb @@ -60,7 +60,7 @@ " return(num * factorial(num - 1))\n", "\n", "# Testing factorial()\n", - "print fatorial(5)" + "print factorial(5)" ], "language": "python", "outputs": [ From f91c8a0cb5b2bb9f46eabaeb3b1ea9442ad72181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Sun, 24 Sep 2017 19:22:36 +0200 Subject: [PATCH 13/14] Reset to run notebook with default config --- Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d766a8e..6299277 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,4 @@ COPY . /home/jovyan RUN chown -R jovyan:users /home/jovyan RUN echo 'PATH="$PATH:/opt/conda/bin"' >> .bashrc -# config to run without authentication -USER jovyan -RUN mkdir /home/jovyan/.jupyter >> /dev/null || echo "" -RUN echo "c.NotebookApp.token = u''" >> /home/jovyan/.jupyter/jupyter_notebook_config.py - CMD /bin/bash -c "source activate py27; start-notebook.sh" From ee7de31054b1661142674a3a40d8debf2115165a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= Date: Sun, 24 Sep 2017 19:23:17 +0200 Subject: [PATCH 14/14] Added Docker section to README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ca9b7a9..a87543d 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,16 @@ The e-book "Python para Desenvolvedores" ("Python for Developers") aimed to fill This e-book was originally written in Portuguese and was translated by a small group of volunteers who do not speak English natively, so we ask for help from those who know the English language better, to refine the work, which we believe is a meaningful contribution to the Python users around the world. Visit the e-book website: [http://ricardoduarte.github.io/python-for-developers/](http://ricardoduarte.github.io/python-for-developers/) + +Run in docker +------------- +There is a dockerfile prepared to ease the deployment of the notebook. + +To build and run the container run the following commands + +``` +docker build -t python-for-developers:latest . +docker run -itp 8888:8888 python-for-developers:latest +``` + +After this the notebook will be available at `http://localhost:8888` with the token printed to the terminal.