To 'with' or not to 'with': how is the question ?

Tim Peters tim_one at email.msn.com
Sat Sep 2 07:17:29 EDT 2000


[Jason Cunliffe]
> ouchdamn.. my 'with' example should have read
>
> <quote>
> For example in VBScript:
>
> Set evilcommondocument = CreateObject("Word.Document")
>
> With evilcommondocument   <<<
>     .AutoHyphenation = True
>     .PrintPreview
>     evilcommondocument.Close
> End With
>
> Set evilcommondocument = Nothing
> </quote>

It's unclear whether you value the abbreviation or the indentation here.  Since
"everything's an object" in Python, the abbreviation is usually very easy to get just by
binding a short name to however much of the initial segment of

    name1.name2.name3...

you're interested in.  Use an underscore or two or three for the name, and it will "look
indented" too if you squint <wink>:

evilcommondocument = CreateObject("Word.Document")
_ = evilcommondocument
_.AutoHyphenation = True
_.PrintPreview()
_.Close()

I don't read VBScript, though, so it's possible that the Python version actually works
<wink>.






More information about the Python-list mailing list