Term
|
Definition
Called Logical AND operator. If both the operands are true then then condition becomes true.
ex. (a and b) is true. |
|
|
Term
|
Definition
The del statement is a way to remove an item from a list given its index instead of its value: the del statement.
ex. a = [-1, 1, 66.25, 333, 333, 1234.5] del a[0] a [1, 66.25, 333, 333, 1234.5] |
|
|
Term
|
Definition
The root of a from-import statement. The from-import statement is used to import specific objects from a module.
ex. from x import y |
|
|
Term
|
Definition
A negation for the defined operation.
ex. not(2 == 1) |
|
|
Term
|
Definition
The while loop continues until the expression becomes false. The expression has to be a logical expression and must return either a true or a false value.
ex. while (x < 10): |
|
|
Term
|
Definition
Used in a 'with' statement to define the alias to assign each result of with x to.
ex. with open("x.log") as x |
|
|
Term
|
Definition
A conditional execution statement following an 'if'. Shorthand for an else-if.
ex. if x==0: do stuff elif x==1: do more stuff |
|
|
Term
|
Definition
The global statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals.
ex. globes = 0 def glob_1(): global globes globes = 1 def glob_2(): print globes glob_1() glob_2() |
|
|
Term
|
Definition
Boolean operator to accept if either condition is True, return True.
ex. if (1==1 or 1==2): |
|
|
Term
|
Definition
The with statement is used to wrap the execution of a block with functionality provided by a separate guard object (see context-managers). This allows common try-except-finally usage patterns to be encapsulated for convenient reuse.
ex. with open("bzr.log") as x: data = x.read() print data |
|
|
Term
|
Definition
The assert statement verifies that the expression defined resolves to true. If it does not it will raise an AssertionError with an optional expression2.
ex. assert (x==1 or x==2) |
|
|
Term
|
Definition
When all conditional execution statements in an If, Elif block return false, the else will catch and execute.
ex. if x==1: do1 elif x==2: do2 else: do3 |
|
|
Term
|
Definition
A conditional execution statement which executes some code if a statement is True.
ex. if you == stinkypant: print "whew!" |
|
|
Term
|
Definition
A null operation. When this is executed nothing happens.
ex. if x<0: derp() else pass |
|
|
Term
|
Definition
Return a generator object(like a list or tuple) instead of a static object.
ex. def direct(path): yield os.path.walk(path) |
|
|
Term
|
Definition
Will exit out of the 'nearest' loop.
ex. while x<10: if x<0: break print x x = x+1 |
|
|
Term
|
Definition
When a try statement fails the except catches the failure and returns.
ex. while True: try: num = raw_input(int()) break except: print "Thats not an int." |
|
|
Term
|
Definition
The import statement initializes an external module so its functions can be used in the current environment.
ex. import os print os.path("c:") |
|
|
Term
|
Definition
The print statement will export the argument to STDOUT.
ex. print "sup" |
|
|
Term
|
Definition
A object that contains functions and can be instantiated.
ex. class Man: def height(self): print "TALL DUDE" |
|
|
Term
|
Definition
Allows for the dynamic execution of Python code.
ex. test = print "Sup" exec(test) |
|
|
Term
|
Definition
When used with an if, allows the code to loop through all members of a generator object.
ex. x = 1 if x in [1,2,3,4,5]: print "Sup" |
|
|
Term
|
Definition
Used to call an exception that can be customized per situation.
ex. raise Exception, "PC LOAD LETTER" |
|
|
Term
|
Definition
When encountered, causes the application to skip the rest of the current loop.
ex. k = [1,2,3,4,5] for x in k: if x>3: print "TOO BEEG" continue print x |
|
|
Term
|
Definition
The finally statement is the cleanup function in a 'try' statement. While all of the try...except...else are executed, if an exception is raised it is parsed and printed in the finally statement. This also causes any application that is preemptively interrupted to still execute the finally statement before closing out of the loop.
ex. try: d = file("herp.txt") while True: line = d.readline() if len(line) == 0: break time.sleep(2) print line, finally: d.close() print "Cleaning up your mess." |
|
|
Term
|
Definition
Compares the object identity of two objects. Two objects referencing the same memory location will return True, but objects that are 'equal' will not.
ex. 1 == 1 1 is 1 [] == [] [] is [] |
|
|
Term
|
Definition
Outputs the value returned by a function. This cannot be a generator object as return will only return that it is a generator function.
ex. def poop return 2 * 2 |
|
|
Term
|
Definition
Define a function.
ex. def testfunc(poops) |
|
|
Term
|
Definition
Iterate through a generator object. The for specifically defines a variable to store each individual iteration as the generator counts through.
ex. i = ["Hello","world!"] for x in i: print x |
|
|
Term
|
Definition
Creates an anonymous function that is not bound to a specific namespace.
ex. for i in (1,2,3,4,5): a = lambda x: x * x print a(i) |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
A string is a sequence characters which mathematical functions cannot be performed on. |
|
|
Term
|
Definition
Numbers are a sequence of numbers that math can be performed on. |
|
|
Term
|
Definition
A float is a string of numbers that is equal to 32-bit storage of integers and fraction representing decimal places. |
|
|
Term
|
Definition
A list is a dynamic storage of multiple variables in a single object that can be iterated. Unlike a tuple, lists can be changed after creation. |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
signed decimal (same as %d) |
|
|
Term
|
Definition
Signed decimal (obsolete) |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
floating point in exponential format, lowercase |
|
|
Term
|
Definition
floating point in exponential format, uppercase |
|
|
Term
|
Definition
floating point decimal format |
|
|
Term
|
Definition
floating point decimal format |
|
|
Term
|
Definition
floating point format. Lowercase exponential format if less than -4, decimal format otherwise |
|
|
Term
|
Definition
floating point format. Uppercase exponential format if less than -4, decimal format otherwise |
|
|
Term
|
Definition
|
|
Term
|
Definition
String, converts using repr(), "x" |
|
|
Term
|
Definition
string, converts using str(), x |
|
|
Term
|
Definition
No argument converted. Results in '%' in the result |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
Exponentiation, 'to the power of' |
|
|
Term
|
Definition
|
|
Term
|
Definition
quotient, division without any remainder |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
not equal to comparison (obsolete) |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
declaration of a variable |
|
|
Term
|
Definition
add to the variable by argument and re-declare as the new value |
|
|
Term
|
Definition
subtract from the variable by the argument and re-declare as the new value |
|
|
Term
|
Definition
divide by the variable by the argument and re-declare as the new value |
|
|
Term
|
Definition
multiply the variable by the argument and re-declare as the new value |
|
|
Term
|
Definition
get the quotient of the variable by the argument and re-declare as the new value |
|
|
Term
|
Definition
Get the remainder by dividing the variable by the argument and re-declaring it as the new value |
|
|
Term
|
Definition
exponentiate the variable by the argument and re-declare as the new value |
|
|