Naive last name first function


def last_first(name):
  """
  Return last_name, first_name.
  Checks for already reversed names.
  Assumes no suffix and one part last names.
  """
  retval = name
  if name and ',' not in name:
    parts = name.split()
    retval = parts[-1] + ', ' + ' '.join(parts[:-1])
  return retval

Advertisements

About freegnu

freegnu and other stuff too
This entry was posted in python and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s