Top Banner
DETONANDO MITOS EM PYTHON
30

Derrubando mitos em Python

Jul 06, 2015

Download

Documents

Denis Costa
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Derrubando mitos em Python

DETONANDOMITOS EMPYTHON

Page 2: Derrubando mitos em Python

DENIS COSTA@deniscostadsc

Page 3: Derrubando mitos em Python

“Existem alguns mitos no mundo do python...”

Page 4: Derrubando mitos em Python

“...e nós vamos detoná-los hoje.”

Page 5: Derrubando mitos em Python

“Tipo Regex”

Page 6: Derrubando mitos em Python

r'<[^>]*>'

Page 7: Derrubando mitos em Python

r'Raw String'

Page 8: Derrubando mitos em Python

>>> print('\n\n1') 1

Page 9: Derrubando mitos em Python

>>> print(r'\n\n1')\n\n1

Page 10: Derrubando mitos em Python

>>> backslash = '\\'>>> print(backslash)\>>> raw_string = re.compile(r'\\')>>> raw_string.sub('1', backslash)'1'

Page 11: Derrubando mitos em Python

>>> backslash = '\\'>>> print(backslash)\>>> normal_string = re.compile('\\\\')>>> normal_string.sub('1', backslash)'1'

Page 12: Derrubando mitos em Python

Para aprender maishttp://docs.python.org/2/library/re.html

http://docs.python.org/2/reference/lexical_analysis.html#literals

Page 13: Derrubando mitos em Python

“O todo poderoso encoding”

Page 14: Derrubando mitos em Python

# -*- encoding: utf-8 -*-

Page 15: Derrubando mitos em Python

r'coding[:=]\s*([-\w.]+)'

http://hg.python.org/cpython/file/0e41c4466d58/Parser/tokenizer.c#l208

Page 16: Derrubando mitos em Python

Emacs# -*- coding: <encoding name> -*-

Page 17: Derrubando mitos em Python

Vim# vim: set fileencoding=<encoding name> :

Page 18: Derrubando mitos em Python

# coding: utf-8

Page 19: Derrubando mitos em Python

Para aprender maishttp://www.python.org/dev/peps/pep-0263/

Page 20: Derrubando mitos em Python

UnicodeDecodeError

Page 21: Derrubando mitos em Python

Para aprender maishttp://www.youtube.com/watch?v=qa-VkmCSr0s

Page 22: Derrubando mitos em Python

Quebras de linhas onipresentes

Page 23: Derrubando mitos em Python

a = 1 or \2

Page 24: Derrubando mitos em Python

a = (1 or2)

Page 25: Derrubando mitos em Python

“Nem por Odin, suporta orientação a

objetos”

Page 26: Derrubando mitos em Python

>>> l = [1, 2, 3, 4]>>> len(l)4

Page 27: Derrubando mitos em Python

>>> l = [1, 2, 3, 4]>>> l.__len__()4

Page 28: Derrubando mitos em Python

>>> n + 67

Page 29: Derrubando mitos em Python

>>> n = 1>>> n.__add__(6)7

Page 30: Derrubando mitos em Python

Perguntas?