Python keywords

gtb goodTweetieBird at hotmail.com
Thu Apr 26 14:49:39 EDT 2007


On Apr 26, 10:16 am, Larry Bates <larry.ba... at websafe.com> wrote:
> gtb wrote:
> > Have done some searching but have not found a place where I can look
> > up python keywords. I was looking at a script that contained the
> > following line:
>
> > assert self.getResponseCode() in (200, 304, 302)
>
> > I can infer the usage here but previously I had thought that "in" was
> > only used with '"for". I looked thru 'the Python Reference Manual and
> > found "in" is a keyword but in skimming thru I found it only with
> > "for". The reference manual seems good but seems not to be setup for
> > searching. Or maybe I just missed something.
>
> > Thanks,
>
> > gtb
>
> http://docs.python.org/ref/keywords.html
>
> in keyword is a general one and can be used for many objects.
>
> x in 'xyz'
>
> y in ['a','b','c','y','z'']
>
> z in ('a','b','c','y','z']
>
> key in {'key1':1, 'key2': 2}
>
> The in you see with a for isn't associated with the for loop
> but rather the sequence you are iterating over
>
> for i in range(10):
>
> -Larry

Thanks Larry. I saw that page you referenced above and that is how I
knew it was a keyword. But I still have found nodocumentation that
supports the examples you provided.


Thanks again,

john




More information about the Python-list mailing list