Robert Bradshaw wrote: > On Mon, 18 Aug 2008, Stefan Behnel wrote: >> Dag Sverre Seljebotn wrote: >> >>> for i in range(3): >>> print 2, >>> print >> >> Right, that makes sense. The Py3 print() function (that we map the print >> statement to when running under Py3) has an explicit 'end' keyword that >> keeps >> it from having to do any "softspace" special casing. So this is a >> difference >> that is hard to emulate in Py3, which (as opposed to Py2) does not >> expose the softspace hint at all. >> >> http://www.python.org/dev/peps/pep-3105/ >> >> Open poll: >> >> a) would it be acceptable if this difference persisted, i.e. if Cython >> code >> that uses something like the example above would behave different in >> Py3 >> b) should Cython try to special case this in Py3 to emulate the Py2 >> behaviour >> in common cases >> c) should Cython stick to the Py3 behaviour also in Py2 (thus breaking >> the >> complete semantics of the print statement) > > I certainly think (b) is the rigth option, depending on how hard and/or > hackish it is. After that is should fall back to (a). I really don't like > option (c), not only does it break existing code but the print statement > doesn't even exist in Py3 so trying to "match" it is probably a bad > thing.
When I say "emulate", this means that we have to keep track of the print call and insert the "," induced space /before/ the next print instead of appending it to the current print. This means that code that lets Python output things in the meantime would still break, but output that comes only from Cython could be made to work. Since this is definitely hackish, I would then want to see the "print_statement" future import implemented also (i.e. the print function implemented in Cython on Py2), so that we can use a well-defined function instead of something that may or may not break in Py3. That should actually be easier than trying to get the above semantics of the print statement right in as many cases as possible. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
