Mega Code Archive

 
Categories / Python Tutorial / Class
 

Mutable Type Example

class SortedKeyDict(dict):     def keys(self):         return sorted(super(             SortedKeyDict, self).keys()) d = SortedKeyDict((('A', 67), ('B', 68),('C', 2))) print 'By iterator:'.ljust(12), [key  for key  in d] print 'By keys():'.ljust(12), d.keys()