Shane Hathaway wrote: > Nick Coghlan wrote: > >> Which means finding a different name for '__else__'. Two possibilities that >> occur to me are '__ok__' or '__no_except__'. The latter makes a fair >> amount of sense, since I can't think of a way to refer to the thing other >> than as a 'no exception' handler. > > > While we're on the subject of block handler method names, do the method names > need four underscores? 'enter' and 'exit' look better than '__enter__' and > '__exit__'. It's traditional for slots (or pseudo-slots) to have magic method names. It implies that the methods are expected to be called implicitly via special syntax or builtin functions, rather than explicitly in a normal method call. The only exception I can think of is the 'next' method of the iterator protocol. That method is often called explicitly, so the exception makes sense. For resources, there doesn't seem to be any real reason to call the methods directly - the calls will generally be hidden behind the 'with' block syntax. Hence, magic methods. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4