slappyjam
slappyjam

Reputation: 69

Declaring classes inside a python module

I have a python module that I've made that contains regular function defintions as well as classes. For some reason when I call the constructor and pass a value, it's not updating the class variable.

My module is called VODControl (VODControl.py). The class I have declared inside the module is called DRMPath. The DRMPath class has two instance vairables: logfile and results. logfile is a string and results is a dictionary.

My constructor looks like this:

def __init__(self, file):
    self.logilfe = file
    self.results['GbE1'] = ""
    self.results['GbE2'] = ""
    self.results['NetCrypt'] = ""
    self.results['QAM'] = ""

when I import it from my other python script I do:

import VODControl

The call i use is the following:

d = VODControl.DRMPath('/tmp/adk.log')

However, when I print the value of the logfile instance variable, it isn't updated with what I passed to the constructor:

print d.logfile

After printing, it's still an empty string. What gives?

Upvotes: 1

Views: 150

Answers (1)

bossylobster
bossylobster

Reputation: 10163

self.logilfe = file is not the same as self.logfile = file In addition, it is likely returning None, not an empty string.

Upvotes: 2

Related Questions