I can't understand how x and y are the same list. I've been trying to debug it using print statements and import code; code.interact(local=locals()) to drop into various points, but I can't figure out what on earth is going on :-(
from collections import namedtuple, OrderedDict
coordinates_2d=["x","y"]
def virtual_container(virtual_container, objects_type):
    """Used to create a virtual object given a the type of container and what it holds.
    The object_type needs to only have normal values."""
    if issubclass(virtual_container, list):
        class my_virtual_container_class:
            """This singleton class represents the container"""
            def __init__(self):
                #Define the default values
                __vals__=OrderedDict([(key,list()) for key in objects_type])
                print(id(__vals__["x"]), id(__vals__["y"]))#ids are different: 12911896 12911968
                #Then functions to access them
                d={key: lambda self: self.__vals__[key] for key in objects_type}
                d["__vals__"]=__vals__
                #Construct a named tuple from this
                self.attr=type('attr_cl',(), d)()
                print(id(self.attr.x()), id(self.attr.y()))#ids are same: 32904544 32904544
            #TODO: Define the operators __del__, setitem, getitem. Also append
        return my_virtual_container_class()
#Nice method of handling coordinates
coordinates=virtual_container(list, coordinates_2d)
x=coordinates.attr.x()
y=coordinates.attr.y()
x.append(1)
y.append(2)
print(x, y)#Prints [1, 2] [1, 2]
 
     
    