Yesterday I was asked a question in an interview to implement getIPAdrress() which could return the IP address of a system irrelevant of OS its running.
I tried to write it using os, subprocess module.where I first check for the os name and based on that I fire a command(ipconfig\ifconfig) using subprocess and then find and return the IP address from there.
I know this approach is not good as was told. I was further asked to some design pattern of my choice to do the same thing, basically which could run no matter what the os is, as if now my function would only run in windows and linux alike os.
with this post I want to learn if there is a better way of doing it.
Thanks, Learning Ninja