stchris / untangle

Converts XML to Python objects
MIT License
612 stars 83 forks source link

Using in class #10

Closed excellentingenuity closed 10 years ago

excellentingenuity commented 10 years ago

I may be missing something but following your example of using untangle does not work inside of a class for example:

import untangle

Class foo:

def load(self):
     xmldoc = untangle.parse('test.xml')

I have tried assigning it to a class variable but was unable to. Any help would be appreciated.

stchris commented 10 years ago

What exactly is the error message you get? You can use untangle inside classes, see the test case I just added.

excellentingenuity commented 10 years ago

Here is the error I am getting

NameError: global name 'untagle' is not defined

I imported untangle in my python file above the class definition as in my example above. Also, I have untangled installed via pip, I double checked that earlier. Thanks

stchris commented 10 years ago

First of all: check the spelling, the error you posted above says "untagle", correct is: "untangle".

Then: after pip installing it, open a python interpreter and check that "import untangle" works. Do you have more than one python version installed? Which python version does pip correspond to?

excellentingenuity commented 10 years ago

Thanks, I can't believe I missed the spelling error.

stchris commented 10 years ago

No worries. I'm glad we sorted it out ;)