more concise than get then check then either return or progress further
<p>I have a function that checks if user is allowed to post a comment of an image. <em>With one database read</em>, the code results in 1 of 3 outcomes:</p>

<ol>
<li>Image exists and user has not commented on it before. Allow comment.</li>
<li>Image exists but the user has already commented on it. Not allow comment.</li>
<li>Image does not exist. Not allow comment.</li>
</ol>

<p>If option 1 happens then the code progresses to submit the comment, but if 2 or 3 occurs then a bail out occurs and an error code is returned to the user:</p>

<pre><code>    def post_comment():
        check_allow_result = check_allowed_to_comment()
        if check_allow_result in (2,3):
            return check_allow_result        
        # rest of code
</code></pre>

<p>Is there a more concise way of doing this? I don't like the </p>

<p>get <code>check_allow_result</code></p>

<p>check <code>check_allow_result</code></p>

<p>return <code>check_allow_result</code></p>
