python commands Flashcards
pop function
.pop
var1.pop(var2)
.pop(var1)
Removes and returns an object from a list.
Calls the pop function.
from container var1, run pop function on var2
OR
Call pop function on parameter var2 which is in container var1
Call pop function on var1
.split
split function
Calls the split function.
Makes each word in string a separate piece(objects/strings) of data, basically turns strings into lists.
.append
append function
Calls the append function.
Adds to the end of a list.
.join
join function
Calls the join function.
Joins all objects together from a list.
i.e. print ‘ ‘.join(chris)
will print: bread butter scones jam tea coffee
joins a specified range of objects together from a list
i.e. print ‘ and ‘.join(chris[3:6])
will print: jam and tea and coffee
chris [bread butter scones jam tea coffee].
.exist
exist function
Calls the exist function.
Checks to see if a file/module exists and returns True if yes or False if no.
.open
open function
Calls the open function.
Opens a file/module.
.close
close function
Calls the close function.
Saves and closes a file/module.
.read
Calls the read function.
Reads the contents of a file.
.readline
deadline function
Calls the readline function.
Reads a specific line of file contents.
.truncate
truncate function
Calls the truncate function.
Deletes all data in a file.
.write
write function
Calls the write function.
Write to a file. overwrites existing data.
.items
item function
Calls the items function.
Retrieves data associated with variables or whatever it is called on.
.get
get function
Calls the get function.
Safely retrieves data that may or may not be there.
.key
?