The constructor method in this program has the attribute of name. The __str__() method creates a string representation of the object. See different ways to access attributes in the program below.
Sunday, June 14, 2015
Tuesday, May 5, 2015
Monday, April 27, 2015
Friday, April 24, 2015
Pickling and Shelving Data
The following program stores data to a .dat file rather than a .txt file. To store more complex information, such as lists, .dat files are used. The shelf module allows you to randomly access data. It basically takes pickled data one step further by making a dictionary out of the lists which can be randomly accessed.
Thursday, April 23, 2015
Writing to a text file
The following program write three lines and creates a text file. The writelines method can be used to write lines from a list to a text file.
Subscribe to:
Posts (Atom)