Skip to main content

Posts

Showing posts from 2006

Flow Testing - Initial Ideas

I'm toying with the idea of a new way to write tests. This is a cross between state and interaction based testing, and also tries to make setting up the test environments easier. I call it "Flow Testing" as it tests how the various states of the test target flow from one to the next. The idea is several-fold. We begin on the idea that we are testing names, because everything in Python starts with a name. You will test different things about names, such as type, what attributes or other properties apply to certain conditions, etc. Flow testing is very tree-oriented. For every name, you define the state you expect to begin, and branch into the state you expect for various properties. For example, you may have a state for the name 'foo' and a branch state for 'foo.bar'. These are branches within one state, while wthere are other branches across states called Interaction Branches. These states define the interactions that lead to them and the states expected.

Holidays

I am on vacation. It is very, very nice. Even before this, things have been slow. On the edge of worryingly slow, but still not slow enough that I've had to fret over anything. I've been enjoying some relaxation and time with my growing baby boy and my beatiful wife. We've taken the holiday with her family and our friends in sunny North Carolina, where I have been enjoying warm, sunny weather to start my winter. I actually miss the cold. Although not much has happened externally, a lot has happened internally. I am using the down time to organize myself, my plans, and prepare movements forward for proper exploration of some plans I've had on the back burner for a while now. More of my time has been able to be spent on more recreational activities, as well, and that is nice. Reading has been lost to me for some time, and I've picked up a few books I've enjoyed. I plan to start another blog, which will be focused on reviews of literature developers, gamers, and ot

ExtSession 0.3

I released ExtSession 0.3 today. Added error reporting through the result objects, iteration over remote objects, cleaned up much of the code, and did a some bugfixing. Also included a tutorial on extsession usage, so hopefully some of the people that had difficulty can read that and understand how to use it. Go and get it. EDIT: Fixed a broken link! What a way to mess up a release, no matter how small.

Announce: ExtSession

As a support package for some other things, I've written a little module called ExtSession. The basic idea is to have an easy way to control a python session running in another process. You can simply instansiate the ExtSession class, and call the execute() method. The results are asyncronous-like, but will be improved later. Very likely support will be added to get Deferreds. For now, you can simply poll or wait. The results of each execute() call (best done one line at a time) are seperated and returned individually of output from other commands, making it very easy to work with over a session's lifetime. Following is a stripped pydoc pull of the docstrings. I hope someone finds this as useful as I think I will. NAME extsession FILE /home/calvin/extsession/extsession.py DESCRIPTION ExtSession Module For executing code in an external interpreter. There are many cases where operations are either intensive or blocking by waiting, and in both situations th

Statement Functions

At a small suggestion in #python, I wrote up a simple module that allows the use of many python statements in places requiring statements. This post serves as the announcement and documentation. You can find the release here . The pattern is the statement's keyword appended with a single underscore, so the first, of course, is print_. The example writes 'some+text' to an IOString for a URL query string. This mostly follows what it seems the print function will be in py3k. print_("some", "text", outfile=query_iostring, sep="+", end="") An obvious second choice was to wrap if statements. They take a condition value, and expect a truth value or callback an an optional else value or callback. Values and callbacks are named if_true, cb_true, if_false, and cb_false. if_(raw_input("Continue?")=="Y", cb_true=play_game, cb_false=quit) Of course, often your else might be an error case, so raising an exception could be useful

Calling [adultswim] Fans

Adult Swim fan? Thought to myself "would be nice to converse with fellow fans during the block". Especially during Sunday nights. Interested? Join ##adultswim over at irc.freenode.net, the next time you're watching [as]. PS - The double #'s is due to an oft-critisized policy at freenode for "non-official" channels to be moved to such a name, signifying it as an "about channel", and allocating the single # channels as "official".

Bad Blogging Weekend?

Is it just me or does it seem like a bad weekend for blogging? I don't want to say I expect huge traffic, but I'm definately seeing a huge decrease in hits since friday night. Massive, even. Is a two-console launch weekend too much drain on the blogosphere to make much blogging worth it?

Forums, Feeds, and Foundations for Answers

