msg131817 - (view) |
Author: anatoly techtonik (techtonik) |
Date: 2011-03-22 23:59 |
http://docs.python.org/library/2to3.html#using-2to3 contains an example.py sample which is claimed to be Python 2.x source, but that's not true:
def greet(name):
print "Hello, {0}!".format(name)
print "What's your name?"
name = raw_input()
greet(name)
The code is valid only for Python 2.6+. For previous versions it gives the following traceback:
Traceback (most recent call last):
File "ewe.py", line 5, in <module>
greet(name)
File "ewe.py", line 2, in greet
print "Hello, {0}!".format(name)
AttributeError: 'str' object has no attribute 'format'
|
msg131818 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2011-03-23 00:05 |
Your title is untrue: This example code from the 2.6 docs is valid 2.6 code. I can’t find a problem with that.
|
msg131823 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2011-03-23 00:30 |
Plus, it's recommended to move to 2.6 or 2.7 before trying to port to 3.x.
|
msg131824 - (view) |
Author: anatoly techtonik (techtonik) |
Date: 2011-03-23 00:32 |
Then the docs should say that this is the 2.6 code, not 2.x
|
msg131827 - (view) |
Author: anatoly techtonik (techtonik) |
Date: 2011-03-23 00:35 |
I can't find where it is recommended to move code to Python 2.7 before porting.
|
msg131828 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2011-03-23 00:36 |
I'll agree that the documentation could mention that. Reopening.
Patches accepted.
|
msg131829 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2011-03-23 00:39 |
http://docs.python.org/release/3.2/whatsnew/3.0#porting-to-python-3-0
|
msg132137 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2011-03-25 19:10 |
See also the fifth piece in http://docs.python.org/release/3.2/howto/pyporting#universal-bits-of-advice
Resources are here, but lack links.
|
msg338692 - (view) |
Author: Cheryl Sabella (cheryl.sabella) * |
Date: 2019-03-23 19:31 |
Since the HOWTO for Porting from 2 to 3 was created in February 2011, there have been many updates over time to improve that document. It seems to me that it is thorough in its explanation, including the suggestion of upgrading to 2.7 before converting to Python 3. As such, I believe this issue can be closed, but wanted to make sure others agreed before I changed the status. Thanks!
https://docs.python.org/3.7/howto/pyporting.html
|
msg338693 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2019-03-23 19:33 |
I agree we should close this.
|
msg338696 - (view) |
Author: Cheryl Sabella (cheryl.sabella) * |
Date: 2019-03-23 20:15 |
Thanks, Eric!
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:15 | admin | set | github: 55853 |
2019-03-23 20:15:07 | cheryl.sabella | set | status: open -> closed resolution: out of date messages:
+ msg338696
stage: needs patch -> resolved |
2019-03-23 19:33:09 | eric.smith | set | messages:
+ msg338693 |
2019-03-23 19:31:31 | cheryl.sabella | set | nosy:
+ cheryl.sabella messages:
+ msg338692
|
2011-05-28 13:12:15 | adam.woodbeck | set | nosy:
+ adam.woodbeck
|
2011-03-25 19:10:05 | eric.araujo | set | status: pending -> open versions:
+ Python 3.1, Python 2.7, Python 3.2, Python 3.3 title: 2to3 documentation should mention that the sample file requires 2.6 or better -> Cross-link 2to3 documentation, what’s new and pyporting howto messages:
+ msg132137
resolution: out of date -> (no value) stage: needs patch |
2011-03-23 00:39:16 | eric.araujo | set | status: open -> pending
messages:
+ msg131829 resolution: out of date nosy:
eric.smith, techtonik, eric.araujo, docs@python |
2011-03-23 00:36:33 | eric.smith | set | status: closed -> open
components:
- 2to3 (2.x to 3.x conversion tool) title: 2to3 example.py is not a Python 2.x file -> 2to3 documentation should mention that the sample file requires 2.6 or better nosy:
eric.smith, techtonik, eric.araujo, docs@python messages:
+ msg131828 resolution: not a bug -> (no value) stage: resolved -> (no value) |
2011-03-23 00:35:30 | techtonik | set | nosy:
eric.smith, techtonik, eric.araujo, docs@python messages:
+ msg131827 |
2011-03-23 00:32:08 | techtonik | set | nosy:
eric.smith, techtonik, eric.araujo, docs@python messages:
+ msg131824 |
2011-03-23 00:30:41 | eric.smith | set | nosy:
+ eric.smith messages:
+ msg131823
|
2011-03-23 00:05:30 | eric.araujo | set | status: open -> closed
nosy:
+ eric.araujo messages:
+ msg131818
resolution: not a bug stage: resolved |
2011-03-23 00:00:06 | techtonik | set | assignee: docs@python
components:
+ Documentation nosy:
+ docs@python |
2011-03-22 23:59:52 | techtonik | create | |