473,388 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Python keywords

gtb

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

Apr 26 '07 #1
6 2106
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
Apr 26 '07 #2
In <11*********************@r35g2000prh.googlegroups. com>, 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.
If you look in the library reference index you'll find a link to the
`Sequence Types`_ section where it is mentioned as an operator that tests
if some object "contains" another. And the reference manual has an index
entry called `in operator` which leads to the page Comparisons_, telling
how to overwrite the behaviour in your own classes.

... _Sequence Types: http://docs.python.org/lib/typesseq.html
... _Comparisons: http://docs.python.org/ref/comparisons.html

Ciao,
Marc 'BlackJack' Rintsch
Apr 26 '07 #3
gtb
On Apr 26, 10:16 am, Larry Bates <larry.ba...@websafe.comwrote:
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

Apr 26 '07 #4
gtb

Thanks Marc.

Apr 26 '07 #5
gtb
On Apr 26, 1:59 pm, "Hamilton, William " <wham...@entergy.comwrote:
-----Original Message-----
From: python-list-bounces+whamil1=entergy....@python.org
[mailto:python-
list-bounces+whamil1=entergy....@python.org] On Behalf Of gtb
Sent: Thursday, April 26, 2007 1:50 PM
To: python-l...@python.org
Subject: Re: Python keywords
On Apr 26, 10:16 am, Larry Bates <larry.ba...@websafe.comwrote:
>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.

http://docs.python.org/ref/comparisons.html#l2h-438

This information is 2 clicks away from any page in the reference: click
the index link, then scroll down to the link to "in operator".

---
-Bill Hamilton
Thanks, Bill.

I clicked there before and decided I must be experiencing an indexing
error or such due to using firefox instead of IE when I didn't see "in
operator" at the top of the page.

Best Regards,

john

Apr 26 '07 #6
gtb <go*************@hotmail.comwrote:
Have done some searching but have not found a place where I can look
up python keywords.
>>import keyword
keyword.kwlist
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global',
'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print',
'raise', 'return', 'try', 'while', 'with', 'yield']

call help(kw) from an interpreter prompt for any one of these values for
more information. E.g.,
>>help('and')
will give you section 5.1 (Boolean operations), all the way to
help('yield') giving 6.8 (The yield statement). Some of the keywords
have no specific info, e.g. help('as') will not be very informative:-).
Alex
Apr 27 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Juho Saarikko | last post by:
The program attached to this message makes the Python interpreter segfault randomly. I have tried both Python 2.2 which came with Debian Stable, and self-compiled Python 2.3.3 (newest I could find...
1
by: M.E.Farmer | last post by:
Hello c.l.py!, I have just finished this and decided to share. PySourceColor is a module to convert Python source into colored html. Yes it has been done before, but I like this better:) You can...
8
by: Andr? Roberge | last post by:
In short: Is there a simple way to desactivate Python keywords and built-in keywords Longer description: I want to use a subset of Python as an embedded language and don't want the users to...
4
by: Xah Lee | last post by:
while programing in Python, one can lookup syntax or info for keywords or modules within Python. In the command line, type python to get into the python interactive program. then type...
0
by: todddeluca | last post by:
I am posting code for calling almost any python function from php, because it seems generally useful. Please feel free to suggest improvements or tell me this has already been done better...
6
by: vedrandekovic | last post by:
Hello, I am trying to make a program for 3D modelling with "programming".And I want make my own program commands, for example when user type code in my program: "<<koristiti>OS"- (THIS IS...
6
by: vedrandekovic | last post by:
Hello AGAIN, I on working on windows and Python 2.4. Where can I find and CHANGE python grammar. ( I just want to change the keywords ) PLEASE HELP ME SOMEBODY!!!!!! ...
7
by: Maximus Decimus | last post by:
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced...
145
by: Dave Parker | last post by:
I've read that one of the design goals of Python was to create an easy- to-use English-like language. That's also one of the design goals of Flaming Thunder at http://www.flamingthunder.com/ ,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.