background preloader

Learn Python Through Public Data Hacking

Learn Python Through Public Data Hacking

Twisted Twisted is an event-driven networking engine written in Python and licensed under the open source ​MIT license. Twisted runs on Python 2 and an ever growing subset also works with Python 3. Twisted makes it easy to implement custom network applications. Here's a TCP server that echoes back everything that's written to it: from twisted.internet import protocol, reactor, endpoints class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory()) reactor.run() Learn more about ​writing servers, ​writing clients and the ​core networking libraries , including support for SSL, UDP, scheduled events, unit testing infrastructure, and much more. Twisted includes an event-driven web server. Learn more about ​web application development, ​templates and Twisted's ​HTTP client. Twisted includes a sophisticated IMAP4 client library.

How not to write Python code Lately I’ve been reading some rather unclean Python code. Maybe this is mainly because the author(s) of the code had no in-depth knowledge of the Python language itself, the ‘platform’ delivered with cPython,… Here’s a list of some of the mistakes you should really try to avoid when writing Python code: Some days ago RealNitro pointed me at this list of essential Python readings. “Idiomatic Python” is a must-read, even for experienced Python developers. That’s about it for now, maybe I’ll add some more items to this list later on. Posted in Development, Technology. Tagged with Development, python. By Nicolas – February 8, 2008 Pakete • phpBB.de Deutsche Pakete Aktuelle Version: 3.0.12 Um deutschsprachigen Anwendern die Installation von phpBB zu erleichtern, bieten wir ein fertiges deutsches Paket an. Dieses besteht aus phpBB 3.0.12, den deutschen Sprachdateien (in der Du- und Sie-Version) sowie den deutschen Grafiken für die beiden mitgelieferten Styles (prosilver und subsilver2). Außerdem wird im Ordner phpBB3/docs die deutsche Anleitung „phpBB 3.0“-Schnelleinstieg mitgeliefert. Wenn Sie dieses Paket herunterladen, sind keine zusätzlichen Downloads erforderlich. Komplettpaket Enthält alles was nötig ist, um ein deutsches phpBB zu installieren. Download phpBB Deutsch 3.0.12 [zip] Dateigröße: Keine Informationen verfügbar MD5-Summe: Keine Informationen verfügbar Automatischer Updater Mit Hilfe des automatischen Updater werden phpBB-Installationen auf die aktuelle Version aktualisiert. phpBB Deutsch 3.0.11 » 3.0.12 [zip] Dateigröße: Keine Informationen verfügbar MD5-Summe: Keine Informationen verfügbar Original Pakete Geänderte Dateien

How to Think Like a Computer Scientist — How to Think like a Computer Scientist: Interactive Edition This interactive book is a product of the Runestone Interactive Project at Luther College, led by Brad Miller and David Ranum. There have been many contributors to the project. Our thanks especially to the following: This book is based on the Original work by: Jeffrey Elkner, Allen B. The Runestone Interactive tools are open source and we encourage you to contact us, or grab a copy from GitHub if you would like to use them to write your own resources.

The Python “with” Statement by Example Python’s with statement was first introduced five years ago, in Python 2.5. It’s handy when you have two related operations which you’d like to execute as a pair, with a block of code in between. The classic example is opening a file, manipulating the file, then closing it: with open('output.txt', 'w') as f: f.write('Hi there!') The above with statement will automatically close the file after the nested block of code. (Continue reading to see exactly how the close occurs.) Here’s another example. This code sample uses a Context object (“cairo context”) to draw six rectangles, each with a different rotation. cr.translate(68, 68) for i in xrange(6): cr.save() cr.rotate(2 * math.pi * i / 6) cr.rectangle(-25, -60, 50, 40) cr.stroke() cr.restore() That’s a fairly simple example, but for larger scripts, it can become cumbersome to keep track of which save goes with which restore, and to keep them correctly matched. Implementing the Context Manager as a Class Here’s the first approach. Uh oh!

Installation and quick start — nose 1.3.0 documentation nose extends unittest to make testing easier. On most UNIX-like systems, you’ll probably need to run these commands as root or using sudo. Install nose using setuptools/distribute: Or pip: Or, if you don’t have setuptools/distribute installed, use the download link at right to download the source package, and install it in the normal fashion: Ungzip and untar the source package, cd to the new directory, and: However, please note that without setuptools/distribute installed, you will not be able to use third-party nose plugins. This will install the nose libraries, as well as the nosetests script, which you can use to automatically discover and run tests. Now you can run tests for your project: cd path/to/project nosetests You should see output something like this: .................................. ---------------------------------------------------------------------- Ran 34 tests in 1.440s OK Indicating that nose found and ran your tests. For help with nosetests’ many command-line options, try:

