---
name: "pydhcplib.ipv4"
section: "3"
platform: "linux"
package: "python-pydhcplib"
version: "0.6.2-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/pydhcplib.ipv4"
---

# pydhcplib.ipv4(3)

Type for IP addresses version 4

## NAME

pydhcplib.ipv4 - Type for IP addresses version 4

## SYNOPSIS

from pydhcplib.type\_ipv4 import ipv4

a = ipv4()\
 a = ipv4(string)\
 a = ipv4(strlist)\
 a = ipv4(int)

## DESCRIPTION

The class pydhcplib.ipv4 is a type "IP address version 4". It's used for string processing like "192.168.0.4".

The class creation argument can be a string like "192.168.0.4".

The class creation argument can be a list of bytes like \[192,168,0,4\].

## METHODS

The implemented methods in this class are mostly methods of comparison (= =, \>, etc...)

else :

str() return data converted into a printable string.

list() return data converted into a list of bytes.

int() return data converted into an 4 bytes int.

## EXAMPLES

**Example program ipv4\_example.py :**

from pydhcplib.type\_ipv4 import ipv4

address = ipv4()\
 address1 = ipv4("192.168.0.1")\
 address2 = ipv4("10.0.0.1")\
 address3 = ipv4(\[192,168,0,1\])

print "a0 : ",address\
 print "a1 : ",address1\
 print "a2 : ",address2\
 print "a3 : ",address3

if address1 == address2 : \
\
 	print "test 1 : ",address1, "==",address2\
 else : \
\
 	print "test 1 : " ,address1, "!=",address2

if address1 == address3 : \
\
 	print "test 2 : ", address1, "==",address3\
 else : \
\
 	print "test 2 : ", address1, "!=",address3

## SEE ALSO

[pydhcp(8)](/pydhcp/8.md), pydhcplib.hwmac(3), [pydhcplib.ipv4(3)](/pydhcplib.ipv4/3.md), [pydhcplib.strlist(3)](/pydhcplib.strlist/3.md), pydhcplib.DhcpPacket(3), pydhcplib.DhcpBasicPacket(3), pydhcplib.DhcpNetwork(3), pydhcplib.DhcpClient(3), pydhcplib.DhcpRawClient(3), pydhcplib.DhcpDerver(3)

## BUGS

See http://pydhcplib.tuxfamily.org/ for more information.

## AUTHOR

Mathieu Ignacio (mignacio\[AT\]april.org)
