[Python-Dev] Examples in Py2 or Py3 (original) (raw)
rdmurray at bitdance.com rdmurray at bitdance.com
Thu Jan 29 17:17:50 CET 2009
- Previous message: [Python-Dev] Examples in Py2 or Py3
- Next message: [Python-Dev] Partial function application 'from the right'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Examples in Py2 or Py3
- Next message: [Python-Dev] Partial function application 'from the right'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]