[Tutor] Languages, was Which programming language is better

Kirby Urner urnerk@qwest.net
Thu, 28 Mar 2002 14:08:00 -0800


At 05:27 PM 3/28/2002 +0000, alan wrote:

> > I miss 'with' a lot.
>
>me too ;-)

What's this 'with'?

In FoxPro we have the following (maybe similar):

If writing

    this.parent.parent.otherwidget.subwidget1.value = 1
    this.parent.parent.otherwidget.subwidget2.value = 2
    this.parent.parent.otherwidget.subwidget3.value = 3
    ...

(long parts repeat) you can instead do:

with this.parent.parent.otherwidget
     .subwidget1.value = 1
     .subwidget2.value = 2
     .subwidget3.value = 3
     ...
endwith

i.e. I capture a lot of the repetitious "path" type
stuff with the 'with' (note:  parent.parent... refers to
a containment hierarchy i.e. what's inside what in a
GUI, not to a subclass/superclass hierarchy).

But in Python you can do something very similar just by
assigning the unchanging part of the path to a variable
e.g.

o = container.otherobject.containedobject
o.property1.value = 1
o.property2.value = 2
o.property3.value = 3
     ...

Kirby