[Tutor] beginsWith multiple prefixes
Alan Gauld
alan.gauld at btinternet.com
Fri Dec 26 12:47:41 CET 2008
"Kent Johnson" <kent37 at tds.net> wrote
>> for d in os.listdir():
>> if MyString(d).upper().beginswith(....):
>
> But that won't work, the result of calling upper() will be a normal
> str, not a MyString.
Ah yes. Immutability of strings strikes again. upper() returns
a new string, I forgot about that. pity.
You can do
if MyString(d.upper()).beginswith(...)
But that loses a lot in elegance and is hardly better than
using a fiunction.
Alan G
More information about the Tutor
mailing list