elfs: (Default)
[personal profile] elfs

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?

This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com

Date: 2009-10-20 06:14 pm (UTC)
From: [identity profile] codeamazon.livejournal.com
I'd try to remember this this way:

"regex starts with r. The call that uses it should too! But they got it WRONG and it DOESN'T start with r."

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 1st, 2026 11:14 am
Powered by Dreamwidth Studios