Not Able To Access Object-defined variables

I am unable to access any object-defined variables, such as a varible like this:

self.code.append("hello world!")

Link: PyMash

When using objects, be sure to instantiate the object from the class before using the variable.

# wrong
thing = dict
thing.update({1: 1})

# right
thing = dict()
thing.update({1: 1})

What would I change to make self.code = [] usable from other functions within the object?

1 Like

Right now, the problem is in your file. Your actual class is fine.

import pymash

site = pymash.html  # wrong: should be 'site = pymash.html()'
site.add_line("h1","hello world")

I would recommend changing your class name to better fit with naming conventions, from html to HTML.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.