title: How to overcome Python 3.4 NameError: name 'basestring' is not defined
body: <p>I've got a file called hello.txt in the local directory along side the test.py, which contains this Python 3.4 code:</p>
  
  <pre><code>import easywebdav
  webdav = easywebdav.connect('192.168.1.6', username='myUser', password='myPasswd', protocol='http', port=80)
  srcDir = "myDir"
  webdav.mkdir(srcDir)
  webdav.upload("hello.txt", srcDir)
  </code></pre>
  
  <p>When I run this I get this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./test.py", line 196, in &lt;module&gt;
      webdav.upload("hello.txt", srcDir)
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/easywebdav/client.py", line 153, in upload
      if isinstance(local_path_or_fileobj, basestring):
  NameError: name 'basestring' is not defined
  </code></pre>
  
  <p>Googling this results in several hits, all of which <a href="https://github.com/oxplot/fysom/issues/1" rel="noreferrer">point</a> to the same fix which, in case the paths moved in future, is to include "right after import types":</p>
  
  <pre><code>try:
      unicode = unicode
  except NameError:
      # 'unicode' is undefined, must be Python 3
      str = str
      unicode = str
      bytes = bytes
      basestring = (str,bytes)
  else:
      # 'unicode' exists, must be Python 2
      str = str
      unicode = unicode
      bytes = str
      basestring = basestring
  </code></pre>
  
  <p>I wasn't using import types, but to include it or not doesn't appear to make a difference in PyDev - I get an error either way.  The line which causes an error is:</p>
  
  <pre><code>unicode = unicode
  </code></pre>
  
  <p>saying, 'undefined variable'.</p>
  
  <p>OK my python knowledge falters at this point and I've looked for similar posts on this site and not found one specific enough to basestring that I understand to help.  I know I need to specify basestring but I don't know how to. Would anyone be charitable enough to point me in the right direction?</p>