What is a pythonic way to select data from one of two locations?
<p>I am making a backwards incompatible change to an api endpoint in a different app that I call from a client app (where this code lives). I need to for a time support it handling both the previous case (where the data lived at the "ledger" level") and the new case (where the data lived at the "profile" ledger).</p>

<p>The code below works to grab it from either place but I have a nagging feeling there must be a more pythonic way to do this. Any ideas?</p>

<pre><code>class Profile(object):

    @property
        def account_owner(self):
            owner_data_from_ledger = self.account.ledger.data.get('owner', None)
            owner_data_from_profile = self.data.get('owner', None)

            owner_data = owner_data_from_ledger if owner_data_from_ledger else owner_data_from_profile

            if owner_data:
                return Human(owner_data)
            return None
</code></pre>

<p>Instead of</p>

<pre><code>owner_data = owner_data_from_ledger if owner_data_from_ledger else owner_data_from_profile
</code></pre>

<p>you can write this which is equivalent:</p>

<pre><code>owner_data = owner_data_from_ledger or owner_data_from_profile
</code></pre>

<p>Alternatively shorten the whole thing:</p>

<pre><code>owner_data_ = self.account.ledger.data.get('owner',
                  self.data.get('owner', None))
</code></pre>

<p>You can also leave out the <code>None</code> at the end above since that's the default value of that argument.</p>

python styles readability