PEP 501 has a very, very brief discussion of this. I'm pretty sure there
was a discussion at the time about user-defined string prefixes, but
since there's a lot of discussion about the inter-related PEPs 498, 501,
and 502, it's hard to find the exact discussion of custom string
prefixes in python-dev or python-ideas.
But, if you're serious about this proposal, you should find those
existing conversations and try to address their objections.
Eric
On 7/1/2020 2:45 AM, artem6191 wrote:
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/
_______________________________________________
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/MEE3X3HNLKU3ZX6JWHP3XCFUHELKHNLK/
Code of Conduct: http://python.org/psf/codeofconduct/