comments

Can I add comments to a pip requirements file?

Can I add comments to a pip requirements file? Question: I’d like to add comments for a few packages in a pip requirements file. (Just to explain why that package is on the list.) Can I do this? I’m imagining something like Babel==0.9.5 # translation CherryPy==3.2.0 # web server Creoleparser==0.7.1 # wiki formatting Genshi==0.5.1 # …

Total answers: 1

How do I create multiline comments in Python?

How do I create multiline comments in Python? Question: How do I make multi-line comments? Most languages have block comment symbols like: /* */ Asked By: Dungeon Hunter || Source Answers: I think it doesn’t, except that a multiline string isn’t processed. However, most, if not all Python IDEs have a shortkey for ‘commenting out’ …

Total answers: 27

Python AST with preserved comments

Python AST with preserved comments Question: I can get AST without comments using import ast module = ast.parse(open(‘/path/to/module.py’).read()) Could you show an example of getting AST with preserved comments (and whitespace)? Asked By: Andrei || Source Answers: The ast module doesn’t include comments. The tokenize module can give you comments, but doesn’t provide other program …

Total answers: 7

Why does python use unconventional triple-quotation marks for comments?

Why does python use unconventional triple-quotation marks for comments? Question: Why didn’t python just use the traditional style of comments like C/C++/Java uses: /** * Comment lines * More comment lines */ // line comments // line comments // Is there a specific reason for this or is it just arbitrary? Asked By: mmtauqir || …

Total answers: 5

Mid-line comment in Python?

Mid-line comment in Python? Question: I’m wondering if there is any way to comment out part of a line, like you can do in c++ with /*this*/. The only comments I know about are # this which always goes to the end of the line and the “””these””” ones, which do not work mid-line. Example …

Total answers: 2

Manage #TODO (lots of files) with VIM

Manage #TODO (lots of files) with VIM Question: I use VIM/GVIM to develop my python projects and I randomly I leave #TODO comments in my code. Is there any way to manage (search, list and link) all the #TODO occurrences inside VIM? I tried the tasklist plugin, it’s almost what I need, but it only …

Total answers: 1

Do comments slow down an interpreted language?

Do comments slow down an interpreted language? Question: I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions …

Total answers: 11

Comments (#) go to start of line in the insert mode in Vim

Comments (#) go to start of line in the insert mode in Vim Question: Whenever I want to add a comment to an indented line in vim, I hit Shift–o (open a new row above the current, switch to insert mode) and start typing a Python comment (using #). That hash is then magically moved …

Total answers: 4

Script to remove Python comments/docstrings

Script to remove Python comments/docstrings Question: Is there a Python script or tool available which can remove comments and docstrings from Python source? It should take care of cases like: “”” aas “”” def f(): m = { u’x’: u’y’ } # faake docstring 😉 if 1: ‘string’ >> m if 2: ‘string’ , m …

Total answers: 7

Python: How to ignore #comment lines when reading in a file

Python: How to ignore #comment lines when reading in a file Question: In Python, I have just read a line form a text file and I’d like to know how to code to ignore comments with a hash # at the beginning of the line. I think it should be something like this: for if …

Total answers: 10