Skip to main content
edited body
Source Link
JimmyJames
  • 30.9k
  • 3
  • 59
  • 110

This is a somewhat subjective thing and I think you can make an argument for many different approaches here (including duplication) but here's one I might consider based on what you've shown.

def process(object):
    try:
        if suitedForA(object):
            methodA(object)
            return
    except SomeExceptionType:
        pass # log if desireable

    try:
        methodB(object)
    except SomeExceptionType:
        methodC(object)

OnAs a sidenote, I highly recommend you start following the PEP 8 standards. I have found pylama to be a good tool for helping with that.

This is a somewhat subjective thing and I think you can make an argument for many different approaches here (including duplication) but here's one I might consider based on what you've shown.

def process(object):
    try:
        if suitedForA(object):
            methodA(object)
            return
    except SomeExceptionType:
        pass # log if desireable

    try:
        methodB(object)
    except SomeExceptionType:
        methodC(object)

On a sidenote, I highly recommend you start following the PEP 8 standards. I have found pylama to be a good tool for helping with that.

This is a somewhat subjective thing and I think you can make an argument for many different approaches here (including duplication) but here's one I might consider based on what you've shown.

def process(object):
    try:
        if suitedForA(object):
            methodA(object)
            return
    except SomeExceptionType:
        pass # log if desireable

    try:
        methodB(object)
    except SomeExceptionType:
        methodC(object)

As a sidenote, I highly recommend you start following the PEP 8 standards. I have found pylama to be a good tool for helping with that.

Source Link
JimmyJames
  • 30.9k
  • 3
  • 59
  • 110

This is a somewhat subjective thing and I think you can make an argument for many different approaches here (including duplication) but here's one I might consider based on what you've shown.

def process(object):
    try:
        if suitedForA(object):
            methodA(object)
            return
    except SomeExceptionType:
        pass # log if desireable

    try:
        methodB(object)
    except SomeExceptionType:
        methodC(object)

On a sidenote, I highly recommend you start following the PEP 8 standards. I have found pylama to be a good tool for helping with that.