Python 3.5.1 (default, Jun 1 2016, 13:15:26) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def f(a): ... class D: ... pass ... D.a = a ... return D ... >>> c = f(42) >>> c <class '__main__.f.<locals>.D'> >>> c.a 42 -- Greg