background preloader

Tutorials

Facebook Twitter

It's All Geek to Me. Hiring a Python web application developer November 26th, 2013 My client is looking to hire a new Python developer, initially for an 8 month contract.

It's All Geek to Me

It's a home working position, we communicate mostly via Skype / email / gtalk etc. Although we do meet up in meatspace from time to time, so ideally a candidate would be in the London / Oxford area. You will be working with your truly. So there is some genuinely interesting technology there, and more such projects planned. See the Careers page on wildfoundry.com for the full details. Finding the first bit set with Python November 25th, 2013 Here's a Python gotcha that I spent some time tracking down. I had an integer with a single bit set, and I wanted to find the index of that bit.

You can do this in two ways; either check each bit in turn until you find a 1, or you can use math as a shortcut. >>> import math>>> myint = 4>>> int(math.log(myint, 2))2 Simple right? >>> myint = 4L>>> int(math.log(myint, 2))1 And that was the result of my headache. How to Build a Python Bot That Can Play Web Games. In this tutorial we'll explore the ins and outs of building a Computer Vision-based game bot in Python, which will be able to to play the popular Flash game Sushi Go Round.

How to Build a Python Bot That Can Play Web Games

You can use the techniques taught in this tutorial to create bots for automatically testing your own web games. Final Result Preview Let's take a look at the final result we will be working towards: Prerequisites This tutorial, and all the code within it, requires that a few additional Python libraries be installed. Some of the code and libraries are Windows-specific. You'll need to download and install the following libraries: The final tool we'll need is a decent paint program. We'll use a few games as examples along the way Introduction This tutorial is written to gave a basic introduction to the process of building bots that play browser-based games.

With this approach we lose a bit of refined detail and control, but make up for it in shortened dev time and ease of use. Have fun! How to Code a Twitter Bot in Python on Dreamhost. I made a twitter bot that checks every hour for someone who has asked the question, “Why do homeless people have dogs?”

How to Code a Twitter Bot in Python on Dreamhost

And automatically replies, “Because a dog will love you even though you are homeless.” It’s running right now at @YHobosHaveDogs. Figuring out how to code this took a couple evenings and a little hair pulling, so I decided to document the process in this blog article to make it easier for the next programmer. This will be making a Twitter bot in Python using the python-twitter module (which runs on Python 2, not Python 3), and then running the bot from my Dreamhost server (but most likely any web host will work just fine. Or if you have a computer that is always online, you can run the bot from that). Download the python-twitter module (I tried some of the other modules but didn’t like them as much.)Unzip this file and from the command line in the unzipped directory, run “python setup.py install” to install the twitter module. A real-world, location based, iPhone adventure game.

Python 101: How to submit a web form. Today we’ll spend some time looking at three different ways to make Python submit a web form.

Python 101: How to submit a web form

In this case, we will be doing a web search with duckduckgo.com searching on the term “python” and saving the result as an HTML file. We will use Python’s included urllib modules and two 3rd party packages: requests and mechanize. We have three small scripts to cover, so let’s get cracking! Submitting a web form with urllib We will start with urllib and urllib2 since they are included in Python’s standard library. The first thing you have to do when you want to submit a web form is figure out what the form is called and what the url is that you will be posting to. Submitting a web form with requests The requests package does form submissions a little bit more elegantly.

With requests, you just need to create a dictionary with the field name as the key and the search term as the value. Python 101: How to Download a File. Downloading files from the internet is something that almost every programmer will have to do at some point.

Python 101: How to Download a File

Python provides several ways to do just that in its standard library. Probably the most popular way to download a file is over HTTP using the urllib or urllib2 module. Python also comes with ftplib for FTP downloads.