You can use the AST module to get the abstract syntax tree of the expression:
>>> import ast
>>> m = ast.parse('0xbin()')
>>> ast.dump(m)
'Module(
body=[Expr(
value=Compare(left=Num(n=11),
ops=[In()],
comparators=[Tuple(elts=[],
ctx=Load())
]
))])'
See the abstract grammar for how to interpret the expression, but tl;dr: Num(n=11)
is the 0xb
part, and Tuple(elts=[], ...)
hints towards an empty tuple rather than a function call.