The web forum. Mailing lists. Newsgroups. They all boil down to the same thing: digital forums of discussion. We have relied on these mediums to carry the Internet from prototype to fad to craze to necessary base of our culture. The discussions we enable through the web (and its friends) drive everything we do in the digital world. How can we pay tribute to this with an upgrade? We have migrated from discussing to just broadcasting our opinions. Maybe we'll tune in to some other opinions on similar topics. Maybe some of them will have read ours, who knows. We are deviating from the formula that has driven us to everything we think models the technology we desire. We need to move back to real discussions, bringing what we've learned from feeds, blogging, and content subscriptions. Forums, beloved as they are, have lost their way. Unfortunately the number of Internet users has risen so high that no forum can carry nearly the percentage of knowledgeable users they once could. This

Help JMRI

I don't even use the software from the JMRI project, but I had to donate a little to help their potentially important case. The violators are claimer that by being free (as in beer), all copyright is waived and thus any GPL restrictions are not even the project's own to claim. Wow, that is an evil claim. Do what you can, even ajust five or ten bucks.

Self Promotion

I am trying to improve and promote my media (reviews and such) and arts (writing and painting) blogs, so here is a bit of shameless self promotion. Spilt Mind has some ramblings about my attempts at rejuvenating my creative side. Mental Outlash just got a review to the amazing Stranger Than Fiction . Interested? Check them out. Otherwise, sorry to bother you. I want to keep these minimum. I should probably append some cross references to the end of the next post I write here.

Asyncronous Database Records

Through persistance systems, notably Divmod's Axiom project, i have been experimenting with the idea of asyncronous request of items which may or may not exist for some time. The idea is an abstraction of a terrible first idea for "persistant deferreds," which my very suggestion of lead to horrible responses over in #twisted, but well deserved, I now believe. The concept is similar but perhaps simplified for the limitations and complications involved. Operations may return an "asyncronous item," which in my implementation is done by an Item implementing the IAsyncronousOperation ("operation" may be replaced with "Item") interface. This is akin to returning a deferred. The item allows the caller to control the response to the availability of the item, but in a way that can survive server crashes and reboots, and is otherwise a persistant record, and not an emphemeral object. Borrowing additionally from Twisted, the asyncronous results can sup

Design for Testing

Good testing influences your design. Too many developers (and managers) are stuck in the waterfall mentality of design, code, test, and deploy. Forces across the industry are pushing to move the testing phase to the beginning of this line, and many just don't understand how that works. Testing should be the first consideration, and thus is influential to all other aspects of the development process. The problem with testing as a secondary consideration is the design and architecture of the software never lends itself to proper testing when you don't plan way ahead. The consideration of testing can drive your design to be easier to test, but also can encourage generally good programming practices and well-made designs in the architecture. We can use a persisted class as a good example, because this is a use-case where testing is very important, but we have to consider the burden of a full database tied into the class we are testing. When we develop our database item class befor

Spilt Mind

I won't be able to use it much, but if I have the need to write something and get some creativity flowing (it helps improve your coding mind, as well), I will be posting those writings or art pieces to a new blog I created, Spilt Mind . So easy to make a new blog, and I keep getting distraught over my lack of writing and painting over the last year or two. This is a much needed outlet, however much it gets used.

Uprooting and Replanting

It looks my time doing contract work is coming to an end. I will soon be officially accepting a full-time position with a relocation to the Houston, TX area. I'll have much more to blog about as we accelerate development timetables and things begin to roll along. I'm tired and exhausted from spending days with this on my mind, so I'm not writing much. I just wanted to ask, is anyone from the area? I see there is no User Group near Houston, at least not listed at the Wiki. Does anyone know of one or would be interested in starting one? Any tips for long (1700 mile) moves?

Identity Comparison vs Comparing Identities

An explaination of the virtues of foo is not None over foo != None lead to an explaination of identity comparison with the is operator. A fellow equated this to, roughly, id(a.x) == id(b.x) , which I told him was roughly correct but probably not actually correct. It only took a little bit of through to see how uncorrect it was. The following code creates a simple class with one property descriptor (read-only). It solves the requirements that with to instances of this class, a and b, id(a.x)==id(b.x) can be true while a.x is not b.x ! How does this happen? class foo(object): x = property(lambda s: id(s)) a = foo() b = foo() assert id(a.x) == id(b.x) assert a.x is not b.x How on earth does this code prove what it does? a.x and b.x are created on the fly, passed to the id function, and then destroyed with no references left. Because they are both created in the right order with the id(a.x)==id(b.x) expression, they just happen to get the same memory addresses, which in CPython i

