1

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?

asked May 2, 2012 at 22:02
2
  • I would recommend renaming the file parameter to fname or something, as you're currently shadowing the builtin file type Commented May 2, 2012 at 22:26
  • +1 for posting the exact code, which includes the logilfe typo. Too many posters insert a snippet that reflects what they meant to write, but which omits the key typo or other boo-boo. Commented May 2, 2012 at 22:42

1 Answer 1

2

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

answered May 2, 2012 at 22:04
Sign up to request clarification or add additional context in comments.

1 Comment

Well don't I feel like a huge jackass. Sometimes you just need a second set of eyes. Thank the gods that I have StackOverflow instead of my coworkers to make a fool of myself in front of. Thanks fellas, the mispelling was it... duh

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.