background preloader

Advanced python

Facebook Twitter

Virtual Environments. Virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.

Virtual Environments

Basic Usage Create a virtual environment for a project: $ cd my_project_folder $ virtualenv my_project virtualenv my_project will create a folder in the current directory which will contain the Python executable files, and a copy of the pip library which you can use to install other packages. The name of the virtual environment (in this case, it was my_project) can be anything; omitting the name will place the files in the current directory instead. This creates a copy of Python in whichever directory you ran the command in, placing it in a folder named my_project. You can also use the Python interpreter of your choice (like python2.7). $ virtualenv -p /usr/bin/python2.7 my_project or change the interpreter globally with an env variable in ~/.bashrc: $ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7.

The Flask Mega-Tutorial, Part I: Hello, World! This is the first article in a series where I will be documenting my experience writing web applications in Python using the Flask microframework.

The Flask Mega-Tutorial, Part I: Hello, World!

NOTE: This article was revised in September 2014 to be in sync with current versions of Python and Flask. Here is an index of all the articles in the series that have been published to date: My background I'm a software engineer with double digit years of experience developing complex applications in several languages. I first learned Python as part of an effort to create bindings for a C++ library at work. PyQt4.QtGui.QDialogButtonBox.

Hidden features of Python. A gentle introduction to itertools. (Showing code.

A gentle introduction to itertools

Click to hide.) itertools is pretty much the coolest thing ever. Despite a vaguely technical name and a decreased emphasis in most introductory Python materials, it’s the kind of builtin package that makes list comprehensions much less of a syntactical mess. The biggest barrier to using itertools is that there are, well, a lot of methods that tend to all do similar things. With that in mind, this post is a showcase of some of the more basic — yet completely rad — things you can do with these methods. Setup and a Disclaimer First, let’s get the boring part out of the way: import itertools letters = ['a', 'b', 'c', 'd', 'e', 'f'] booleans = [1, 0, 1, 0, 0, 1] numbers = [23, 20, 44, 32, 7, 12] decimals = [0.1, 0.7, 0.4, 0.4, 0.5] Well, that was easy. chain() chain() does exactly what you’d expect it to do: give it a list of lists/tuples/iterables and it chains them together for you.

Let’s try it out! Oh god what happened Relax. Yay, much better! Count() Which isn’t bad at all! Whee! Shut Up and Ship. Learning Python, Linux, Java, Ruby and more with Videos, Tutorials and Screencasts. Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world.

Learning Python, Linux, Java, Ruby and more with Videos, Tutorials and Screencasts

Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined. At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration. Screencasting is easier than you think, and we're happy to help you. The Basics of Python Multithreading and Queues - Troy Fawkes. I’m getting really annoyed at reading through programmer speak.

The Basics of Python Multithreading and Queues - Troy Fawkes

Hey guys, this stuff really isn’t that hard. You just suck at explaining things. Improve Your Python: Python Classes and Object Oriented Programming. The class is a fundamental building block in Python.

Improve Your Python: Python Classes and Object Oriented Programming

It is the underpinning for not only many popular programs and libraries, but the Python standard library as well. Understanding what classes are, when to use them, and how the can be useful is essential, and the goal of this article. In the process, we'll explore what the term Object-Oriented Programming means and how it ties together with Python classes. Everything Is An Object... What is the class keyword used for, exactly?

What do we mean by "logical grouping"? Regardless, classes are a modeling technique; a way of thinking about programs. ..So Everything Has A Class? Classes can be thought of as blueprints for creating objects. Welcome to Python for you and me — Python for you and me 0.3.alpha1 documentation.