Last active
August 29, 2015 14:12
-
-
Save marcwebbie/c2f9438cb126ff65e952 to your computer and use it in GitHub Desktop.
write-python3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future___ import print_function | |
try: | |
input = raw_input | |
str = unicode | |
range = xrange | |
except NameError: | |
pass | |
try: | |
from io import StringIO | |
from unittest.mock import Mock | |
except ImportError: | |
import StringIO | |
from mock i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request, urllib.parse, urllib.error | |
value = list(range(1, 10))[-1] | |
if value != 9: | |
print("Value %s is not 9" % value) | |
else: | |
print("Value is 9") | |
try: | |
assert 1 == 2 | |
except AssertionError as e: | |
print(e) | |
print(urllib.request.urlopen('https://docs.python.org/2/library/exceptions.html').read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
value = range(1, 10)[-1] | |
if value <> 9: | |
print "Value %s is not 9" % value | |
else: | |
print "Value is 9" | |
try: | |
assert 1 == 2 | |
except AssertionError, e: | |
print e | |
print urllib.urlopen('https://docs.python.org/2/library/exceptions.html').read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment