Question: We have a whole bunch of websites with very similar web.config files.

Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?

We are looking to centralise an assembly reference in the GAC.

Structure:

* Containing Directory
	+ Website 1 Directory
	+ Website 2 Directory
	+ Website 3 Directory
	+ Web.Config File for all above sites

Answer: 
[Python Decorators](https://stackoverflow.com/questions/739654/understanding-python-decorators) are what you want.

You said the except block is always the same. Make a custom decorator that does what you want. You'll have to apply this to each function/method but it sure does save duplication.

```
def handleError(function):
    def handleProblems():
        try:
            function()
        except Exception:
            print "Oh noes"
    return handleProblems

@handleError
def example():
   raise Exception("Boom!")

```

When calling a method with the decorator applied:

```

>>> 
>>> example()
Oh noes
>>> 

```

You will need to change the exception types as well as what you do, but you get the jist of where I'm going with this.
The answer above does not apply for Functions that take arguments - for the later case, I think you would want something like this: 

```
def handleError(f):
    def handleProblems(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except Exception:
            print "Oh noes"
    return handleProblems

```

We can test it like so: 

```
@handleError
def addTwo(x, y): 
    print(x + y) 

>>> addTwo(5,5)
10
>>> addTwo(5, 's')
Oh noes 

```