import string
import random


def generatePRandomPW(pwlen=16, mix_case=1):
    """Generate a pseudo-random password.
    
    Generate a pseudo-random password of given length, optionally 
    with mixed case.  Warning: the randomness is not cryptographically 
    very strong.

    """
    
    if mix_case:
        chars = string.ascii_letters + string.digits
    else:
        chars = string.ascii_lowercase + string.digits
        
    pw = ''
    for i in range(0, pwlen):
        pw += random.choice(chars)
    return pw