What to do after Python?
Roy Smith
roy at panix.com
Sun Feb 18 19:02:14 EST 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