@Ethin
Could you elaborate on what difficulties you ran into with Panda3D?
@amerikranian
Yes you can, though it can also depend on how you declare it in some cases. In most instances you can declare a variable in the class itself, for example:
class example(object):
number = 5
Or with the "self" prefix:
class example(object):
def __init__(self):
self.number = 5
You can then print or access those variables by using the classes container as a prefix, like so:
a = example()
print a.number
a.number = 6
print a.number
But you can also create new variables to a class that way too:
However, when using functions in a class it follows domain specific name spacing. What this means is if you create a variable inside a function within a class without the "self" prefix, that variable will live and die in that function unless returned or passed to a variable in the class. For example:
class example(object):
def test(self):
number = 5
a = example()
a.test()
print a.number
This would throw an error that "number" doesn't exist, because variables declared in functions end when the function does. But you can add the "self" prefix to assign the variable to the class itself outside the function, so it can be stored and used elsewhere:
class example(object):
def test(self):
self.number = 5
a = example()
a.test()
print a.number
This makes classes really useful, since you can store variables within them, then use functions in those same classes to change, add, or remove data as needed.
-
BrushTone v1.3.3: Accessible Paint Tool
-
AudiMesh3D v1.0.0: Accessible 3D Model Viewer