Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Remove str.find in 3.0?

Bill Janssenjanssen at parc.com
Sat Aug 27 04:40:29 CEST 2005


> There are basically two ways for a system, such as a> Python function, to indicate 'I cannot give a normal response."  One (1a)> is to give an inband signal that is like a normal response except that it> is not (str.find returing -1).  A variation (1b) is to give an inband> response that is more obviously not a real response (many None returns).> The other (2) is to not respond (never return normally) but to give an> out-of-band signal of some sort (str.index raising ValueError).>> Python as distributed usually chooses 1b or 2.  I believe str.find and> .rfind are unique in the choice of 1a.Doubt it.  The problem with returning None is that it tests as False,but so does 0, which is a valid string index position.  The reasonstring.find() returns -1 is probably to allow a test:      if line.find("\f"): ... do somethingMight add a boolean "str.contains()" to cover this test case.Bill


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp