Middle strings in Python?

I am wondering if there is a way to comment out part of the line, as you can do in C ++ with /*this*/ . The only comments I know are # this , which always go to the end of the line and """these""" , which do not work in the middle of the line.

Use-case example: using a subprocess and you need to temporarily comment on the -p 0 argument from the list:

 ['../some/guy', '-m', '10', '-p', '0', '-n', '100', '-f', '/dev/stdout'] 

It would be nice to have a key combination to comment on the selection, for now I just copy the entire line below

 #['../some/guy', '-m', '10', '-p', '0', '-n', '100', '-f', '/dev/stdout'] ['../some/guy', '-m', '10', '-n', '100', '-f', '/dev/stdout'] 

I expect a big fat "no", but I guess this doesn’t hurt to ask, python surprised me several times earlier.

+42
python syntax comments
Apr 11 2018-11-11T00:
source share
2 answers

You are right, the answer is big fat NO .

+31
Apr 11 2018-11-11T00:
source share

In fact, if you break your expression on multiple lines, you can.

Something like:

 ['../some/guy', '-m', '10', # '-p', '0', '-n', '100', '-f', '/dev/stdout'] 

must work.

+50
Apr 11 2018-11-11T00:
source share



All Articles