background preloader

The Python Tutorial — Python v3.2.3 documentation

The Python Tutorial — Python v3.2.3 documentation
Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, and may be freely distributed. The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. For a description of standard objects and modules, see The Python Standard Library. The Glossary is also worth going through.

Python Programming Language – Official Website Electric Imp ID: 1129 - $29.95 What is the electric imp? In essence, the Imp provides an easy, integrated way to connect almost any hardware device both to other devices and to internet services. It's more than just a WiFi card, or even a WiFi module with processing built in - it's an integrated platform that deals with the drudgery of connectivity, allowing you to concentrate on the application instead of the mechanics. The Imp itself is very small - 32mm x 24mm x 2.1mm - but packs a lot inside. For starters, there's industry standard 802.11b/g/n WiFi, complete with WEP, WPA and WPA2 encryption, along with a great antenna. Next, there's the processor. Finally, there's the I/O. For more details, see the electric imp hardware page. Developing for the Imp is quite unlike most embedded development. Software that runs on the Imp is written in Squirrel, a C-like language, with extensions to communicate with the hardware interfaces and the service. PLEASE NOTE: The April board is not included!

Khan Academy Introduction to unittest Starting Testing with Python Note In Python 2.7 and 3.2 a whole bunch of improvements to unittest will arrive. The major changes include new assert methods, clean up functions, assertRaises as a context manager, new command line features, test discovery and the load_tests protocol. unittest2 is a backport of the new features (and tests) to work with Python 2.4, 2.5 & 2.6. See: unittest2: improvements to the unittest module As a dynamic language Python is substantially easier to test than other languages, which means that there is absolutely no excuse for not having good tests for your Python projects. This article is about testing in Python, mainly using the Python standard library testing framework unittest. There are many different ways of categorizing tests, and many names for subtly different styles of testing. Unit testsFunctional tests (black box tests, acceptance tests, integration tests)Regression tests Regression testing checks that bugs you’ve fixed don’t recur. python discover.py

Intro by Pete Shinners pete@shinners.org This article is an introduction to the Pygame library for Python programmers. The original version appeared in the Py Zine, volume 1 issue 3. Pygame started in the summer of 2000. I discovered a small project already underway with exactly the same idea, PySDL. I wanted to put together a project that really took advantage of Python. I find the best way to understand a new library is to jump straight into an example. 1 import sys, pygame This is as simple as you can get for a bouncing animation. On line 8 we create a graphical window with the call to "pygame.display.set_mode()". At line 10 we load our ball image. At this point, line 13, our program is initialized and ready to run. It is time to update our position for the ball. On line 23 we erase the the screen by filling it with a black RGB color. On line 24 we draw the ball image onto the screen. The last thing we need to do is actually update the visible display. "Is Python suitable for gaming?"

Connecting the MAX31855 Thermocouple Amplifier breakout to an Electric Imp If you are interested in Internet of Things projects, this tutorial is a simple and very practical way to get started. The Electric Imp platform was created specifically for Internet of Things devices, and measuring temperature is a great way to learn. In this tutorial, we will be connecting an Electric Imp to the Adafruit MAX31855 Thermocouple Amplifier breakout board using one of the Serial Peripheral Interface Buses (SPI) available on the Electric Imp. Our maker objectives: Assemble the breakout boards. computing notes 26.2. pdb — The Python Debugger Source code: Lib/pdb.py The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. The debugger is extensible — it is actually defined as the class Pdb. The debugger’s prompt is (Pdb). >>> import pdb>>> import mymodule>>> pdb.run('mymodule.test()')><string>(0)? pdb.py can also be invoked as a script to debug other scripts. python -m pdb myscript.py When invoked as a script, pdb will automatically enter post-mortem debugging if the program being debugged exits abnormally. New in version 2.4: Restarting post-mortem behavior added. The typical usage to break into the debugger from a running program is to insert import pdb; pdb.set_trace() at the location you want to break into the debugger. The typical usage to inspect a crashed program is: pdb.set_trace() w(here)

the Tricorder project | blog A bit of a story, and then a lot of pictures — by far the most interesting class I’ve ever taken was Advanced Brain Imaging in grad school. As a hands on lab class, each week we’d have a bit of a lecture on a new imaging technique, and then head off to the imaging lab where one of the grad students would often end up in the Magnetic Resonance Imager (MRI) and we’d see the technique we’d just learned about demonstrated. Before the class I was only aware of the structural images that most folks think of when they think of an MRI, as well as the functional MRI (or fMRI) scans that measure blood oxygenation levels correlated with brain activity and are often used in cognitive neuroscience experiments. But after learning about Diffusion Tensor Imaging, spin-labeling, and half a dozen other techniques, I decided that the MRI is probably one of the most amazing machines that humans have ever built. And I really wanted to build one. Safety is very important to me. thanks for reading!

ATtiny10 resources UPDATE: A huge thanks to Keri DuPrey, Nat Blundell and others who have been continually improving the code. The latest version(as of 2014-3-22) is here: ATtiny4_5_9_10_20_40Programmer.inoAlso, avr-libc 1.7 and newer support ATtiny10! I have not tried it, but I reckon you can now use avr-gcc for the tiny10. However, with only 1kB of program memory, assembly is still useful. The ATtiny10 is an intriguing little thing. But hark! d.hatena.ne.jp/pcm1723/20111208/1323351725Hardware Now let's think about hardware. Here is the basic hardware setup. Really, some of those resistors may be unnecessary, but they don't hurt. Note that pin 1 goes in the top right corner. SoftwareWell, that was simple enough. Then we have to get the program onto the chip. Commands:

Python - Dictionary Data Type A dictionary is mutable and is another container type that can store any number of Python objects, including other container types. Dictionaries consist of pairs (called items) of keys and their corresponding values. Python dictionaries are also known as associative arrays or hash tables. The general syntax of a dictionary is as follows: You can create dictionary in the following way as well: Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. Keys are unique within a dictionary while values may not be. Accessing Values in Dictionary: To access dictionary elements, you can use the familiar square brackets along with the key to obtain its value. When the above code is executed, it produces the following result: dict['Name']: Zara dict['Age']: 7 If we attempt to access a data item with a key, which is not part of the dictionary, we get an error as follows: Updating Dictionary: Delete Dictionary Elements:

PalmOrb: Use your PalmOS PDA as a LCD status display via serial, USB, BlueTooth or IR SensorMonkey

Related: