Did you know?#

Well… at least I did not.

The size of an instance of the smallest new-style user defined class is 32 bytes:

class X(object):
    pass

x=X()
x.__sizeof__()

Class attributes starting with a dunder are not overwritten by a sub class:

"""
Demonstration, that dunder attributes are not overwritten by subclasses.
"""

class A(object):
    _foo = 1
    def f(self):
        print self._foo


class B(A):
    _foo = 2


A().f()
B().f()


print '---------'


class A1(object):
    __foo = 1
    def f(self):
        print self.__foo


class B1(A1):
    __foo = 2


A1().f()
B1().f()

b1 = B1()