RuPy, Snakes and Rubies, Night and Day

What is going on? All around me I see people relating Python and Ruby. The communities seem somehow intertwined with their users, usages, and publicity. It seems like you can never find a blog that talks about one without the other, or a new frontier being tested by one of the "new" languages and not being explored by its counterpart. Where do people see this distorted similarity between two languages that are as different as night and day? To Rubyist out there, don't take offense. I have far more experience with Python, than with Ruby, so I might sound biased. Please, take this as an honestly unbiased opinion. I'm just talking from the middle in this case. Python stands out from most of the other languages around. Largely it is understood as "the language without brackets", but it is not entirely alone there. Ruby almost appears like a language extremist. Their core types have fifty million methods each, because if you expect it to be there, it should be th

Balence, Tranquility, and SOAP

I am behind schedule with my work. I attribute a good bit of this to my vices as a developer, and just as much of the problem to my good attributes. I place an equal portion of the blame on SOAP. Striving for the goal of Beautiful Code, we can find ourselves lost on the way to actually writing something that gets the job done. Throwing away perfectly working code, because an alternative way to achieve the same results is more elegant isn't something that we might see as a bad idea. If the code is more l33t now, it will give us less trouble tomorrow when we need to port it to my toaster. We'll use anything to justify the overworking for code beauty. Is it always worth it? How beautiful is enough and when are we just wasting our time (and money)? There are terms thrown around like "elegant" and "pythonic" to measure the quality of code with no attention to the code actually reaching the goal it sets out to perform. The code may work, but that doesn't make

You Go, Gamer!

I would consider myself a gamer. The video game industry has been a huge influence on my life from childhood to parenthood. My father was a gamer, who even owned an arcade as a younger man, before I was born. The last machines, a unremembered pinball unit and a standup Qix were the first things walking in the door of his place. I even had a two-screen, six-player TMNT Turtles in Time arcade machine, which made me the coolest kid among my friends. Yes, I am a gamer. Today I denounce my fellow gamers, and I call out to those of you with any backbone to stand with me in decrying those among us who, basically, just make us look bad. The subject of debate is a recent survey making statements about the percentage of females among the online gaming community. The surprising results state that 64% of online gamers are female , and the response to this news is just as surprising: outright denial. Male gamers seem completely impossible to accept that they are not the majority of gamers, while

Movable IDLE: Keep it Free, Fuzzyman!

Several weeks ago, I contacted Michael Foord (aka, Fuzzyman) about the idea of a simpler, slimmed version of his Movable Python distribution for those interested in the language, and often not computer literate enough to put up with all the different components you need for any decent development environment. This is exactly what we need to convince those people still hanging on to BASIC . I don't know if its from my suggestion, although I got a personal e-mail from Fuzzy on the announcement , but its here and its free and its exactly what I need for the many interested people I am trying to bring Python to.

Google Reader Upgrade Dissappoints

Yet again, I find myself wishing I could say I like what Google has done with something, only to be forced into admitting: they disappoint me. Well, add one more to the list of things Google can't get right, even with an army of PhD holders and more money than you can shake a redwood forest at: Google Reader has gone from simple gold to contorted crap. The original version was a great excersize in simplicity in design that let me jump in, read, and get on with my life. The "upgrade" is a mess of a noisy interface for me to get lost in as my browser slows to a crawl with far more JavaScript than a simple reader needs, and even the occassional forgetting of everything I haven't read yet. I was a little late in the Blogscene, which is a relative statement given that most of the world doesn't know what a blog is, despite the fact that most bloggers think otherwise. I started with my trusty KDE's Akregator, which is admirably usable, and then looked for a web-solut

Stuff of Interest - Week of Sept 17 - 23, 2006

Wow! It has been almost two weeks since my last post, and I was doing so well. Unfortunately, i got quite sick and then had an unexpected trip out of state (read: I forgot about it until the day before!) and now feel ill, yet again. But, determination brings me back. I was planning to post this on the 23rd of September, but the 6th of October is close enough. Regular posting will continue starting tomorrow. This is the first in my weekly post of interesting links around the web. These are articles, websites, services, photos, and anything that else that I want to bring up on my blog, but can't use an entire post for. Being on any aggregation sites makes you think harder on each post and puts some weight on you against those little posts, at least in my mind. Hopefully, you'll enjoy whatever I post here. Maybe you'll find a useful site, or learn something you wouldn't otherwise. Really Smart Stuff Ross Jekel, over on the Python 3000 mailing list, supported the existance

