In this chapter, we have seen some useful built-in functions. We summarize them in Table 2.1 and present a few other useful ones (note that these may not be the full syntax, only what we feel would be useful for you now).
Table 2.1. Useful Built-In Functions for New Python Programmers
Function
Description
dir([obj])
Display attributes of object or the names of global variables if no parameter given
help([obj])
Display object's documentation string in a pretty-printed format or enters interactive help if no parameter given
int(obj)
Convert object to an integer
len(obj)
Return length of object
open(fn,mode)
Open file fn with mode ('r' = read, 'w' = write)
range([[start, ]stop[,step])
Return a list of integers that begin at start up to but not including stop in increments of step; start defaults to 0, and step defaults to 1
raw_input(str)
Wait for text input from the user, optional prompt string can be provided