A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-April/052875.html below:

[Python-Dev] PEP 310 and exceptions

[Python-Dev] PEP 310 and exceptions [Python-Dev] PEP 310 and exceptionsNick Coghlan ncoghlan at gmail.com
Sun Apr 24 08:42:18 CEST 2005
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

More information about the Python-Dev mailing list

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