| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | :orphan: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-03 22:01:54 +00:00
										 |  |  | .. _pyporting-howto:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-24 11:28:23 +02:00
										 |  |  | *************************************
 | 
					
						
							|  |  |  | How to port Python 2 Code to Python 3
 | 
					
						
							|  |  |  | *************************************
 | 
					
						
							| 
									
										
										
										
											2011-02-03 22:01:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | :author: Brett Cannon
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | Python 2 reached its official end-of-life at the start of 2020. This means
 | 
					
						
							|  |  |  | that no new bug reports, fixes, or changes will be made to Python 2 - it's
 | 
					
						
							|  |  |  | no longer supported: see :pep:`373` and
 | 
					
						
							|  |  |  | `status of Python versions <https://devguide.python.org/versions>`_.
 | 
					
						
							| 
									
										
										
										
											2014-12-05 10:56:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | If you are looking to port an extension module instead of pure Python code,
 | 
					
						
							|  |  |  | please see :ref:`cporting-howto`.
 | 
					
						
							| 
									
										
										
										
											2016-12-17 12:37:20 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | The archived python-porting_ mailing list may contain some useful guidance.
 | 
					
						
							| 
									
										
										
										
											2014-12-05 10:56:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | Since Python 3.13 the original porting guide was discontinued.
 | 
					
						
							|  |  |  | You can find the old guide in the
 | 
					
						
							|  |  |  | `archive <https://docs.python.org/3.12/howto/pyporting.html>`_.
 | 
					
						
							| 
									
										
										
										
											2014-12-05 10:56:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-24 11:28:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | Third-party guides
 | 
					
						
							|  |  |  | ==================
 | 
					
						
							| 
									
										
										
										
											2023-08-24 11:28:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | There are also multiple third-party guides that might be useful:
 | 
					
						
							| 
									
										
										
										
											2014-12-05 10:56:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-12 14:59:58 +03:00
										 |  |  | - `Guide by Fedora <https://portingguide.readthedocs.io>`_
 | 
					
						
							|  |  |  | - `PyCon 2020 tutorial <https://www.youtube.com/watch?v=JgIgEjASOlk>`_
 | 
					
						
							|  |  |  | - `Guide by DigitalOcean <https://www.digitalocean.com/community/tutorials/how-to-port-python-2-code-to-python-3>`_
 | 
					
						
							|  |  |  | - `Guide by ActiveState <https://www.activestate.com/blog/how-to-migrate-python-2-applications-to-python-3>`_
 | 
					
						
							| 
									
										
										
										
											2014-12-05 10:56:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-05 00:23:58 +05:30
										 |  |  | .. _python-porting: https://mail.python.org/pipermail/python-porting/
 |