My logic goes like this:def A(val):    return {'a':val}print(A(7)['a'])is the same asclass A:    def __init__(self, val):        self.a = valprint(A(7).a)Obviously, there are problems and some differences:This only applies to languages like python where you can create a dictionary with different types in it.The syntax of creating an 'object'. This is the reason (I think) classes are superior, because using a function to create classes would quickly become very irritating.Special shortcut treatments. Like str(x) calls __str__ and obj.function() changes into cls.function(obj).Inheritance.Actual class objects (if A is the class, you can get A.__init__ (for example) as an unbound method.Apart from these small cases, dictionaries == classes (to me). Do you agree with me?
In Python, is there any difference (apart from a few listed exceptions) between classes and dictionaries?
python;class;dictionary
You can think of an object o as an entity containinga collection of local variables v1, v2, ... (the state of the object),a collection of closures m1, m2, ... that close over v1, v2, m1, m2 (the methods of the object),a mechanism to access the local variable and methods by name: an object is basically a higher-order function that takes a name as input and returns a field or a method as a result.In a Python object you use the dot notation (o.var, o.foo()) to access members and methods. Of course, you can easily simulate this by means of a dictionary as you have described: a dictionary is also a mapping (see point 3) and you can use it to store object fields or methods.So I would say that the class construct is a more convenient syntax to express the object pattern. You can simulate objects with dictionaries too, it just gets more verbose.The syntax of creating an 'object'. This is the reason (I think) classes are superior, because using a function to create classes would quickly become very irritating.Instead of having functions to create classes, I would imagine using functions to create objects (i.e. special dictionaries), which would correspond to class constructors. See also your example: function A() is the constructor function corresponding to the __init__() method of class A.Inheritance.I think that if you model classes with constructor functions returning dictionaries, then you can model inheritance by using the superclass constructor in the subclass constructor.The subclass constructor can call the superclass constructor and then extend / override the resulting dictionary with its own definitions.For example:# Superclass A.def A(val):    def toString(a):        return str(a['a'])    def printOut(a):        print(a['toString'](a))    return {'a': val, 'toString': toString, 'printOut': printOut}# B is a subclass of A.def B(val):    # Override method.    def toString(a):        return 'value = ' + str(a['a'])    r = A(val)    r['toString'] = toString    return rSummarizing, I would not say that dictionaries are the same as classes:A dictionary is an arbitrary mapping.An object is a special mapping from names to variables and methods.A class is a language construct that gathers together objects with similar structure and helps to create objects.Objects and classes can be simulated in a straightforward way using functions and dictionaries.