guneysus
12/16/2015 - 8:02 PM

Person.py

#!/usr/bin/env python
# coding=utf-8
__author__ = 'ahmed'


class Person(object):
    def __init__(self, first_name=None, last_name=None, full_name=None):
        self._first_name = first_name or ''
        self._last_name = last_name or ''
        self.full_name = full_name

    @property
    def first_name(self):
        return self._first_name

    @first_name.setter
    def first_name(self, val):
        self._first_name = ' '.join([_.capitalize() for _ in val.split()])

    @property
    def last_name(self):
        return self._last_name

    @last_name.setter
    def last_name(self, val):
        self._last_name = val.upper()

    @property
    def full_name(self):
        return "{0} {1}".format(self.first_name, self.last_name).strip()

    @full_name.setter
    def full_name(self, val):
        self.last_name = val.split()[-1]
        self.first_name = ' '.join(val.split()[:-1])