the annoying, verbose self

Ton van Vliet at green.meadow
Sat Nov 24 14:09:04 CET 2007

On 24 Nov 2007 08:48:30 GMT, Marc 'BlackJack' Rintsch <bj_666 at>

>On Sat, 24 Nov 2007 09:12:34 +0100, Ton van Vliet wrote:
>> Just bringing up something I sometimes miss from good-old Turbo-Pascal
>> here, which has the WITH statement to reduce the typing overhead with
>> (long) record/struct prefixes, used like:
>> with <prefix> do begin
>>     a = ...
>>     b = ...
>> end;
>> where all variables would be automatically prefixed with the <prefix>
>> (if present in the already available record definition!)
>And here lies the problem:  The compiler decides at compile time which
>names are local to a function and there is no equivalent of a record
>definition to make that decision.

The whole clause following 'using self:' could be seen as the record
definition: all attribute assignments/bindings in there should be
prefixed with 'self' (if not already existing in the self namespace?)
and thereby become instance attributes, which outside the 'using self'
clause still need 'self.' as the (namespace?) prefix.

It would not bring an 'implicit' self, but could possibly improve
readability in some areas (btw, personally, I don't have anything
against the 'explicit' self in general)

Even in Pascal the 'with' statement was not meant to improve speed,
but merely for readability, especially with complex records.

Please, bear with me, I am relatively new to Python (reading books,
scanning newsgroups, etc) and feel in no way capable of giving
'educated' or 'well overthought' advise, just my 2 cents ;-)


More information about the Python-list mailing list