What is the 'Python' way of creating class attributes
<p>I am a beginner in Python. I would like to know which is the better way of creating attributes...</p>

<p>In the first method I am explicitly defining the attribute and then having a method return a value to it:</p>

<pre><code>class A:
    def __init__(self, number):
        self.a = self._meth( number)

    def _meth(self, num):
        #some executable code here

        return 8 ** num
</code></pre>

<p>In the second variant the method is being called by itself and is creating the attribute by it self.</p>

<pre><code>class A:
    def __init__(self, number):
        self._meth(num)

    def _meth(self, num)
        #some executable code here
        self.a = 8 ** num
</code></pre>

<p>So my question is which one is the more accepted way of going about this?</p>

<p>this is the code I want to use this for...</p>

<pre><code>class Initializer():
    def __init__(self):
        self.ParseArguments()
        self.InitializeLogger()

    # Parse command line arguments and display help text    
    def ParseArguments(self):
        help = textwrap.dedent('''\ Help text here''')
        Arguments = argparse.ArgumentParser('This Script Pulls NAV data from the '
                            'AMFI website', 
                            formatter_class=argparse.RawDescriptionHelpFormatter, 
                            description=help)
        Arguments.add_argument('-f', '--file',
                               help= 'location of the config')
        self.ArgumentDict = vars(Arguments.parse_args())
        self.ArgumentParser = Arguments




    def CreateLogFile(self, level, name,):
        path = self.ArgumentDict['loc']
        if path == None:
            if platform.system() == 'Windows':
                location = os.environ.get("TEMP") + '\\' + name
            elif platform.system == 'Linux':
                location = os.getenv("HOME") + '/' + name
            else:
                print "Unsupported OS"
                raise ValueError
        else:
            location = path
        formatter = logging.Formatter("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s")
        logfile = logging.FileHandler(location)
        logfile.setLevel(logging.DEBUG)
        logfile.setFormatter(formatter)
        self.logger.addHandler(logfile)


    def InitializeLogger(self):
        self.logger = logging.getLogger('main')
        if self.ArgumentDict['debug'] == True:
            self.logger.setLevel(logging.DEBUG)
        else:
            self.logger.setLevel(logging.INFO)
        self.CreateLogFile(logging.INFO, 'NavUpdaterLog.log')) 
</code></pre>
