re.compile(
    '(\xaa)([\x04-\xff]{1})([\x00-\xff]{1})([\x10-\xff]{1})([\x00-\xff]*)([\x00-\xff]{1})(D)'
    )
match = self.packet_regex.search(self.buffer)
if match and match.groups():
    groups = match.groups()
python regex use capture group to define another groups length { }