More pythonic way to write this?
<p>I have this code here:</p>

<pre><code>import re
def get_attr(str, attr):
    m = re.search(attr + r'=(\w+)', str)
    return None if not m else m.group(1)

str = 'type=greeting hello=world'

print get_attr(str, 'type')   # greeting    
print get_attr(str, 'hello')  # world
print get_attr(str, 'attr')   # None
</code></pre>

<p>Which works, but I am not particularly fond of this line:</p>

<pre><code>return None if not m else m.group(1)
</code></pre>

<p>In my opinion this would look cleaner if we could use a ternary operator:</p>

<pre><code>return (m ? m.group(1) : None)
</code></pre>

<p>But that of course isn't there. What do you suggest?</p>
