[omaha] Fwd: [Chicago] constant length string manipulation

Jeff Hinrichs - DM&T jeffh at dundeemt.com
Sat Dec 1 05:56:50 CET 2007

Ok, now this is funny.  For the past two days this thread about
returning a len 5 string has been going on the Chicago user group
list.  Everyone creating a more boneheaded obfuscated method to do it,
even Ian Bicking wrote some off the cuff C extension for python to do
it at blazing fast speeds.  (The original posters question had been
answered in the first response, but the conversation since then this
thread is the closest thing to a monty python skit I've read in a

---------- Forwarded message ----------
From: Chris McAvoy <chris.mcavoy at gmail.com>
Date: Nov 30, 2007 9:52 AM
Subject: Re: [Chicago] constant length string manipulation
To: The Chicago Python Users Group <chicago at python.org>

On Nov 29, 2007 3:21 PM, Lukasz Szybalski <szybalski at gmail.com> wrote:
> On Nov 29, 2007 3:06 PM, Lukasz Szybalski <szybalski at gmail.com> wrote:
> > Hello,
> > Is there a string function in python that does the following:
> > I need a string of length 5 char, and I will pass a longer and shorter
> > string but I always need to get string of length 5.
> > If my string is longer its easy:

This task is stupid.

You should only address the "string is longer" issue, use cut (see
'man cut' if you need help), and then tell whomever is asking you to
do this that it can't be done.

(wipes hands, beams triumphantly)

I win.

Otherwise, if they insist that the "edge case" of a string shorter
than five characters needs to be lengthened (do those even exist???)
insist that their inflexibility is hurting the agility of your team,
and demand that they find budget to hire an intern.  Also, pad your
estimate with acronyms, like TDD and BUTT.

If they continue to give you flak, cough and say "anassholesayswhat."
When they say, "what?"  Laugh.

Maybe try writing this in Rails.  I'm pretty sure they have a template
tag that says ""some string of unfathomable
 Notice that you don't have to import that (agile!) and you don't have
to use parens (agile!).

If they won't let you write it in Rails, quit.

Maybe Erlang can handle this?  I'm pretty sure conditional lengthening
/ shortening of strings is something that Functional languages do
better than procedural languages.  Paul Graham wrote an article about
it in 1992, right before he created Ebay in Lisp.

Do you use a Mac?  You should.  Because the Mac takes care of Strings.


Chicago mailing list
Chicago at python.org

Jeff Hinrichs
Dundee Media & Technology, Inc
jeffh at dundeemt.com

More information about the Omaha mailing list