background preloader


Facebook Twitter

How I Implemented HFSM In Python. Learning step-by-step implementation of… Getting Started Learning the step-by-step implementation of HFSM concepts in Python.

How I Implemented HFSM In Python. Learning step-by-step implementation of…

I wanted to use the HFSM (Hierarchical Finite State Machine) in my Pacman AI Agent Implementation to fully understand the concepts and to compare it with the Behavior Tree. In my experience, after reading books and papers of some technical topics, my comprehension of the topics would greatly improve if I implemented them in code. Passing Messages to Processes — PyMOTW 3. As with threads, a common use pattern for multiple processes is to divide a job up among several workers to run in parallel.

Passing Messages to Processes — PyMOTW 3

Effective use of multiple processes usually requires some communication between them, so that work can be divided and results can be aggregated. Turn Photos into Cartoons Using Python. To create a cartoon effect, we need to pay attention to two things; edge and color palette.

Turn Photos into Cartoons Using Python

Those are what make the differences between a photo and a cartoon. To adjust that two main components, there are four main steps that we will go through: Load imageCreate edge maskReduce the color paletteCombine edge mask with the colored image Before jumping to the main steps, don’t forget to import the required libraries in your notebook, especially cv2 and NumPy. import cv2import numpy as np# required if you use Google Colabfrom google.colab.patches import cv2_imshowfrom google.colab import files The first main step is loading the image. Call the created function to load the image. Cool New Features in Python 3.7. Python 3.7 is officially released!

Cool New Features in Python 3.7

This new Python version has been in development since September 2016, and now we all get to enjoy the results of the core developers’ hard work. Python Tutorial: Easy Introduction into Decorators and Decoration. Introduction Decorators belong most probably to the most beautiful and most powerful design possibilities in Python, but at the same time the concept is considered by many as complicated to get into.

Python Tutorial: Easy Introduction into Decorators and Decoration

To be precise, the usage of decorators is very easy, but writing decorators can be complicated, especially if you are not experienced with decorators and some functional programming concepts. 6 Things to Know to Demystify Namespaces and Scopes in Python. 16.4. argparse — Parser for command-line options, arguments and sub-commands — Python 3.6.12 documentation. The argparse module makes it easy to write user-friendly command-line interfaces.

16.4. argparse — Parser for command-line options, arguments and sub-commands — Python 3.6.12 documentation

The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. The argparse module also automatically generates help and usage messages and issues errors when users give the program invalid arguments. Python Attribute Access and the Descriptor Protocol. October 16, 2019 Let’s look at the following snippet: class Foo: def __init__(self): = 'hello!

Python Attribute Access and the Descriptor Protocol

' foo = Foo()print( We already know how Foo instantiation works. Today, our question is this: Implementation of Common Design Patterns in Python. In software development, design patterns are a proven solution to a common problem in a specific context.

Implementation of Common Design Patterns in Python

Their main goal is to show us good ways to program things and explain why other options won’t work. Using common design patterns, you can: Speed up the development process;Reduce the number of lines of code;Make sure your code is well-designed;Anticipate future problems arising from small issues. Design patterns can considerably improve the life of a software developer disregarding the programming language (s)he uses. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) Ever wonder about that mysterious Content-Type tag?

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

You know, the one you’re supposed to put in HTML and you never quite know what it should be?


Variables, scopes et closures en Python. Il est un sujet en Python qui concentre beaucoup d’interrogations : celui de la gestion des variables.

Variables, scopes et closures en Python

Les variables sont l’un des premiers mécanismes que l’on rencontre en Python, mais on peut facilement constater que leur fonctionnement est souvent mal compris. Malheureusement, cela est dû à des explications souvent trompeuses voire erronées dans les cours enseignant le Python. Part 1: Introduction to Classic RPyC — RPyC. We’ll kick-start the tutorial with what is known as classic-style RPyC, i.e., the methodology of RPyC 2.60. Since RPyC 3 is a complete redesign of the library, there are some minor changes, but if you were familiar with RPyC 2.60, you’ll feel right at home. And even if you were not – we’ll make sure you feel at home in a moment ;) Running a Server¶ Let’s start with the basics: running a server. In this tutorial we’ll run both the server and the client on the same machine (the localhost). Autour du code. Nous allons voir comment distribuer un projet python sur pypi pour que n'importe qui puisse l'installer en utilisant la commande pip install.

