Advertisement
DeaD_EyE

namedtuple_example

Jan 2nd, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from __future__ import print_function
  2. from collections import namedtuple
  3.  
  4. CHAR_FIELDS = namedtuple('CHARS', [
  5.     'PFEIL_HOCH',
  6.     'PFEIL_RUNTER',
  7.     'PFEIL_RECHTS',
  8.     'CELSIUS'
  9.     ])
  10.  
  11. CHARS = CHAR_FIELDS(
  12.     [0, 0, 4, 14, 31, 0, 0, 0],
  13.     [0, 0, 31, 14, 4, 0, 0, 0],
  14.     [0, 8, 12, 14, 12, 8, 0, 0],
  15.     [24, 24, 3, 4, 4, 4, 3, 0],
  16.     )
  17.  
  18. class dummy_lcd(object):
  19.     def create_char(self, idx, char):
  20.         print('Index: {idx}\tZeichen: {char}'.format(idx=idx, char=char))
  21.  
  22.  
  23. if __name__ == '__main__':
  24.     lcd = dummy_lcd()
  25.     for (i, chars) in enumerate(chars):
  26.         lcd.create_char(i, char)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement