background preloader

Python's blogs&sites

Facebook Twitter

Django and Python Coding Style and Best Practices. 10 нояб. 2011 г.

Django and Python Coding Style and Best Practices

Python Learning Foundation: Computer Programming for Everybody, Tutorials, Book Reviews, Code, and Fun, CP4E. Simeon Visser. Real-World Regular Expressions for Python - Python Central. We’ve covered a lot of ground in this series of articles, so let’s now put it all together and work through a real-life application.

Real-World Regular Expressions for Python - Python Central

A common task is to parse a Windows INI file, which are key/value pairs, separated into sections, something like this: Let’s first write a bit of Python code that reads in a test file, line by line: We will now extend this by writing some regular expressions that figure out what is on each line. Identifying section headers The first thing we’ll do is write a regular expression that will recognize a section header, the lines that start and end with square brackets. In plain English: Match ^ (the start of the line).Match a [ character (escaped, since [ normally has a special meaning in a regular expression).Match one or more characters (the section name), captured in a group.Match a ] character (it’s actually not necessary to escape this).Match $ (the end of the line).

If we update our code to use this regular expression: We get this output: Seems to work fine! A non-magical introduction to Pip and Virtualenv for Python beginners - Blog - DabApps - Brighton, UK. Tagged: python technical One of the hurdles that new Python developers have to get over is understanding the Python packaging ecosystem.

A non-magical introduction to Pip and Virtualenv for Python beginners - Blog - DabApps - Brighton, UK

This blog post is based on material covered in our Python for Programmers training course, which attempts to explain pip and virtualenv for new Python users. Prerequisites Python for Programmers is aimed at developers who are already familiar with one or more programming languages, and so we assume a certain amount of technical knowledge. Pip. Henry’s Weblog. Python Interview Question and Answers»Between engineering and real life. Python — imaplib IMAP example with Gmail. I couldn’t find all that much information about IMAP on the web, other than the RFC3501.

Python — imaplib IMAP example with Gmail

The IMAP protocol document is absoutely key to understanding the commands available, but let me skip attempting to explain and just lead by example where I can point out the common gotchas I ran into. Let’s start by searching our inbox for all mail with the search function. Use the built in keyword “ALL” to get all results (documented in RFC3501). We’re going to extract the data we need from the response, then fetch the mail via the ID we just received. The imap search function returns a sequential id, meaning id 5 is the 5th email in your inbox. This is unacceptable. Luckily we can ask the imap server to return a UID (unique id) instead. Python Programming Examples, Tutorials and Recipes. Getting Started: Python 2.5 - Google App Engine. Python command line oneliners. There is list of pretty useful python small command line oneliners available out of the box.

Python command line oneliners

That means if you already have installed python on your system (most Linux, *BSD, including OSX) then you can use it even if you are not python developer. I love most way to create fake SMTP server: $ python -m smtpd -n -c DebuggingServer localhost:25. Binary Integer Programming With Python. My research is focused on biomolecular NMR and, as such, often involves transferring resonance assignments from one multidimensional NMR spectrum to another.

Binary Integer Programming With Python

In theory this should be a simple task, but it can be extremely time consuming due to small variations in the sample used to acquire the data or in the way the data were acquired. The good news, however, is that it is possible to automate this process using an optimization. Optimization problems, such as aligning x-ray crystallographic models of homologous proteins, are often encountered in structural biology. In the case of a structural alignment, the transformed structure can occupy any set of coordinates, provided the shape of the molecule itself is not changed. PythonTestingToolsTaxonomy - Cheesecake - Trac. NOTE: This is a deprecated version of the PTTT.

PythonTestingToolsTaxonomy - Cheesecake - Trac

For the 'golden image', please visit the official Python wiki page. Unit Testing Tools Mock/Stub Testing Tools. Small parts of Python builtins functionality you might overlook. Python Module of the Week. SecurityTube.net Hack of the Day. Max Burstein's Blog. Nic Young. Python provides a high level threading library that makes threading virtually painless.

Nic Young

Generally, you should only use threads if the following is true: Sharing memory between threads is not an issue.You are not looking for the best optimized performance since threads share memory within a process.You want to be able to share objects between threads.You take precautions that threads are not working on the same object at the same time. Anybody with any experience with threads know that you have to have a way to synchronize the tasks between the threads.

Python once again makes this easy by providing the Queue data structure. The following will be an in depth look at one of the multi-threaded paradigms you can take advantage of using Python's built-in threading and Queue library. Producer and Consumer Paradigm. Python Conquers The Universe. Python, OpenStack, etc.

Python Developer Center. Python Software Foundation News. Planet Python.