|
71 | 71 | <div class="photo">
|
72 | 72 | <img src="img/20python_lib.png" alt="python" border="1" height="256" width="256">
|
73 | 73 | </div>
|
74 |
| - <div class="info"> |
| 74 | + < class="info"> |
75 | 75 | <h2>
|
76 | 76 | 20 Python Libraries You Aren't Using!
|
77 | 77 | </h2>
|
78 | 78 | <h6>
|
79 |
| - Author: Akash Singh <br/>Date: December 20, 2019 |
| 79 | + Author: Akash Singh <br/>Date: December 20, 2019 |
80 | 80 | </h6>
|
81 |
| - <p> |
82 |
| - content here |
| 81 | + <br><br> |
| 82 | + <p style="color:black;font-size:20px;"> |
| 83 | + I have been using Python for quite a while now, still learning a lot of simple and |
| 84 | + new things. Sometimes these simple things saves time and bring a lot of joy to me. I |
| 85 | + will be sharing a breif overview of the book: |
| 86 | + <blockquote><q>20 Python Libraries You Aren't Using |
| 87 | + (But Should)</q> - <b>Caleb Hattingh</b></blockquote> |
| 88 | + <p style="color:black;font-size:20px;">This book primarily focuses on some of the lesser-known libraries from the third-party ecosystem.</p> |
| 89 | + <ol>Libraries</ol> |
| 90 | + <ul style="color:black;font-size:20px;"> |
| 91 | + <li>collections.OrderedDict: gives you a <i>dict</i> that maintains the order of |
| 92 | + insertion. |
| 93 | + </li> |
| 94 | + <li>collections.defaultdict: allows you to specify a default value to all new |
| 95 | + keys. |
| 96 | + </li> |
| 97 | + For example: |
| 98 | + <pre> |
| 99 | + <code> |
| 100 | + >>> import collections |
| 101 | + >>> d = collections.defaultdict(list) |
| 102 | + >>> d['random_key'] |
| 103 | + [] # output -> auto-initilized to list |
| 104 | + </code> |
| 105 | + </pre> |
| 106 | + <li>collections.namedtuple: namedtuple incurs no extra runtime cost and can make your much easier to read.</li> |
| 107 | + <pre> |
| 108 | + <code> |
| 109 | + >>> point = (1.0, 2.0) |
| 110 | + >>> from collections import namedtuple |
| 111 | + >>> point_using_named_tuple = namedtuple('Point', 'x_axis, y_axis') |
| 112 | + >>> point_tuple = Point(x_axis=1.0, y_axis=2.0) |
| 113 | + >>> point_tuple.x_axis |
| 114 | + 1.0 |
| 115 | + </code> |
| 116 | + </pre> |
| 117 | + <li>contextlib: context manager is what simplifies cleanup step. It is what you use with the <i>with</i> statement. You can use the <i>contextmanager</i> decorator from the contextlib libary to create your own context manager.</li> |
| 118 | + Though the default, “low level” way to make a context manager is to make a class which follows the context management protocol, by implementing <i>__enter__</i> and <i>__exit__</i> methods, the simplest way is using the contextmanager decorator from the contextlib library, and invoking yield in your context manager function in between the setup and teardown steps. |
| 119 | + <pre> |
| 120 | + <code> |
| 121 | + @contextmanager |
| 122 | + |
| 123 | + </code> |
| 124 | + </pre> |
| 125 | + <li>concurrent.futures: </li> |
| 126 | + <li>logging</li> |
| 127 | + <li>sched</li> |
| 128 | + </ul> |
83 | 129 |
|
84 | 130 | </p>
|
85 | 131 | </div>
|
|
0 commit comments