Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 str.endswith(): vague documentation
#1
reading up on str.endswith() i find the optional arguments start and end to be described vaguely. it does not say how they apply, like whether they affect both strings at the same time or just one of them. and if they apply to the string in argument 1, does the end of its substring always get checked as if it was located with end at the end?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
>>> s = 'spam ham eggs'
>>> s.endswith('ham', None, 8)
True
>>> s.endswith('ham', 3, 8)
True
I would guess that s.endswith(x, start, stop) gives the same result as s[start:stop].endswith(x) but it saves the creation of a str instance.
Quote
#3
that was one of the guesses i had. but the documentation does not give enough clue to pin that down or confirm it. is saving the creation of a string instance considered important in a system where performance considerations are generally limited (to use the correct algorithm)?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#4
The endswith() method returns True if a string ends with the given suffix otherwise returns False.

Syntax :

str.endswith(suffix, start, end)
Quote
#5
(Nov-22-2019, 05:29 AM)LeanbridgeTech Wrote: The endswith() method returns True if a string ends with the given suffix otherwise returns False.

Syntax :

str.endswith(suffix, start, end)

even if start and end have random int values in those argument positions?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)