creating class instances from a text file in python
问题 I have a polynomial class: class Polynomial: def __init__(self, *termpairs): self.termdict = dict(termpairs) To add an instance to this class, you enter the following: P = Polynomial((3,2), (4,5), (9,8)) Now I'm trying to create a function that reads information from a text file, and from that text file, it creates an instance of the Polynomial class. The information is stored in the text file like this: 4 6 2 3 9 8 3 5 0 42 So far, the function looks like this: def read_file(polyfilename):