Python Cheatsheet

ToString() for Classes
class ObjModel(object):

    def __init__(self):
        self.vertices = []

    def __str__(self):
        return str(self.vertices[5][0])
Enumerations
class ObjFaceType(Enum):
    TRIANGLE = 1
    QUADRILATERAL = 2
    UNKNOWN = 999
Create Enumeration-Value from Integer
detectedFaceType = ObjFaceType(999)
Compare Value to Enumeration
if (currentFaceType == ObjFaceType.UNKNOWN):
Switch over Enumeration-Values

There is no such feature!

Create a new Class
# as a .obj file contains several objects, the ObjModelContainer stores all those objects
class ObjModelContainer(object):

    def __init__(self):
        self.objects = []
Create a Instance of a Class
objAdapter = ObjAdapter()

 

Leave a Reply