[Tutor] beginsWith multiple prefixes

Emad Nawfal (عماد نوفل) emadnawfal at gmail.com
Fri Dec 26 14:14:34 CET 2008


On Fri, Dec 26, 2008 at 6:47 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "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
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>

Thank you Alan and everybody. I simply prefer the built-in one. I had no
idea it could take a tuple.
What is amazing is that I learn  more from this list than I do from any
other source.

-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington
http://emnawfal.googlepages.com
--------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081226/9842306f/attachment.htm>


More information about the Tutor mailing list