Nov-10-2020, 10:12 AM
(Nov-10-2020, 09:22 AM)perfringo Wrote: in order to get sorted unique ip addresses one should first uniquify and then sort.I didn't go into details about sorting, because from OP it looked like a means to find the unique ip addresses.
(Nov-10-2020, 09:22 AM)perfringo Wrote: from Python 3.9 there is also IPv4Address.__format__(fmt) for converting into other types (string, binary, hex).
great point, just to add that normally
.__format__()
is not meant to be invoked directly. I will just copy the example from the docs>>> format(ipaddress.IPv4Address('192.168.0.1')) '192.168.0.1' >>> '{:#b}'.format(ipaddress.IPv4Address('192.168.0.1')) '0b11000000101010000000000000000001' >>> f'{ipaddress.IPv6Address("2001:db8::1000"):s}' '2001:db8::1000' >>> format(ipaddress.IPv6Address('2001:db8::1000'), '_X') '2001_0DB8_0000_0000_0000_0000_0000_1000' >>> '{:#_n}'.format(ipaddress.IPv6Address('2001:db8::1000')) '0x2001_0db8_0000_0000_0000_0000_0000_1000'
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs