Newbie learning OOP

LenS lsumnler at uniqueinsuranceco.com
Sun May 29 09:42:23 EDT 2005


Trying to learn OOP concepts and decided to use Python for this
purpose.  I have coded the following CLASS and it seems to work fine.
Any comments on the code or suggestions would be appreciated.

The class let you take a person's name and split it up into first last
and middle.  The class defaults to the assumption that the name will be
passed in as a string in first last and middle order however you can
set the format attribute to take last first and middle order. You can
then get a string back in and opposite order.

class names:
    def __init__(self, format = "F"):
        self.format = format

    def namesplit(self, name):
        if self.format == "F":
            self.namelist = name.split()
            self.first = self.namelist[0]
            self.init = self.namelist[1]
            self.last = self.namelist[2]
        else:
            self.namelist = name.split()
            self.first = self.namelist[1]
            self.init = self.namelist[2]
            self.last = self.namelist[0]

        return self.first, self.init, self.last

    def fjoin(self):
        self.namestring = self.first + ' ' + self.init + ' ' +
self.last

    def ljoin(self):
        self.namestring = self.last + ' ' + self.first + ' ' +
self.init

            
Any comments appreciated.

Len Sumnler




More information about the Python-list mailing list