def get_dev_bpf():
 for bpf in range(0, 8):
  try:
   fd = os.open(('/dev/bpf%i' % bpf), os.O_RDWR)
   return (fd, bpf)
  except OSError as err:
   continue
 raise Scapy_Exception('No /dev/bpf handle is available !')

def get_dev_bpf ( ) : for bpf in range ( 0 , 8 ) : try : fd = os . open ( ( '/dev/bpf%i' % bpf ) , os . O_RDWR ) return ( fd , bpf ) except OSError as err : continue raise Scapy_Exception ( 'No /dev/bpf handle is available !' )
returns an opened bpf file object .