diff --git a/README.md b/README.md index 32a7f16..9b893a7 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ Range Enumerate --------- ```python -for i, el in enumerate(, start=0): # Returns iterator of `(index+start, )` tuples. +for i, el in enumerate(, start=0): # Returns next element and its index on each pass. ... ``` @@ -981,20 +981,20 @@ class MyClass: #### Expressions that call the str() method: ```python -print() -f'{}' -logging.warning() -csv.writer().writerow([]) -raise Exception() +print() +f'{}' +logging.warning() +csv.writer().writerow([]) +raise Exception() ``` #### Expressions that call the repr() method: ```python -print/str/repr([]) -print/str/repr({: }) -f'{!r}' -Z = dataclasses.make_dataclass('Z', ['a']); print/str/repr(Z()) ->>> +print/str/repr([]) +print/str/repr({: }) +f'{!r}' +Z = dataclasses.make_dataclass('Z', ['a']); print/str/repr(Z()) +>>> ``` ### Inheritance @@ -1415,14 +1415,14 @@ except (, [...]) as : ... * **Also catches subclasses of the exception.** * **Use `'traceback.print_exc()'` to print the full error message to stderr.** * **Use `'print()'` to print just the cause of the exception (its arguments).** -* **Use `'logging.exception()'` to log the passed message, followed by the full error message of the caught exception. For details see [logging](#logging).** +* **Use `'logging.exception()'` to log the passed message, followed by the full error message of the caught exception. For details see [logging](#logging).** * **Use `'sys.exc_info()'` to get exception type, object, and traceback of caught exception.** ### Raising Exceptions ```python raise raise () -raise ( [, ...]) +raise ( [, ...]) ``` #### Re-raising caught exception: @@ -1555,7 +1555,7 @@ p.add_argument('', type=, nargs='?/*') # Optional arg ``` * **Use `'help='` to set argument description that will be displayed in help message.** -* **Use `'default='` to set option's or optional argument's default value.** +* **Use `'default='` to set option's or optional argument's default value.** * **Use `'type=FileType()'` for files. Accepts 'encoding', but 'newline' is None.** @@ -2200,15 +2200,15 @@ match : ### Patterns ```python - = 1/'abc'/True/None/math.pi # Matches the literal or a dotted name. - = () # Matches any object of that type. - = _ # Matches any object. - = # Matches any object and binds it to name. - = | [| ...] # Matches any of the patterns. - = as # Binds the match to the name. - = [, ...] # Matches sequence with matching items. - = {: , ...} # Matches dictionary with matching items. - = (=, ...) # Matches object with matching attributes. + = 1/'abc'/True/None/math.pi # Matches the literal or a dotted name. + = () # Matches any object of that type. + = _ # Matches any object. + = # Matches any object and binds it to name. + = | [| ...] # Matches any of the patterns. + = as # Binds match to name. Also (). + = [, ...] # Matches sequence with matching items. + = {: , ...} # Matches dictionary with matching items. + = (=, ...) # Matches object with matching attributes. ``` * **Sequence pattern can also be written as a tuple.** * **Use `'*'` and `'**'` in sequence/mapping patterns to bind remaining items.** @@ -2288,26 +2288,26 @@ CRITICAL:my_module:Running out of disk space. Introspection ------------- ```python - = dir() # Names of local variables, functions, classes, etc. - = vars() # Dict of local variables, etc. Also locals(). - = globals() # Dict of global vars, etc. (incl. '__builtins__'). + = dir() # Names of local vars, functions, classes and modules. + = vars() # Dict of local vars, functions, etc. Also locals(). + = globals() # Dict of global vars, etc. (including '__builtins__'). ``` ```python - = dir() # Names of object's attributes (including methods). - = vars() # Dict of writable attributes. Also .__dict__. - = hasattr(, '') # Checks if getattr() raises an AttributeError. -value = getattr(, '') # Default value can be passed as the third argument. -setattr(, '', value) # Only works on objects with __dict__ attribute. -delattr(, '') # Same. Also `del .`. + = dir() # Names of all object's attributes (including methods). + = vars() # Dict of writable attributes. Also .__dict__. + = hasattr(, '') # Checks if getattr() raises AttributeError. +value = getattr(, '') # Default value can be passed as the third argument. +setattr(, '', value) # Only works on objects with __dict__ attribute. +delattr(, '') # Same. Also `del .`. ``` ```python - = inspect.signature() # Returns function's Signature object. - = .parameters # Dict of Parameter objects. Also .return_type. - = .kind # Member of ParameterKind enum (KEYWORD_ONLY, ...). - = .default # Returns param's default value or Parameter.empty. - = .annotation # Returns param's type hint or Parameter.empty. + = inspect.signature() # Returns function's Signature object. + = .parameters # Dict of Parameter objects. Also .return_type. + = .kind # Member of ParamKind enum (Parameter.KEYWORD_ONLY, …). + = .default # Returns parameter's default value or Parameter.empty. + = .annotation # Returns parameter's type hint or Parameter.empty. ``` @@ -3526,8 +3526,8 @@ import * **Script needs to be saved with a `'pyx'` extension.** ```python -cdef = -cdef [n_elements] = [, , ...] +cdef = +cdef [n_elements] = [, , ...] cdef ( ): ... ``` diff --git a/index.html b/index.html index 6631a50..4b39f68 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -212,7 +212,7 @@ Point(x=1, y=2
>>> [i for i in range(3)]
 [0, 1, 2]
 
