My big use case is after the fact, which is why the example docstring
isn’t garnished up with this stuff - I build module README.md files by
processing the docstrings, and do the fancy stripping during that
process. This leaves me with compact and readable docstrings and
dedented/stripped text in the readme file.
If I’m using this in the code I’d generally like:
from cs.lex import stripped_dedent as dent
............
class X:
''' Purely to get some indent in this example.
'''
def use_the_code(self):
code = dent('''
for i in range(10):
print(i)
''')
as required. Looks succinct to me, with no quotes hard against the left
edge (column 1).
I’m a big believer in making anything I do regularly a function so that
code isn’t littered with expressions-I-have-to-decode-to-understand. I
keep a host of handy little lexical things in cs.lex ready to hand,
and I’m sure nearly none of them belong in the stdlib.
I’ll omit my reflex snarky remark here But I suspect that choice may
have been influenced by things like CP/M having filenames like
‘filename/ext’, which meant that a forward slash might not have been
considered not very available for a path separator.
Yes, UNIX was well around then anyway with slashes.
Or of course it could have just been Microsoft being Microsoft and being
deliberately different and incompatible. This is the same company who
devised their own network connection protocol when TCP already existed
IIRC. Corporately they’ve always been a bit like this, for all that they
have many good people doing good things in good faith.
if a == b and c == 1 and d >= 2.7 \ # Here I couldn't use quotations!
I think this might annoy a few people.
And would be an unnecessary restriction, I think. There’s currently no problem with having quote characters in a comment, and I don’t see why these proposed backslash-following comments should be any different.
Trying to make it possible to put comments inside a string literal, on the other hand,would be madness. There are already ways to get the same effect, e.g.
s = ("This is a string" # just in case you didn't notice
" and here is some more of it.")
It is like a client saying: “The chicken is bad in this resturant”. Instead of them look and try to modify the chicken recipe ( my first intent), they say: eat pork and leave the chiken.
No, it’s more like saying “I don’t think this restaurant should promise that its chicken is organically grown, because I don’t care about that”, and the restaurant saying “If you don’t care, why is that a problem?”