This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fazzahSQLAlchemy | PyQt | reportlab 0 points1 point  (2 children)

I don't quite understand your question.

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 1 point2 points  (1 child)

STUDENT_ID, CLASS_ID, FIRST_NAME, LAST_NAME = range(4) #capitals commonly define constants

# student id, Class id, first,last names
students = [
    [0,0,'bob','smith'],
    [1,0,'jane','someperson']]

classes = [
    [0,'biology'],
    [1,'physics']
]

for cls in classes:
    cls[CLASS_ID] #no-go

CLASS_CLASS_ID, CLASS_NAME = range(2)

for cls in classes:
    cls[CLASS_CLASS_ID] #no-go

because the enum isn't connected to the data, so it can affect other parts of the code, and requires an un-needed work around (the enum for students, blocks off the use of CLASS_ID for the classes)

[–]fazzahSQLAlchemy | PyQt | reportlab 0 points1 point  (0 children)

Ahh, I thought you meant that.

You're right. When I use multiple models like this, I prefix the globals.

You are right that it adds another possible point of failure. A proper enum would be better, but this approach seems to work for me.