Skis / Toys / Fun

Appeal to greatness not guilt

Skis / Toys / Fun

Python wierdness

August 30th, 2010

Just frustrated, why the output is Broken = 2 and Wierd = 3 at one level make no sense, since after all you would think that if you referenced a member variable it’s context would remain the same… class Foo : BROKEN = 1 WIERD = 1 def __init__(self) : print(‘Before broken=%d weird=%d’ %( self.BROKEN, [...]

Tags:  

Twisted code review…

November 12th, 2009

If you have a few minutes and speak python & twisted, it would be useful to have an extra set of eyes on this section of code. The basic idea of this is to be a reconnecting thrift client, such that I can just write simple client.function(a,b,c) calls without having to worry about if there [...]

Tags:   · ·

Set permission_required for your view functions

September 22nd, 2008

Working with django 1.0 and google app engine… Wanted to set every view on my admin page to have admin permission. def _perm_admin(rootfunc) : import sys module = sys.modules.get(rootfunc.__module__) for key, value in module.__dict__.items() : if type(value) is types.FunctionType and key[0] != ‘_’ and rootfunc.__module__ == value.__module__: module.__dict__[key] = permission_required(‘admin’)(value) _perm_admin(main)

Tags:   ·

Python Documentation — Fail!

September 5th, 2008

One of many rants against python documentation.  Fundamentally, things like this only re-enforce why it didn’t receive the rapid acceptance of PHP. $ pydoc list ….  |  index(…)  |      L.index(value, [start, [stop]]) -> integer — return first index of value …. Ok, that’s good… But what about the “not found” case, is it documented, nope!  [...]

Tags:  

Performance of Python, PHP and Perl

June 10th, 2008

Had a 7GB text file that I needed to run some parsing on (to prepare for a DB import).  As part of my habit I pulled out perl and whipped up a quick program to parse and generate some loadable files.  While watching it run I got to thinking about … why … why perl [...]

Tags:   · · ·