if string in bigstring:
It gets a mention in the "if" section but not a lot.
--
Chris Green
>From http://docs.python.org/reference/expressions.html#in
The operators in and not in test for collection membership. x in
s evaluates to true if x is a member of the collection s, and
false otherwise. x not in s returns the negation of x in s. The
collection membership test has traditionally been bound to
sequences; an object is a member of a collection if the
collection is a sequence and contains an element equal to that
object. However, it make sense for many other object types to
support membership tests without being a sequence. In
particular, dictionaries (for keys) and sets support membership
testing.
For the list and tuple types, x in y is true if and only if
there exists an index i such that x == y[i] is true.
For the Unicode and string types, x in y is true if and only if
x is a substring of y. An equivalent test is y.find(x) != -1.
Note, x and y need not be the same type; consequently, u'ab' in
'abc' will return True. Empty strings are always considered to
be a substring of any other string, so "" in "abc" will return
True.
Changed in version 2.3: Previously, x was required to be a
string of length 1.
For user-defined classes which define the __contains__() method,
x in y is true if and only if y.__contains__(x) is true.
For user-defined classes which do not define __contains__() and
do define __getitem__(), x in y is true if and only if there is
a non-negative integer index i such that x == y[i], and all
lower integer indices do not raise IndexError exception. (If any
other exception is raised, it is as if in raised that
exception).
It's tough to find those generic keywords. It happens to be
documented a bit here:
http://docs.python.org/library/operator.html#operator.contains
http://docs.python.org/reference/expressions.html#id12
HTH,
-tkc
--
Chris Green
>t> I've had this trouble before, how do I find the details of how "in"
>t> works in the documentation. E.g. the details of:-
>t> if string in bigstring:
>t> It gets a mention in the "if" section but not a lot.
It is explained in The Python Language Reference, chapter Expressions,
section Comparisons. At least that's were it is in the 2.6 doc.
--
Piet van Oostrum <pi...@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: pi...@vanoostrum.org
Lots of people have been very helpful
but isn't the OP's real problem
that "in" is not included in the 2.6.1
Help index?
Colin W.
Also, from the interactive interpreter:
>>> help("in")
Comparisons
***********
[...]
Note that you have to use quotes around "in" because it's a keyword,
help(in) is invalid.
--
Gabriel Genellina
Well, this may not solve the OP's problem, but the current
(2.7a0) .chm file has a much better index for operators and
keywords. And "in" is in there. If you're interested in
comparing, there's a copy here:
http://timgolden.me.uk/python/downloads/snapshots/trunk/Python27a0.chm
TJG
Thanks for the link (should be a lowercase 'p' - python27a0.chm -
BTW). But having had a look at this file (under kchmviewer rather than
the Windows help viewer) ....
Ye Gods - it's almost unreadable. Not because of the content, but
because of the page style. I'm getting black text on a sort of slate
blue background. Is this the expected appearance?
Jon N
--
Chris Green
Ummm. No. It uses the same css as the standard Python docs.
Frankly I think the contrast could be better, but it's
certainly readable.
Maybe some issue with the kchmviewer rendering? Might be
easier for non-Windows users to look at the dev docs online:
since that's built from the same source / index. I find the
.chm far easier to search but the online docs are pretty good.
The (js-based) online search feature does work but, unfortunately,
is naive in its selection, so searching for "in" turns up any
page with the word "in" in it! The index page is rather better:
http://docs.python.org/dev/genindex-I.html
Hope that helps
TJG
I trust that the improved docs will go
back to 2.6, unless 2.7 is almost ready.
Colin W
Worked for me. What was the problem?
TJG