title: #ifdef python3 print_with_parantheses #else print_using_python2_style #endif
body: <p>Is there a way to achieve something like &quot;conditional interpretation&quot; in <a href="/questions/tagged/python" class="post-tag" title="show questions tagged &#39;python&#39;" rel="tag">python</a> similar to the conditional compilation <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a> pre-processor directives allow? I would like to use the same code in Python 2.7 and Python 3, keeping the few <a href="/questions/tagged/print" class="post-tag" title="show questions tagged &#39;print&#39;" rel="tag">print</a>-s that code has right now. That is, I would like to have <strong>syntactically incorrect code</strong> not interpreted in some cases.</p>
  <p>A simple work-around like this one:</p>
  <pre><code>if sys.version_info.major == 3:
      print(&quot;init message&quot;)
  else:
      print &quot;init message&quot;
  </code></pre>
  <p>results in a &quot;SyntaxError: invalid syntax&quot;. Is there any way to tell the interpreter to skip evaluation?</p>