-

#Enumerate

for i, el in enumerate(<coll>, start=0):   # Returns iterator of `(index+start, <el>)` tuples.
+

#Enumerate

for i, el in enumerate(<coll>, start=0):   # Returns next element and its index on each pass.
     ...
 
@@ -826,18 +826,18 @@ player = Player(point, direction) # >>> obj.a, str(obj), repr(obj) (1, '1', 'MyClass(1)')
-

Expressions that call the str() method:

print(<el>)
-f'{<el>}'
-logging.warning(<el>)
-csv.writer(<file>).writerow([<el>])
-raise Exception(<el>)
+

Expressions that call the str() method:

print(<obj>)
+f'{<obj>}'
+logging.warning(<obj>)
+csv.writer(<file>).writerow([<obj>])
+raise Exception(<obj>)
 
-

Expressions that call the repr() method:

print/str/repr([<el>])
-print/str/repr({<el>: <el>})
-f'{<el>!r}'
-Z = dataclasses.make_dataclass('Z', ['a']); print/str/repr(Z(<el>))
->>> <el>
+

Expressions that call the repr() method:

print/str/repr([<obj>])
+print/str/repr({<obj>: <obj>})
+f'{<obj>!r}'
+Z = dataclasses.make_dataclass('Z', ['a']); print/str/repr(Z(<obj>))
+>>> <obj>
 

Inheritance

