Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with ipaddress package
#3
(Jul-12-2022, 10:08 PM)Larz60+ Wrote: The /24 indicated the number of bits in the network mask.
I am not sure, but expect that this should be stripped before calling ipaddress methods.

I wouldnt think so, because i have this other function below in the same total code block, that works as expected..

def valid_ip_or_cidr(ip):
    try:
        ipaddress.IPv4Address(ip)
        #print('This is a valid IPs address')
        return True
    except:
        try:
            ipaddress.IPv4Network(ip)
            #print('This is a valid network CIDR')
            return True
        except:
            print(ip + ' This is neither a valid IPV4 address  or a valid IPV4 CIDR notation, please check your data and try again')
            #return False
            sys.exit()
Reply


Messages In This Thread
help with ipaddress package - by jcrubaugh45 - Jul-12-2022, 08:55 PM
RE: help with ipaddress package - by Larz60+ - Jul-12-2022, 10:08 PM
RE: help with ipaddress package - by jcrubaugh45 - Jul-12-2022, 10:26 PM
RE: help with ipaddress package - by jcrubaugh45 - Jul-12-2022, 10:27 PM
RE: help with ipaddress package - by supuflounder - Jul-13-2022, 02:01 AM
RE: help with ipaddress package - by jcrubaugh45 - Jul-13-2022, 02:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ipaddress.IPv4Network tomthirteen 11 6,858 Jan-08-2019, 10:20 PM
Last Post: tomthirteen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020