Permalink
Browse files

Final fix for HTTP request to handle Python2 or Python3.

urllib2 library in Py2 is just a port of Py3 urllib libraray. Added
conditional imports to make sure to get the approriate namespace for
import for each version of Python.
  • Loading branch information...
deconstructionalism
deconstructionalism committed Jul 6, 2018
1 parent 9c0fee7 commit 3630ccd8fdf9fd3615359c24cce203f5d3b1a5ee
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/bin/notes.py
@@ -5,10 +5,12 @@
import os
import sys
from datetime import datetime as dt
import urllib.request as urllib2
# from urllib import urlopen, HTTPError
from urllib.error import HTTPError as HTTPError
from urllib.request import urlopen as urlopen

if sys.version_info[0] > 2:
from urllib.request import urlopen
from urllib.error import HTTPError
else:
from urllib2 import urlopen, HTTPError

__author__ = "Arjun Ray"
__email__ = "deconstructionalism@gmail.com"

0 comments on commit 3630ccd

Please sign in to comment.