
Hi!
In the Python Argentina mail list there's already people passing examples and asking help about Python 3.
This introduces the problem that some examples are in Py2 and others are in Py3. Sometimes this is not explicit, and gets confusing. I'm trying to avoid this confusion when preparing my own examples. So far, I use (py3) as a prefix for any example block, like:
(Py3k)
(some example)
(some result)
Is there any recommended way to avoid confusion in these cases? (I'm thinking about changing the prompt in my Python installation, to something like ">2>>" and ">3>>", to be explicit about it... but I wanted to know if there's another better way)
Thanks.

Facundo Batista wrote: Hi!
In the Python Argentina mail list there's already people passing examples and asking help about Python 3.
For complete snippets: #!/usr/bin/env python3.0
vs #!/usr/bin/env python2.6
And for blocks of code
# this for python 3.0 # this is for python 2.6
I know, it is very rudimentary, but I have followed snippets with written these identifications.

2009/1/29 Senthil Kumaran orsenthil@gmail.com:
And for blocks of code
# this for python 3.0 # this is for python 2.6
Too much work, ;)
Seriously, most probably people will forgot to add that after the third example...

On Thu, 29 Jan 2009 at 10:50, Facundo Batista wrote:
This introduces the problem that some examples are in Py2 and others are in Py3. Sometimes this is not explicit, and gets confusing. I'm trying to avoid this confusion when preparing my own examples. So far, I use (py3) as a prefix for any example block, like:
(Py3k)
(some example)
(some result)
Is there any recommended way to avoid confusion in these cases? (I'm thinking about changing the prompt in my Python installation, to something like ">2>>" and ">3>>", to be explicit about it... but I wanted to know if there's another better way)
My suggestion would be to run the examples in the interpreter shell to validate them before posting, and just cut and paste the banner along with the example:
Python 2.6.1 (r261:67515, Jan 7 2009, 17:09:13) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "hello world" hello world
Python 3.0 (r30:67503, Dec 18 2008, 19:09:30) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print("hello world") hello world
A bit noisier, but not much more work than cutting and pasting the example without the banner :)
--RDM
participants (3)
-
Facundo Batista
-
rdmurray@bitdance.com
-
Senthil Kumaran