Matching a constant string at beginning
François Pinard
pinard at iro.umontreal.ca
Thu Jan 20 17:30:07 EST 2000
More information about the Python-list mailing list
Thu Jan 20 17:30:07 EST 2000
- Previous message (by thread): read from binary file
- Next message (by thread): Socket module on Mac
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Fred L. Drake, Jr." <fdrake at acm.org> écrit: > François Pinard writes: > > is rather tedious. Of course, I could write a very small function to > > match a constant string at the beginning of another, but there just must > > be some idiom for doing this. > François, Another possibility, if you're willing to use the CVS version(!), > is to use the string methods: > s = some string... > if s.startswith("Simpsons"): > do something interesting... > Or you could write that annoying little function while waiting for 1.6. ;) I think I'll do that (write that annoying little function). "Barry A. Warsaw" <bwarsaw at cnri.reston.va.us> writes: > Two new methods `startswith' and `endswith' have been added, which will > fit the bill perfectly: String methods will be one of those new features > that'll change your life. :) Wait'll you try s.join(). > -------------------- snip snip -------------------- > >>> ' & '.join(['Guido', 'Tim', 'Gordon', 'David', 'Biff', 'etc.']) > 'Guido & Tim & Gordon & David & Biff & etc.' > >>> > -------------------- snip snip -------------------- How strange! :-) I'm curious to see 1.6, indeed... -- François Pinard http://www.iro.umontreal.ca/~pinard
- Previous message (by thread): read from binary file
- Next message (by thread): Socket module on Mac
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list