Python 2to3: Difference between revisions

Pro-panda (talk | contribs)
No edit summary
Pro-panda (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 17: Line 17:
: Target: Should be compatible with both Python 2 and Python 3, to support the large number of activities currently in Python 2
: Target: Should be compatible with both Python 2 and Python 3, to support the large number of activities currently in Python 2
: WIP: https://github.com/Pro-Panda/sugar-toolkit-gtk3/tree/python3-port
: WIP: https://github.com/Pro-Panda/sugar-toolkit-gtk3/tree/python3-port
: Status: Mostly complete; what remains is an entire project in itself of [https://github.com/orgs/sugarlabs/projects/4 porting the Telepathy Bindings]
: Status: Mostly Complete; what remains is an entire project in itself of [https://github.com/orgs/sugarlabs/projects/4 porting the Telepathy Bindings].
: Critical changes implelmented:
:* Python 3 activities must be instantiated with sugar-activity3 instead of sugar-activity
:* sugar-activity-web will call the Python 3 version of the toolkit and will be installed only with the same
:* warning logged if activity is not ported to Python 3
Note: To test the toolkit without porting the telepathy bindings, please use the Python 3 bindings (not for release), https://github.com/pro-panda/telepathy3
 


;Sugar-Datastore
;Sugar-Datastore
Line 30: Line 36:


;Sugar Desktop Activities
;Sugar Desktop Activities
 
: Guide to porting activities to Python 3 is [https://github.com/sugarlabs/sugar-docs/blob/master/src/python-porting-guide.md here]
{| style="text-align: center;"
{| style="text-align: center;"
! | Activity
! | Activity
Line 112: Line 118:
There are several ways of contributing to the project
There are several ways of contributing to the project
; Port Telepathy bindings
; Port Telepathy bindings
: Telepathy does not have python 2 bindings and needs to be ported to its PyGObject bindings as a prerequisite for porting to Python 3
: Telepathy does not have python 3 bindings and needs to be ported to its PyGObject bindings as a prerequisite for porting to Python 3
: See https://github.com/orgs/sugarlabs/projects/4
: See https://github.com/orgs/sugarlabs/projects/4


Line 131: Line 137:


== Notes ==
== Notes ==
* httplib.HTTP is not available in Python 2; use http.client.HTTPConnection instead
* httplib.HTTP is not available in Python 3; use http.client.HTTPConnection instead
* cmp function does not exist in Python 3, use the cmp_to_key function; see https://docs.python.org/3/howto/sorting.html#sortinghowto
* cmp function does not exist in Python 3, use the cmp_to_key function; see https://docs.python.org/3/howto/sorting.html#sortinghowto
* list.sort function requires named parameters in Python 3
* list.sort function requires named parameters in Python 3