[Tutor] (no subject)

Alan Gauld alan.gauld@blueyonder.co.uk
Mon Jun 9 00:09:02 2003


> At 06:43 PM 6/8/2003 +0200, Abel Daniel wrote:
> >(of course this means that you have to type "Tkinter." a lot of
places,
>
> <soapbox> perhaps this is a good place to mention (again) the
desirability
> of a "with" statement in Python.</soapbox>

Bob,

How would a with statement help in Python? I've seen this request
often for C++ where it could be useful, but with Python's reference
based naming I've never felt a need for a with in Python?

I usually just use 'it' as a handy shortcut to any long chains:

it = foo.bar.baz.whatever
it.item = 42
it.another = 27
it.save()

and so on...

What exactly would a 'with' do that an 'it' doesn't?

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld