ultra newbie question (don't laugh)

John Salerno johnjsal at NOSPAMgmail.com
Tue Sep 26 15:56:03 CEST 2006

Ok, I've decided to make a little project for myself which involves 
storing employee information in an XML file. I'm doing this partly to 
experiment with working with XML. The blocks in the file will look 
something like this:

<researcher id="salerjo01">
   <birth_country>United States</birth_country>

I also plan to make a GUI frontend with wxPython for entering the 
records. This will be fairly easy, but not as fun as writing the logic. 
For now I've decided to focus just on writing the logic, and not worry 
about the GUI yet.

So this is what I came up with so far, then I sat staring at the screen 
wondering how to proceed:

class LabXMLWriter(object):

     def write_name(self, first, last, given=''):

Suddenly I realized I just have no idea how to start thinking about what 
I need to do. My first instinct was to use a class, as above, but then I 
wondered if that was even necessary, since all I need to do is get 
information from a user and write it to a file. Do I really need that 
information stored in an object?

Then I wondered if I needed an __init__ method, and what could go in it? 
Or should I just make separate methods for each bit of information to 
write to the file (i.e., name, birth location, address, phone number, 
etc.). I thought maybe I could create the ID in the __init__ method 
(salerjo01), but to do that I need the name first. I could do this:

def __init__(self, first_name, last_name, given_name=''):
     # code to initialize name and create ID

But then I wondered if this detracts from the work that the class 
methods would do later.

So you see, what I'm asking for is very basic help, sort of along the 
lines of "what things do I need to consider before I even begin this?" 
Is OOP necessary here? Would utility functions work just as well for 
simply writing the information to a file?

Perhaps I should just take some kind of programming intro class! I read 
all these Python books, but when it comes time to write something 
non-trivial, I get stuck almost immediately with all the possibilities.


More information about the Python-list mailing list