[Tutor] Question about startswith() and endswith() in 2.5
Dick Moores
rdm at rcblue.com
Mon Sep 25 18:46:04 CEST 2006
At 09:04 AM 9/25/2006, Carroll, Barry wrote:
>Hello, Dick.
>
>Let's compare your final startswith method and the endswith method in
>is_image_file:
>
> >>>>>>>
>s.startswith("er","q","ty")
>filename.endswith(('.gif', '.jpg', '.tiff'))
> >>>>>>>
>
>Notice that, while startswith has THREE parameters, endswith has only
>ONE. ('.gif', '.jpg', '.tiff') is a tuple, and the interpreter sees it
>as a single parameter. In other words your method is passing the
>following parameters:
>
> prefix = "er"
> start = "q"
> end = "ty
>
>while the example method is passing:
>
> suffix = ('.gif', '.jpg', '.tiff')
> start = None
> end = None
>
>Does that make sense?
Sure does now.
Thanks, Barry
Dick
More information about the Tutor
mailing list