Browse Source

completed the six presentation

master
Julio Biason 8 years ago
parent
commit
cd52526a28
  1. BIN
      _images/crying-on-sofa1.gif
  2. BIN
      _images/logo-horizontal-claro.png
  3. BIN
      _images/logo-horizontal-escuro.png
  4. BIN
      _images/snake-six.jpg
  5. 96
      python23six.html

BIN
_images/crying-on-sofa1.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

BIN
_images/logo-horizontal-claro.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
_images/logo-horizontal-escuro.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
_images/snake-six.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

96
python23six.html

@ -36,6 +36,14 @@
.happy { .happy {
color: yellow; color: yellow;
} }
.semi-opaque {
background-color: rgba(0, 0, 0, 0.7);
}
.reveal section img {
border: none;
}
</style> </style>
</head> </head>
@ -43,19 +51,19 @@
<div class="reveal"> <div class="reveal">
<div class="slides"> <div class="slides">
<section> <section>
<section> <section data-background="_images/snake-six.jpg">
<h1>Python 2 + 3 = Six</h1> <h1 class="semi-opaque">Python 2 + 3 = Six</h1>
</section> </section>
</section> </section>
<section> <section>
<section> <section>
<img src="_images/AYV1X0yv.png" alt="Me" style="float:left;"> <img src="_images/AYV1X0yv.png" alt="Me" style="float:left;" class="no-border">
<div> <div>
<ul> <ul>
<li>Júlio Biason</li> <li>Júlio Biason</li>
<li>CWI Software</li> <li><img src="_images/logo-horizontal-claro.png" alt="CWI Software" class='no-border'>
<li>@juliobiason</li> <li>@juliobiason</li>
<li>julio.biason@gmail.com</li> <li>julio.biason@gmail.com</li>
</ul> </ul>
@ -69,6 +77,8 @@
<ul> <ul>
<li>Unicode por padrão <span class="frament">(adeus UnicodeDecodeError)</span></li> <li>Unicode por padrão <span class="frament">(adeus UnicodeDecodeError)</span></li>
<li class="fragment">Mock é uma classe padrão</li>
<li class="fragment">Enum é uma classe padrão</li>
<li class="fragment">AsyncIO</li> <li class="fragment">AsyncIO</li>
<li class="fragment">SUPORTE AO PYTHON 2 TERMINA EM 2020!</li> <li class="fragment">SUPORTE AO PYTHON 2 TERMINA EM 2020!</li>
</ul> </ul>
@ -127,19 +137,26 @@
<section> <section>
<section> <section>
<h3>"Mais minha infra usa Centos 4 e não tem Python 3 pra Centos!"</h3> <h3>"Minha infra usa Centos 4 e não tem Python 3 pra Centos!"</h3>
<img src="_images/boycrying.jpg" alt=""/> <img src="_images/boycrying.jpg" alt=""/>
</section> </section>
<section>
<h3>"Eu mantenho uma aplicação Python 2.6!"</h3>
<img src="_images/crying-on-sofa1.gif" alt=""/>
</section>
<section> <section>
<h1>Six ao resgate!</h1> <h1>Six ao resgate!</h1>
<h2 class="fragment">e seu fiel companheiro <code>__future__</code>!</h2> <h2 class="fragment">e seu fiel companheiro <code>__future__</code>!</h2>
<h3 class="fragment">...mas apenas para aqueles com Python 2.7.</h3>
</section> </section>
<section> <section>
<h2>Exemplo <span class="fragment">(estúpido)</span></h2> <h2>Exemplo <span class="fragment">(estúpido)</span></h2>
<pre><code>import collections <pre><code class='python'>import collections
class Model(object): class Model(object):
def __init__(self, word): def __init__(self, word):
@ -158,7 +175,7 @@ class Model(object):
</section> </section>
<section> <section>
<pre><code> <pre><code class='python'>
@property @property
def letters(self): def letters(self):
return self._count return self._count
@ -169,7 +186,7 @@ class Model(object):
</section> </section>
<section> <section>
<pre><code> <pre><code class='python'>
if __name__ == "__main__": if __name__ == "__main__":
word = Model('This is an ex-parrot') word = Model('This is an ex-parrot')
for letter, count in word.letters.iteritems(): for letter, count in word.letters.iteritems():
@ -240,7 +257,7 @@ print('{} {}'.format(letter, count))
<h2>Compatível entre 2 e 3</h2> <h2>Compatível entre 2 e 3</h2>
<h3>(sugestão)</h3> <h3>(sugestão)</h3>
<pre><code> <pre><code class='python'>
print('{letter} {count}'.format(letter=letter, print('{letter} {count}'.format(letter=letter,
count=count)) count=count))
</code></pre> </code></pre>
@ -257,7 +274,7 @@ print('{letter} {count}'.format(letter=letter,
<h2>Compatível entre 2 e 3</h2> <h2>Compatível entre 2 e 3</h2>
<h3>(sugestão mais melhor ainda)</h3> <h3>(sugestão mais melhor ainda)</h3>
<pre><code> <pre><code class='python'>
import six import six
[...] [...]
@ -275,7 +292,7 @@ six.print_('{letter} {count}'.format(letter=letter,
<section> <section>
<h2>Compatível entre 2 e 3</h2> <h2>Compatível entre 2 e 3</h2>
<pre><code> <pre><code class='python'>
for letter, count in word.letters.iteritems(): for letter, count in word.letters.iteritems():
</code></pre> </code></pre>
@ -296,6 +313,63 @@ for letter, count in six.iteritems(word.letters):
<p class="fragment">... o código era estúpido mesmo...</p> <p class="fragment">... o código era estúpido mesmo...</p>
</section> </section>
</section> </section>
<section>
<section>
<h2>Exemplo 2<span class="fragment"> (real)</span></h2>
<pre><code class="python">import urllib
import urlparse
def add_querystring(url, querystring, value):
frags = list(urlparse.urlsplit(url))
query = frags[3]
query_frags = urlparse.parse_qsl(query)
query_frags.append((querystring, value))
frags[3] = urllib.urlencode(query_frags)
return urlparse.urlunsplit(frags)
if __name__ == "__main__":
print add_querystring('http://python.org', 'doc', 'urllib')
print add_querystring('http://python.org?doc=urllib',
'page', '2')</code></pre>
</section>
<section>
<h2>E Python 3?</h2>
<p><code>urlparse</code> foi "juntada" com <code>urllib</code>.</p>
<p>Coisas da <code>urllib</code> mudaram de lugar.</p>
</section>
<section>
<h2>Compatível entre 2 e 3</h2>
<pre><code class="python">import six
def add_querystring(url, querystring, value):
frags = list(six.moves.urllib.parse.urlsplit(url))
query = frags[3]
query_frags = six.moves.urllib.parse.parse_qsl(query)
query_frags.append((querystring, value))
frags[3] = six.moves.urllib.parse.urlencode(query_frags)
return six.moves.urllib.parse.urlunsplit(frags)
if __name__ == "__main__":
six.print_(add_querystring('http://python.org', 'doc', 'urllib'))
six.print_(add_querystring('http://python.org?doc=urllib',
'page', '2'))</code></pre>
</section>
</section>
<section data-background='_images/thats-all-folks.jpg'>
<section>
<h1 class="fragment semi-opaque">Perguntas?</h1>
<p class="fragment semi-opaque">E antes que alguém pergunte,
é 2 <strong>*</strong>3, não 2 <strong>+</strong>3.</p>
</section>
</section>
</div> </div>
</div> </div>

Loading…
Cancel
Save