[Tutor] associating two objects without ORM and processing a text file

neubyr neubyr at gmail.com
Mon Feb 11 06:14:14 CET 2013

I have a text file with each line in following format:

Book Name, Author Name, Genre, Publication Date

I would like to perform following queries on this file:
 * Get all books written by an author
 * Remove all books of an author
 * Get information about a book (pretty print matching line!)
 * Get books of particular genre

Also, I would like to add and delete entries in this file. I am not
planning to use any database for this purpose and would like to get better
grasp on file parsing and classes/OOP. I need some help in creating classes
and following are my initial thoughts:

# Create a class for Book object
class Book:
  atributes: name, author_name, genre, publication-date

# Create
 attribute(s): name

# Create class for reading and writing to the file
class Booksfile:
  methods: ??

* How do I associate/relate Book and Author classes so that it will help me
in getting information like 'get list of books written by an author'? Data
* Should I create a new Booksfile object for reading, writing and deleting
entries in the file OR add corresponding methods to the book object itself?

I am not planning to use SQLite or any database and would like to use text
file only. Appreciate any help on designing such application.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130210/0a41875c/attachment.html>

More information about the Tutor mailing list