import string
import random


def generate_random_string( length ):
    """Generate a random string of a given length containing uppercase and lowercase letters, digits and ASCII punctuation."""
    source = string.ascii_lowercase + string.ascii_uppercase + string.digits + string.punctuation
    return ''.join( random.choice( source ) for i in range( length ) )