On Mon, Feb 21, 2011 at 8:55 AM, sebastien piquemal <[email protected]> wrote: > Hi ! > > It might be a stupid question, but is there a reason why > `django.trunk.django.core.files.base.File` is not a subclass of > `file` ? > I ask this because after debugging my code - some urllib2 handler > (http://dpaste.com/437031/), based on a snippet I found somewhere - I > figured out that posted files were not handled like I wanted to ... > just because they were not `file` objects ... Wouldn't it be cleaner > that they would actually be `file` objects ?
Inheriting file may produce behavioral side effects in your class that are hard to predict. The normal way in Python to do this is just replicate the interface and substitute (duck typing). If the snippet you have explicitly checks for inheritance (with isinstance, for example), I'd say the snippet is not very pythonic. I suggest asking how to fix it in django-users, posting a copy/link of the snippet Regards, D. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
