Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AmigaOS Manual: Reserved Python Words"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
(Table of keywords)
 
m
 
(5 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
| and || A logical operator
 
| and || A logical operator
 
|-
 
|-
| as ||
+
| as || Creates an alias
 
|-
 
|-
  +
| assert || Used for debugging. Raises an AssertionError exception with a specified error message if the supplied condition is False.
| assert ||
 
 
|-
 
|-
| break ||
+
| break || Exits loop
 
|-
 
|-
| class ||
+
| class || Defines a class
 
|-
 
|-
  +
| continue || Terminates the current loop iteration and begins the next one
| continue ||
 
 
|-
 
|-
| def ||
+
| def || Defines a function
 
|-
 
|-
| del ||
+
| del || Deletes an object
 
|-
 
|-
| elif ||
+
| elif || A short for "else if"
 
|-
 
|-
  +
| else || Defines actions that are executed when if condition is False. See if. When used with exception handler, defines actions that are executed when there there was no error. See try.
| else ||
 
 
|-
 
|-
  +
| except || Defines an error handler for an exception handler. See try.
| except ||
 
 
|-
 
|-
| exec ||
+
| exec || Executes the supplied Python code
 
|-
 
|-
| False ||
+
| False || A boolean value
 
|-
 
|-
  +
| finally || Defines actions for exception handler that are executed always. See try.
| finally ||
 
 
|-
 
|-
| for ||
+
| for || Creates a for loop
 
|-
 
|-
| from ||
+
| from || Imports a part of a module
 
|-
 
|-
| global ||
+
| global || Declares a global variable
 
|-
 
|-
  +
| if || Defines actions that are executed when if condition is True.
| if ||
 
 
|-
 
|-
| import ||
+
| import || Imports a module
 
|-
 
|-
  +
| in || Checks if a value is present in an array
| in ||
 
 
|-
 
|-
| is ||
+
| is || Tests if two values are equal
 
|-
 
|-
| lambda ||
+
| lambda || Defines an anonymous function
 
|-
 
|-
| None ||
+
| None || Defines a null value
 
|-
 
|-
 
| not || A logical operator
 
| not || A logical operator
Line 55: Line 55:
 
| or || A logical operator
 
| or || A logical operator
 
|-
 
|-
| pass ||
+
| pass || Does nothing, a null statement
 
|-
 
|-
| print ||
+
| print || Prints a message to the screen
 
|-
 
|-
| raise ||
+
| raise || Raises an exception
 
|-
 
|-
| return ||
+
| return || Exits a function and returns a value
 
|-
 
|-
| True ||
+
| True || A boolean value
 
|-
 
|-
  +
| try || Defines an exception handler (tests a block of code for errors). See except, finally, and else.
| try ||
 
 
|-
 
|-
| while ||
+
| while || Creates a while loop
 
|-
 
|-
| with ||
+
| with || Manages external resources
 
|-
 
|-
  +
| yield || Exits a generator function and returns a value
| yield ||
 
 
|}
 
|}
   
All the keywords except False, None, and True are in lowercase and they must be written as they are.
+
All the keywords except '''False''', '''None''', and '''True''' are in lowercase and they must be written as they are.

Latest revision as of 13:14, 5 December 2022

Python has 34 keywords that have a predefined meaning and thus they cannot be used as a variable name. The keywords are:

Keyword Description
and A logical operator
as Creates an alias
assert Used for debugging. Raises an AssertionError exception with a specified error message if the supplied condition is False.
break Exits loop
class Defines a class
continue Terminates the current loop iteration and begins the next one
def Defines a function
del Deletes an object
elif A short for "else if"
else Defines actions that are executed when if condition is False. See if. When used with exception handler, defines actions that are executed when there there was no error. See try.
except Defines an error handler for an exception handler. See try.
exec Executes the supplied Python code
False A boolean value
finally Defines actions for exception handler that are executed always. See try.
for Creates a for loop
from Imports a part of a module
global Declares a global variable
if Defines actions that are executed when if condition is True.
import Imports a module
in Checks if a value is present in an array
is Tests if two values are equal
lambda Defines an anonymous function
None Defines a null value
not A logical operator
or A logical operator
pass Does nothing, a null statement
print Prints a message to the screen
raise Raises an exception
return Exits a function and returns a value
True A boolean value
try Defines an exception handler (tests a block of code for errors). See except, finally, and else.
while Creates a while loop
with Manages external resources
yield Exits a generator function and returns a value

All the keywords except False, None, and True are in lowercase and they must be written as they are.