Question: Is it common in Python to keep testing for type values when working in a OOP fashion?

```
class Foo():
    def __init__(self,barObject):
        self.bar = setBarObject(barObject)

    def setBarObject(barObject);
        if (isInstance(barObject,Bar):
            self.bar = barObject
        else:
            # throw exception, log, etc.

class Bar():
    pass

```

Or I can use a more loose approach, like:

```
class Foo():
    def __init__(self,barObject):
        self.bar = barObject

class Bar():
    pass

```

Answer: 
I think that it's good practice to check *input* for type. It's reasonable to assume that if you asked a user to give one data type they might give you another, so you should code to defend against this.

However, it seems like a waste of time (both writing and running the program) to check the type of input that the program generates independent of input. As in a strongly-typed language, checking type isn't important to defend against *programmer error*.

So basically, check input but nothing else so that code can run smoothly and users don't have to wonder why they got an exception rather than a result.
I agree with some of the above answers, in that I generally never check for type from one function to another.

However, as someone else mentioned, anything accepted from a user should be checked, and for things like this I use regular expressions. The nice thing about using regular expressions to validate user input is that not only can you verify that the data is in the correct format, but you can parse the input into a more convenient form, like a string into a dictionary.