[Python-Dev] Extended Function syntax

Michael Hudson mwh@python.net
Mon, 03 Feb 2003 12:27:58 +0000


Bernhard Herzog <bh@intevation.de> writes:

> Alex Martelli <aleax@aleax.it> writes:
>
>> be helpful too?  Meaning to use local variable <identifier> in lieu of
>> the abstract _x -- for example in order to enable:
>> 
>> with myfile = auto_closing_file('blah.txt', 'rb'):
>>     xx = myfile.read(23)
>>    # rest of suite snipped
>> 
>> where auto_closing_file is a subclass of file defining useful __enter__
>> (empty -- might be nice to have it optional...) and __exit__ = close
>> synonyms (or file itself might grow __exit__ as a synonym for close).
>> 
>> How would I do this elegantly without the assignment...?
>
> Just as you do with if:

Good point.  "with" testlist ':' NEWLINE it is, if it's me that gets
to write the PEP.

Cheers,
M.

-- 
  Or here's an even simpler indicator of how much C++ sucks: Print
  out the C++ Public Review Document.  Have someone  hold it about
  three feet  above your head and then drop it.  Thus  you will be
  enlightened.                                        -- Thant Tessman