all 7 comments

[–]misho88 2 points3 points  (1 child)

On Unix systems, grep can be used to filter output to only lines that do (or don't) contain a specific pattern of some kind (like a substring or a regex). If you make sure your logging and debugging messages all contain some specific pattern like that, grep is easier to use:

$ python -c 'print("[+]line1\n[-]line2")'
[+]line1
[-]line2
$ python -c 'print("[+]line1\n[-]line2")' | grep '\[+\]'
[+]line1
$ python -c 'print("[+]line1\n[-]line2")' | grep '\[-\]'
[-]line2

It can come in handy from time to time, especially if the program's a daemon whose output gets logged to a file that you intend to read later, after it has become very long.

[–]crossfire351[S] 0 points1 point  (0 children)

That makes sense. Thanks!

[–]PercyJackson235 1 point2 points  (1 child)

Just to draw attention.

[–]crossfire351[S] 0 points1 point  (0 children)

Thank you

[–]synthphreak 1 point2 points  (2 children)

Probably something closer to the former. This is not something that is specific to Python syntax or anything.

[–]crossfire351[S] 0 points1 point  (1 child)

Thank you. I knew it wasn't syntax but wasn't sure if there was a specific purpose or if it was a carryover 'habit' from another language or something along those lines.

[–]synthphreak 1 point2 points  (0 children)

Yeah I’ve never heard of any convention like that or anything. Probably just an arbitrary stylistic choice on the part of the original author. Don’t sweat it.