def rand_base(length, bad, chars):
 cset = (set(chars) - set(list(bad)))
 if (len(cset) == 0):
  return ''
 chars = [list(cset)[random.randrange(len(cset))] for i in xrange(length)]
 chars = map(str, chars)
 return ''.join(chars)

def rand_base ( length , bad , chars ) : cset = ( set ( chars ) - set ( list ( bad ) ) ) if ( len ( cset ) == 0 ) : return '' chars = [ list ( cset ) [ random . randrange ( len ( cset ) ) ] for i in xrange ( length ) ] chars = map ( str , chars ) return '' . join ( chars )
generate a random string with chars collection .