Organiser son projet pour le distribuer Dans cet exemple, on va distribuer un projet fictif nommé felkafe. Sans titre. - Charsets et encoding. ( Cet article est la traduction française de ) Si vous pensez que texte = ASCII = 8 bits = 1 octet par caractère, vous avez tout faux. C'est une façon de voir très étriquée. Il y a quelquechose que tout développeur devrait savoir, sans quoi il se prendra forcément les pieds dedans un jour ou l'autre: Charsets et encoding (Jeux de caractères et encodage) Ok, laissez-moi mettre les points sur les i: Vous savez que l'ordinateur est une grosse machine stupide. Les jeux de caractères (charset) Tout d'abord, nous devons choisir quel nombre utiliser pour représenter chaque symbole. Keon/algorithms: Minimal examples of data structures and algorithms in Python.

Awesome Python.

Tests & Jeux d'essais

The Python Exception Class Hierarchy. The Python exception class hierarchy consists of a few dozen different exceptions spread across a handful of important base class types. As with most programming languages, errors occur within a Python application when something unexpected goes wrong. Anything from improper arithmetic and running out of memory to invalid file references and unicode formatting errors may be raised by Python under certain circumstances. Most of the errors we’ll explore in this series are considered exceptions, which indicate that these are non-fatal errors. While a fatal error will halt execution of the current application, all non-fatal exceptions allow execution to continue. This allows our code to explicitly catch or rescue the raised exception and programmatically react to it in an appropriate manner.


Multiprogramming. Profiling. Python class decorator - part II - with configuration arguments. Here we continue to reveal protocol about class based decorator and how it is implemented in python3. You can check and previous article: how class decorator constructs without arguments In most cases we’d like to pass arguments to our decorator in order to setup things required for wrapping. The similarity with those without arguments is that again we need both methods init and call … but now logic slightly changed let’s verify: class MyClassDecorator: def __init__(self, *a, **kw): print('__init__',a ,kw) def __call__(self, *a, **kw): print('__call__',a, kw) @MyClassDecorator(1,2,3,"decorator configuration") def my_function(*args, **kwargs): print('call my_function', args, kwargs) return 3.

Ceci n'est pas un blog: Le challenge du logo ANSSI. MAJ 07/03/2015 : Le site web de l'ANSSI a fait peau neuve il y a quelques jours et du ménage a été fait sur certains contenus. Les fonds d'écran contenant le challenge ne semblent plus hébergés sur le site. Les discours de M. Pailloux auxquels je faisais référence ont également disparu. Décorateurs - Notions de Python avancées. Python 3 Module of the Week — PyMOTW 3. Ksamuel/Pyped: Let you apply a Python expression to a command output like Perl or Awk would do. Python Language - * args et ** kwargs. Darko-itpro/training-python. Creating a singleton in Python. Pièges communs — The Hitchhiker's Guide to Python. Pour la plus grande partie, Python vise à être un langage propre et cohérent qui permet d’éviter des surprises. Cependant, il y a quelques cas qui peuvent être sources de confusion pour les nouveaux arrivants. Certains de ces cas sont intentionnels, mais peuvent être potentiellement surprenants. Certains pourraient sans doute être considérés comme des verrues du langage.

En général, ce qui suit est une collection de comportements potentiellement délicats qui pourraient sembler étranges à première vue, mais qui sont généralement raisonnables une fois que vous êtes au courant de la cause sous-jacente de cette surprise. Using the ffi/lib objects — CFFI 1.13.2 documentation. Keep this page under your pillow. Working with pointers, structures and arrays¶ The C code’s integers and floating-point values are mapped to Python’s regular int, long and float. Moreover, the C type char corresponds to single-character strings in Python. (If you want it to map to small integers, use either signed char or unsigned char.) Similarly, the C type wchar_t corresponds to single-character unicode strings. New in version 1.11: in addition to wchar_t, the C types char16_t and char32_t work the same but with a known fixed size.

Pointers, structures and arrays are more complex: they don’t have an obvious Python equivalent., [initializer]): this function builds and returns a new cdata object of the given ctype. The memory is initially filled with zeros.