|
|
|
@ -234,6 +234,166 @@
|
|
|
|
|
A part of the main.</p> |
|
|
|
|
<p>-- John Donne</p> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>Type Hinting: Love it</h2> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<p>"Mas Python não tem tipos!"</p> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
In [1]: type(object) |
|
|
|
|
Out[1]: type |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<img class="stretch" src="_images/isso-nao-prova-nada.png" alt=""> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<pre><code data-trim> |
|
|
|
|
In [4]: type("a") |
|
|
|
|
Out[4]: str |
|
|
|
|
|
|
|
|
|
In [5]: type(str) |
|
|
|
|
Out[5]: type |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<pre><code data-trim> |
|
|
|
|
def to_fahrenheit(temperature: int) -> int: |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<pre><code data-trim> |
|
|
|
|
@dataclass |
|
|
|
|
class Celcius: |
|
|
|
|
temperature: int |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_fahrenheit(temperature: Celcius) -> int: |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>mypy</h2> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<img class="stretch" src="_images/tweet-python2020.png" alt=""> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>??</h2> |
|
|
|
|
|
|
|
|
|
<p class="fragment">None-aware operator (PEP 505)</p> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
a ??= 'value' |
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
a = a if a is not None else 'value' |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>@</h2> |
|
|
|
|
|
|
|
|
|
<p class="fragment">Dedicated infix operator for matrix multiplication (PEP 465)</p> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>|</h2> |
|
|
|
|
|
|
|
|
|
<p class="fragment">Union Operator to Dict (PEP 584)</p> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
dict1.update(dict2) # in-place |
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
dict3 = dict1 | dict2 |
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
dict1 |= dict2 # same as .update() |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>:=</h2> |
|
|
|
|
|
|
|
|
|
<p class="fragment">Assignment Operator (PEP 572)</p> |
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code data-trim> |
|
|
|
|
while chunk := file.read(8192): |
|
|
|
|
process(chunk) |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>@dict[key].attr[0].decorator</h2> |
|
|
|
|
|
|
|
|
|
<p class="fragment">Relaxing Grammar Restrictions On Decorators (PEP 614)</p> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h2>Steering Council <span class="fragment"> 🤔 </span></h2> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h3>Python Positional-Only Parameters (PEP 570)</h3> |
|
|
|
|
|
|
|
|
|
<pre><code data-trim> |
|
|
|
|
pow(x, y, z=None, /) |
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
>>> pow(x=5, y=3) |
|
|
|
|
Traceback (most recent call last): |
|
|
|
|
File "<stdin>", line 1, in <module> |
|
|
|
|
TypeError: pow() takes no keyword arguments |
|
|
|
|
</code></pre> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<p>"Without the ability to specify which parameters are |
|
|
|
|
positional-only, library authors must be careful when |
|
|
|
|
choosing appropriate parameter names."</p> |
|
|
|
|
|
|
|
|
|
<h1 class="fragment">🤦</h1> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<img class="stretch" src="_images/chrysalis.jpeg" alt=""> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<img class="stretch" src="_images/oogway.jpeg" alt=""> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<img class="stretch" src="_images/fear.jpeg" alt=""> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
<h1>??</h1> |
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
<section data-background='_images/thats-all-folks.jpg'> |
|
|
|
|
<div class="semi-opaque"> |
|
|
|
|
<ul class="empty"> |
|
|
|
|
<li><a href="https://functional.cafe/@juliobiason">https://functional.cafe/@juliobiason</a></li> |
|
|
|
|
<li><a href="https://t.me/juliobiason">https://t.me/juliobiason</a></li> |
|
|
|
|
<li>julio.biason@pm.me</li> |
|
|
|
|
<li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li> |
|
|
|
|
</ul> |
|
|
|
|
</div> |
|
|
|
|
</section> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|