I'm looking into overloading the +
operator for a certain string so I was thinking of subclassing the string class then adding the code in the new class. However I wanted to take a look at the standard string class first but I can't seem to find it... stupid eh?
Can anyone point the way? Even online documentation of the source code.
It's documented here. The main implementation is in
Objects/stringobject.c
. Subclassingstr
probably isn't what you want, though. I would tend to prefer composition here; have an object with a string field, and special behavior.my implementation is similar, though not as neat:
You might mean this.
It works like this.