Issue 36392: IPv4Interface Object has no attributte prefixlen (original) (raw)

Issue36392

Created on 2019-03-21 19:45 by Eddgar Rojas, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg338566 - (view) Author: Eddgar Rojas (Eddgar Rojas) Date: 2019-03-21 19:45
The python the Class IPv4Interface on the ipaddress module when I try to use the .prefixlen attribute it says that do not exist but is i have access by using ._prefixlen if i have on the IPv4Interface class the .netmask attribute and the .nethost attribute Why not the .prefixlen attribute?, I reported like a bug as i think that attribute should appear on the IPv4Interface Class Below test I did >>> import ipaddress as ip >>> addr = ip.ip_interface('192.168.1.1/24') >>> addr.prefixlen Traceback (most recent call last): File "", line 1, in AttributeError: 'IPv4Interface' object has no attribute 'prefixlen' >>> addr.netmask IPv4Address('255.255.255.0') >>> addr._prefixlen 24
msg396521 - (view) Author: Václav Šmilauer (eudoxos) * Date: 2021-06-25 08:21
This one works: addr.network.prefixlen. It took me a while to find out; I find the documentation somewhat confusing in this point.
msg407699 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-12-05 04:55
The docs for current bugfix releases (3.9+) have clear links from the Interface class attribute `network` to the Network class which lists the `prefixlen` attribute. I don't think it can be made clearer - there's two ways to find it - either searching for `prefixlen` and working backwards from network to interface, or following the link from Interface.network.
msg407820 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-12-06 14:52
The link to what Andrei is referring to: https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Network.prefixlen
History
Date User Action Args
2022-04-11 14:59:12 admin set github: 80573
2021-12-06 14:52:27 kj set messages: +
2021-12-05 04:55:28 andrei.avk set status: open -> closednosy: + kj, andrei.avkmessages: + resolution: not a bugstage: resolved
2021-06-25 08:21:30 eudoxos set nosy: + eudoxosmessages: +
2019-03-21 19:53:14 SilentGhost set nosy: + pmoody
2019-03-21 19:45:12 Eddgar Rojas create