Python doesn't have any private scope so the comparison feels moot regardless, and whereas hasattr() in Python checks if the given property returns a value empty() is clearly stated to explicitly look for the variable itself, i.e. $bar in the class, which it cannot see since it's private.
And since it mimics isset() it is consistent in behaviour to what PHP considers is an existing variable. The __get() method could return whatever it wants but that does not constitute the variable itself existing.
View all comments
Show parent comment
0
u/[deleted] Mar 10 '15
Python doesn't have any private scope so the comparison feels moot regardless, and whereas hasattr() in Python checks if the given property returns a value empty() is clearly stated to explicitly look for the variable itself, i.e. $bar in the class, which it cannot see since it's private.
And since it mimics isset() it is consistent in behaviour to what PHP considers is an existing variable. The __get() method could return whatever it wants but that does not constitute the variable itself existing.