[Python-ideas] Mitigating 'self.' Method Pollution

Steven D'Aprano steve at pearwood.info
Sat Jul 11 16:41:16 CEST 2015


On Sat, Jul 11, 2015 at 03:02:23AM -0700, Andrew Barnert via Python-ideas wrote:

> But the idea that self is a more important default than local, and we 
> should therefore have SLEGB instead of LEGB for unqualified lookups, 
> and self for unqualified assignments instead of local? Definitely not. 

Fortunately, Michael has not suggested that.

Michael has suggested optional syntax to explicitly declare attributes. 
He has not suggested to add attributes to the existing implicit lookup 
order.

If "spam" is declared with "self spam", then it must be an attribute. 
Not a local, nonlocal, global or builtin.

If "eggs" is *not* likewise declared, then it *cannot* be an attribute, 
and the same implicit lookup rules that Python already uses will 
continue to apply.



-- 
Steve


More information about the Python-ideas mailing list