Posts Tagged ‘python

It’s funny what a day’s wrestling with a hard problem can lead to as inspiration. I’m going to start with a piece of Django code that someone else wrote: Django Activity Stream, a simple piece of code that lets you track “everything” the actors in your system do: every bookmark made, every comment made, every […]

The correct call for posting to a user’s facebook wall with Python and pyfacebook, after you’ve established both user authentication via FacebookConnect and gotten stream_publish permission, is: message = render_to_string(template_path, fb_context), action_links = simplejson.dumps( [{‘text’: “Check Us Out!”, ‘href’: “”}]), target_id = ‘nf’) See that ‘nf’ down there in target_id?  It’s not on any […]

One of the nifty things that Django provides is the {% url backreference %} syntax, which allows you to name the targets in your list of URL objects and then refer to them by an explicit name. You can sometimes use the function name instead, and Django has a way of turning the function name back into the […]

I’m prepping for an interview this afternoon at what is primarily a Perl shop, and so I’m mainlining the O’Reilly Perl in a Nutshell book as a way of reminding myself about the little details of the language. I can write Perl just fine– I just made some major hacks to dailystrips for example, and […]

Introduction When you roll around the web you see lots of web applications that show off some localized capability to get data from a back-end in a semi-real-time manner. The most famous is the “search suggestion” drop-down that comes off Google or Bing, and those are wonderful, but often the Javascript for the drop down […]

Most people encountering the Ajax components of Django for the first time usually encounter this pairing: from django.utils import simplejson … return HttpResponse(simplejson.dumps(some_python_obj)) For most applications, this is enough.  But I’m especially fond of iterators, generators, functors and closures, dense components that express one thought well: the structure of a tree, or the rows of […]


Python can be just as ugly as PHP…

Posted by Elf Sternberg as PHP, python

I was reading through the WordPress source code, trying to figure out a problem for a contractor, when I saw the function compact().  When I saw it I boggled, read the description, and shook my head. Compact() takes a list of variable names as strings, and returns a hash of those variable names and their […]


C __LINE__ equivalent in Python

Posted by Elf Sternberg as programming, python

I started using this recently. If you do a lot of Python, you’ll sometimes find yourself desperate for breadcrumbs, little print statements scattered throughout your code as you try to figure what you told it to do, since it’s obviously not doing what you want it to do. I’d used inspect previously to unravel exception […]

For the past eight days or so, I’ve been having the absolute pleasure of working on a pure research project, re-implementing FireWatir in Python. The project is known internally as “Whiskey,” (FireWatir without the R) and at some 1805 lines is faster and more concise than firewatir’s 6522 lines. The real trick was to stop […]


Added to library:

Posted by Elf Sternberg as programming, python

I was up last night hacking on my toolchain and getting it ready for production, and I realized that part of it could be ripped out and put up as a library. I had searched for this library and found nothing, so I scratched that itch and tossed it together. I use Emacs MUSE mode […]

Subscribe to Feed



May 2020
« Jan