from os.path import abspath, join, dirname
import random


__title__ = 'names'
__version__ = '0.2'
__author__ = 'Trey Hunner'
__license__ = 'MIT'


full_path = lambda filename: abspath(join(dirname(__file__), filename))


FILES = {
    'first:male': full_path('dist.male.first'),
    'first:female': full_path('dist.female.first'),
    'last': full_path('dist.all.last'),
}


def get_name(filename):
    selected = random.random() * 90
    with open(filename) as name_file:
        for line in name_file:
            name, _, cummulative, _ = line.split()
            if float(cummulative) > selected:
                return name


def get_first_name(gender=None):
    if gender not in ('male', 'female'):
        gender = random.choice(('male', 'female'))
    return get_name(FILES['first:%s' % gender]).capitalize()


def get_last_name():
    return get_name(FILES['last']).capitalize()


def get_full_name(gender=None):
    return u"%s %s" % (get_first_name(gender), get_last_name())

from os.path import abspath, join, dirname
import random


__title__ = 'names'
__version__ = '0.2'
__author__ = 'Trey Hunner'
__license__ = 'MIT'


full_path = lambda filename: abspath(join(dirname(__file__), filename))


FILES = {
    'first:male': full_path('dist.male.first'),
    'first:female': full_path('dist.female.first'),
    'last': full_path('dist.all.last'),
}


def get_name(filename):
    selected = random.random() * 90
    with open(filename) as name_file:
        for line in name_file:
            name, _, cummulative, _ = line.split()
            if float(cummulative) > selected:
                return name


def get_first_name(gender=None):
    if gender not in ('male', 'female'):
        gender = random.choice(('male', 'female'))
    return get_name(FILES['first:%s' % gender]).capitalize()


def get_last_name():
    return get_name(FILES['last']).capitalize()


def get_full_name(gender=None):
    return unicode("%s %s").format(get_first_name(gender), get_last_name())

Fix unicode string syntax for Python 3
Fix unicode string syntax for Python 3

  from os.path import abspath, join, dirname
  import random
  
  
  __title__ = 'names'
  __version__ = '0.2'
  __author__ = 'Trey Hunner'
  __license__ = 'MIT'
  
  
  full_path = lambda filename: abspath(join(dirname(__file__), filename))
  
  
  FILES = {
      'first:male': full_path('dist.male.first'),
      'first:female': full_path('dist.female.first'),
      'last': full_path('dist.all.last'),
  }
  
  
  def get_name(filename):
      selected = random.random() * 90
      with open(filename) as name_file:
          for line in name_file:
              name, _, cummulative, _ = line.split()
              if float(cummulative) > selected:
                  return name
  
  
  def get_first_name(gender=None):
      if gender not in ('male', 'female'):
          gender = random.choice(('male', 'female'))
      return get_name(FILES['first:%s' % gender]).capitalize()
  
  
  def get_last_name():
      return get_name(FILES['last']).capitalize()
  
  
  def get_full_name(gender=None):
-     return u"%s %s" % (get_first_name(gender), get_last_name())
+     return unicode("%s %s").format(get_first_name(gender), get_last_name())
  
Fix unicode string syntax for Python 3
## Code Before:
from os.path import abspath, join, dirname
import random


__title__ = 'names'
__version__ = '0.2'
__author__ = 'Trey Hunner'
__license__ = 'MIT'


full_path = lambda filename: abspath(join(dirname(__file__), filename))


FILES = {
    'first:male': full_path('dist.male.first'),
    'first:female': full_path('dist.female.first'),
    'last': full_path('dist.all.last'),
}


def get_name(filename):
    selected = random.random() * 90
    with open(filename) as name_file:
        for line in name_file:
            name, _, cummulative, _ = line.split()
            if float(cummulative) > selected:
                return name


def get_first_name(gender=None):
    if gender not in ('male', 'female'):
        gender = random.choice(('male', 'female'))
    return get_name(FILES['first:%s' % gender]).capitalize()


def get_last_name():
    return get_name(FILES['last']).capitalize()


def get_full_name(gender=None):
    return u"%s %s" % (get_first_name(gender), get_last_name())

## Instruction:
Fix unicode string syntax for Python 3
## Code After:
from os.path import abspath, join, dirname
import random


__title__ = 'names'
__version__ = '0.2'
__author__ = 'Trey Hunner'
__license__ = 'MIT'


full_path = lambda filename: abspath(join(dirname(__file__), filename))


FILES = {
    'first:male': full_path('dist.male.first'),
    'first:female': full_path('dist.female.first'),
    'last': full_path('dist.all.last'),
}


def get_name(filename):
    selected = random.random() * 90
    with open(filename) as name_file:
        for line in name_file:
            name, _, cummulative, _ = line.split()
            if float(cummulative) > selected:
                return name


def get_first_name(gender=None):
    if gender not in ('male', 'female'):
        gender = random.choice(('male', 'female'))
    return get_name(FILES['first:%s' % gender]).capitalize()


def get_last_name():
    return get_name(FILES['last']).capitalize()


def get_full_name(gender=None):
    return unicode("%s %s").format(get_first_name(gender), get_last_name())
