use of "self", was "No Do while/repeat until looping construct in python?"

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Mar 16 18:09:53 EST 2003


> From: William Sonna [mailto:wsonna at attglobal.net]
>
> There actually is another alternative - mass qualification.
> 
> There is/(was)? a scripting lanuage that uses/(d)? the following:
> 
> ::method tag
>     expose name address salutation
>     separator = 'at:'
>     return salutation name separator address

Ah - the common "with" suggestion.

The major problem with "with"-type suggestions is that they only work at one level. As soon as you get to multi-level qualifications you immeditely lose the ability to know what name belongs where.

Indeed, in Python you can lose that ability immediately.

class Klass:

    def func (self, anotherObject):

        a = 1

        with self:
            b = 1

            with anotherObject:
                a = 2
                c = b

Okay - in the last line, what namespace(s) are `a`, `b` and `c` using?

Tim Delaney





More information about the Python-list mailing list