Skip to content

Commit 487390f

Browse files
committed
feat(samples): python 3
1 parent 557800a commit 487390f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

spec/code_samples/Python/me/get.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
try:
1111
pprint(flat_api.AccountApi(flat_api_client).get_authenticated_user())
1212
except ApiException as e:
13-
print e
13+
print(e)

spec/code_samples/Python/scores/post.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pprint import pprint
2-
import os, urllib2
2+
import os
3+
from urllib.request import urlopen
4+
from urllib.error import HTTPError
35

46
import flat_api
57
from flat_api.rest import ApiException
@@ -12,7 +14,7 @@
1214

1315
try:
1416
# Download a MusicXML "Hello World"
15-
hello_world = urllib2.urlopen(SCORE_TO_IMPORT).read()
17+
hello_world = urlopen(SCORE_TO_IMPORT).read().decode('utf-8')
1618

1719
# The new score meta, including the MusicXML file as `data`
1820
new_score = flat_api.ScoreCreation(
@@ -23,5 +25,5 @@
2325

2426
# Create the document and print the meta returned by the API
2527
pprint(flat_api.ScoreApi(flat_api_client).create_score(new_score))
26-
except (ApiException, urllib2.HTTPError) as e:
27-
print e
28+
except (ApiException, HTTPError) as e:
29+
print(e)

0 commit comments

Comments
 (0)