Py-dea: Streamline string literals now!

Lie Ryan lie.1296 at gmail.com
Thu Dec 29 18:19:10 EST 2011


On 12/29/2011 12:44 PM, Dan Sommers wrote:
> On Wed, 28 Dec 2011 22:54:16 +0000, Steven D'Aprano wrote:
>
>> On Wed, 28 Dec 2011 11:36:17 -0800, Rick Johnson wrote:
>>
>>> The point is people, we should be using string delimiters that are
>>> ANYTHING besides " and '. Stop being a sheep and use your brain!
>>
>> "ANYTHING", hey?
>>
>> I propose we use ئ and ร as the opening and closing string delimiters.
>> Problem solved!
>
> Why stop at pre-determined, literal delimiters?  That's way too easy on
> the parser, whether that parser is a computer or a person.
>
> __string_delimiter__ = Ω  # magic syntax; no quotes needed
>
> x = ΩhelloΩ
>
> __string_delimiter__ = #  # that first # isn't a comment marker
>
> x = # this isn't a comment; it's part of the string
> this is a multi-line string
> #
>
> __string_delimiter__ = ''  # the delimiter is delimited by whitespace
> # now I can have comments, again, too
>
> x = ''"hello"''  # now x contains two double-quote characters
>
> I'm sure that the implementation is trivial, and it's so much easier to
> write strings that contain quotes (not to mention how easy it is to read
> those strings back later).

right and you can generalize this idea even further

__comment_marker__ = $
__string_delimiter__ = [#, %]
$ also, even further
__comment_marker_keyword = #__my_own_comment_marker__%
__my_own_comment_marker__ = [&, *]
__assignment_symbol__ = <-
__attribute_delimiter__ <- -> & for attributes *
__call_delimiter__ = [!,@]
l = []
l->append!5@

you're a genius!!




More information about the Python-list mailing list