5 Blog Entries tagged: python
Pygmalion - Python Interface to Ma.gnolia
This is very cool...
>>> import pygmalion
>>> dir(pygmalion)
['Exceptions', 'Handlers', 'Pygmalion', 'Types', '__builtins__', '__doc__', '__file__', '__name__', '__path__']
>>> pyg = pygmalion.Pygmalion('your API key here')
>>> dir(pyg)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'apikey', 'bookmarks_add', 'bookmarks_delete', 'bookmarks_find', 'bookmarks_get', 'bookmarks_tags_add', 'bookmarks_tags_delete', 'bookmarks_tags_replace', 'bookmarks_update', 'headers', 'tags_find']
>>> bookmarks = pyg.bookmarks_find(person='robhudson')
>>> b = bookmarks[0]
>>> b
<Bookmark: Pygmalion (http://code.google.com/p/pygmalion/)>
>>> dir(b)
['Tags', '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'created', 'description', 'id', 'owner', 'private', 'rating', 'screenshot_url', 'tags', 'title', 'updated', 'url']
>>> b.title ...
Javascript becoming more Pythonic?
http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7
Javascript is picking up Iterators and Generators (with the yield keyword). And array comprehensions! Does this look familiar?
var ten_squares = [i * i for (i in range(0, 10))];
I wish browsers would simply open it up to allow:
<script type="text/python" src="mypython.py" />
Most graphical toolkits have APIs for many languages, why not the browser?
But I like seeing that Javascript is seemingly becoming more Pythonic.
Apple releases Python based calendar server
During the WWDC Apple announced a number of open source projects. One interesting project for Python was the release of the iCal Server which is Python based. It uses the Twisted networking framework as its server component and all the other bits are Python. It implements CalDAV. The source page is here: http://trac.macosforge.org/projects/collaboration.
PyNewbie on making cryptograms
I used to enjoy cryptograms a lot and wanted to generate some on my own. I originally wrote a script to do this in Perl. While learning Python, I rewrote it and learned a few things about the string library in the process. Here goes...
import sys, string, random
We're going to be using sys to catch arguments passed to our script, or to catch input from a pipe. We've got lots of string manipulation so we're importing the string module. The random module will give us a way to shuffle a list so we can match ...
PyNewbie on Using Sockets in Python
A socket is a connection from one program to another. The two programs are typically on different machines, but they can also be on the same machine. Most sockets are from a client program connect to a server program to get some sort of information. Most socket transmissions are bi-directional -- send a request, receive some information. When you request a web page from within a web browser, you are causing the initiation of a socket connect from your computer (the client) to the web server's computer (the server, which could also be located on the same machine). You request ...