Remove all comments from input source. Note: comments are NOT recognized inside of strings! Parameters ---------- src : string A single or multiline input string. Returns ------- String with all Python comments removed.
(src)
| 244 | |
| 245 | |
| 246 | def remove_comments(src): |
| 247 | """Remove all comments from input source. |
| 248 | |
| 249 | Note: comments are NOT recognized inside of strings! |
| 250 | |
| 251 | Parameters |
| 252 | ---------- |
| 253 | src : string |
| 254 | A single or multiline input string. |
| 255 | |
| 256 | Returns |
| 257 | ------- |
| 258 | String with all Python comments removed. |
| 259 | """ |
| 260 | |
| 261 | return re.sub('#.*', '', src) |
| 262 | |
| 263 | |
| 264 | def get_input_encoding(): |
nothing calls this directly
no outgoing calls
no test coverage detected