Re: A ChatGPT conversation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stewart,
Did you try Google Bard with Gemini?
Hesham

On Wed, Dec 20, 2023, 7:07 AM Stewart Bryant <stewart.bryant@xxxxxxxxx> wrote:
I am building a small program and thought I would ask CharGPT to build the
Framework.   I asked it the following question as part of asking a 
larger question about some code I wanted it to write:
write python3 code to read two parameters from the command line. The first is IP Address the second is Port. If the command line is not properly formatted print an error with the correct format. Now construct an http URL using the IP address and the port with trailing /. store the URL in string global variable RelayURL Print RelayURL

I got

if len(sys.argv) != 3:

    print("Error: Incorrect number of arguments.")

    print("Usage: python script.py <IP Address> <Port>")

    sys.exit(1)


ip_address = sys.argv[1]

port = sys.argv[2]


# Check if the IP Address and Port are properly formatted

try:

    # Check if IP Address is valid

    parts = ip_address.split('.')

    if len(parts) != 4 or not all(0 <= int(part) < 256 for part in parts):

        raise ValueError("Invalid IP Address format")


    # Check if Port is a valid integer

    if not (0 < int(port) < 65536):

        raise ValueError("Invalid Port number”)


I must say that I was impressed with the quality of the checking it automatically generated but perhaps disappointed that it assumed IP Address == IPv4. As it turns out I am am using IPv4 but it was a bit presumptuous to assume that :)

- Stewart




[Index of Archives]     [IETF Annoucements]     [IETF]     [IP Storage]     [Yosemite News]     [Linux SCTP]     [Linux Newbies]     [Mhonarc]     [Fedora Users]

  Powered by Linux