From 4274e465a623b148b822398294ec707ff26c179d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 9 Jul 2019 23:41:18 +0200 Subject: [PATCH] Indentation of comments --- README.md | 49 ++++++++++++++++++++++++++----------------------- index.html | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index eb37e14..00df799 100644 --- a/README.md +++ b/README.md @@ -746,10 +746,10 @@ Inline ### Comprehension ```python - = [i+1 for i in range(10)] # [1, 2, ..., 10] - = {i for i in range(10) if i > 5} # {6, 7, 8, 9} - = (i+5 for i in range(10)) # (5, 6, ..., 14) - = {i: i*2 for i in range(10)} # {0: 0, 1: 2, ..., 9: 18} + = [i+1 for i in range(10)] # [1, 2, ..., 10] + = {i for i in range(10) if i > 5} # {6, 7, 8, 9} + = (i+5 for i in range(10)) # (5, 6, ..., 14) + = {i: i*2 for i in range(10)} # {0: 0, 1: 2, ..., 9: 18} ``` ```python @@ -774,8 +774,8 @@ from functools import reduce ### Any, All ```python - = any() # False if empty. - = all(el[1] for el in ) # True if empty. + = any() # False if empty. + = all(el[1] for el in ) # True if empty. ``` ### If - Else @@ -1589,30 +1589,33 @@ Command Execution ```python import os -os.chdir() # Changes the current working directory. - = os.getcwd() # Returns current working directory. +os.chdir() # Changes the current working directory. + = os.getcwd() # Returns current working directory. ``` ```python -os.remove() # Deletes the file. -os.rmdir() # Deletes empty directory. -shutil.rmtree() # Deletes an entire directory tree. +os.remove() # Deletes the file. +os.rmdir() # Deletes empty directory. +shutil.rmtree() # Deletes an entire directory tree. ``` ```python -os.rename(from, to) # Renames the file or directory. -os.replace(from, to) # Same, but overwrites 'to' if it exists. +os.rename(from, to) # Renames the file or directory. +os.replace(from, to) # Same, but overwrites 'to' if it exists. ``` ```python -os.mkdir(, mode=0o777) # Creates a directory. - = os.scandir(path='.') # Returns os.DirEntry objects located at path. +os.mkdir(, mode=0o777) # Creates a directory. + = os.scandir(path='.') # Returns os.DirEntry objects located at path. ``` #### DirEntry: ```python - = .name # Final component of the path. - = .path # Path with final component. + = .name # Final component of the path. + = .path # Path with final component. +``` + +```python = .is_file() = .is_dir() = .is_symlink() @@ -1900,8 +1903,8 @@ from collections import deque ```python .appendleft() = .popleft() -.extendleft() # Collection gets reversed. -.rotate(n=1) # Rotates elements to the right. +.extendleft() # Collection gets reversed. +.rotate(n=1) # Rotates elements to the right. ``` ```python @@ -2156,10 +2159,10 @@ Plot ```python # $ pip3 install matplotlib from matplotlib import pyplot -pyplot.plot( [, , ...]) # Or: hist, pie, ... +pyplot.plot( [, , ...]) # Or: hist(). pyplot.savefig() pyplot.show() -pyplot.clf() # Clears figure. +pyplot.clf() # Clears figure. ``` @@ -2321,7 +2324,7 @@ Profile ### Basic ```python from time import time -start_time = time() # Seconds since Epoch. +start_time = time() # Seconds since Epoch. ... duration = time() - start_time ``` @@ -2329,7 +2332,7 @@ duration = time() - start_time ### High Performance ```python from time import perf_counter as pc -start_time = pc() # Seconds since restart. +start_time = pc() # Seconds since restart. ... duration = pc() - start_time ``` diff --git a/index.html b/index.html index aa6c3e1..a8189cf 100644 --- a/index.html +++ b/index.html @@ -745,10 +745,10 @@ func(*args, **kwargs) <function> = lambda <argument_1>, <argument_2>: <return_value>

Comprehension

-
<list> = [i+1 for i in range(10)]         # [1, 2, ..., 10]
-<set>  = {i for i in range(10) if i > 5}  # {6, 7, 8, 9}
-<iter> = (i+5 for i in range(10))         # (5, 6, ..., 14)
-<dict> = {i: i*2 for i in range(10)}      # {0: 0, 1: 2, ..., 9: 18}
+
<list> = [i+1 for i in range(10)]                   # [1, 2, ..., 10]
+<set>  = {i for i in range(10) if i > 5}            # {6, 7, 8, 9}
+<iter> = (i+5 for i in range(10))                   # (5, 6, ..., 14)
+<dict> = {i: i*2 for i in range(10)}                # {0: 0, 1: 2, ..., 9: 18}
 
