comments

What is the common header format of Python files?

What is the common header format of Python files? Question: I came across the following header format for Python source files in a document about Python coding guidelines: #!/usr/bin/env python “””Foobar.py: Description of what foobar does.””” __author__ = “Barack Obama” __copyright__ = “Copyright 2009, Planet Earth” Is this the standard format of headers in the …

Total answers: 5

How to write meaningful docstrings?

How to write meaningful docstrings? Question: What, in Your opinion is a meaningful docstring? What do You expect to be described there? For example, consider this Python class’s __init__: def __init__(self, name, value, displayName=None, matchingRule=”strict”): “”” name – field name value – field value displayName – nice display name, if empty will be set to …

Total answers: 7

Why doesn't Python have multiline comments?

Why doesn't Python have multiline comments? Question: OK, I’m aware that triple-quotes strings can serve as multiline comments. For example, “””Hello, I am a multiline comment””” and ”’Hello, I am a multiline comment”’ But technically speaking these are strings, correct? I’ve googled and read the Python style guide, but I was unable to find a …

Total answers: 18

Remove C and C++ comments using Python?

Remove C and C++ comments using Python? Question: I’m looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.) I realize that I could .match() substrings with a Regex, but that doesn’t solve nesting /*, or having a // inside a /* */. …

Total answers: 13