These pack/unpack php capabilities appear to be precisely because the identically named perl capabilities.
So pack("H*", ...) converts an ascii string to an byte-string.
And unpack("C*", ...) converts a byte-string to an array of byte values.
In python, pack("H*", $scriptpubkey) can be: binascii.a2b_hex(scriptpubkey)
The second step just isn’t wanted in python, since byte-arrays are already lists of byte values in python. Should you entry a single aspect: a[0] you’ll get the integer worth 0x41 on this case. Whereas accessing a subrange: a[1:] would get you a byte-array containing the pubkey.
Then one other comment, in case your variable accommodates a hexadecimal illustration of your script, it may be clearer to point that within the variablename, as an illustration by naming it hex_scriptpubkey.