out = [i+j for i in range(10) for j in range(10)]
 
@@ -765,8 +765,8 @@ func(*args, **kwargs) <int> = reduce(lambda out, x: out + x, range(10)) # 45

Any, All

-
<bool> = any(<collection>)                  # False if empty.
-<bool> = all(el[1] for el in <collection>)  # True if empty.
+
<bool> = any(<collection>)                          # False if empty.
+<bool> = all(el[1] for el in <collection>)          # True if empty.
 

If - Else

<expression_if_true> if <condition> else <expression_if_false>
@@ -1431,23 +1431,24 @@ value = args.<name>
 
  • All exceptions are either 'OSError' or its subclasses.
  • import os
    -os.chdir(<path>)               # Changes the current working directory.
    -<str> = os.getcwd()            # Returns current working directory.
    +os.chdir(<path>)                  # Changes the current working directory.
    +<str> = os.getcwd()               # Returns current working directory.
     
    -
    os.remove(<path>)              # Deletes the file.
    -os.rmdir(<path>)               # Deletes empty directory.
    -shutil.rmtree(<path>)          # Deletes an entire directory tree.
    +
    os.remove(<path>)                 # Deletes the file.
    +os.rmdir(<path>)                  # Deletes empty directory.
    +shutil.rmtree(<path>)             # Deletes an entire directory tree.
     
    -
    os.rename(from, to)            # Renames the file or directory.
    -os.replace(from, to)           # Same, but overwrites 'to' if it exists.
    +
    os.rename(from, to)               # Renames the file or directory.
    +os.replace(from, to)              # Same, but overwrites 'to' if it exists.
     
    -
    os.mkdir(<path>, mode=0o777)   # Creates a directory.
    -<iter> = os.scandir(path='.')  # Returns os.DirEntry objects located at path.
    +
    os.mkdir(<path>, mode=0o777)      # Creates a directory.
    +<iter> = os.scandir(path='.')     # Returns os.DirEntry objects located at path.
     

    DirEntry:

    -
    <str>  = <DirEntry>.name       # Final component of the path.
    -<str>  = <DirEntry>.path       # Path with final component.
    -<bool> = <DirEntry>.is_file()
    +
    <str>  = <DirEntry>.name          # Final component of the path.
    +<str>  = <DirEntry>.path          # Path with final component.
    +
    +
    <bool> = <DirEntry>.is_file()
     <bool> = <DirEntry>.is_dir()
     <bool> = <DirEntry>.is_symlink()
     <Path> = Path(<DirEntry>)
    @@ -1667,8 +1668,8 @@ cursor.execute('<query>', <dict/namedt
     
    <deque>.appendleft(<el>)
     <el> = <deque>.popleft()
    -<deque>.extendleft(<collection>)  # Collection gets reversed.
    -<deque>.rotate(n=1)               # Rotates elements to the right.
    +<deque>.extendleft(<collection>)            # Collection gets reversed.
    +<deque>.rotate(n=1)                         # Rotates elements to the right.
     
    >>> a = deque([1, 2, 3], maxlen=3)
     >>> a.append(4)
    @@ -1854,10 +1855,10 @@ reader(adder(printer()))  # 100, 101, ..., 109
     

    #Plot

    # $ pip3 install matplotlib
     from matplotlib import pyplot
    -pyplot.plot(<data_1> [, <data_2>, ...])  # Or: hist, pie, ...
    +pyplot.plot(<data_1> [, <data_2>, ...])  # Or: hist(<data>).
     pyplot.savefig(<filename>)
     pyplot.show()
    -pyplot.clf()  # Clears figure.
    +pyplot.clf()                             # Clears figure.
     

    #Table

    Prints a CSV file as an ASCII table:

    @@ -1982,13 +1983,13 @@ run(host='0.0.0.0', port=#Profile

    Basic

    from time import time
    -start_time = time()  # Seconds since Epoch.
    +start_time = time()                  # Seconds since Epoch.
     ...
     duration = time() - start_time
     

    High Performance

    from time import perf_counter as pc
    -start_time = pc()    # Seconds since restart.
    +start_time = pc()                    # Seconds since restart.
     ...
     duration = pc() - start_time