def bitflags(*sequential, **named):
  """ Enum helper to generate bit-flag values 
      usage: ENUM_TYPE = bitflags(VALUE, VALUE2, VALUE3)
         or: EnumType = bitflags(VALUE1, VALUE2, VALUE3=0x0ff)
      
      The result will be VALUE = 0x1, VALUE2 = 0x2, VALUE3 = 0x4, etc.
  """
  values = []
  base = 1
  for _ in range(len(sequential)):
    values.append(base)
    base *= 2
  enums = dict(zip(sequential, values), **named) 
  return type('Enum', (), enums)