Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import os
  2. import sys
  3. import random
  4.  
  5. class color():
  6.     def __init__(self, **args):
  7.         self.__dict__.update(args)
  8.    
  9.     def update(self, arg):
  10.         for i in arg.keys():
  11.             if i in self.__dict__.keys():
  12.                 break;
  13.         return self.__dict__.update(arg)
  14.        
  15.     def __len__(self):
  16.         return len(self.__dict__)
  17.        
  18.     def __str__(self):
  19.         color = ''
  20.         for i in self.__dict__.keys():
  21.             color += self.__dict__[i] + i + '\033[0m' + '\n'
  22.         return color
  23.            
  24.     def __getattr__(self, color):
  25.         try:
  26.             return self.__dict__[color]
  27.         except Exception as e:
  28.             return e, 'Color not found'
  29.  
  30.     def list(self):
  31.         l = []
  32.         for i in self.__dict__.keys():
  33.             l.append(i)
  34.         return l
  35.  
  36. def generate_color_list():
  37.     pass
  38.    
  39. def main():
  40.  
  41.     colors = {
  42.         'black' : '\033[95m',
  43.         'write' : '\033[94m',
  44.         'green' : '\033[42m'
  45.         }
  46.     c = color(**colors)
  47.     print c
  48.    
  49.  
  50. if __name__ == '__main__':
  51.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement