dsandler.org

Tag: python

Irritating:

$ python2.3 -c 'import urllib; print urllib.getproxies()'
{}
$ python2.4 -c 'import urllib; print urllib.getproxies()'
{'http': 'http://localhost:8501'}

Is it documented somewhere that getproxies() just plain doesn’t work in OS X with the Apple-supplied 2.3 build?

Hi. It’s been a while. I beg your forgiveness.

I gave a slightly silly talk about the programming language Python to the Rice CS Club last Thursday. It was a pretty mixed audience (ranging from “I’m not sure what Python is” to “what do you think of the new 2.5 features?”) so I tailored the lecture to experienced programmers and scientists new to Python in particular. The slides, along with some links I promised to the attendees, are collected on my new python page.

While we’re on the topic: If you’re a parselmouth and build web applications for fun or profit, you should be aware that web.py version 0.2 came out last week. The tutorial has been updated to use all the schmancy new features, like the built-in template system (replacing Cheetah, which is a little heavyweight for the web.py approach, which is something along the lines of “the absolute least amount of code that still saves you a substantial amount of work”). I’m looking forward to using the 0.2 release to whip up a redesign of the Beer-Bike tee shirt database in time for the 50th anniversary of the college system (and, hence, of Beer-Bike).

A new Web startup to watch, as recently reviewed by Mossberg: Tabblo, a photo-sharing site with a twist: they allow you to do nice layouts and collages (instead of locking you into a slide-sorter aesthetic). [Side note for pygeeks: Tabblo is a Django app.]

As you know, my work on the Campanile opened my eyes to the power of photo presentation; you need some gridlines, some breathing room, contrasting colors and sizes, a little text, and pretty soon you can tell a story (or several). Sometimes it’s fun to roll the dice and let entropy decide these things. (e.g.: Chanukah 2001, PalmSource moving out and in, Monterey, a nice pen, doodles, a lovely wedding.)

One little nitpick on Tabblo, though: the photo viewer looks oddly familiar.

I’ve been meaning to look at the Mercurial source-control system for about a year now. It’s Python, it’s distributed. Sounds like a winner. But I go to their home page, which is a Moin wiki, and…well, where’s the darned introduction? I was hoping to find a document along the lines of, “This is the SCM system for you, and here’s why.” The QuickStart motivates use of the system by showing how lightweight it is to get started, but that’s a do-it-yourself kind of sales pitch. I guess I’ve been reading too many ebullient research papers, but I figure if you built something cool and want people to use it, you should—clearly, concisely—tell them what it is and why it’s better than everything else that’s come before.

Take a look at the new python.org and see for yourself. The bizarre, quirky, pseudo-unnavigable, recognizable blue design has been replaced with…what, exactly? It’s not quite a facelift. More of a Botox treatment—seemingly smooth and youthful, but upon closer inspection weirdly plastic and static. And while I do like the new logo (at right), it seems a little feeble in execution—I feel it could be made stronger.

This article (and ensuing thread) about lightweight Sparklines in Ruby reminded me that I’d intended to write a super-lightweight PNG library (for those times when you want a quick and dirty Web graphic and don’t have a proper graphics toolkit handy).

I don’t really speak Ruby yet (any more than I do Japanese…konban wa, watashi wa dsandler), so here’s minipng.py. Requires: Python 2.x, and nothing else. Currently supported: 8bpp RGB, with optional single-color transparency (tRNS). Sample code:

# should result in a black smiley face on yellow background
from minipng import MiniPNG, Color
mp = MiniPNG(9, 6, Color.YELLOW)
for pt in [(2,1), (6,1), (1,3), (7,3), (2,4), (3,4), (4,4), (5,4), (6,4)]:
    mp.plot(pt, Color.BLACK)
pngdata = mp.to_png()

I’ll probably add grayscale, gray+alpha, and RGBA soon (next time I’m bored and near a computer). [ :) ]

I hate configuration files, don’t you? Wouldn’t it be simpler if the user’s preferences were just hard-coded into the script?

#!/usr/bin/python

import sys, re

PASSWORD = 'bar'

if len(sys.argv) > 1:
    PASSWORD = sys.argv[1]
    
    script = open(__file__, 'r').readlines()
    for i in xrange(len(script)):
        l = script[i]
        if re.match(r'^PASSWORD =', l):
            script[i] = 'PASSWORD = %s\n' % `PASSWORD`
            break
    
    open(__file__, 'w').write(''.join(script))

print "PASSWORD = %s" % `PASSWORD`

subscribe to dsandler.org

  •  
  • for faster updates, subscribe with FeedTree

mac software made on premises

toastycode.com: toasty software for the mac pyrotheque: a new (old) fireworks screensaver for the mac
Cuckoo—the bell tolls for your Mac.

twitter/dsandler [RSS]

    loading…

elsewhere

highlights

between the couch cushions

strongly connected

  • erinmak is not to be trifled with
  • pixelknave says moof when upside-down
  • dave is dangerous
  • rod is one groovy mother
  • adam is googling us all
  • amar is not really a pirate
  • angi sees little blue dots
  • harbinger lets you know it's coming
  • jason looks like an idiot in that hat
  • jeff is keeping austin weird
  • regan seems to tolerate jason
  • emann will not abide your IM-speak
  • jim is a stranger in ein anderes Land
  • liscio is pronounced "lee-show"
  • darryl has no need of identifying objects
  • friends as they appear on dsandler.org
  • sportsgirl reports…on all the pro courts

Search

Recent

Archives

dsandler.org is Dan Sandler's website and notebook.

Powered by WordPress and here's why.