Re: None

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Fri, 10 Dec 1993 17:41:18 -0500

On Dec 10, 13:52, "Jaap Vermeulen (jaap)" wrote:
>
> My proposal is to add an 'else:' statement to the try:except: statement.
> This statement would only be executed if the try: succeeded. This would be
> consistent with the while:else: statement and for for:else: statement. The
> code fragment would become:
>
> try:
> file = open('...', 'r')
> except:
> data = process_something_else()
> else:
> data = process_file(file)
>
> What think?
>

I like it. I too have run into that problem ( and sometimes I haven't
even NOTICED that it was a potential problem, as in the case you picked
out. )

>
> Actually, I once toyed with the idea to have every object return something,
> itself by default (a la Smalltalk). Then you add an ignore() method to all
> objects. This would result in being able to say
>
> ''.ignore()
>

Well, pulling another card out of my list of things which I had
intended to wait until next year to start discussing ( knowing
that Guido is hard at work on the 1.0 release now... ), BUT:
[ This is actually unrelated to your suggestion, but your suggestion
reminded me of it. ]

I was considering proposing that in addition to __getitem__, etc.
that if a method __func__ is defined, then that is the default
function and can be called by 'object()' as well as
'object.__func__()' .

They other reason I didn't post this suggestion earlier is that
I haven't quite marshalled all of my arguments FOR this feature.
In short, though, the reason is to extend the capability of
separating interface from implementation. It is suggested by
the usefulness of the sequence like object interface.

You can return a method from Class().init(), but now the
convention is to use __init__, which doesn't allow a non
None return. Of course, the negative argument is that is
doesn't add much over tha existing capability.

[ There is also an argument against introducing something
so context dependent, but it's really no more context
dependant than 'object[i]' . ]

Now that I've gone ahead and brought this up, I'll now try to
forget about it until next year, when I have time to assemble
a better argument.

- Steve M.