diff options
| author | Peter Moody <pmoody@google.com> | 2010-05-10 05:54:16 +0000 |
|---|---|---|
| committer | Peter Moody <pmoody@google.com> | 2010-05-10 05:54:16 +0000 |
| commit | d9c3704814986df2a7783ec641882d35d7025852 (patch) | |
| tree | 073f23452d894abc6a1cddf927fd7dfab864f9c3 /ipaddr.py | |
| parent | b002fb292645ea2b08a5baf822c44a578473ef3b (diff) | |
| download | ipaddr-py-d9c3704814986df2a7783ec641882d35d7025852.tar.gz | |
+ add masked() to _BaseNet to automatically mask out
the host bits of a network object. issue58.
Reported by Robert Thomson.
git-svn-id: https://ipaddr-py.googlecode.com/svn/trunk@166 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'ipaddr.py')
| -rw-r--r-- | ipaddr.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -903,6 +903,11 @@ class _BaseNet(_IPAddrBase): yield current + def masked(self): + """Return the network object with the host bits masked out.""" + return IPNetwork('%s/%d' % (self.network, self._prefixlen), + version=self._version) + def subnet(self, prefixlen_diff=1, new_prefix=None): """Return a list of subnets, rather than an interator.""" return list(self.iter_subnets(prefixlen_diff, new_prefix)) |
