Skip to content

📙 Refurbishment of Python code examples #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cyb3rko opened this issue Aug 6, 2022 · 3 comments · Fixed by #896
Closed

📙 Refurbishment of Python code examples #894

cyb3rko opened this issue Aug 6, 2022 · 3 comments · Fixed by #896

Comments

@cyb3rko
Copy link
Contributor

cyb3rko commented Aug 6, 2022

Link to section:
I don't know how many doc entries contain Python code but in the REST API guide are most of them:
https://docs.parseplatform.org/rest/guide

What is the issue?
The shown Python 2 code is outdated and gives instant errors if you try to run it in Python 3 (which is out since 2008, so definitely the today's standard):

image

Can you propose a solution?
To just make it work again it would be

import json,http.client   # new import
connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443)   # using new import
connection.connect()
connection.request('GET', '/parse/classes/GameScore', '', {
    "X-Parse-Application-Id": "${APPLICATION_ID}",
    "X-Parse-REST-API-Key": "${REST_API_KEY}"
})
result = json.loads(connection.getresponse().read())
print(result)   # changed print syntax

But according to the PEP 8 coding guidelines the imports should be on seperate lines and there should be 2 blank lines after the import section:

import http.client
import json


...

Do we want to renew all the Python examples step by step to have modern examples you can directly use without errors and Googling what to change to make everything work again???

I'm interested in doing this if you say we want this to be done.

@mtrezza
Copy link
Member

mtrezza commented Aug 6, 2022

I'd say that would be preferred. Is there a reason why it wouldn't be?

@cyb3rko
Copy link
Contributor Author

cyb3rko commented Aug 6, 2022

Alright. I don't think there's a reason not to do so.

@mtrezza
Copy link
Member

mtrezza commented Aug 6, 2022

Got it. In that case it would be fantastic if you wanted to take this on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants