title: Find the combination Geometric Sequence number in the ratio of 2
body: <p>By given permission class, is there any better method to enchant my list_permission method that i can find out available permission</p>
  
  <p>What i have tried:</p>
  
  <pre><code>class Permission:
      READ = 1
      WRITE = 2
      EDIT = 4
      DELETE = 8
  
  sum = 0
  def has_permission(num, perm):
      """
      Return boolean for permission checking
      &gt;&gt;&gt; has_permission(Permission.Read)
      assume sum = 6
      False
      """
      return num &amp; perm == perm
  
  def add_permission(num, perm):
      """
      sum permission number
      &gt;&gt;&gt; add_permission(Permission.Read)
      sum + 1
      """
      return num += perm
  
  def list_permission(num):
      pers = (per for per in dir(Permission) if not per.startswith("__"))
      lists = []
      for value in pers:
          if(has_permission(num, getattr(Permission, value))):
              lists.append(value)
      return lists
  
  
  &gt; print(list_permission(6))
  &gt; # [WRITE, EDIT]
  </code></pre>