Re: ultra newbie question (don't laugh)



John Salerno wrote:
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">
<first_name>John</first_name>
<last_name>Salerno</last_name>
<birth_country>United States</birth_country>
<birth_state>Texas</birth_state>
<birth_city>Houston</birth_city>
#etc.......
<researcher>

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.

Thanks,
John

I think this is marely a matter of programming style in your case. If
you like to use OOP use it. If not, don't. It doesn't seem to me that
OOP is necessary to anything you just mentioned. Don't let the
possibilities slow you - they're there so you can use whatever you
like, not to flood you with too many options.

Good luck,
Gal

.



Relevant Pages

  • Re: How to edit a large xml file (250MB)?
    ... I also have no access to editor which exported mentioned xml file. ... inserting and deleting some lines of text; writing something)" is very fast. ...
    (comp.text.xml)
  • ultra newbie question (dont laugh)
    ... I've decided to make a little project for myself which involves storing employee information in an XML file. ... I also plan to make a GUI frontend with wxPython for entering the records. ... For now I've decided to focus just on writing the logic, and not worry about the GUI yet. ... Would utility functions work just as well for simply writing the information to a file? ...
    (comp.lang.python)
  • Read and Write Files
    ... I am writing an ISAPI extension for the Windows CE Webserver. ... but now I try to write and read files in the ISAPI. ... I have a XML file, and I transform it with a XSL to a HTML Form inside ... FILE *stream; ...
    (microsoft.public.windowsce.app.development)
  • Re: Saving to files - XML - C#
    ... This link has an example of writing out an XML file. ... > I have several windows which contain settings for an embedded target. ... > created an INI type file, but now we want to do XML. ...
    (microsoft.public.dotnet.languages.csharp)
  • Make instance global -- possbile?
    ... Rather new to OOP in Python... ... I'm writing an app where several objects need to access and change the ... I could of course instantiate the instance and then pass it along the ...
    (comp.lang.python)