My way won't fail the doctest. But if you don't like modifying after creation then send it '%s_%i' % (name, Dummy._count)' instead of 'name'.