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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/T3B56IXWSIPYFD33CMOSSYWMHPGLTDEZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to