On Sat, Feb 6, 2010 at 10:35 AM, David <ld...@gmx.net> wrote: > Hello again, > > in Knowlton's 2008 book "Python: Create, Modify, Reuse" the author makes > frequent use of the term -1 in his code, but doesn't tell to what aim. For > want of search terms Google is not helpful. Could someone please enlighten > me by means of a one-liner as a reply? > > In [1]: item = 'some string'
In [3]: help(item.find) Help on built-in function find: find(...) S.find(sub [,start [,end]]) -> int Return the lowest index in S where substring sub is found, such that sub is contained within s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. HTH, Wayne > Thank you! > > David > > > Example Code: > > for item in filelist: > if item.find(extension)!= -1: > snaplist.append(item) > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn’t. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor