lower case globals & import Records
MODIFY
mode/examples/Topics/File IO/LoadFile2/LoadFile2.pyde
mode/examples/Topics/File IO/LoadFile2/LoadFile2.pyde
@@ -7,15 +7,15 @@ the miles per gallon, cylinders, displacement, etc., for more than 400 different
makes and models. Press a mouse button to advance to the next group of entries.
"""
-from Record import *
+from Record import Record
-RECORDS = []
-RECORD_COUNT = 0
-NUM = 9 # Display this many entries on each screen.
-STARTING_ENTRY = 0 # Display from this entry number
+records = []
+record_count = 0
+num = 9 # Display this many entries on each screen.
+starting_entry = 0 # Display from this entry number
def setup():
- global RECORDS, RECORD_COUNT
+ global records, record_count
size(200, 200)
fill(255)
noLoop()
@@ -27,25 +27,25 @@ def setup():
for l in lines:
pieces = l.split(TAB) # Load data into array
if len(pieces) == 9:
- RECORDS.append(Record(pieces))
- RECORD_COUNT += 1
+ records.append(Record(pieces))
+ record_count += 1
- if RECORD_COUNT != len(RECORDS):
- RECORDS = RECORDS[:RECORD_COUNT]
+ if record_count != len(records):
+ records = records[:record_count]
def draw():
background(0)
- for i in range(NUM):
- this_entry = STARTING_ENTRY + i
- if this_entry < RECORD_COUNT:
- entry_text = "{} > {}".format(this_entry, RECORDS[this_entry].name)
+ for i in range(num ):
+ this_entry = starting_entry + i
+ if this_entry < record_count:
+ entry_text = "{} > {}".format(this_entry, records[this_entry].name)
text(entry_text, 20, 20 + i * 20)
def mousePressed():
- global STARTING_ENTRY
- STARTING_ENTRY += NUM
- if STARTING_ENTRY > len(RECORDS):
- STARTING_ENTRY = 0 # go back to the beginning
+ global starting_entry
+ starting_entry += num
+ if starting_entry > len(records):
+ starting_entry = 0 # go back to the beginning
redraw()

lower case globals & import Records