I'm personally looking for a way to convert a string which includes bytecode into a bytecode type but I'm also curious if it is possible to do this process for essentially any variable type without using eval.
Working example using eval:
a = "b'gAAAAABhI1vlZaaVcD7VcXpk5kEpqtn5ItujPJUnP92QgwUOc07ulG95YbCyn9M0zolk-z04GywKmGehChhrj27KA5BQVafQ8w=='"
print(type(eval(a)))
Output:
<class 'bytes'>
eval(), with all its consequences.ast.literal_evalis exactly what I was looking for. Thanks!