background preloader

Python 3

Facebook Twitter

The definitive guide on how to use static, class or abstract methods in Python. Doing code reviews is a great way to discover things that people might struggle to comprehend.

The definitive guide on how to use static, class or abstract methods in Python

While proof-reading OpenStack patches recently, I spotted that people were not using correctly the various decorators Python provides for methods. So here's my attempt at providing me a link to send them to in my next code reviews. :-) This article has been kindly converted and recorded as a video by Webucator, provider of Python training. It's a good alternative to reading, if you prefer listening to someone and following step-by-step explanation of the code.. (A Semi-Official) Python FAQ Zone. This effbot zone, a sister site to the Python Tutorial Wiki, contains a copy of the standard Python FAQ.

(A Semi-Official) Python FAQ Zone

This site replaces the version hosted at infogami. This site is being used as an editing and staging area; “stable” versions will be published over at python.org at regular intervals, once all the tools are in place. Modifying the __add__ method of a Python Class. Learn how you should modify the __add__ method of a Python class to be able to add two instances of a custom object.

Modifying the __add__ method of a Python Class

We also talk about the __radd__ method, necessary to sum a list of instances. When we sum two objects in Python, like. Advanced Objects: Special Methods. At first glance, The __new__() method seems similar to the __init__() method, but it is actually quite different.

Advanced Objects: Special Methods

You will remember that you instantiate a class (that is, create a new instance of that class) by calling the class. The __init__() method returns nothing—it merely initializes what __new__() has created. The __new__() method, on the other hand, returns the object that will become the return value of the instantiation call. Like __init__(), __new__() receives the arguments that the caller passes when calling the class.

Python3 Tutorial: Magic Methods. Introduction The so-called magic methods have nothing to do with wizardry.

Python3 Tutorial: Magic Methods

You have already seen them in previous chapters of our tutorial. They are the methods with this clumsy syntax, i.e. the double underscores at the beginning and the end. IdleX - IDLE Extensions for Python. Redis Quick Start – Redis. This is a quick start document that targets people without prior experience with Redis.

Redis Quick Start – Redis

Reading this document will help you: Download and compile Redis to start hacking. Use redis-cli to access the server. Use Redis from your application. Understand how Redis persistence works. The suggested way of installing Redis is compiling it from sources as Redis has no dependencies other than a working GCC compiler and libc. You can either download the latest Redis tar ball from the redis.io web site, or you can alternatively use this special URL that always points to the latest stable Redis version, that is,

Virtualenv with Eclipse with PyDev on Windows 10 – London App Developer. This article will explain how to install virtualenv and create a new Python Project in eclipse which uses a custom virtual environment.

Virtualenv with Eclipse with PyDev on Windows 10 – London App Developer

There is also a little Hello World style example at the end! This article assumes that you have Python, Eclipse and the PyDev plugin installed on your machine. If you need to know how to do this, please see my previous post: Setting up your Windows 10 System for Python Development (PyDev, Eclipse, Python). In the current public version of Python, there is a bug in one of the packages which will display the following error message if you try to install any packages using pip: This bug has been fixed in the current dev release but still exists in the production version at the time of writing this article.

Python Virtual Environments - a primer. In this article, we’ll show how to use virtual environments to create and manage separate environments for your Python projects, each using different versions of Python for execution, as well as how Python dependencies are stored and resolved.

Python Virtual Environments - a primer

Updated 11/06/2016: Added section on changing Python versions with virtualenv. Why the need for virtual environments? Python, like most other modern programming languages, has its own unique way of downloading, storing, and resolving packages (or modules). While this has its advantages, there were some interesting decisions made about package storage and resolution, which has lead to some problems – namely how and where packages are stored. Multiprocessing — Manage Processes Like Threads — PyMOTW 3. What’s New In Python 3.6 — Python 3.6.0 documentation. This article explains the new features in Python 3.6, compared to 3.5.

What’s New In Python 3.6 — Python 3.6.0 documentation

Python 3.6 was released on December 23, 2016. See the changelog for a full list of changes. New Features PEP 498: Formatted string literals PEP 498 introduces a new kind of string literals: f-strings, or formatted string literals. Formatted string literals are prefixed with 'f' and are similar to the format strings accepted by str.format(). PEP 526: Syntax for variable annotations. Communication Between Processes - Python Module of the Week. As with threads, a common use pattern for multiple processes is to divide a job up among several workers to run in parallel.

Communication Between Processes - Python Module of the Week

Effective use of multiple processes usually requires some communication between them, so that work can be divided and results can be aggregated. Passing Messages to Processes A simple way to communicate between process with multiprocessing is to use a Queue to pass messages back and forth. Any pickle-able object can pass through a Queue. import multiprocessing class MyFancyClass(object): def __init__(self, name): self.name = name def do_something(self): proc_name = multiprocessing.current_process().name print 'Doing something fancy in %s for %s! ' Welcome to the wxPython Phoenix Project — wxPython Phoenix 3.0.3 documentation. WxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. What is wxPython. Index of /Phoenix/snapshot-builds. How to install Django on Windows.

Installation — Wand 0.4.5. Wand itself can be installed from PyPI using pip: Wand is a Python binding of ImageMagick, so you have to install it as well: Note Wand yet doesn’t support ImageMagick 7 which has several incompatible APIs with previous versions. For more details, see the issue #287. Or you can simply install Wand and its entire dependencies using the package manager of your system (it’s way convenient but the version might be outdated): Install ImageMagick on Debian/Ubuntu If you’re using Linux distributions based on Debian like Ubuntu, it can be easily installed using APT: $ sudo apt-get install libmagickwand-dev If you need SVG, WMF, OpenEXR, DjVu, and Graphviz support you have to install libmagickcore5-extra as well: $ sudo apt-get install libmagickcore5-extra Install ImageMagick on Fedora/CentOS If you’re using Linux distributions based on Redhat like Fedora or CentOS, it can be installed using Yum: $ yum update $ yum install ImageMagick-devel.

Requests: HTTP for Humans — Requests 2.10.0 documentation. Jupyter and the future of IPython — IPython. Try Jupyter! Python Properties. It is often considered best practice to create getters and setters for a class's public properties. Many languages allow you to implement this in different ways, either by using a function (like person.getName()), or by using a language-specific get or set construct. In Python, it is done using @property. In this article I'll be describing they Python property decorator, which you may have seen being used with the @decorator syntax: Inner functions - what are they good for? Python-xy.GitHub.io by python-xy.