import sys def python_to_bingbong(python_code): """ Converts a string of Python code into its BingBong binary representation. """ byte_array = python_code.encode('utf-8') binary_string = ''.join(f'{byte:08b}' for byte in byte_array) bingbong_code = binary_string.replace('0', '.').replace('1', ',') return bingbong_code if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python py_to_bingbong.py ") sys.exit(1) python_file = sys.argv[1] try: with open(python_file, 'r') as f: python_code = f.read() bingbong_code = python_to_bingbong(python_code) output_file = python_file.replace('.py', '.bb') with open(output_file, 'w') as f: f.write(bingbong_code) print(f"Successfully converted {python_file} to {output_file}") except FileNotFoundError: print(f"Error: File not found at '{python_file}'") sys.exit(1)