Chris wrote: > try: > push = getattr(self, 'get_%s_content' % self.name) > except AttributeError: > raise "Method does not exist" > if callable(push): > push(**argv)
There are a couple of problems with this code. 1. It's more readable to call hasattr than to catch an exception from getattr: if hasattr(self, 'get_%s_content' % self.name): raise Exception('Method does not exists') if callable(push): push(**argv) 2. Raising another exception instead of the standard AttributeError looks suspicious. Why are you doing it? 3. Exceptions should be instances of class Exception, not strings. 4. The code silently does nothing when attribute is here but is not callable. Of all these, points 1 and 3 are certainly worth addressing but for 2 and 4 you may have valid reasons which I don't know :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---