diff --git a/README.md b/README.md index 12c4031..1953f29 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Contents **   ** **3. Syntax:** **         ** **[`Args`](#arguments)**__,__ **[`Inline`](#inline)**__,__ **[`Closure`](#closure)**__,__ **[`Decorator`](#decorator)**__,__ **[`Class`](#class)**__,__ **[`Duck_Type`](#duck-types)**__,__ **[`Enum`](#enum)**__,__ **[`Exception`](#exceptions)**__.__ **   ** **4. System:** **        ** **[`Exit`](#exit)**__,__ **[`Print`](#print)**__,__ **[`Input`](#input)**__,__ **[`Command_Line_Arguments`](#command-line-arguments)**__,__ **[`Open`](#open)**__,__ **[`Path`](#paths)**__,__ **[`OS_Commands`](#os-commands)**__.__ **   ** **5. Data:** **             ** **[`JSON`](#json)**__,__ **[`Pickle`](#pickle)**__,__ **[`CSV`](#csv)**__,__ **[`SQLite`](#sqlite)**__,__ **[`Bytes`](#bytes)**__,__ **[`Struct`](#struct)**__,__ **[`Array`](#array)**__,__ **[`Memory_View`](#memory-view)**__,__ **[`Deque`](#deque)**__.__ -**   ** **6. Advanced:** **   ** **[`Threading`](#threading)**__,__ **[`Operator`](#operator)**__,__ **[`Introspection`](#introspection)**__,__ **[`Metaprograming`](#metaprograming)**__,__ **[`Eval`](#eval)**__,__ **[`Coroutines`](#coroutines)**__.__ +**   ** **6. Advanced:** **   ** **[`Threading`](#threading)**__,__ **[`Operator`](#operator)**__,__ **[`Introspection`](#introspection)**__,__ **[`Metaprograming`](#metaprogramming)**__,__ **[`Eval`](#eval)**__,__ **[`Coroutines`](#coroutines)**__.__ **   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profiling)**__,__ **                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__,__ **[`Games`](#pygame)**__,__ **[`Data`](#pandas)**__.__ @@ -1670,6 +1670,7 @@ import os, shutil ```python os.chdir() # Changes the current working directory. os.mkdir(, mode=0o777) # Creates a directory. Mode is in octal. +os.makedirs(, mode=0o777) # Creates all directories in the path. ``` ```python @@ -1850,13 +1851,14 @@ import sqlite3 ### Write ```python .execute('') # Can raise a subclass of sqlite3.Error. -.commit() # Commits all transactions since last commit. +.commit() # Saves all changes since the last commit. +.rollback() # Discards all changes since the last commit. ``` #### Or: ```python -with : - .execute('') +with : # Exits block with commit() or rollback(), + .execute('') # depending on whether an exception occurred. ``` ### Placeholders @@ -1901,7 +1903,7 @@ Bytes = b'' # Only accepts ASCII characters and \x00-\xff. = [] # Returns int in range from 0 to 255. = [] # Returns bytes even if it has only one element. - = .join() # Joins elements using bytes object as separator. + = .join() # Joins elements using bytes as a separator. ``` ### Encode @@ -1950,6 +1952,7 @@ from struct import pack, unpack, iter_unpack = iter_unpack('', ) ``` +### Example ```python >>> pack('>hhl', 1, 2, 3) b'\x00\x01\x00\x02\x00\x00\x00\x03' @@ -2160,8 +2163,8 @@ from inspect import signature ``` -Metaprograming --------------- +Metaprogramming +--------------- **Code that generates code.** ### Type diff --git a/index.html b/index.html index 4b6f801..820e084 100644 --- a/index.html +++ b/index.html @@ -238,7 +238,7 @@ pre.prettyprint { '3. Syntax': [Args, Inline, Closure, Decorator, Class, Duck_Type, Enum, Exception], '4. System': [Exit, Print, Input, Command_Line_Arguments, Open, Path, OS_Commands], '5. Data': [JSON, Pickle, CSV, SQLite, Bytes, Struct, Array, Memory_View, Deque], - '6. Advanced': [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine], + '6. Advanced': [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine], '7. Libraries': [Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile, NumPy, Image, Audio, Games, Data] } @@ -1556,6 +1556,7 @@ value = args.<name>
os.chdir(<path>)                    # Changes the current working directory.
 os.mkdir(<path>, mode=0o777)        # Creates a directory. Mode is in octal.
+os.makedirs(<path>, mode=0o777)     # Creates all directories in the path.
 
shutil.copy(from, to)               # Copies the file. 'to' can exist or be a dir.
 shutil.copytree(from, to)           # Copies the directory. 'to' must not exist.
@@ -1686,11 +1687,12 @@ CompletedProcess(args=['bc', Write
<conn>.execute('<query>')                       # Can raise a subclass of sqlite3.Error.
-<conn>.commit()                                 # Commits all transactions since last commit.
+<conn>.commit()                                 # Saves all changes since the last commit.
+<conn>.rollback()                               # Discards all changes since the last commit.
 
-

Or:

with <conn>:
-    <conn>.execute('<query>')
+

Or:

with <conn>:                                    # Exits block with commit() or rollback(),
+    <conn>.execute('<query>')                   # depending on whether an exception occurred.
 

Placeholders

    @@ -1724,7 +1726,7 @@ CompletedProcess(args=['bc', #Bytes

    Bytes object is an immutable sequence of single bytes. Mutable version is called bytearray.

    <bytes> = b'<str>'                       # Only accepts ASCII characters and \x00-\xff.
     <int>   = <bytes>[<index>]               # Returns int in range from 0 to 255.
     <bytes> = <bytes>[<slice>]               # Returns bytes even if it has only one element.
    -<bytes> = <bytes>.join(<coll_of_bytes>)  # Joins elements using bytes object as separator.
    +<bytes> = <bytes>.join(<coll_of_bytes>)  # Joins elements using bytes as a separator.
     
@@ -1761,11 +1763,12 @@ CompletedProcess(args=['bc', '<format>', <bytes>) <tuples> = iter_unpack('<format>', <bytes>)
-
>>> pack('>hhl', 1, 2, 3)
+

Example

>>> pack('>hhl', 1, 2, 3)
 b'\x00\x01\x00\x02\x00\x00\x00\x03'
 >>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
 (1, 2, 3)
-
+
+

Format

For standard type sizes start format string with:

  • '=' - native byte order (usually little-endian)
  • '<' - little-endian
  • @@ -1921,7 +1924,7 @@ delattr(<object>, '<attr_name>') <memb> = <Param>.kind # Member of ParameterKind enum.
-

#Metaprograming

Code that generates code.

Type

Type is the root class. If only passed an object it returns its type (class). Otherwise it creates a new class.

<class> = type('<class_name>', <parents_tuple>, <attributes_dict>)
+

#Metaprogramming

Code that generates code.

Type

Type is the root class. If only passed an object it returns its type (class). Otherwise it creates a new class.

<class> = type('<class_name>', <parents_tuple>, <attributes_dict>)
@@ -2300,7 +2303,7 @@ right = [[0.1 , 0.6< right = [[0.1, 0.6, 0.8], [0.1, 0.6, 0.8], [0.1, 0.6, 0.8]] # Shape: (3, 3) <- ! -

3. If neither non-matching dimension has size 1, raise an error.

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
+

3. If neither non-matching dimension has size 1, raise an error.

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
  [ 0.1,  0.6,  0.8]
 >>> wrapped_points = points.reshape(3, 1)
 [[ 0.1],
diff --git a/parse.js b/parse.js
index 2d56bc6..c760811 100755
--- a/parse.js
+++ b/parse.js
@@ -24,7 +24,7 @@ const TOC =
   '    \'3. Syntax\':      [Args, Inline, Closure, Decorator, Class, Duck_Type, Enum, Exception],\n' +
   '    \'4. System\':      [Exit, Print, Input, Command_Line_Arguments, Open, Path, OS_Commands],\n' +
   '    \'5. Data\':        [JSON, Pickle, CSV, SQLite, Bytes, Struct, Array, Memory_View, Deque],\n' +
-  '    \'6. Advanced\':    [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine],\n' +
+  '    \'6. Advanced\':    [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine],\n' +
   '    \'7. Libraries\':   [Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile,\n' +
   '                       NumPy, Image, Audio, Games, Data]\n' +
   '}\n' +
diff --git a/pdf/index_for_pdf.html b/pdf/index_for_pdf.html
index 43ffa77..afd9e5c 100644
--- a/pdf/index_for_pdf.html
+++ b/pdf/index_for_pdf.html
@@ -20,7 +20,7 @@
 

C

cache, 13
callable, 17
-class, 4, 14-20, 31-32
+class, 4, 14-20, 31-32
closure, 12-13
collection, 4, 18, 19
collections module, 2, 3, 4, 19, 29
@@ -85,7 +85,7 @@ math module, 7
memoryviews, 29
metaclass attribute, 32
-metaprograming, 31-32
+metaprogramming, 31-32
mysql library, 27

N

namedtuples, 3
@@ -139,7 +139,7 @@ threading module, 30
time module, 34, 36
tuples, 3, 4, 11
-type, 4, 31-32

+type, 4, 31-32

W

wave module, 40-41
web, 36

diff --git a/web/script_2.js b/web/script_2.js index 97691b4..efb56e9 100644 --- a/web/script_2.js +++ b/web/script_2.js @@ -5,7 +5,7 @@ const TOC = ' \'3. Syntax\': [Args, Inline, Closure, Decorator, Class, Duck_Type, Enum, Exception],\n' + ' \'4. System\': [Exit, Print, Input, Command_Line_Arguments, Open, Path, OS_Commands],\n' + ' \'5. Data\': [JSON, Pickle, CSV, SQLite, Bytes, Struct, Array, Memory_View, Deque],\n' + - ' \'6. Advanced\': [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine],\n' + + ' \'6. Advanced\': [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine],\n' + ' \'7. Libraries\': [Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile,\n' + ' NumPy, Image, Audio, Games, Data]\n' + '}\n'; @@ -30,7 +30,7 @@ const TOC_MOBILE = ' Memory_View, Deque],\n' + ' \'6. Advanced\': [Threading, Operator,\n' + ' Introspection,\n' + - ' Metaprograming, Eval,\n' + + ' Metaprograming, Eval,\n' + ' Coroutine],\n' + ' \'7. Libraries\': [Progress_Bar, Plot, Table,\n' + ' Curses, Logging, Scraping,\n' +