def get_unique_name(check, prefix='', suffix='', length=None, skip=None):
 if length:
  _name = '_'.join([_ for _ in (prefix, '%s', suffix) if _])
  for _ in xrange(1000):
   name = (_name % generate_random_string(length))
   if check(name):
    return name
 else:
  _name = '_'.join([_ for _ in (prefix, '%s', suffix) if _])
  for i in xrange(skip, (skip + 1000)):
   name = (_name % i)
   if check(name):
    return name
 raise StopIteration(('Fail to get unique name in 1000 iterations. (%s)' % _name))

def get_unique_name ( check , prefix = '' , suffix = '' , length = None , skip = None ) : if length : _name = '_' . join ( [ _ for _ in ( prefix , '%s' , suffix ) if _ ] ) for _ in xrange ( 1000 ) : name = ( _name % generate_random_string ( length ) ) if check ( name ) : return name else : _name = '_' . join ( [ _ for _ in ( prefix , '%s' , suffix ) if _ ] ) for i in xrange ( skip , ( skip + 1000 ) ) : name = ( _name % i ) if check ( name ) : return name raise StopIteration ( ( 'Fail to get unique name in 1000 iterations. (%s)' % _name ) )
get unique name according to check function .