Python: loop over classes?
<p>How can I combine the following into a loop in python?</p>

<pre><code>    try:
        [fb.delete() for fb in FacebookProfile.objects.filter(user_id=user.id)]
    except FacebookProfile.DoesNotExist:
        pass

    try:
        [fb.delete() for fb in FacebookUser.objects.filter(user_id=user.id)]
    except FacebookUser.DoesNotExist:
        pass

    try:
        [fb.delete() for fb in FacebookLike.objects.filter(user_id=user.id)]
    except FacebookLike.DoesNotExist:
        pass

    try:
        [fb.delete() for fb in FacebookInvite.objects.filter(user_id=user.id)]
    except FacebookInvite.DoesNotExist:
        pass
</code></pre>

<p>As we can see it's the same code block, just with the class name changing in each one, so I'm looking to iterate over an array of class names and run each through a generated function with the same semantics as above.</p>
