Is there a better way to format this Python/Django code as valid PEP8?

Posted by Ryan Detzel on Stack Overflow See other posts from Stack Overflow or by Ryan Detzel
Published on 2012-10-27T12:26:11Z Indexed on 2012/10/27 17:01 UTC
Read the original article Hit count: 174

Filed under:
|
|

I have code written both ways and I see flaws in both of them. Is there another way to write this or is one approach more "correct" than the other?

def functionOne(subscriber):
    try:
        results = MyModelObject.objects.filter(
            project__id=1,
            status=MyModelObject.STATUS.accepted,
            subscriber=subscriber).values_list(
                'project_id',
                flat=True).order_by('-created_on')
    except:
        pass
def functionOne(subscriber):
    try:
        results = MyModelObject.objects.filter(
            project__id=1,
            status=MyModelObject.STATUS.accepted,
            subscriber=subscriber)
        results = results.values_list('project_id', flat=True)
        results = results.order_by('-created_on')
    except:
        pass

© Stack Overflow or respective owner

Related posts about python

Related posts about django