Re:Python best practices
by etal on Wednesday July 09, 2008 @02:35PM
(#241489)
Most of the builtins have a corresponding __magic_attribute__ for objects that support it: bool -> foo.__bool__, len -> foo.__len__, iter -> foo.__iter__. This is usually because some syntactic sugar or other built-in function/method relies on it being there. Example: "for x in foo" relies on foo having __iter__ (or an equivalent, maybe).
[ Parent
| on HN ]
There are no comments on this comment yet.