19

Python 3, patterns and indioms

Embed Size (px)

DESCRIPTION

Palestra apresentada na PythonBrasil[9], 2013 em Brasília. http://www.youtube.com/watch?v=phSzMwBzd08

Citation preview

Page 1: Python 3, patterns and indioms

Python3 Patterns and Idioms

Ramiro Batista da Luz

Associação Python Brasil

3 de Outubro de 2013

Page 2: Python 3, patterns and indioms

I Site o�cial http://www.mindviewinc.com/Books/Python3Patterns/Index.php

I Criar conta em http://www.bitbucket.org

I Fork (opcional) https://bitbucket.org/BruceEckel/python-3-patterns-idioms/

I Clone - hg clonehttps://bitbucket.org/BruceEckel/python-3-patterns-idioms

I Se você criou um fork (Use o botão Clone para obter ocomando para clonar seu fork) - hg clonehttps://[email protected]/ramiroluz/python-3-patterns-idioms

Page 3: Python 3, patterns and indioms

I O livro é para quem já programa. Capítulo curtointrodutório.

I Scripting vs. Programming.

I Built-in containers.

I Functions.

I Strings.

I Classes. (class, def, __init__, self, __name__,herança.

I Técnicas úteis. PythonForProgrammers/arguments.py,PythonForProgrammers/utility.py ePythonForProgrammers/compose.py

Page 4: Python 3, patterns and indioms

I __new__() vs. __init__().Initialization/new_vs_init.py

I Atributos estáticos. Initialization/static.py

I Clean Up. Initialization/cleanup.py

I WeakRef. Initialization/weakref_clean.py

Page 5: Python 3, patterns and indioms

I Escreva os testes primeiro.

I Teste simples em python. code/SanityCheck.py

I Um framework de testes muito simples.UnitTesting/UnitTest.py

I Escrevendo os testes. UnitTesting/UnitTest.py eUnitTesting/TestDemo2.py

I Testes White-Box e Black-Box. UnitTesting/Testable.py,UnitTesting/TooMuchAccess.py,UnitTesting/testable/Testable.py,UnitTesting/BlackBoxTest.py

I Rodando os testes. UnitTesting/RunUnitTests.py

Page 6: Python 3, patterns and indioms

I História das macros.

I Objetivos das macros.

I o que pode ser feito com decorators?PythonDecorators/entry_exit_function.py

I Function decorators. PythonDecorators/my_decorator.py

I Um pouco mais útil.PythonDecorators/entry_exit_class.py

I Usando funções como decorators.PythonDecorators/entry_exit_function.py

I Revisão: Decoradores sem argumentos.PythonDecorators/decorator_without_arguments.py

I Decorators com argumentos.PythonDecorators/decorator_with_arguments.py

Page 7: Python 3, patterns and indioms

I Iterators. Iterables/sum_�rst_n_list.py,Iterables/sum_�rst_n_iterable.py

I Generators. Iterables/gen.py esum_of_�rst_n_generator.py

I Itertools. Iterables/itertools_chain.py,Iterables/itertools_izip.py, Iterables/itertools_islice.py

Page 8: Python 3, patterns and indioms

I Compreensão de listas.

I Compreensão aninhada.

I Tecnicas.

I Um exemplo mais complexo.

I Compreensão de conjuntos.

I Compreensão de dicionários.

Page 9: Python 3, patterns and indioms

I O GIL

I Multiprocessing. Concurrency/multiprocess_bar.py

Page 10: Python 3, patterns and indioms

I Singleton pattern.

I New singleton.

I Borg singleton.

I Class Variable singleton.

I Singleton decorator.

I Singleton MetaClass.

Page 11: Python 3, patterns and indioms

I ProxyDemo.py

I ProxyDemo2.py

I StateDemo.py

Page 12: Python 3, patterns and indioms

I StateMachine/State.py

I StateMachine/StateMachine.py

I StateMachine/mouse/MouseAction.py

I StateMachine/mousetrap1/MouseTrapTest.py

I StateMachine/mousetrap2/MouseTrap2Test.py

Page 13: Python 3, patterns and indioms

I Decorator/nodecorators/Co�eeShop.py

I Decorator/alldecorators/EspressoDecorator.py

I Decorator/alldecorators/Co�eeShop.py

I Decorator/compromise/Co�eeShop.py

Page 14: Python 3, patterns and indioms

I Util/TypedIterator.py

Page 15: Python 3, patterns and indioms

I Factory/shapefact1/ShapeFactory1.py

I Factory/shapefact1/NestedShapeFactory.py

I Factory/shapefact2/ShapeFactory2.py

I Factory/Games.py

I Factory/Games2.py

Page 16: Python 3, patterns and indioms

I FunctionObjects/CommandPattern.py

I FunctionObjects/StrategyPattern.py

I FunctionObjects/ChainOfResponsibility.py

Page 17: Python 3, patterns and indioms

I http://www.mindviewinc.com/Books/

I Thinking in Python

I First Steps in Flex

I Thinking in Java 4th Edition

I Electronic book: Thinking in C++, Second Edition(Volumes 1 & 2)

I Thinking in C++, Volume 2: Practical Programming

I Thinking in Patterns

Page 18: Python 3, patterns and indioms

I Revisão.

I Tradução.

I Revisão da Tradução.

Sua ideia aqui

Page 19: Python 3, patterns and indioms

I Tânia, Rafahela, Cintia.

I Patrocinadores.

I Comunidade.