Fluent Python: Clear, Concise, and Effective Programming
Rate it:
28%
Flag icon
The == operator compares the values of objects (the data they hold), while is compares their identities.
28%
Flag icon
+=
28%
Flag icon
= on a tuple creates a new tuple and rebinds the variable l2[2] here.
29%
Flag icon
The problem is that HauntedBus instances that don’t get an initial passenger list end up sharing the same passenger list among themselves.
29%
Flag icon
list. The fix is simple: in __init__, when the passengers parameter is provided, self.passengers should be initialized with a copy of it, as we did correctly in Example 8-8 (“Deep and Shallow Copies of Arbitrary Objects”):
30%
Flag icon
Therefore, we say that a weak reference does not prevent the referent from being garbage collected.
31%
Flag icon
Using eval here shows that the repr of a Vector2d is a faithful representation of its constructor call.2
31%
Flag icon
type(self).__name__
Burak Balasaygun
type(self).__name__ if Self was an instance of Vector2d then "Vector2d" == type(self).__name__
« Prev 1 2 Next »