Pythonic Self

Python is a great language, but one of its problems is that every parameter passed into an __init__ method must be manually assigned to an instance variable, like this:

class Microsoft
  def __init__(self, param):
    self.param = param

and it’s an annoying waste of time. To fix this, I have written a short Python script that goes through a Python source code file and adds in the “self.param = param” statements for every init method with more than just a self parameter. Here’s the source code (credit me if you use this code, please):

selfer.py

 

There are no comments on this post

Leave a Reply