class Person:
@@ -1207,12 +1207,12 @@ LogicOp = Enum('LogicOp', {'traceback.print_exc()' to print the full error message to stderr.
 
  • Use 'print(<name>)' to print just the cause of the exception (its arguments).
  • -
  • Use 'logging.exception(<message>)' to log the passed message, followed by the full error message of the caught exception. For details see logging.
  • +
  • Use 'logging.exception(<str>)' to log the passed message, followed by the full error message of the caught exception. For details see logging.
  • Use 'sys.exc_info()' to get exception type, object, and traceback of caught exception.
  • Raising Exceptions

    raise <exception>
     raise <exception>()
    -raise <exception>(<el> [, ...])
    +raise <exception>(<obj> [, ...])
     

    Re-raising caught exception:

    except <exception> [as <name>]:
    @@ -1320,7 +1320,7 @@ p.add_argument('<name>', type=<type>
     
     
    • Use 'help=<str>' to set argument description that will be displayed in help message.
    • -
    • Use 'default=<el>' to set option's or optional argument's default value.
    • +
    • Use 'default=<obj>' to set option's or optional argument's default value.
    • Use 'type=FileType(<mode>)' for files. Accepts 'encoding', but 'newline' is None.

    #Open

    Opens the file and returns a corresponding file object.

    <file> = open(<path>, mode='r', encoding=None, newline=None)
    @@ -1804,15 +1804,15 @@ first_element    = op.methodcaller('pop', 
    -

    Patterns

    <value_pattern> = 1/'abc'/True/None/math.pi          # Matches the literal or a dotted name.
    -<class_pattern> = <type>()                           # Matches any object of that type.
    -<wildcard_patt> = _                                  # Matches any object.
    -<capture_patt>  = <name>                             # Matches any object and binds it to name.
    -<or_pattern>    = <pattern> | <pattern> [| ...]      # Matches any of the patterns.
    -<as_pattern>    = <pattern> as <name>                # Binds the match to the name.
    -<sequence_patt> = [<pattern>, ...]                   # Matches sequence with matching items.
    -<mapping_patt>  = {<value_pattern>: <pattern>, ...}  # Matches dictionary with matching items.
    -<class_pattern> = <type>(<attr_name>=<patt>, ...)    # Matches object with matching attributes.
    +

    Patterns

    <value_pattern> = 1/'abc'/True/None/math.pi        # Matches the literal or a dotted name.
    +<class_pattern> = <type>()                         # Matches any object of that type.
    +<wildcard_patt> = _                                # Matches any object.
    +<capture_patt>  = <name>                           # Matches any object and binds it to name.
    +<or_pattern>    = <pattern> | <pattern> [| ...]    # Matches any of the patterns.
    +<as_pattern>    = <pattern> as <name>              # Binds match to name. Also <type>(<name>).
    +<sequence_patt> = [<pattern>, ...]                 # Matches sequence with matching items.
    +<mapping_patt>  = {<value_pattern>: <patt>, ...}   # Matches dictionary with matching items.
    +<class_pattern> = <type>(<attr_name>=<patt>, ...)  # Matches object with matching attributes.
     
      @@ -1878,23 +1878,23 @@ CRITICAL:my_module:Running out of disk space. 2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
    -

    #Introspection

    <list> = dir()                             # Names of local variables, functions, classes, etc.
    -<dict> = vars()                            # Dict of local variables, etc. Also locals().
    -<dict> = globals()                         # Dict of global vars, etc. (incl. '__builtins__').
    +

    #Introspection

    <list> = dir()                          # Names of local vars, functions, classes and modules.
    +<dict> = vars()                         # Dict of local vars, functions, etc. Also locals().
    +<dict> = globals()                      # Dict of global vars, etc. (including '__builtins__').
     
    -
    <list> = dir(<object>)                     # Names of object's attributes (including methods).
    -<dict> = vars(<object>)                    # Dict of writable attributes. Also <obj>.__dict__.
    -<bool> = hasattr(<object>, '<attr_name>')  # Checks if getattr() raises an AttributeError.
    -value  = getattr(<object>, '<attr_name>')  # Default value can be passed as the third argument.
    -setattr(<object>, '<attr_name>', value)    # Only works on objects with __dict__ attribute.
    -delattr(<object>, '<attr_name>')           # Same. Also `del <object>.<attr_name>`.
    +
    <list> = dir(<obj>)                     # Names of all object's attributes (including methods).
    +<dict> = vars(<obj>)                    # Dict of writable attributes. Also <obj>.__dict__.
    +<bool> = hasattr(<obj>, '<attr_name>')  # Checks if getattr() raises AttributeError.
    +value  = getattr(<obj>, '<attr_name>')  # Default value can be passed as the third argument.
    +setattr(<obj>, '<attr_name>', value)    # Only works on objects with __dict__ attribute.
    +delattr(<obj>, '<attr_name>')           # Same. Also `del <object>.<attr_name>`.
     
    -
    <Sig>  = inspect.signature(<function>)     # Returns function's Signature object.
    -<dict> = <Sig>.parameters                  # Dict of Parameter objects. Also <Sig>.return_type.
    -<memb> = <Param>.kind                      # Member of ParameterKind enum (KEYWORD_ONLY, ...).
    -<obj>  = <Param>.default                   # Returns param's default value or Parameter.empty.
    -<type> = <Param>.annotation                # Returns param's type hint or Parameter.empty.
    +
    <Sig>  = inspect.signature(<function>)  # Returns function's Signature object.
    +<dict> = <Sig>.parameters               # Dict of Parameter objects. Also <Sig>.return_type.
    +<memb> = <Param>.kind                   # Member of ParamKind enum (Parameter.KEYWORD_ONLY, …).
    +<obj>  = <Param>.default                # Returns parameter's default value or Parameter.empty.
    +<type> = <Param>.annotation             # Returns parameter's type hint or Parameter.empty.
     

    #Coroutines

    • Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.
    • @@ -2875,8 +2875,8 @@ ex.line(df, x='Date', y=Definitions:
      • All 'cdef' definitions are optional, but they contribute to the speed-up.
      • Script needs to be saved with a 'pyx' extension.
      • -
      cdef <ctype> <var_name> = <el>
      -cdef <ctype>[n_elements] <var_name> = [<el>, <el>, ...]
      +
    cdef <ctype> <var_name> = <obj>
    +cdef <ctype>[n_elements] <var_name> = [<el_1>, <el_2>, ...]
     cdef <ctype/void> <func_name>(<ctype> <arg_name>): ...
     
    @@ -2932,7 +2932,7 @@ $ deactivate # Deactivates the activ diff --git a/parse.js b/parse.js index d69537a..355602a 100755 --- a/parse.js +++ b/parse.js @@ -75,11 +75,11 @@ const PARAMETRIZED_DECORATOR = ' return x + y\n'; const REPR_USE_CASES = - 'print/str/repr([<el>])\n' + - 'print/str/repr({<el>: <el>})\n' + - 'f\'{<el>!r}\'\n' + - 'Z = dataclasses.make_dataclass(\'Z\', [\'a\']); print/str/repr(Z(<el>))\n' + - '>>> <el>\n'; + 'print/str/repr([<obj>])\n' + + 'print/str/repr({<obj>: <obj>})\n' + + 'f\'{<obj>!r}\'\n' + + 'Z = dataclasses.make_dataclass(\'Z\', [\'a\']); print/str/repr(Z(<obj>))\n' + + '>>> <obj>\n'; const CONSTRUCTOR_OVERLOADING = 'class <name>:\n' + @@ -309,8 +309,8 @@ const GROUPBY = 'c 7 8 6'; const CYTHON_1 = - 'cdef <ctype> <var_name> = <el>\n' + - 'cdef <ctype>[n_elements] <var_name> = [<el>, <el>, ...]\n' + + 'cdef <ctype> <var_name> = <obj>\n' + + 'cdef <ctype>[n_elements] <var_name> = [<el_1>, <el_2>, ...]\n' + 'cdef <ctype/void> <func_name>(<ctype> <arg_name>): ...\n'; const CYTHON_2 = @@ -827,7 +827,7 @@ function fixHighlights() { $(`code:contains( = ±0b)`).html(BIN_HEX); $(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE); $(`code:contains(@debug(print_result=True))`).html(PARAMETRIZED_DECORATOR); - $(`code:contains(print/str/repr([]))`).html(REPR_USE_CASES); + $(`code:contains(print/str/repr([obj]))`).html(REPR_USE_CASES); $(`code:contains((self, a=None):)`).html(CONSTRUCTOR_OVERLOADING); $(`code:contains(make_dataclass(\'\')`).html(DATACLASS); $(`code:contains(shutil.copy)`).html(SHUTIL_COPY); @@ -842,7 +842,7 @@ function fixHighlights() { $(`code:contains(samples_f = (sin(i *)`).html(AUDIO); $(`code:contains(collections, dataclasses, enum, io, itertools)`).html(MARIO); $(`code:contains(>>> gb = df.groupby)`).html(GROUPBY); - $(`code:contains(cdef = )`).html(CYTHON_1); + $(`code:contains(cdef = )`).html(CYTHON_1); $(`code:contains(cdef class :)`).html(CYTHON_2); $(`code:contains(cdef enum : , , ...)`).html(CYTHON_3); $(`ul:contains(Only available in)`).html(INDEX);