Random combination of letters?
Question: Using Python, how can I get a randomized combination of letters?

I want to do something like this:

    
    
    def ranStr():
        # some code
        return random_string
    

So, if I call `ranStr()`, I want to get out things like (random combination of
random length of letters):

    
    
    'aAFGresdFTg'
    'EFRwdfWe'
    'rgAijD'
    


Answer: This is one way of doing it.

    
    
    import random
    def generate_key():
        STR_KEY_GEN = 'ABCDEFGHIJKLMNOPQRSTUVWXYzabcdefghijklmnopqrstuvwxyz'
        return ''.join(random.choice(STR_KEY_GEN) for _ in xrange(70))
    

OR

    
    
    import random, string
    def generate_key():
        return ''.join(random.choice(string.ascii_letters) for _ in xrange(70))
    

Based on the suggestions.