Being Helpful by Not Answering Questions

As some of my readers (I have readers?) may know, I am a frequent of #python over at Freenode. A great place. One of the most supportive IRC channels I have ever been a member of. Over the years I have been a frequent member of this channel, I have received an awful lot of help. It is where I went when I first decided to learn Python, and the kind folks there did great things to guide me along. I learned and I stayed, because I still need some good minds to knock ideas around with, and figure things out. I also stayed because the best way I can repay the help I received is to return it to others who seek just that. I want to think my help is appreciated. I happen to know it is. There is an increasing number of regulars, learning their way through, who explicitly seek me for help, send me entire projects to look over, and generally befriend me in response to the advice I give them. I try not to think highly of myself, but I do believe I am valuable to that channel and that many others w

User Expectations for Free Services

"Google, you have no right to track my searches!" How many people have been saying that, especially since the whole thing with AOL "leaking" those users' search records? "Leak" nothing, they released them carefully as an opportunity for research, and we did nothing but attack them. They could have sold them, names and personal billing information included, without ever telling us a thing. What they did was perfectly within their bounds, just read your agreement with them. Google seems to almost get more cruft about the whole thing than AOL. Maybe people just can't get surprised when they think they see something a company they never liked doing something they disagree with. People want to love Google, so they will get defensive about them almost to the point of taking it personally. How do you draw a line to the rights of users, when they do not even pay for the services being considered? Can we have any rights without being customers? If I asked y

Thank God for Standards! Or, Thank Someone Else?

Millions of dollars went into the development of the Digital Video Disc format, its licenses, encryption schemes, patents, bushiness deals to ensure its success, and all the work that went into getting rid of those troublesome plastic cases with yard after yard of magnetic tape. We can all be thankful for that! We have gone through many forms of video, and we can take a lesson from the history of recorded audio. In 1878, Edison invented the phonograph, which we usually think of today as a cylindrical record. The lateral-disc records were technically invented in 1888, as a direct adaptation from Edison's design, but remained covered by patents and used as novelty talking toy technology for another thirty years, until the patents ran out in 1918, forty years after Edison's original invention. It would be another 56 years before the introduction of the cassette tape in Germany. The trend ended there, and we became frustrated with cassette limitations, seeing the introduction of th

Concurrency and Stabilty. More Zen for Python.

I was planning on writing something about the current conversations on the Python-3000 list about concurrency, which just doesn't stop being brought up and never gets resolved to any point that anyone is happy with. In an unrelated action, I went to check on my older blog, which I thought of resurrecting for some non-development articles, and I found a draft from a previous time the topic came up. I read it and was surprised to find that it proposes pretty much exactly what is being put on the table over this past weekend, with reference to walling off multiple interpreters in a single process and controlling messages past between them. The same technique scales for multiple cores, multiple processors, or multiple machines. I've decided to take the easy way out and just post the original draft with minor editing. I enjoy how spot on I ended up being with what is currently becomming an acceptable solution, it might seem. The original was written nearly a year ago. Does this mean

Responding to Mencia About "Outdated" Technology

I wasn't planning to write this, but a quick segment on Mind of Mencia made me want to say something about his piece on tonight's show. It was a rerun, of course, but I don't get to watch the show regularly, although I am a fan. Carlos Mencia blasted some technologies he deemed as outdated and berated anyone who still uses them. I normally enjoy anything he does, having been a fan since before his currently popular show. However, I just had to say something how much I disagree with him on all but one of these technologies. Corded Phones Yeah, I can't go without a cordless phone in a large-ish two story home, but sometimes you can't beat a five dollar phone that you can't loose between the couch cushions. Nintendo 64 Retro gaming. I don't have to say more. Fax Machine I hate fax machines, but the gas company won't let me e-mail them forms because, like it or not, its still easier than e-mail to get from deadtree to deadtree across long distances in a few

Developing is the new Programming

