diff --git a/docs/classes.rst b/docs/classes.rst index 717dc4a..08392f5 100644 --- a/docs/classes.rst +++ b/docs/classes.rst @@ -469,7 +469,7 @@ The output: :: - $ python3 code/lenexample.py + $ python3 code/lenexample.py Length of the f object is 5 __contains__ method @@ -587,7 +587,7 @@ Let us look at it in details in the following example. def can_sudo(self): return self.sudo - + u = User("kdas", 1000, 1000, "/home/kdas", True) pprint(u.__dict__) diff --git a/docs/click.rst b/docs/click.rst index 67e770f..9b1bce1 100644 --- a/docs/click.rst +++ b/docs/click.rst @@ -71,7 +71,7 @@ is optional). :: - $ myhello + $ myhello Hello World $ myhello --help Usage: myhello [OPTIONS] @@ -160,7 +160,7 @@ option which will take a string as input. --help Show this message and exit. $ myhello Hello World - Bye + Bye $ myhello --name kushal Hello World Bye kushal @@ -260,8 +260,8 @@ The output looks like below: --password TEXT --help Show this message and exit. $ myhello - Password: - Repeat for confirmation: + Password: + Repeat for confirmation: Hello World We received hello as password. @@ -305,4 +305,4 @@ The output looks like: Click has many other useful features, like *yes parameter*, *file path input*. I am not going to write about all of those here, but you can always from the -`upstream documentation `_. \ No newline at end of file +`upstream documentation `_. diff --git a/docs/datastructure.rst b/docs/datastructure.rst index b437f52..3231654 100644 --- a/docs/datastructure.rst +++ b/docs/datastructure.rst @@ -78,7 +78,7 @@ We can store anything in the list, so first we are going to add another list *b .. index:: sort -Above you can see how we used the *a.extend()* method to extend the list. To sort any list we have *sort()* method. The *sort()* method will only work if elements in the list are comparable. We will remove the list b from the list and then sort. +Above you can see how we used the *a.extend()* method to extend the list. To sort any list we have *sort()* method. The *sort()* method will only work if elements in the list are comparable. We will remove the list b from the list and then sort. :: @@ -525,7 +525,7 @@ changes the variable outside of the function. def modify(numbers): numbers.append(42) - + modify(numbers) print(numbers) [1, 2, 4, 42] diff --git a/docs/flask.rst b/docs/flask.rst index 0426dde..4ed85ad 100644 --- a/docs/flask.rst +++ b/docs/flask.rst @@ -117,9 +117,9 @@ Put the following code in this file filename='hello.css')}}" /> - + It works! - + diff --git a/docs/functions.rst b/docs/functions.rst index 0025f1b..b8f0168 100644 --- a/docs/functions.rst +++ b/docs/functions.rst @@ -244,7 +244,7 @@ From Python3.8, we can also mark any function to have only positional arguments. >>> def add(a, b, /): ... return a + b - ... + ... >>> add(2, 3) 5 >>> add(a=2, b=3) @@ -351,7 +351,7 @@ number, we can do it easily like this. .. note:: To know more read `this link `_. -map +map ==== `map` is a very useful class in python. It takes one function @@ -388,7 +388,7 @@ In the above example, `name` and `age` are the parameters of the `hello`, and `k the arguments passed to the function. -*args and **kwargs in function definition +*args and **kwargs in function definition ========================================= There are times when we don't know the number of arguments before hand. There @@ -406,12 +406,12 @@ This is where we use `*args` and `**kwargs` in the function. print(f"We received {len(kwargs)} keyword arguments. And they are:") for k, v in kwargs.items(): print(f"key={k} and value={v}") - - + + unknown(30, 90, "kushal", lang="python", editor="vim") We received 3 positional arguments. And they are: - 30 90 kushal + 30 90 kushal We received 2 keyword arguments. And they are: key=lang and value=python key=editor and value=vim diff --git a/docs/hardwaresimulation.rst b/docs/hardwaresimulation.rst index 9cf247e..5f6f3ae 100644 --- a/docs/hardwaresimulation.rst +++ b/docs/hardwaresimulation.rst @@ -4,7 +4,7 @@ Learning using hardware simulation ================================== From this section and in the future chapters, there will be examples and problems -which is using a special device simulation in VS Code editor. +which is using a special device simulation in VS Code editor. We will use the simulation to have a `Circuit Playground Express device `_, and learn to interact with the device. We will be able to turn on lights of different diff --git a/docs/ifelse.rst b/docs/ifelse.rst index 38889c0..4ecf238 100644 --- a/docs/ifelse.rst +++ b/docs/ifelse.rst @@ -81,9 +81,9 @@ The elegant way to test Truth values is like pass .. warning:: Don't do this - + :: - + if x == True: pass diff --git a/docs/loopingonhardware.rst b/docs/loopingonhardware.rst index 1a750be..ca6c499 100644 --- a/docs/loopingonhardware.rst +++ b/docs/loopingonhardware.rst @@ -12,7 +12,7 @@ One NeoPixel at a time .. figure:: img/oneneoatatime.gif -The `cpx.pixels` can be accessed by index numbers, from 0 to 9. This way, we can turn on +The `cpx.pixels` can be accessed by index numbers, from 0 to 9. This way, we can turn on one NeoPixel at a time. .. code-block:: python diff --git a/docs/modules.rst b/docs/modules.rst index 36c0b4b..c16ece0 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -56,7 +56,7 @@ Now we are going to see how modules work. Create a file called bars.py. Content Prints a bar with - :arg num: Length of the bar - + """ print("-" * num) @@ -136,7 +136,7 @@ a single function from the module. Look at the following updated `bars.py` examp Prints a bar with - :arg num: Length of the bar - + """ print("-" * num) @@ -164,7 +164,7 @@ the module from there. All imported modules are of type `module`. ['ANSWER', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'hashbar', 'simplebar', 'starbar'] >>> type(bars) - >>> bars.__name__ + >>> bars.__name__ 'bars' >>> bars.__file__ '/home/kdas/code/pym/code/bars.py' @@ -317,7 +317,7 @@ Using the *view_dir* example. :: >>> view_dir('/') - .readahead bin boot dev etc home junk lib lib64 lost+found media mnt opt + .readahead bin boot dev etc home junk lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var @@ -355,7 +355,7 @@ The *text* attribute holds the HTML returned by the server. Using this knowledge, let us write a command which can download a given file (URL) from Internet. -.. code:: python +.. code:: python #!/usr/bin/env python3 import os @@ -383,7 +383,7 @@ Using this knowledge, let us write a command which can download a given file (UR Here we used something new, when the module name is *__main__*, then only -ask for a user input and then download the given URL. This also prevents +ask for a user input and then download the given URL. This also prevents the same when some other Python code imports this file as a Python module. To learn more about requests module, go to their `wonderful documentation `_. diff --git a/docs/mu.rst b/docs/mu.rst index 5525acb..a4bcfbb 100644 --- a/docs/mu.rst +++ b/docs/mu.rst @@ -7,7 +7,7 @@ working on actual projects. In this chapter we will learn about **mu editor**, which is a very simple and beginner friendly editor for anyone starting with Python. It is developed by Nicholas Tollervey. -If you already have an editor of your choice, you can skip this chapter. +If you already have an editor of your choice, you can skip this chapter. Installation ============= diff --git a/docs/projectstructure.rst b/docs/projectstructure.rst index 53c511b..a3f59fa 100644 --- a/docs/projectstructure.rst +++ b/docs/projectstructure.rst @@ -271,7 +271,7 @@ First, we will have to install **twine** using **pip** (we are using a virtualen $ twine upload --repository-url https://test.pypi.org/legacy/ dist/* Uploading distributions to https://test.pypi.org/legacy/ Enter your username: kushaldas - Enter your password: + Enter your password: Uploading pymfactorial-0.1-py3-none-any.whl 100%|██████████████████████████████████████| 4.29k/4.29k [00:01<00:00, 3.77kB/s] Uploading pymfactorial-0.1.tar.gz diff --git a/docs/strings.rst b/docs/strings.rst index 00edca1..6efe4b4 100644 --- a/docs/strings.rst +++ b/docs/strings.rst @@ -237,7 +237,7 @@ You can iterate over a string using simple `for` loop. >>> for ch in "Python": ... print(ch) - ... + ... P y t diff --git a/docs/thebeginning.rst b/docs/thebeginning.rst index b0d9c24..a78650e 100644 --- a/docs/thebeginning.rst +++ b/docs/thebeginning.rst @@ -10,7 +10,7 @@ can write the code in a file and then run the file. In this topic, we will first write the code using the interpreter, after starting Python in the command prompt (shell or terminal). If you are new to Linux command line, you can read about Linux commands in `this -book `. +book `_. The following is from Fedora 32 machine. @@ -18,10 +18,10 @@ The following is from Fedora 32 machine. :: - Python 3.8.2rc1 (default, Feb 12 2020, 00:00:00) + Python 3.8.2rc1 (default, Feb 12 2020, 00:00:00) [GCC 10.0.1 20200130 (Red Hat 10.0.1-0.7)] on linux Type "help", "copyright", "credits" or "license" for more information. - >>> + >>> Using the Python interpreter @@ -37,9 +37,9 @@ In our first code we are going to print "Hello World!" using the interpreter. To Using a source file ===================== -As a serious programmer, you might want to write the above code into a source file. Use any text editor you like to create the file called helloworld.py. I used vi. You can even use GUI based tools like `Kate ` or `gedit `. +As a serious programmer, you might want to write the above code into a source file. Use any text editor you like to create the file called helloworld.py. I used vi. You can even use GUI based tools like `Kate `_ or `gedit `_. -Open a shell or terinal and perform these steps. +Open a shell or terminal and perform these steps. 1. Enter the following text: @@ -101,7 +101,7 @@ There are more places where you should be following the same type of whitespace - Add a space after "," in dicts, lists, tuples, and argument lists and after ":" in dicts. -- Spaces around assignments and comparisons (except in argument list) +- Spaces around assignments and comparisons (except in argument list). - No spaces just inside parentheses. diff --git a/docs/virtualenv.rst b/docs/virtualenv.rst index 4c44ce0..db1dd59 100644 --- a/docs/virtualenv.rst +++ b/docs/virtualenv.rst @@ -53,7 +53,7 @@ So, now we will install a Python module called redis. (virt1)$ python3 -m pip install redis Collecting redis Downloading redis-2.10.5-py2.py3-none-any.whl (60kB) - 100% |████████████████████████████████| 61kB 607kB/s + 100% |████████████████████████████████| 61kB 607kB/s Installing collected packages: redis Successfully installed redis-2.10.5 @@ -169,7 +169,7 @@ the following Python code in a file named *main.py*. :: $ pipenv shell - $ $ python main.py + (myproject-dbBcpQ4l) $ python main.py Your IP is 192.168.1.2 Exiting from the virtualenv