What to do after Python?

Roy Smith roy at panix.com
Mon Feb 19 01:02:14 CET 2001

Kenneth Loafman <ken at lt.com> wrote:
> Consider one case I found
> where the goal was to remove the last character of a line.  Instead of
> using something like:
>    if (strlen(s)) s[strlen(s)-1] = 0
> the (7-year C++ veteran) wrote several lines of code that:
>    reversed the string
>    trimmed the first char
>    re-reversed the string

How about:

   if (length = strlen(s))
      s[length-1] = 0;

and cut your instruction count in half :-)

More information about the Python-list mailing list