wheres pythonmonks <[email protected]> writes: > How do I build an "int1" type that has a default value of 1? > [Hopefully no speed penalty.] > I am thinking about applications with collections.defaultdict.
You can supply an arbitary function to collections.defaultdict.
It doesn't have to be a class. E.g.
d = collections.defaultdict(lambda: 1)
will do what you are asking.
--
http://mail.python.org/mailman/listinfo/python-list
