[Chicago] constant length string manipulation

Chris McAvoy chris.mcavoy at gmail.com
Fri Nov 30 16:52:55 CET 2007

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.


More information about the Chicago mailing list