multiline

What is the proper way to format a multi-line dict in Python?

What is the proper way to format a multi-line dict in Python? Question: In Python, I want to write a multi-line dict in my code. There are a couple of ways one could format it. Here are a few that I could think of: mydict = { “key1”: 1, “key2”: 2, “key3”: 3, } mydict …

Total answers: 8

How to remove extra indentation of Python triple quoted multi-line strings?

How to remove extra indentation of Python triple quoted multi-line strings? Question: I have a python editor where the user is entering a script or code, which is then put into a main method behind the scenes, while also having every line indented. The problem is that if a user has a multi line string, …

Total answers: 10

Regular expression matching a multiline block of text

Regular expression matching a multiline block of text Question: I’m having a bit of trouble getting a Python regex to work when matching against text that spans multiple lines. The example text is (n is a newline) some Varying TEXTn n DSJFKDAFJKDAFJDSAKFJADSFLKDLAFKDSAFn [more of the above, ending with a newline]n [yep, there is a variable …

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