A little disappointed so far
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue May 20 08:48:43 EDT 2003
Tom Bryan <tbryan at python.net> wrote in
news:FPoya.61371$fr6.3606207 at twister.southeast.rr.com:
> # does the string end in a slash
> if ($myString =~ /\/$/)
>
> Where in Python, that would be
> if myString[-1] == '/':
>
You probably ought to use a slice here otherwise it breaks if you have an
empty string:
if myString[-1:] == '/':
Or, for even more clarity use:
if myString.endswith('/'):
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list