Tag: Python

ACM: Python Now The Most Popular Intro Language At Top US Universities

pythonlogo.jpgAs a long-time fan of the python language, I was intrigued by this post on the ACM’s blog: “Python is Now the Most Popular Introductory Teaching Language at Top U.S. Universities“. The post begins with a summary:

At the time of writing (July 2014), Python is currently the most popular language for teaching introductory computer science courses at top-ranked U.S. departments.

Specifically, eight of the top 10 CS departments (80%), and 27 of the top 39 (69%), teach Python in introductory CS0 or CS1 courses.

… and then goes into greater detail.  Of course, the moment you publish one of these “XXXXXX language is the most popular programming language” type of posts, you immediately get reflexive reactions from programmers who favor all the other languages out there…  and this Hacker News thread with 357 comments (so far) shows exactly that, with people either supporting the idea or ripping apart the article’s methodology and explaining why the author is wrong, wrong, wrong… 🙂

The programming language wars will always continue.  In the meantime, though, as someone who likes the python language, I’m pleased to see the uptake at universities around the U.S.  (and, as noted in the HN thread, by other universities around the world, too).

New version 0.1.3 of Tropo-webapi-python: Build Tropo voice/SMS/IM/Twitter apps using python

Tropo Logo

My former colleague Justin Dupree just posted a new version of the Tropo-webapi-python package to Pypi at:

http://pypi.python.org/pypi/tropo-webapi-python/

To install the package, assuming you have pip installed, you should be able to just type:

pip install tropo-webapi-python

and then you can get started building Tropo applications that use voice, SMS, IM or Twitter as channels to communicate with people. The documentation for the Tropo WebAPI provides a full explanation of the API and also sample applications. Samples are also provided in the distribution.

The “tropo-webapi-python” package lives on Github at:

https://github.com/tropo/tropo-webapi-python

and those of you wanting to live on the edge can simply clone the repository from Github and use it there.

I’ll also mention that at this point I’ve completely stepped away from the maintenance of this ‘tropo-webapi-python’ package (as I’m no longer with Voxeo) and Justin and the Voxeo Labs team are now maintaining the package.

Have fun with it! I definitely enjoy creating Tropo apps using python!

Dulwich – a native python way to access Git repositories

Ever wanted to manipulate Git repositories directly in python? Well, okay… I haven’t really myself, but in writing about Google Code’s support for git yesterday, I noticed that they are using Dulwich, a native python implementation of git. Rather than wrapping command-line git with python scripts, Dulwich is a python module giving you direct access to a git repository. As shown in the Dulwich tutorial, creating a new repo is simply this:

>>> from dulwich.repo import Repo
>>> from os import mkdir
>>> mkdir("myrepo")
>>> repo = Repo.init("myrepo")
>>> repo
<Repo at 'myrepo'>

Once a repo is created (or you connect to an existing repo), you can do what you would do with git at the command line: adding files to the repo, committing files, and changing files.

While I don’t know that I personally will use this… it’s very cool that Dulwich is out there for python programmers who want to interact with git repos. Very cool to see!

My Github repo of SMSified experiments

Smsified 1Earlier in the week I mentioned a quick python app I wrote to send SMS messages using SMSified. I’m storing that code and some other experiments up in a Github repo at:

https://github.com/danyork/smsified-experiments/

If you are a Github user and also interested in building SMS apps, please feel free to “watch” that repo and follow along with my own experiments. Code will probably be a mixture of python and Node.js, with occasional other languages thrown in.

Skulpt – a JavaScript-based way to run Python inside your web browser

SkulptIn the process of writing about the site that lets you run Linux in your web browser, I learned about Skulpt.org that is essentially the same idea only for a python command line.

The demo at www.skulpt.org is pretty cool… just modify the python code in the screen and press Ctrl+Enter to execute the code and have the output appear in the box below.

To play with it yourself, you can get the code at http://code.google.com/p/skulpt/ or as author Scott Graham shows on the Skulpt.org page you can just use mercurial to clone the repo.

I haven’t installed it myself… again, like the “Linux in your browser” experiment, I think this is very cool but I’m not entirely sure where I’d personally ever use. Still, I’m very glad people build projects like this – if for no other reason than showing that this could be done!

Cool stuff…

A Quick Python App to Send SMS via SMSified’s REST API

Smsified 1Today Voxeo[1] launched SMSified a new service that lets you use a really simple RESTful API to send text messages within the US for only 1 cent per message. I and other colleagues have been writing about SMSified on the SMSified blog and after writing a tutorial about using SMSified with curl, I figured I’d play around with python a bit and code up an example of sending a SMS via python.

