[Chicago] constant length string manipulation

Martin Maney maney at two14.net
Sun Dec 2 03:07:44 CET 2007


On Thu, Nov 29, 2007 at 03:45:37PM -0600, Ian Bicking wrote:
> def fivespaces(s):
>      while len(s) < 5:
>          s += ' '
>      while len(s) > 5:
>          s = s[:-1]
>      return s

Hey!  That's like a Monty Python kit, but in code.  Waiter, forget
about that earlier order.  Oh, and tell the operator she can keep the
dime, too.

-- 
Now people have pondered this time and again (Who dies? Everyone dies)
We suspect that we're more than mere mortal remains (Oh, everyone dies)
Wise men and prophets they've all had their say
  on the nature of our afterlives
But in case there's no beer there we'll have one more round (Oh everyone dies)
 -- James Keelaghan in "Who Dies?", an upbeat song about mortality



More information about the Chicago mailing list