diff --git a/README.md b/README.md index eaf4779..d61ef64 100644 --- a/README.md +++ b/README.md @@ -493,7 +493,7 @@ Format Numbers ------- ```python - = int() # Or: math.floor() + = int() # Or: math.trunc() = float() # Or: = complex(real=0, imag=0) # Or: ± j = fractions.Fraction(0, 1) # Or: Fraction(numerator=0, denominator=1) @@ -931,7 +931,7 @@ from functools import cache def fib(n): return n if n < 2 else fib(n-2) + fib(n-1) ``` -* **Potential problem with cache is that it can grow indefinitely. To clear its stored values run `'fib.cache_clear()'`, or use `'@lru_cache(maxsize=)'` decorator instead.** +* **Potential problem with cache is that it can grow indefinitely. To clear stored return values run `'fib.cache_clear()'`, or use `'@lru_cache(maxsize=)'` decorator instead.** * **CPython interpreter limits recursion depth to 3000 by default. To increase it run `'sys.setrecursionlimit()'`.** ### Parametrized Decorator @@ -1055,9 +1055,9 @@ class : * **For attributes of arbitrary type use `'typing.Any'`.** ```python - = make_dataclass('', ) - = make_dataclass('', ) - = ('', [, ]) +Point = make_dataclass('Point', ['x', 'y']) +Point = make_dataclass('Point', [('x', float), ('y', float)]) +Point = make_dataclass('Point', [('x', float, 0), ('y', float, 0)]) ``` ### Property @@ -1293,7 +1293,7 @@ class MySequence: ``` #### Discrepancies between glossary definitions and abstract base classes: -* **Glossary on Python's website defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.** +* **Python's glossary defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.** * **Passing ABC Iterable to isinstance() or issubclass() checks whether object/class has method iter(), while ABC Collection checks for iter(), contains() and len().** ### ABC Sequence diff --git a/index.html b/index.html index 5321090..21d0344 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@
- +
@@ -444,7 +444,7 @@ Point(x=1, y=2 {90:X} # '5A'. Number 90 in uppercase hexadecimal. -

#Numbers

<int>      = int(<float/str/bool>)                # Or: math.floor(<float>)
+

#Numbers

<int>      = int(<float/str/bool>)                # Or: math.trunc(<float>)
 <float>    = float(<int/str/bool>)                # Or: <int/float>e±<int>
 <complex>  = complex(real=0, imag=0)              # Or: <int/float> ± <int/float>j
 <Fraction> = fractions.Fraction(0, 1)             # Or: Fraction(numerator=0, denominator=1)
@@ -778,7 +778,7 @@ player = Player(point, direction)                   #
 
 
 
    -
  • Potential problem with cache is that it can grow indefinitely. To clear its stored values run 'fib.cache_clear()', or use '@lru_cache(maxsize=<int>)' decorator instead.
  • +
  • Potential problem with cache is that it can grow indefinitely. To clear stored return values run 'fib.cache_clear()', or use '@lru_cache(maxsize=<int>)' decorator instead.
  • CPython interpreter limits recursion depth to 3000 by default. To increase it run 'sys.setrecursionlimit(<int>)'.

Parametrized Decorator

A decorator that accepts arguments and returns a normal decorator that accepts a function.

from functools import wraps
@@ -886,9 +886,10 @@ Z = dataclasses.make_dataclass('Z', [Function field() is needed because '<attr_name>: list = []' would make a list that is shared among all instances. Its 'default_factory' argument can be any callable.
 
  • For attributes of arbitrary type use 'typing.Any'.
  • -
    <class> = make_dataclass('<class_name>', <coll_of_attribute_names>)
    -<class> = make_dataclass('<class_name>', <coll_of_tuples>)
    -<tuple> = ('<attr_name>', <type> [, <default_value>])
    +
    Point = make_dataclass('Point', ['x', 'y'])
    +Point = make_dataclass('Point', [('x', float), ('y', float)])
    +Point = make_dataclass('Point', [('x', float, 0), ('y', float, 0)])
    +

    Property

    Pythonic way of implementing getters and setters.

    class Person:
         @property
         def name(self):
    @@ -1098,7 +1099,7 @@ Hello World!
     
     
     

    Discrepancies between glossary definitions and abstract base classes:

      -
    • Glossary on Python's website defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.
    • +
    • Python's glossary defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.
    • Passing ABC Iterable to isinstance() or issubclass() checks whether object/class has method iter(), while ABC Collection checks for iter(), contains() and len().
    @@ -2923,7 +2924,7 @@ $ deactivate # Deactivates the active
    - +
    diff --git a/parse.js b/parse.js index 50c4790..e932798 100755 --- a/parse.js +++ b/parse.js @@ -842,7 +842,7 @@ function fixHighlights() { $(`code:contains(@debug(print_result=True))`).html(PARAMETRIZED_DECORATOR); $(`code:contains(print/str/repr([]))`).html(REPR_USE_CASES); $(`code:contains((self, a=None):)`).html(CONSTRUCTOR_OVERLOADING); - $(`code:contains(make_dataclass(\'\')`).html(DATACLASS); + //$(`code:contains(make_dataclass(\'\')`).html(DATACLASS); $(`code:contains(shutil.copy)`).html(SHUTIL_COPY); $(`code:contains(os.rename)`).html(OS_RENAME); $(`code:contains(\'s\')`).html(STRUCT_FORMAT);