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

Chris Angelico rosuav at gmail.com
Sat Jul 11 10:02:42 CEST 2015

On Sat, Jul 11, 2015 at 5:49 PM, Michael Hewitt <michael at hewitts.us> wrote:
> This is totally backwards.  If anything, the opposite should be true.
> 'global.' should be required for *all* global references, of which there
> should be very few in well-written, modular code, and 'self.' should not be
> required for class references because of course methods are going to
> naturally refer to variables within their class.

How many times do you call on standard library functions? Those are
almost always global references. Either you're looking for something
directly from the builtins (eg len, max, range), or you import a
module at the top of your file and then use that (eg math.sin,
logging.info), in which case the module reference is itself a global
of your own module. So, no. Globals are extremely common - just not
often reassigned.


More information about the Python-ideas mailing list