Automatically strip the number in front of python codes when pasting
Question: When I am reading an ebook or website, instead of inefficiently writing all
the codes, I can obviously copy and paste the python codes. But about
sometimes the format of the python code has a **number, a period, and a
space** in front of the actual python code lines, I wonder if there is any
technique/tools to remove them automatically? For example, from...

    
    
    68. # File name: floatlayout.py
    69. 
    70. from kivy.app import App
    71. from kivy.uix.floatlayout import FloatLayout
    

to ...

    
    
    # File name: floatlayout.py
    
    from kivy.app import App
    from kivy.uix.floatlayout import FloatLayout
    


Answer: 
     def remove_spaces(file_path):
         with open(file_path) as myfile, open('newfile.py', mode='w+') as newfile:
            for line in myfile:
                idx = line.find(' ')
                if idx < 0 or idx + 1 >= len(line) or is_int(line.strip()[:-1]):
                    newfile.write('\n')
                    continue
    
                newfile.write(line[idx+1:] + '\n')
    
    def is_int(str):
        try: int(str)
        except: return False
    
        return True
    