I've been saying this increasingly in debates and discussions over in #python, where I frequent. It has to be something considered before, by more intelligable people than myself, but I don't remember hearing such a statement from anyone else. The focus on the software world has drifted over the years from a focus on programming to a focus on developing. The difference is import and subtle. We can see this in the trend of popular software related books, the evolution of practices and languages, and changing patterns in the industry markets. Books, Blogs, and Bantering The landscape has changed on the kind of information pushed across the board to techie types. Where as reading the official specification of the C language was once a good software book, the best of today have no mention or dependance on any particular language. The emphasis is on books on development as can be applied broadly and generally, such as the excellent Prefactoring . This can also be seen on the blogsce

3 1/2 out of 10 Languages You Should Learn Right Now

Yes, I do believe a good developer has to know more than a handful of languages . Ten sure is an arbitrary number to pick, but whatever! Read the list, I don't want to recap it. Of the ten languages listed, I don't find three and a half of them compelling choices. C# Python JavaScript AJAX (this is the half) Some people might find that an odd list. If you know a little about any of the languages, you might find it even odder. If you know a lot about the languages, you'll have no trouble agreeing, I feel confident. C# is largely what Java should have been. Python is, of course, a fantastic language for most purposes. JavaScript is essential for web work, and web work is essential for getting the rent paid, these days. AJAX, much the same. C# and JavaScript get some crap from the OSS communities. People look down their noses at C#, having such a distaste for all things wearing the brand of Gates. JavaScript can be an ugly, incompatable-with-anything mess, but it can be elega

The Internet Flashed Me

IGN has a case of split personality. On the one hand, I don't have a new enough version of Flash installed for Firefox on Linux to play their videos. On the other hand, if I want to watch some advertising, they wouldn't dare to stop me from doing what I wanna do! Why do so many sites think I don't have a new enough version? Is newer Flash better? No, but the company pays for new versions of Flash Studio anyway, and it exports by default to a newer version, so why bother to change it? Thats like a couple mouse clicks or something! Jeez.

But, didn't PHP break the Web in the first place?

Rasmus Lerdorf is an opinionated man. However, so am I, so I have some things to say about these particular opinions. Lerdorf is claiming the web is broken. I do not disagree. Lerdorf is claiming PHP is the cure, and I couldn't disagree more if he had written that statement on a shard of tin and jammed it in my stomach. That is quite a strong disagreement. I mean, didn't PHP break the web in the first place? Right off the bat, I should note that I do believe PHP can be used well. Any language (almost) can be used properly enough that it can be a decent environment to use, so long as you follow strict rules. PHP is a great example of a language that promotes ignoring any rules. Following a good set of policies, one can develop well structured and elegant applications with PHP, but the fact of the matter is that the language does very little to promote anything in the way of good use of itself. PHP might not promote bad coding, but it simply does so little in the way o

Why Johnny Can Code

This is in response to the article Why Johnny Can't Code , over at Salon Tech . I have heard several people already agreeing with the arguments against this article, so I know I am not alone. Although I completely agree that it is a very good thing for kids to have a quick and easy way to program on their computers, should they have the curiosity, I do not believe the author made very compelling points on the use of BASIC, or anything resembling it. Particularly, I think the author has far too high a reverence for BASIC and fails completely to see the damage the language can do to an aspiring developer, which I won't go into in this article. Conversely he seems to find languages that could fill the gap he says, namely Python, as somehow wrong for a job, which is entirely an incorrect idea. This is pointing from multiple vantages as being written by an unenlightened developer. Yes, a fundamental understanding of how software works can be a good starting point for a life of tec

IronPython and a New Era

As many people have written about, IronPython 1.0 was recently released. There has been a lot said about it, and most interesting has been the response from many groups with little or no connection to the Python community. The fact that the language runs on .Net is more important than most Pythoners realize yet, and there is a predicted large number of future users of Python coming in from this new area of exploration. Many developers using C# or Visual Basic will be glad to move to a fun language like Python for at least part of their projects, and the integration with the CLR makes it flawless to mix with the rest of the components. It all reminds me of a line from Victor Vernado , the black albino comedian: its all the fun of dating a black man, without the disappointing look from your father. IronPython opens the door for a lot people who were unable to move into the community, due to personal or corporate barriers to leave the safety of the Microsoft Umbrella. IronPython is a brid

Give it a REST

