def _get_next_name(names, name):
 indexes = [int(a.group(2)) for x in names for a in re.finditer('(^{} \\()(\\d{{1,}})(\\)$)'.format(name), x)]
 if ((name not in names) and (not indexes)):
  return name
 return '{} ({})'.format(name, (max(indexes, default=1) + 1))

def _get_next_name ( names , name ) : indexes = [ int ( a . group ( 2 ) ) for x in names for a in re . finditer ( '(^{} \\()(\\d{{1,}})(\\)$)' . format ( name ) , x ) ] if ( ( name not in names ) and ( not indexes ) ) : return name return '{} ({})' . format ( name , ( max ( indexes , default = 1 ) + 1 ) )
returns next possible attribute name .