Skip to content

Commit

Permalink
clean up reference chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Rother committed Feb 11, 2024
1 parent 85316ff commit 8d8d8b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion reference/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ A Python program is simply a text file that contains Python statements.

To execute a Python program, you run it from the command line with:

::

:::bash
python my_program.py

For those unfamiliar with the command line all Python editors have
Expand Down
1 change: 1 addition & 0 deletions reference/print.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ operations separated by commas.
Examples for print statements:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python3
print('Hello World\n')
print(3 + 4)
Expand Down
13 changes: 6 additions & 7 deletions reference/reading_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Reading a table with multiple columns
Frequently you have data in text files separated into multiple columns,
like this:

::

:::bash
Emily;Smith;23
Charlie;Parker;45

Expand All @@ -62,7 +62,7 @@ finally breaks the line into a list of items at the ``;`` character
(``split``).

The ``str.strip()`` function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------

With the string function ``strip()``, you chop off whitespace characters
(spaces, newline characters and tabs) from both ends of a string. The
Expand Down Expand Up @@ -105,27 +105,27 @@ When opening files, you often need to specify a directory name as well.
You can use both full or relative directory names. A full file name
contains the entire path from the root directory, e.g.:

::

:::bash
/home/kristian/Desktop/myfile.txt

or on Windows

::

:::bash
C:/Python3/python.exe

A relative directory name starts from the current working directory,
often the directory in which your program is started:

::

:::bash
data/my_file.txt

or go one directory level up, then move into the folder below:

::

:::bash
../data/my_file.txt

Slashes versus Backslashes
Expand Down Expand Up @@ -161,7 +161,6 @@ The modern way to open files in Python is using a **Context Manager** (a
code block started by ``with``). The ``with`` statement takes care of
closing the file automatically:


.. code:: python3
with open('my_file.txt') as f:
Expand Down

0 comments on commit 8d8d8b5

Please sign in to comment.