I'm wrapping up a REST layer to the service backend I've been developing for my still-unnamed-employer (find out when we launch, real soon now!). I had never developed a service under the "REST" acronym before, so my boss gave me a crash course, I read some things, I thought I got it. REST, a buzzword in its own right, is like stapling smoke to water when you try to define it. That isn't because its vague, its because most of the people who talk about it don't know what they're talking about. Maybe I'm one of them and I shouldn't be posting this. REST is Not: HTTP XML RPC A protocol, format, or even much of a specification Rest is: An idea(l) Agnostic on just about every specification associated with it Requests on a REST Service are: Atomic. No request relies on any other made before or after it. Self Authenticating. Every request must include any credentials. See point 1. Self Describing. This is most commonly XML, and sometimes people think it m

New Job, Fun Projects, and Amazon S3

I haven't posted in a while, but things have been going on. I thought I'd post about some of the more interesting aspects. I've recently began a fairly regular contracting deal with an interesting company, and I'll have to be a little vauge on some aspects, because of NDAs and such. During one of my usual nights of aiding the Pythoners of #python on irc.freenode.net, I was discussing a project someone was trying to complete and the long debate about various routes that could be taken led to me being contracted for the job, which I've had fun with. I've been contracted to build a Fuse package, which uses Amazon's S3 as its storage mechanism. It is a fun system to work with, because of its simplicity and challenging limitations. For example, all operations are redundant, but non-atomic, because the same data could be changed at the same time, and its unpredictable how it would propogate across their redundant network. Mostly this hasn't been an issue, beca

Pandora Pop-Up White Bars Bug the Crap Out of Me!

Pandora Internet Radio - Find New Music, Listen to Free Web Radio So, they added this weird white-bar to top top of pop-up options, and I wrote them to complain because I find it very ugly and unintuitive. I would expect a titlebar-like control as such to be used to move a widget or window, and the X at its left to close the widget just enforces that thought, even tho the bar seems to serve no purpose. Pandora's people tell me it was for some very soon to come updates and that I would see why soon. So, this morning I see they updated the interface again, and there are auto-appearing controls to vote on songs instead of clicking for the menu on each song. That means I will almost never ever see that popup. Is that what they were talking about? Am I missing something? technorati tags: pandora , music , userinterface Blogged with Flock

I've Joined the Flock

Flock — The web browser for you and your friends So this Firefox-based browser is pretty cool. It integrates del.icio.us, Flickr, and blogging. It seems to be strongly related to Yahoo! I'll probably use this for all my casual browsing, keeping Firefox around for development, only. technorati tags: flock , web , browser , software Blogged with Flock

XML versus Binary Document Format Debates

Responding to Sean McGrath on his recent post about XML-vs-binary document formats: Look, its just like I was trying to say in #python@irc.freenode.net the other day: There is nothing wrong with a format being binary. There is no virtue to be found in every byte of a file being interpreted as a textual character (or part of one) that represents your real data. "There ain't such thing as plain text," says Joel Spolsky! There isn't any difference in interpresting the binary as text than just interpretting it directly as your data. You can easily have XML formats as undocumented and inconsistant between versions as any binary format, but you get the added benefit of extra processing overhead, bloated filesizes, and limitations on structure and performance (try keeping efficient on-disk indexes into an XML file up-to-date). I do believe text-based formats and XML has its place, but these places are limited. I would have much perfered an opening and standardization of a r

DeferArgs 0.4 (Busy day!)

Continuing discussions in #twisted about the benefits and complaints of my deferargs drove me to add more things and release pretty often today. This is version 0.4 . New is tests and ability to move the functionality to the callsite, so you can do this: def printArgs(*args, **kwargs): print args print kwargs deferargs(printArgs)(10, defer.succeed(20)) Also, and I don't know how useful this will be, you can not define specially handled argument types, such as lists that might contain deferreds. These are optional, and not enabled by default. Lists are the only special type handled so far. Use it as follows: @deferargs([list]) def printList(l): print l printList([1,2, defer.succeed(3)]) I might add dictionaries, sets, and tuples to the next release. Filed in: programming python twisted

DeferArgs 0.3 by Example

