python lambda PyCharm suggests adding @Property decorator to function
<pre><code>    def establishedSessions(self):
        return reduce(lambda x, y: x and y, loggedInUsers.values())
</code></pre>

<p>So I have a dictionary of sessions with key of username and value is a Boolean indicating if that user is logged in. I want to know if all users are connected which this function does nicely. PyCharm is suggesting I add a @Property decorator. </p>

<p>I think I kind of understand what the @Property decorator does but I don't see why it would apply in this case. </p>

<p>The <code>@property</code> decorator (not <code>@Property</code>) creates a descriptor that allows you to access what looks like a member variable of an object but whose value is the return value of your function. I.e. you would reference <code>obj.established_sessions</code> rather than <code>obj.established_sessions()</code>.</p>

<p>A property cannot take parameters, and generally should not have side effects. Your function meets both criteria, so it could easily be a property. It doesn't have to be one.</p>

python lambda properties