User Input in class sanitized
Welcome! Let's look at your code:


I notice that you have code that appears to be part of a class, so I will be treating it as a class for the purposes of review. In your original code, you use a class to group all your operations together, but the class doesn't really serve a purpose (i.e. the method could exist independent of the class, with a name like is_prime). In your second version, you have two separate method, and while the encapsulation of different functionally is better, they are not connected in a meaningful way so it is not clear how you run the program. In both cases, a class is unnecessary: you could have a single function that prompts the user for a positive integer input, and another function that checks if a positive integer is prime or composite (which I will demonstrate below). Personally I store my input validation methods in a separate module that I've added to my PYTHONPATH, since it's useful for many different projects if you use the command line often.
Commenting in general on your goal to "check the input implicitly", I would say this is misguided, but I will also say that you can use a property decorator to implicitly check variables on assignment. However, as Michael mentions you still would need to loop to prompt input from the user until they enter valid input, so it's not really that usefully for input validation.


Now, if you're trying to validate input in Python, this SO answer provides a good primer on the subject.


Your check_digit method checks if the input is valid before the user actually enters any input. As mentioned in the above answer, while True and with an if valid: break is a better structure for this kind of validation.
Your userinput method is ambiguously named (you can't tell what it does from the name alone), and it's broken: it only checks if 2 is prime before breaking. You need to only check if the number is composite inside the loop, and return prime if a composite factor is not detected.


Here's code that demonstrates the principles I mention above:

def prompt_positive_number(message):
    while True:
        try:
            num = int(input(message))
            if num &lt;= 0:
                message = "Please enter a positive number. "
            else:
                return num
        except ValueError:
            message = "Please enter a number. "

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

if __name__ == "__main__":
    user_input = prompt_positive_number("Check if a number is prime: ")
    if is_prime(user_input):
        print(user_input, "is prime!")
    else:
        print(user_input, "is composite!")


There's one more optimization I can use to make my code even shorter: using the built-in function any for is_prime:

def is_prime(num):
    return not any(num % i == 0 for i in range(2, num))


Or, reversing the equality check, all is even shorter:

def is_prime(num):
    return all(num % i != 0 for i in range(2, num))


Finally, commenting on the algorithm, there are more efficient ways to check if a number is prime; however, this is outside of the scope of my knowledge and you'd have to do your own research on that. Rather famously in the world of computational complexity, it was proved that primes is in P.