6
ความเข้าใจในรายการจะย้อนชื่อแม้จะอยู่ในขอบเขตของความเข้าใจ นี่ใช่มั้ย?
ความเข้าใจกำลังมีปฏิสัมพันธ์ที่ไม่คาดคิดกับการกำหนดขอบเขต นี่คือพฤติกรรมที่คาดหวังหรือไม่? ฉันมีวิธีการ: def leave_room(self, uid): u = self.user_by_id(uid) r = self.rooms[u.rid] other_uids = [ouid for ouid in r.users_by_id.keys() if ouid != u.uid] other_us = [self.user_by_id(uid) for uid in other_uids] r.remove_user(uid) # OOPS! uid has been re-bound by the list comprehension above # Interestingly, it's rebound to the last uid …