So here it is… stored up in my Github account, but also here:

[python]
#!/usr/bin/env python

# Really simple python app for playing with sending SMS messages
# via SMSified – http://www.smsified.com/
# Created by Dan York – May 2011

import json
import urllib

senderid = "dandemo" account
password = "notmyrealpassword" password
sendernum = "5853260800" phone number

apiurl = "https://"+senderid+":"+password+"@api.smsified.com/v1/
smsmessaging/outbound/"+sendernum+"/requests"

address = "14079678424" # Phone num to which you want to send
message = "Hello there" # Whatever msg you want to send

data = urllib.urlencode(((‘address’,address),(‘message’,message)))

f = urllib.urlopen(apiurl,data)

print json.loads(f.read())[‘resourceReference’][‘resourceURL’]
[/python]

As you can see in the code, there are really only three lines of importance: the one building “apiurl”; the one urlencoding the data; and the one opening the URL. The rest are really just for the convenience of using variables.

The final line simply prints out the info included in the result JSON. I was going to (and still may) make that print out prettier or say something more… and if you are reading this sometime in the future, the version on Github may have already morphed and evolved into something different. The point is that now that you get JSON back, you can parse it and start to take action on it.

Anyway, this was just a quick sample app to experiment with SMSified. If you have checked out the new service, it’s free to set up a developer account and currently is free entirely during the beta period.

[1] In full disclosure, Voxeo is my employer.

Using PostBin to Debug Webhooks

Recently I was trying to debug a python app that ran on Tropo.com Scripting and made a web call back to an application on another server. I wanted to see exactly what was being sent in the HTTP POST rom Tropo to the other server… and that’s when my colleague Mark Headd pointed me over to PostBin.org:

postbin.jpg

PostBin is very cool because literally all you do is click the “Make a PostBin” button and then you get a URL that looks like

http://www.postbin.org/1dlalso

Now you just do a HTTP POST to that URL and… ta da… the results of your post appear on the new webpage.

It’s a very cool way to debug webhooks!

P.S. Obviously there is no language limitation here. I happened to use python because that was what I was debugging, but you can use PostBin with ANY language that is sending HTTP connections.

Test Out Python… Directly In Your Web Browser

Pretty cool little site to test out python directly inside your web browser (found via Hacker News):

http://syntensity.com/static/python.html

You just type in some python code and press the “Execute” button. Now, sure, it doesn’t have support for much outside the very core language… and you could get all of that by simply flipping to a terminal window and using python from the command line.

Still, it’s a fun way to be able to show people new to python what they can do… and a cool proof-of-concept of running python directly inside your web browser!

Emscripten_ Python.jpg

Setting Up a PyPI Account – And Uploading the Tropo WebAPI Library

Python logoIt’s funny… I’ve been writing small python programs for 10 or 15 years now (makefaq being perhaps the one most widely used), but in all that time, I had never set myself up with a PyPI account. PyPI, for those not in the python world, is the “Python Package Index” which lists all the uploaded packages and makes them easy to install onto systems. It’s sort of the python version of Perl’s CPAN, PHP’s PEAR or Ruby’s gems.

However, as I wrote about over on the Tropo blog, thanks to a developer suggesting we upload the Tropo WebAPI library to PyPI, I now finally have a PyPI account. My first (and currently only) submission is naturally:

http://pypi.python.org/pypi/tropo-webapi-python/0.1.0

Now that I’ve done that, I may take some of my other modules and upload them as well.

The cool part about this is that developers can now very easily install the Tropo WebAPI library and use it with their free Tropo account to start creating apps that use voice, SMS, IM, or Twitter for real-time communications (or near real-time, anyway). All they have to do is use one of these commands:

easy_install tropo-webapi-python

pip install tropo-webapi-python

depending upon whether they prefer easy_install or pip to install packages.

Cool stuff... and I'm glad I'm finally on the PyPI train! :-)

Python heading up O’Reilly’s recent book promotion?

oreillybooks.jpgTwo days ago, Tim O’Reilly published an interesting post around the books people chose as part of O’Reilly’s Cyber-Monday deal. What I found interesting was the number of books all about…

python!

Given that I’ve been programming now and then in python for over 10+ years, I just found it both interesting and pleasing to see that python is still growing in interest. Google has certainly driven much of that interest in recent years with AppEngine, but Tim O’Reilly points to “data science” as a new driver:

… while Python has a large following in data science. It’s particularly interesting, and important, that using Python to collect data from sensors (“Real World Instrumentation with Python”) made it onto the list.

Very cool to see!

P.S. I agree with Tim that the list is a very interesting view into what programmers (who buy from O’Reilly) are interested in…