30 Jun
2020
30 Jun
'20
11:45 p.m.
This will be helpful for python linters, own data types, etc. Example: class SQL_String(str): @property def __chr__(self): # SQL_string.__chr__ will return string that need to be before string start return 's' def __check__(self): # This method will be called by intepreter to check if string is OK if not str(self).endswith(';'): # For example, we want to make that this string always needed to ends with ";" raise SyntaxError('Missing ";" at the end of string') else: return True my_sql_string = s'SELECT * FROM information_schema.tables' # SyntaxError my_sql_string_2 = s'SELECT * FROM information_schema.tables;' # all is ok