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

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Jul 11 02:00:15 CEST 2015


On Fri, Jul 10, 2015 at 6:31 PM, Michael Hewitt <michael at hewitts.us> wrote:

> Here is the proposal:
>
> The name of the first parameter to a method can be used to scope
> subsequent variable references similar to the behavior of 'global'.
>
>
> Here are some examples:
>
> class Foo:
>
> def method_a(self)
>
> self x # subsequent 'x' references are scoped to 'self'
>
> x = 5 # same as self.x = 5
>
>
I will give it a month after something like this goes into the language for
style guides to appear that will recommend prefixing all member variables
with a triple underscore to distinguish them from the locals.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150710/17fa8e3f/attachment.html>


More information about the Python-ideas mailing list