Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 1.27 KB

CommentsRemoval.md

File metadata and controls

101 lines (73 loc) · 1.27 KB

Comments Removal

Overview

This transformation deletes all comments in the code.

Algorithm

Find all comments and delete them. The supported comments type:

  • Single line comment (starts with the hash character #)

  • Multi lines comment with using '''...'''

  • Multi lines comment with using """..."""

Examples

Single line comment example

Code before transformation:

# One line comment
def foo():
    # One line comment
    pass

Code after transformation:

def foo():
    pass

Multi lines comment with using `'''...'''` example

Code before transformation:

'''
This is a comment
written in
more than just one line
'''
def foo():
    '''
    This is a comment
    written in
    more than just one line
    '''
    pass

Code after transformation:

def foo():
    pass

Multi lines comment with using `"""..."""` example

Code before transformation:

"""
This is a comment
written in
more than just one line
"""
def foo():
    """
    This is a comment
    written in
    more than just one line
    """
    pass

Code after transformation:

def foo():
    pass