I recommend
parts = str_ip4.split('.')

then you can do, chr(int(parts[0]) instead of calling str_ip4.split 4 times