Question: I'm using pydev in Classic Eclipse 4.2.2 with Python2.7. Please consider the code and result below as you read. 

Suppose I create an object with a variable of a predefined value. Now, suppose I change this value and create a new object of the same name (i.e., old name points to a new object). I would expect the old name to point to a new object whose value does not differ from the predefined value given in the class definition. That is not the case. Any suggestions as to why? 

Code:

```
class example(object):

    veryImportantDict = {'A': 0}

    def __init__(self):
        pass

    def set_veryImportantNumber(self,key,val):
        self.veryImportantDict[key] = val 

if __name__ == '__main__':

    test = example()
    print "New object: ", test
    print "New object's dict: ",test.veryImportantDict
    test.set_veryImportantNumber('A',5)
    print "Old object's dict: ",test.veryImportantDict
    test = example()
    print "New object: ", test
    print "New object's dict: ",test.veryImportantDict

```

Which returns:

```
New object: <__main__.example object at 0x0478C430> 
New object's dict:  {'A': 0} Old object's dict:  {'A': 5} 
New object: <__main__.example object at 0x0478C450> 
New object's dict:  {'A': 5}

```

Answer: 
I'm still not quite sure what you're asking, but based on your comment

> 
> @PeterGibson by closest I meant, 192.168.1.101 is closer to
>  192.168.56.1 than to 172.30.130.66 . And 192.168.1.254 is closer to 192.168.1.240 than to 192.168.2.1
> 
> 
> 

You could try the following python code for a distance function:

```
import socket
def dist(a, b):
    def to_num(addr):
        # parse the address string into integer quads
        quads = map(ord, socket.inet_aton(addr))
        # spread the quads out 
        return reduce(lambda x,y: x * 0x10000 + y, quads)
    return abs(to_num(a) - to_num(b))

```

The numbers returned are fairly arbitrary, but should suffice for basic needs. I'm still not sure what it should do with broadcast addresses etc though.

Some examples:

```
>>> dist('192.168.1.254', '192.168.1.240')
14L
>>> dist('192.168.1.254', '192.168.2.1')
65283L
>>> dist('192.168.1.101', '192.168.56.1')
3604380L
>>> dist('192.168.1.101', '172.30.130.66')
5630092231245859L

```
I'd start by dividing array into groups, considering reserved ip-addresses (<http://en.wikipedia.org/wiki/Reserved_IP_addresses#Reserved_IPv4_addresses>). Then i'd separate them by regions. Maybe some tree structure would suffice: root nodes are top level regions and then, closing to leafs it goes for smaller regions.