title: Python kivy with open adding backslashes, throws invalid argument on replacing
body: <p>I am trying to open a text file in my kivy app. The code is as follows:</p>
  <pre><code>class kivyx(MDApp):
      def __init__(self, *args, **kwargs):
          self.theme_cls.theme_style = &quot;Light&quot;
          super().__init__(**kwargs)
  
      message = StringProperty('Drop Test')
          
      def build(self):
          Window.bind(on_dropfile=self.on_file_drop)
          print(&quot;MDlabel&quot;)
          return MDLabel(text=self.message, halign=&quot;center&quot;)
  
      def on_file_drop(self, window, file_path):
          self.message = str(file_path)
          path = str(file_path)[1:]
          getPath(path)
  
          return MDLabel(text=self.message, halign=&quot;center&quot;)
  
  def getPath(path):
      print(path)
      with open(path.replace(&quot;\\\\&quot;, &quot;/&quot;), &quot;r&quot;) as f:
          print(f.read())
  
  kivyx().run()
  </code></pre>
  <p>this is my response:</p>
  <pre><code>MDlabel
  [INFO   ] [Base        ] Start application main loop
  'C:\\AMFTrace.log'
  [INFO   ] [Base        ] Leaving application in progress...
   Traceback (most recent call last):
     File &quot;d:/dev/SpectrumX/kivyx.py&quot;, line 33, in &lt;module&gt;
       kivyx().run()
     File &quot;C:\Users\tkulk\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\app.py&quot;, line 950, in run
       runTouchApp()
     File &quot;C:\Users\tkulk\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\base.py&quot;, line 572, in runTouchApp
       EventLoop.mainloop()
     File &quot;C:\Users\tkulk\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\base.py&quot;, line 349, in mainloop
       self.window.mainloop()
     File &quot;C:\Users\tkulk\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\core\window\window_sdl2.py&quot;, line 575, in mainloop
       self.dispatch('on_dropfile', dropfile[0])
     File &quot;kivy\_event.pyx&quot;, line 705, in kivy._event.EventDispatcher.dispatch
     File &quot;kivy\_event.pyx&quot;, line 1248, in kivy._event.EventObservers.dispatch
     File &quot;kivy\_event.pyx&quot;, line 1172, in kivy._event.EventObservers._dispatch
     File &quot;d:/dev/SpectrumX/kivyx.py&quot;, line 24, in on_file_drop
       getPath(path)
     File &quot;d:/dev/SpectrumX/kivyx.py&quot;, line 30, in getPath
       with open(path.replace(&quot;\\\\&quot;, &quot;/&quot;), &quot;r&quot;) as f:
   OSError: [Errno 22] Invalid argument: &quot;'C:/AMFTrace.log'&quot;
  </code></pre>
  <p>This works in the python interpreter, but its adding four backslashes when i use:</p>
  <pre><code>with open(path, &quot;r&quot;) as f:
  </code></pre>
  <p>so I added the replace. What might be the issue?</p>
  <p>It also works when I define the path directly,</p>
  <pre><code>with open(&quot;C:/AMFTrace.log&quot;, &quot;r&quot;) as f:
  </code></pre>
  <p>But it should not matter as both are of type</p>
  <pre><code>&lt;class 'str'&gt;
  </code></pre>