Command/Functions Flashcards
read()
displays text
close()
closes the file
readline
reads just one line
truncate()
empties the file
write(stuff)
writes “stuff” to the file
len()
returns the number of items of a sequence or mapping
raw_input(prompt)
recieves data from the user
range()
gets the values up to the final number (i.e. 1,6 gets 12345)
vars()
Without arguments, equivalent to locals()
With an argument, equivalent to object.__dict__
classmethod()
Convert a function to be a class method It recieves the class as implicit first argument
filepoint.seek(int)
seek moves to a certain part of the file. Use with filepoint to reach a certain point, making “int” the number of bytes down the line. Default is 0.
return()
gives the value of a function. Return 1+2 = 3
super()
calls parent class then calls added functions in the child class
__init__(self,)
creates an empty object inside of a class
open()
opens file