diff --git a/README.md b/README.md index 52c3061..5f96c80 100644 --- a/README.md +++ b/README.md @@ -390,8 +390,8 @@ import re Format ------ ```python - = f'{}, {}' - = '{}, {}'.format(, ) + = f'{}, {}' # Or: '%s, %s' % (, ) + = '{}, {}'.format(, ) # Or: '{0}, {1}'.format(, ) ``` ### Attributes @@ -1014,21 +1014,21 @@ class C(A, B): pass ### Property **Pythonic way of implementing getters and setters.** ```python -class MyClass: +class Person: @property - def a(self): - return self._a + def name(self): + return ' '.join(a if a == 'van' else a.title() for a in self._name) - @a.setter - def a(self, value): - self._a = value + @name.setter + def name(self, value): + self._name = value.lower().split() ``` ```python ->>> obj = MyClass() ->>> obj.a = 123 ->>> obj.a -123 +>>> person = Person() +>>> person.name = ' gUiDo VaN rOsSuM ' +>>> person.name +'Guido van Rossum' ``` ### Dataclass @@ -2624,7 +2624,7 @@ import numpy as np ``` ```python - = np.array() + = np.array() = np.arange(from_inclusive, to_exclusive, ±step_size) = np.ones() = np.random.randint(from_inclusive, to_exclusive, ) diff --git a/index.html b/index.html index db2699e..c08e59e 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -364,8 +364,8 @@ to_exclusive = <range>.stop -

#Format

<str> = f'{<el_1>}, {<el_2>}'
-<str> = '{}, {}'.format(<el_1>, <el_2>)
+

#Format

<str> = f'{<el_1>}, {<el_2>}'                  # Or: '%s, %s' % (<el_1>, <el_2>)
+<str> = '{}, {}'.format(<el_1>, <el_2>)        # Or: '{0}, {1}'.format(<el_1>, <el_2>)
 

Attributes

>>> from collections import namedtuple
@@ -858,21 +858,21 @@ Z = dataclasses.make_dataclass('Z', [>>> C.mro()
 [<class 'C'>, <class 'A'>, <class 'B'>, <class 'object'>]
 
-

Property

Pythonic way of implementing getters and setters.

class MyClass:
+

Property

Pythonic way of implementing getters and setters.

class Person:
     @property
-    def a(self):
-        return self._a
+    def name(self):
+        return ' '.join(a if a == 'van' else a.title() for a in self._name)
 
-    @a.setter
-    def a(self, value):
-        self._a = value
+    @name.setter
+    def name(self, value):
+        self._name = value.lower().split()
 
-
>>> obj = MyClass()
->>> obj.a = 123
->>> obj.a
-123
+
>>> person = Person()
+>>> person.name = ' gUiDo  VaN  rOsSuM '
+>>> person.name
+'Guido van Rossum'
 

Dataclass

Decorator that automatically generates init(), repr() and eq() special methods.

from dataclasses import dataclass, field
 
@@ -2137,7 +2137,7 @@ drawer = output.GraphvizOutput(output_file=filename)
 
-
<array> = np.array(<list>)
+
<array> = np.array(<list/list_of_lists>)
 <array> = np.arange(from_inclusive, to_exclusive, ±step_size)
 <array> = np.ones(<shape>)
 <array> = np.random.randint(from_inclusive, to_exclusive, <shape>)
@@ -2881,7 +2881,7 @@ $ pyinstaller script.py --add-data '<path>:.'