background preloader

Python

Facebook Twitter

Python Design Patterns Guide | Toptal. Let’s say it again: Python is a high-level programming language with dynamic typing and dynamic binding. I would describe it as a powerful, high-level dynamic language. Many developers are in love with Python because of its clear syntax, well structured modules and packages, and for its enormous flexibility and range of modern features. In Python, nothing obliges you to write classes and instantiate objects from them. If you don’t need complex structures in your project, you can just write functions.

Even better, you can write a flat script for executing some simple and quick task without structuring the code at all. At the same time Python is a 100 percent object-oriented language. How’s that? So, you can write simple scripts in Python, or just open the Python terminal and execute statements right there (that’s so useful!). However, because Python is so powerful and flexible, we need some rules (or patterns) when programming in it. Why Is Python Good For Patterns? Python Design Patterns. The Pattern Concept — Python 3 Patterns, Recipes and Idioms. “Design patterns help you learn from others’ successes instead of your own failures [1].” Probably the most important step forward in object-oriented design is the “design patterns” movement, chronicled in Design Patterns (ibid) [2]. That book shows 23 different solutions to particular classes of problems.

In this book, the basic concepts of design patterns will be introduced along with examples. This should whet your appetite to read Design Patterns by Gamma, et. al., a source of what has now become an essential, almost mandatory, vocabulary for OOP programmers. The latter part of this book contains an example of the design evolution process, starting with an initial solution and moving through the logic and process of evolving the solution to more appropriate designs. What is a Pattern? ¶ Initially, you can think of a pattern as an especially clever and insightful way of solving a particular class of problems. So the goal of design patterns is to isolate changes in your code. Footnotes. Gdd pydp.

DesignPatternsInPython ver0.1. Python-patterns/borg.py at master · faif/python-patterns. Examples — Kivy 1.8.1-dev documentation. Py:Patterns. Python - Advanced List Sorting. Consider a list of tuples. We could get such a list when processing information that was extracted from a spreadsheet program. For example, if we had a spreadsheet with raw census data, we can easily transform it into a sequence of tuples that look like the following. jobData= [ (001,'Albany','NY',162692), (003,'Allegany','NY',11986), ... (121,'Wyoming','NY',8722), (123,'Yates','NY',5094) ] Each tuple can be built from a row of the spreadsheet. In this case, we wrote a simple forumla in our spreadsheet to make each row into a tuple. We could have used the csv module to read a version of spreadsheet saved as a .csv file, but cutting and pasting is pretty quick, also.

Once we have each row as a tuple, we can put some []'s around the tuples to make a list. Sorting this list can be done trivially with the list sort method. jobData.sort() Note that this updates the list in place. This kind of sort will simply compare each tuple with each other tuple. Sorting With a Compare Function. Un outil de forensics pour Skype. Un outil de forensics pour Skype Si vous avez besoin de manière rapide et discrète d'extraire les données d'un Skype (pour du forensics par exemple), c'est possible ! Grâce à SkypeFreak, un outil utilisant un script Python, vous pourrez extraire du fichier main.db les détails du profil Skype, les contacts, la liste des appels et l'intégralité des messages.

Il suffit de lancer SkypeFreak, d'entrer le nom d'utilisateur qui vous intéresse (respectez la casse) et tadaaaaa.... L'outil est packagé sous la forme d'un .exe sous Windows mais sur le Github, vous trouverez dans le dossier "Sources" le fichier python capable de sortir toutes ces infos. Donc vous pourrez le faire tourner sous OSX ou Linux. Rien n'est chiffré comme vous pouvez le voir. Du coup, si vous souhaitez éviter ce genre de chose, le mieux c'est de chiffrer complètement votre partition (ou le répertoire contenant ce fameux fichier main.db) avec un outil comme Truecrypt. Source Vous avez aimé cet article ? Python. Pip — pip 1.4.dev1 documentation. Python Reference Manual.