From df72e5e9674be37efed6f5fe978f57148ab9a624 Mon Sep 17 00:00:00 2001 From: FabioGonsalez Date: Fri, 15 Aug 2025 18:57:29 -0300 Subject: [PATCH] Comments on Docstring: Update README.md I added comments in "Docstring" format to make the code more professional. --- README.md | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c5a8f61..4bc9c05 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,49 @@ About ===== -This module allows you to perform IP subnet calculations, there is support for -both IPv4 and IPv6 CIDR notation. -Example Usage -============= +The ipcalc module provides tools for IP address manipulation and calculation, +allowing operations such as iterating over hosts, checking network membership, +calculating netmasks, and converting addresses to integers. -```python +Classes: + IP: Represents an IP address (IPv4 or IPv6). + Network: Represents an IP network, supporting iteration and membership tests. +Example: + >>> import ipcalc >>> for x in ipcalc.Network('172.16.42.0/30'): - ... print str(x) + ... print(str(x)) ... 172.16.42.1 172.16.42.2 + >>> subnet = ipcalc.Network('2001:beef:babe::/48') >>> print(str(subnet.network())) 2001:beef:babe:0000:0000:0000:0000:0000 >>> print(str(subnet.netmask())) ffff:ffff:ffff:0000:0000:0000:0000:0000 - >>> '192.168.42.23' in Network('192.168.42.0/24') + + >>> '192.168.42.23' in ipcalc.Network('192.168.42.0/24') True - >>> int(IP('fe80::213:ceff:fee8:c937')) + + >>> int(ipcalc.IP('fe80::213:ceff:fee8:c937')) 338288524927261089654168587652869703991 -``` + +Args: + address (str): The IP address or network in CIDR notation. + version (int, optional): The IP version (4 or 6). Defaults to auto-detection. + +Returns: + Network or IP object depending on the class initialized. + +Raises: + ValueError: If the provided address is invalid. + TypeError: If an unsupported argument type is passed. + + + Bugs/Features =============