Twitter Updates
- git bloodbath -f 1 day ago
- I've said it before, but I'm going to say it again: I actually like Ke$ha. So there. Good pop music is good. 1 day ago
- @ehthayer I'm pretty good at copying someone else's designs and making them my own, but from scratch, it's really, really hard. 1 day ago
- I fucking suck ass at design. There, I said it. 2 days ago
- Scumbag 3G connection: Resamples JPEGs to lower Q, lets me stream YT and Pandora in full quality. 2 days ago
Blogroll
- 914 electric conversion blog
- ALL ART BURNS
- Arcade Zen
- Brian’s Gallery
- Chili’s World
- Chocomonkey’s Blog
- Follow me on Quora!
- Follow me on Twitter!
- Google Blog
- Juan’s website
- Julia y Daniel
- Katja’s Blog
- Kulick’s blog
- Paul’s Time Sink
- Peter S. Conrad
- Sad Salvation
- Slacy’s Gallery
- Snake Surley
- Sprang’s Blog
- Super Karate Monkey Fist
- Third Time Dad
- Universe Hacking
- Valspark
- Zac’s Story
- Zeigen, Inc.
Tag Archives: python
How to set session variables in Django unit tests.
This was super non-obvious, and I lifted code from a couple of different places. If you’ve got Django view code that gets & sets session values, you’ll want to test it properly, and the standard “self.client” from Django’s TestCase doesn’t … Continue reading
git pull says “You are not currently on a branch…”
Was working through some git error messages generated by pip installs of some Python code, and found that the issue was caused by this error: $ git pull You are not currently on a branch, so I cannot use any … Continue reading
Breaking out of the middle of a try block in Python
I had some code where I wanted to break out of a try block in Python. The code looked something like this: try: print “First” if some_condition: # What do I put here to break out of the try block? … Continue reading
pymacs, ropemacs, and virtualenv, all at the same time.
So, you’re developing for Python, and you want to use rope and ropemacs and pymacs, but it’s totally busted when you use your virtualenv. In addition, the packaged versions of pymacs+ropemacs for ubuntu 10.10 (and 11.04) are also kind of … Continue reading
An extremely simple config pattern for Python
So, you’re developing a Python application. And, you have needs for “production” versus “development” configs. If you’re using a web framework, you might have some support for doing this, but what about your other modules that you’d like to configure … Continue reading
Posted in General
Tagged configs, pattern, python, python config, simple config, web framework
Leave a comment
Extremely simple XML to Python converter
There are a ton of different ways you can encode XML, but for the style that looks like this: <xml> <name>Bob</name> … You can use this nice little function to convert it to a native Python object. I’m using this … Continue reading
Sometimes Python is bat-guano insane
Try this on for size: import pickle d = {‘a’: 1} s1 = pickle.dumps(d) s2 = unicode(s1) assert(s1 == s2) d1 = pickle.loads(s1) d2 = pickle.loads(s2) assert(d1 == d2) So, what do you think happens here? Are s1 and s2 … Continue reading
A dict and an object, all in one.
I’ve been struggling with data modeling decisions for my MongoDB interface layer. Should results from the DB look like a dict, or like an object? Like both? What are the advantages and disadvantages of each approach? I’ve got my own … Continue reading
methodpickle: A Python library for pickling function invocations.
Have you ever wanted to say “I’d like to call this function, but later”? I’ve seen people using Celery for this purpose, and it’s very well respected, but the setup is far from easy. It has several fairly large dependencies, … Continue reading
Trivial function-based and class-based Python decorators.
Here’s a trivial function-based decorator: def wrap(method): def call(*args, **kwargs): print “calling wrapped method” return method(*args, **kwargs) return call @wrap def some_function(arbitrary, arguments=None): print “%s %s” % (arbitrary, arguments) And here’s a trivial class-based decorator: class Wrap(object): def __init__(self, method): … Continue reading