Text

A Text object contains text from a txt file.

Example Usage

filename = pickAFile()
text = Text(filename)

print(text.getWords())

Initialization

Text.Text(self, filename)
Parameters:filename (string) – the name of the text file.
filename = pickAFile()
text = Text(filename)

Methods

Print all words in the text whose length is less than three.

Text.printSmallWords(self)
text.printSmallWords()

Getters

Return a list of the words in the text.

Text.getWords(self)
# Loop through the words, printing each one.
for word in text.getWords():
   print(word)

Return a list of the lines in the text.

Text.getLines(self)
# Loop through the text's lines, printing each one.
for line in text.getLines():
   print(line)

Table Of Contents