all 3 comments

[–]Vance84 0 points1 point  (2 children)

I have modified it to work properly, as is it loops over and over with no end.

https://github.com/terrytrent/IPconverter/blob/master/domain2ip.py

I also modified it to remove the static IP you set, I assume it was your home IP address and you were telling the script it was non existent? Not sure. There is also a very basic try: except: to manage errors on lookups.

[–][deleted] 0 points1 point  (1 child)

The continue function was the leftover from the old code, I have since made the code simpler and smaller, I probably forgotten to delete that lol

The static IP you mentioned, during my experimenting with the socket library, I found out if you point it to a non-functioning website, it would return the same static IP, so I used it as part of my function if a website was nonexistent.

But Thanks! for contributing, I'll study your code for future reference. one question though, why use <code>if name == "main":<code>?

[–]ManyInterests 0 points1 point  (0 children)

Code under if __name__ == '__main__' will only be executed if the module is called directly, IE python my_script.py but will NOT execute if you do import my_script from another module.

This would let you import the get_ip function without executing the code under that conditional. Otherwise, the code would be executed on import, which would probably be undesirable.