background preloader

Domikno

Facebook Twitter

Style Guide for Python Code. Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b.

Style Guide for Python Code

This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value.

Python Exception Handling Techniques - Doug Hellmann. Error reporting and processing through exceptions is one of Python’s key features.

Python Exception Handling Techniques - Doug Hellmann

Care must be taken when handling exceptions to ensure proper application cleanup while maintaining useful error reporting. Error reporting and processing through exceptions is one of Python’s key features. Unlike C, where the common way to report errors is through function return values that then have to be checked on every invocation, in Python a programmer can raise an exception at any point in a program. Salesforce. Arduino Tutorial - Lesson 3 - Breadboards and LEDs. You've started modifying sketches, and played a bit with the onboard LED (or if you have an NG, an LED you added).

Arduino Tutorial - Lesson 3 - Breadboards and LEDs

The next step is to start adding onto the hardware component of the Arduino. We will do this by adding a solderless breadboard to our setup, connecting up new parts with wire. Salesforce development. Getting Started with WSGI. Written on Monday, May 21, 2007 I finally finished the written matura and have some more time to work on projects and write articles.

Getting Started with WSGI

One of the things I wanted to write for a long time is a WSGI tutorial that does not require a specific framework or implementation. So here we go. What's WSGI? Basically WSGI is lower level than CGI which you probably know. WSGI is specified in the PEP 333 and adapted by various frameworks including the well known frameworks django and pylons. Arduino Tutorial - Learn electronics and microcontrollers using Arduino! So, I get two or three emails a day, all basically asking the same thing: "Where can I learn about electronics?

Arduino Tutorial - Learn electronics and microcontrollers using Arduino!

" In general, most of these people have seen some of my projects and want to be able to build similar things. Unfortunately, I have never been able to point them to a good site that really takes the reader through a solid introduction to microcontrollers and basic electronics. I designed this tutorial course to accompany the Arduino starter pack sold at the Adafruit webshop. The pack contains all the components you need (minus any tools) for the lessons Follow these lessons for happiness and prosperity. Lesson 0 Pre-flight check...Is your Arduino and computer ready? Here are some recommended tools: If you need to get any soldering done, you may also want....

All of the content in the Arduino Tutorial is CC 2.5 Share-Alike Attrib. Love it? To some extent, the structure of the material borrows from: The impressively good "What's a microcontroller? " Salesforce. Blog » Python. A Do-It-Yourself Framework — Paste v1.7.5.1 documentation. This tutorial has been translated into Portuguese.

A Do-It-Yourself Framework — Paste v1.7.5.1 documentation

A newer version of this article is available using WebOb. Introduction and Audience This short tutorial is meant to teach you a little about WSGI, and as an example a bit about the architecture that Paste has enabled and encourages. This isn’t an introduction to all the parts of Paste – in fact, we’ll only use a few, and explain each part. Top 40 Arduino Projects of the Web. Linux keyboard shortcuts. Python: List Comprehensions. Python supports a concept called "list comprehensions".

Python: List Comprehensions

It can be used to construct lists in a very natural, easy way, like a mathematician is used to do. The following are common ways to describe lists (or sets, or tuples, or vectors) in mathematics. You probably know things like the above from mathematics lessons at school. In Python, you can write these expression almost exactly like a mathematician would do, without having to remember any special cryptic syntax.

This is how you do the above in Python: I'm sure you want to see a more complicated example. :-) The following is yet another way to compute prime numbers. NB: You can nest list comprehensions inside of each other, so you could write the above example with a single statement (without the need for the temporary variable "noprimes"). Of course, list comprehensions don't only work for numbers. The following works on a list of strings and produces a list of lists. Invent Your Own Computer Games with Python - Learn how to program with a free ebook programming tutorial.

Graphic/Web Design. Ubuntu. Python: interfacing with an arduino. So what is an arduino?

Python: interfacing with an arduino

An arduino is an open source open hardware programmable controller with several inputs and outputs. The image below shows an Ardunio Dicemella. Ardunio Dicemella Annotated Photo. Make Yahoo! Web Service REST calls with Python. Python provides a number of modules for performing HTTP requests.

Make Yahoo! Web Service REST calls with Python

This HOWTO describes how to perform GET and POST requests using the urllib and urllib2 modules from the Python standard library. Simple GET requests The simplest way of retrieving data from a URL uses the urllib.urlopen function: import urllib url = ' u = urllib.urlopen(url) # u is a file-like object data = u.read() Python: Lambda Functions. Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called "lambda".

Python: Lambda Functions

This is not exactly the same as lambda in functional programming languages, but it is a very powerful concept that's well integrated into Python and is often used in conjunction with typical functional concepts like filter(), map() and reduce(). This piece of code shows the difference between a normal function definition ("f") and a lambda function ("g"): As you can see, f() and g() do exactly the same and can be used in the same ways.

Pearltrees videos

Help.