20Oct

Probably my most annoying coding blind spot…

Posted by Elf Sternberg as personal, programming, python

Do you have that one thing that you have to constantly look up?

In python, to replace elements of a string, there are two operators.  One is a strictly linear search, the other uses regular expressions.  The regexp call to replace part of a string with another string is sub, and the string call to replace a part of a string with another string is replace.

I get these backward all the flamin’ time, and it drives me insane.  I use both of these every day, why the Hell can’t I remember which is which?

1 Response to Probably my most annoying coding blind spot…

Anthony Francis

October 22nd, 2009 at 12:07 am

Try a mnemonic. When I was learning C/C++ I always got the darn ordering of the semicolon clauses in for loops wrong, until I started thinking of them as “itty little headers” -> itty -> ITI -> Initialize, Test, Increment. Now it is second nature. I’m sure you can work up one that you can remember for this one.

Comment Form

Subscribe to Feed

Categories

Calendar

October 2009
M T W T F S S
« Sep   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031