import random


def random_string(length=6, password_safe=False):
    """Returns a random string with `length` characters of a-z, A-Z
    and the digits 0-9.

    :param length: number of characters to randomize (default 6 characters).
    :password_safe: set to `True` to exclude o, O and 0.
    """
    if password_safe:
        CHOICES = 'aA1bB2cC3dD4eE5fF6gG7hH8iI9jJkKlLmMnNpPqQrRsStTuUvVwWxXyYzZ'
    else:
        CHOICES = '0aA1bB2cC3dD4eE5fF6gG7hH8iI9jJkKlLmMnNoOpPqQrRsStTuUvVwW' \
                  'xXyYzZ'
    return ''.join(random.choice(CHOICES) for i in range(length))