DeferArgs 0.3, just a few hours after 0.2, is now released here . The only update is support for attemp/catch-all blocks without any @catch(type) handlers. In response to some people in #twisted@irc.freenode.net, here are examples that show what can be done more clearly. To write any function that can accept deferred arguments nicely: @deferargs def printArgs(*args, **kwargs): print args print kwargs To add psuedo-exception handlers and a psuedo-finally block to a @deferargs decorated function: @deferargs def printArgs(*args, **kwargs): print args print kwargs print "This one is important! ", kwargs['important'] @catch(KeyError) def onKeyError(e): print "There was no important kwarg!" @catch() def onAnyError(e): print "Crap!" @cleanup() def _(r): print "Every thing is done." There is also a model for a psuedo-try block, which basically decorates just calls the function immediately when you define it and its

DeferArgs supports asyncronous try/except/finally constructs

A new version of DeferArgs is available at the cheeseshop . New in 0.2 are the attempt, catch, and cleanup decorators. These mirror the functionality of try, except, and finally. Any deferargs decorated function can be followed immediately by any number of error handlers decorated as @catch(ErrorType) or @catch() to catch all, with the same semantics as except clauses if they were after a try block that surrounded the code in the function. The catches can all be followed with a cleanup decorated function, which will be called when everything else is done, errors or not. There is also a convinience decorator called attempt, which automatically calls the function once a @catch() decorated handler is defined (signifying that all error handlers for it are prepared). Of course, calling it only really creates the deferred that fires when its arguments are ready, so you dont have to expect it to run for real untl after the attemp/catch/cleanup is completely defined. As always, comments are we

DeferArgs lets you write syncronous looking functions that really aren't!

So a little side project for my own uses provided a simple decorator that lets me write a function I can pass deferreds and regular arguments to, and have the function return a deferred that fires when all of its deferred arguments are ready and the function has processed them. Some example usage: @deferargs def printArgs(*args, **kwargs): print "Positional Arguments: ", ", ".join(args) print "Keyword Arguments: ", ", ".join("%r=%s"%(k,v) for (k,v) in kwargs.items()) printArgs("foobar", baz=someNetworkRequest()) Really basic, but it can prove useful for a large portion of Twisted code you might write. I'm planning to add some semi-evil way to do something that looks a lot like a try/except/finally block but is actually (obviously) not, and works with any errbacks from deferreds within the try-like block of code. The reaction has been interesting. I've had some people stand up for the idea, which is similar to d

It's a Boy!

This is a little late, because I've just been so busy, but my first child, my son, Caelan Mathew Spealman, was born on May 13, 2006 at 11:45, just fifteen minutes before Mother's Day. It was the most amazing expirience in my life, to go from a couple to a family as my son was brought into this world, and honestly, this is just so cool! I can't wait to teach him to program. I might be showing how much geek I am by saying this, but my one-and-a-half week old son already has his own computer.

Early Morning

Woke up at 6 AM, made a pot of coffee (with my patent pending technique of adding sugar and spices directly into the grounds before brewing), and caught up on my 600+ unread messages in GMail. Really made me want keyboard shortcuts for labelling, but the only Greasemonkey userscript I found didn't seem to work. It was supposed to let me hit the 'l' key and type in an autocompleted label name, but I did it the new old fashioned way in the end. Anyone know of such a userscript that does, in fact, work?

I Can Work in Synergy

Just wanted to quickly link to the Synergy project, which I'm now using. Wow, it is so cool. Anyone who has multiple systems at their desk or sits a laptop beside their desktop's monitor should really take a look at this. Dual screen is one level of cool, but being able to move my mouse across multiple screens running multiple operating systems is a blast, and productive too. Copy and paste and keyboard and mouse can all be shared. Now, I'm very interested in if windows could be dragged between the screens with this one day...

Python AST Manipulation for Transparent Defering of Calls?

A lot of work has been going on with the Python AST and being able to manipulate it for more runtime uses. This is a generalized suggestion for something we could do in the Twisted community to utilize this. Given a simple function like this: def processPage(url): d = getPage(url) d.addCallback(cb_processPage) d.addErrback(eb_processPage) def cb_processPage(page): print page def eb_processPage(error): print "Could not load page. Error: ", error We write like that, but what we really mean, and just need to express in a more difficult manner, is: def processPage(url): try: print getPage(url) except LoadError, e: print "Could not load page. Error: ", e What I want to know, is can we take the second example and process the AST branch to produce the first example? Lets step through and see how it would work. First of all, we need to know what is deferred. A simple way would be to check eve