Eureka moments in Python

Jeff McNeil jeff at jmcneil.net
Tue Mar 13 23:07:59 EDT 2007


Bit of a newbie on this list, but here goes...

Web Services.

The company I'm working for has been pretty big into the WS-* specifications
and the Microsoft .Net WCF components for our business systems. I'm one of
three Unix guys that code the products while we've a larger team of Windows
developers that work on the accounting/billing/provisioning systems. We need
to make them all talk to each other.

Most of my programming experience had been in C and Java up until this
point, so my first reaction was to implement SOAP endpoints using AXIS (I
believe 2 had just come out) on the Unix systems. The back-office developers
would then "simply" generate .Net stub code off of hand-generated WSDL
documents (contract first).

What a nightmare. Honestly. Wow. I've dealt with some messed up systems in
my time but this stuff? It's supposed to be nice and new and shiney. The
complex types didn't match up. Wsdl2py would sit and spin whenever the .Net
development team would use some specific attributes on complex types.  We
spent a few days trying to get this stuff to click.

I wound up giving up on the whole AXIS thing and implementing a Python
framework built on SimpleXMLRPCServer. Rolling out a remote API for a
product component is a three or four day effort, including unit test and
acceptance test automation.  Comparable systems in Java (or heaven forbid,
even C in some instances) would take three to four weeks. Wow. Why didn't we
pick this up sooner?

Since the introduction of that component, we've moved all of our core
backend systems to Python. Systems that were 5 - 6 thousand lines of Java
have dropped down to 5 - 6 hundred lines of Python (SQLObject + dynamic
language eliminates dozens of DTO/DAO classes and corresponding
interfaces!).   I can honestly say that the Windows development group has
started reading a few of my books.  They're contemplating moving over to
Python as well.

All in all, it's been a huge hit. I had been moving smaller components over;
utilities that had been written in early versions of Perl 5 and whatnot. It
wasn't until I took a stab at the WS-* specifications that I realized how
much easier it was in Python.

Though, we've still got a few hundred thousand lines of Java laying around,
I won't be happy until that's history!

Thanks,

Jeff


On 3/13/07, Steven D'Aprano <steve at removeme.cybersource.com.au> wrote:
>
> I'd be interested in hearing people's stories of Eureka moments in Python,
> moments where you suddenly realise that some task which seemed like it
> would be hard work was easy with Python.
>
> I had a recent one, where I had spent some time creating a function which
> took a list as an argument, and then rearranged the items according to
> what magicians call a Monge shuffle. I had started off with a piece of
> code that walked the list, dropping items into two new lists, then
> combining them again. I got the code down to eight lines or so, something
> like this:
>
> # from memory, untested
> top, bottom = True, False # not strictly needed, but helps document code
> where = bottom
> holder = {top: [], bottom: []}
> for item in reversed(alist):
>     holder[where].append(item)
>     where = not where
> holder[bottom].reverse()
> print holder[bottom] + holder[top]
>
>
> And then it suddenly struck me that I could do it as a one-liner:
>
> alist[1::2] + list(reversed(alist[0::2]))
>
> Or if I wanted to be even more concise, if slightly less readable:
>
> alist[1::2] + alist[0::2][::-1]
>
> If only a real Monge shuffle with actual cards was so easy...
>
>
>
>
> --
> Steven D'Aprano
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070313/1a836b55/attachment.html>


More information about the Python-list mailing list