What is the PEP8 standard for systematic multi-dimensional (nested) arrays?
There many ways to structure data in Python, some examples of which are given below. And clearly the 'best' method is the one that meets your needs, even though we have all seen our share of 'sloppy' data structures. But is there a systematic way of actually structuring data that is established as a standard?
For example, a dictionary filled by an ambiguous [list]/(tuple):
# print John's grade
students = {'John':['1','7'],'Kate':['PreK','4']}
print(students['John'][0])
Or a slightly less ambiguous dictionary filled by a dictionary:
# print Kate's grade
students = {'John':{'grade':'1','age':'7'},'Kate':{'grade':'PreK','age':'4'}}
print(students['Kate']['grade'])
Another possible method is to create your own data type and structure using a class:
class timeZone:
def __init__(self, zone_code, city, offset):
self.zone_code = zone_code
self.city = city
self.offset = offset
self.DST_offset = DST_offset
Z = timeZone('Z','Zulu Time',int(0))
Y = timeZone('Y','Fiji',int(-12))
X = timeZone('X','American Samoa',int(-11))
W = timeZone('W','Honolulu, HI',int(-10))
V = timeZone('V','Juneau, AK',int(-9))
Or is there another method/library that is best?