Understanding Python's "with" statement Fredrik Lundh | October 2006 | Originally posted to online.effbot.org Judging from comp.lang.python and other forums, Python 2.5’s new with statement (dead link) seems to be a bit confusing even for experienced Python programmers. As most other things in Python, the with statement is actually very simple, once you understand the problem it’s trying to solve. set things up try: do something finally: tear things down Here, “set things up” could be opening a file, or acquiring some sort of external resource, and “tear things down” would then be closing the file, or releasing or removing the resource. If you do this a lot, it would be quite convenient if you could put the “set things up” and “tear things down” code in a library function, to make it easy to reuse. def controlled_execution(callback): set things up try: callback(thing) finally: tear things down def my_function(thing): do something controlled_execution(my_function) with open("x.txt") as f: data = f.read() do something with data

Python Extension Packages for Windows - Christoph Gohlke by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine. This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language. The files are unofficial (meaning: informal, unrecognized, personal, unsupported, no warranty, no liability, provided "as is") and made available for testing and evaluation purposes. If downloads fail reload this page, enable JavaScript, disable download managers, disable proxies, clear cache, and use Firefox. Most binaries are built from source code found on PyPI or in the projects public revision control systems. Refer to the documentation of the individual packages for license restrictions and dependencies. Use pip version 8 or newer to install the downloaded .whl files. Install numpy+mkl before other packages that depend on it. The files are provided "as is" without warranty or support of any kind. Build Environment

NPR Puzzle: Finding Synonyms with Python and WordNet | Data Dork This week’s puzzle asks: From Alan Meyer of Newberg, Ore.: Think of a common word that’s six letters long and includes a Q. Change the Q to an N, and rearrange the result to form a new word that’s a synonym of the first one. What are the words? This puzzle is a good opportunity to play with some very cool computational language tools available through the Natural Langauge Toolik (NLTK). Before we get to using the NLTK, let’s break down this puzzle into multiple steps. 1. Approach: 1. 2. 3. This is best demonstrated through example and the use of one our language’s most versatile words – shit. So what I’ve done here is started Python in the terminal, and then installed the wordnet module from nltk.corpus. Back to the puzzle at hand, we need to see if any of the words from step 1 and step 2 are synonyms. Going through all the word pairs generated in step 1 and 2, I find there is only one pair of words that satisfy all constraints – uneasy and queasy. Full code available here at github here.

Download – Orange This page contains nightly builds from the code repository. These are typically stable and we recommend using them. Windows ¶ Full package: Snapshot of Orange with Python 2.7 and required libraries This package is recommended to those installing Orange for the first time. It includes all required libraries (Python, PythonWin, NumPy, PyQt, PyQwt ...), though it will not change any libraries you might already have. Mac OS X ¶ Bundle: Orange Snapshot This is an universal bundle with everything packed in and ready for an unadvanced user. easy_install/pip: Orange is available as a PyPi package. From source ¶ setup.py ¶ To build and install Orange you can use the setup.py in the root orange directory (requires GCC, Python and numpy development headers). python setup.py build sudo python setup.py install This will also install orange-canvas script so you can start Orange Canvas from the command line. To install orange locally run: python setup.py install --user make (for developers) ¶ C4.5 files ¶

Book Natural Language Processing with Python – Analyzing Text with the Natural Language Toolkit Steven Bird, Ewan Klein, and Edward Loper This version of the NLTK book is updated for Python 3 and NLTK 3. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Bibliography Term Index This book is made available under the terms of the Creative Commons Attribution Noncommercial No-Derivative-Works 3.0 US License. Pong Pong (marketed as PONG) is one of the earliest arcade video games; it is a tennis sports game featuring simple two-dimensional graphics. While other arcade video games such as Computer Space came before it, Pong was one of the first video games to reach mainstream popularity. The aim is to defeat the opponent in a simulated table tennis game by earning a higher score. Pong quickly became a success and is the first commercially successful video game, which led to the start of the video game industry. Gameplay[edit] The two paddles return the ball back and forth. Pong is a two-dimensional sports game that simulates table tennis. Development and history[edit] Atari engineer Allan Alcorn designed and built Pong as a training exercise. Pong was the first game developed by Atari Inc., incorporated in June 1972 by Nolan Bushnell and Ted Dabney.[4][5] After producing Computer Space, Bushnell decided to form a company to produce more games by licensing ideas to other companies. Home version[edit]

Text Processing in Python (a book) A couple of you make donations each month (out of about a thousand of you reading the text each week). Tragedy of the commons and all that... but if some more of you would donate a few bucks, that would be great support of the author. In a community spirit (and with permission of my publisher), I am making my book available to the Python community. A few caveats: (1) This stuff is copyrighted by AW (except the code samples which are released to the public domain).

s Python Class - Educational Materials Welcome to Google's Python Class -- this is a free class for people with a little bit of programming experience who want to learn Python. The class includes written materials, lecture videos, and lots of code exercises to practice Python coding. These materials are used within Google to introduce Python to people who have just a little programming experience. The first exercises work on basic Python concepts like strings and lists, building up to the later exercises which are full programs dealing with text files, processes, and http connections. The class is geared for people who have a little bit of programming experience in some language, enough to know what a "variable" or "if statement" is. To get started, the Python sections are linked at the left -- Python Set Up to get Python installed on your machine, Python Introduction for an introduction to the language, and then Python Strings starts the coding material, leading to the first exercise.

Related: