Steven D'Aprano wrote: > If Python 3 dropped the print > statement and replaced it with official_print_function(), how would that > help you in your goal to have a single code base that will run on both > Python 2.3 and Python 3, while still using print?
Is there any reason why official_print_function isn't sys.stdout.write?
I can't remember the last time I used print in actual code (apart from short-lived debugging lines), so I'm bewildered as to why print seems to be so important.
On Tue, 20 Feb 2007 00:44:24 +0000, Peter mayne wrote: > Steven D'Aprano wrote: >> If Python 3 dropped the print >> statement and replaced it with official_print_function(), how would that >> help you in your goal to have a single code base that will run on both >> Python 2.3 and Python 3, while still using print?
> Is there any reason why official_print_function isn't sys.stdout.write?
Why would you want a convenience function like print to take one import, three look-ups and 16 characters instead of always available, one look-up and five characters?
> I can't remember the last time I used print in actual code (apart from > short-lived debugging lines), so I'm bewildered as to why print seems to > be so important.
print is important for the convenience, for short-lived debugging, and for use in the interactive interpreter.
On Feb 16, 6:07 am, Steven Bethard <steven.beth...@gmail.com> wrote:
> Python 3.0 is determined not to be hampered by backwards incompatibility > concerns. It's not even clear yet that your average 2.6 code will work
Then Python is pretty much determined to remove itself from consideration from various kinds of international projects like the one I work on. We're already catching flack from people due to a few things that were valid in 2.2 that are not valid in 2.3 (I don't have the details but could scare them up). The project we work on contains code from many different people and has to run on thousands of computers all over the world. The installed base at the moment is a mix of RHEL 3, RHEL 4, and Debian, with a few other machines thrown in. The relevant Python versions at this moment IIRC are 2.2.3 and 2.3.4, because these are the native versions on those platforms.
We are estimating, due to the speed at which our applications follow OS releases, that we can drop RHEL 3 (and hence Python 2.2) support a year from now. Go figure when you think we might be ready to require that all programs run on python 3.0. If it's not backwards compatible, meaning if 2.4 code doesn't run on 3.0, it's rather likely that strong pressure will be applied to port *away* from Python into something less capricious.
Bottom line: practicality and beauty is always a tradeoff. Oberon is the most beautiful language I ever saw, but there is almost nobody using it any more. Too many beauty contests over who had the best proposal for a standard library.
<s...@REMOVE.THIS.cybersource.com.au> wrote: > On Fri, 16 Feb 2007 09:49:03 -0500, Jean-Paul Calderone wrote: > > On Sat, 17 Feb 2007 01:32:21 +1100, Steven D'Aprano > >> [snip]
> >>I don't think that follows at all. print is only a problem if you expect > >>your code to work under both Python 2.x and 3.x. I wouldn't imagine > >>that many people are going to expect that: I know I don't.
> > I think some people are confused that the language "Python 3.x" has "Python" > > in its name, since there is already a language with "Python" in its name, > > with which it is not compatible.
> There is no language "Python 3" -- yet. We're still all guessing just > how compatible it will be with Python 2.
> To be precise, there is an experimental Python 3, but the specifications > of the language are not fixed yet.
> As for the name... big deal. C and C++ and Objective C are completely > different languages.Fortran 77 and Fortran 90 aren't exactly the same; > nobody expects the same code to run unmodified on Forth 77 and FigForth, > or any of another three dozen varieties of Forth.
The attitudes towards backwards compatibility of the Fortran standards committee and the Python BDFL is very different.
Fortran 90 was a superset of Fortran 77, so standard-conforming Fortran 77 programs have the same meaning when compiled with an F90 compiler. The committee does not consider changing things like the meaning of 1/2. Even though WRITE provides a superset of the functionality of PRINT, the committee would not dream of breaking so much code by removing PRINT. No feature is deleted without being declared obsolescent in a previous standard, which makes it easier to plan ahead. In practice Fortran 95 compilers accept deleted features, but they are required to a have a switch that identifies non-standard code.
I think the C and C++ committees also take backwards compatibility seriously, in part because they know that working programmers will ignore them if they break too much old code.
> On Feb 16, 6:07 am, Steven Bethard <steven.beth...@gmail.com> wrote: >> Python 3.0 is determined not to be hampered by backwards incompatibility >> concerns. It's not even clear yet that your average 2.6 code will work
> Then Python is pretty much determined to remove itself from > consideration > from various kinds of international projects like the one I work on.
You snipped the rest of that comment:
"It's not even clear yet that your average 2.6 code will work on 3.0 -- though there's a pretty large contingent trying to make this true."
If you want to make sure average 2.6 code works on 3.0, please help contribute to Python. You can find out where best to focus your efforts by asking on python-dev:
> If it's not backwards compatible, meaning if 2.4 code doesn't run on > 3.0, it's rather likely that strong pressure will be applied to port > *away* from Python into something less capricious.
Well, Python 2.4 code will work on Python 2.6 and 2.7 so just because your code isn't yet compatible with Python 3.0 doesn't mean you should give up on Python.
Python 2.2 was released in early 2003 and you said you'd be dropping support for 2.2 in early 2008, so I conclude that since Python 2.5 was released in late 2006, you'll be ready to drop Python 2.5 support (and have 2.6/3.0 compatible code) by late 2011. Sure, it's a long way off, but you're writing 2.2 compatible code *now*. Is it really that bad to wait four years for Python 3.0?
On Feb 20, 8:59 pm, Steven Bethard <steven.beth...@gmail.com> wrote:
> You snipped the rest of that comment:
> "It's not even clear yet that your average 2.6 code will work on 3.0 -- > though there's a pretty large contingent trying to make this true."
Thanks for pointing this out. I voted for the comp.lang.python newsgroup back in the early 90's, my active days of python 'development' are over, it's all i can do to hang on to the code i've been posting about.
> have 2.6/3.0 compatible code) by late 2011. Sure, it's a long way off, > but you're writing 2.2 compatible code *now*. Is it really that bad to > wait four years for Python 3.0?
As long as when python 3.0 shows up, i don't have to do a massive rewrite. I think I've really only had to change two or three things over the years .. one was that I used to use words like "dict" and "list" in my code, which broke in subtle ways when d = dict() became legal.
I just dug out some code laying around on disk from 1994, and ran it, unchanged, under python 2.3.5. If I can achieve this (running 2007 code under python3.0 in 2011 with no modifications), that'd be OK.
What a load of bull crap. Python is one of the simplest packages to have multiple version of installed. When Python 3.0 is released, all Linux distros will acquire a symlink at /usr/bin/python2 pointing to the latest Python 2.x version installed. Or something equivalent. Rest assured that Linux distributors will not drop Python 2.x support in the nearest decade. They are not stupid.
On 20 Feb 2007 08:49:10 -0800, Jay Tee <jeff.temp...@gmail.com> wrote:
> On Feb 16, 6:07 am, Steven Bethard <steven.beth...@gmail.com> wrote: > > Python 3.0 is determined not to be hampered by backwards incompatibility > > concerns. It's not even clear yet that your average 2.6 code will work
> Then Python is pretty much determined to remove itself from > consideration > from various kinds of international projects like the one I work on. > We're already catching flack from people due to a few things that were > valid > in 2.2 that are not valid in 2.3 (I don't have the details but could > scare them > up). The project we work on contains code from many different people > and has to > run on thousands of computers all over the world. The installed base > at the > moment is a mix of RHEL 3, RHEL 4, and Debian, with a few other > machines thrown in. > The relevant Python versions at this moment IIRC are 2.2.3 and 2.3.4, > because these > are the native versions on those platforms.
> We are estimating, due to the speed at which our applications follow > OS releases, that > we can drop RHEL 3 (and hence Python 2.2) support a year from now. Go > figure when you > think we might be ready to require that all programs run on python > 3.0. If it's not > backwards compatible, meaning if 2.4 code doesn't run on 3.0, it's > rather likely that > strong pressure will be applied to port *away* from Python into > something less capricious.
> Bottom line: practicality and beauty is always a tradeoff. Oberon is > the most beautiful > language I ever saw, but there is almost nobody using it any more. > Too many beauty contests over who had the best proposal for a standard > library.
> Well, Python 2.4 code will work on Python 2.6 and 2.7 so just because > your code isn't yet compatible with Python 3.0 doesn't mean you should > give up on Python.
Perhaps the most important concern in the context of Python 3.0 is what the term "Python" will come to mean to the different communities using the language. Some people will be maintaining software that needs to be compatible with older releases; these people aren't technologically backwards: they just find that such older releases provide sufficient capabilities for the implementation of their solutions. For such people, "Python" will be the language they've always used, with a gradual accumulation of features, some known quirks, and some relatively minor incompatibility issues over the years.
Meanwhile, the risk is that the core developers will only consider Python 3.0 as "Python" and that people doing anything with older releases will be on their own. If the gap is too wide between 2.x and 3.x, any lack of maintenance in the 2.x series will be perceived as an abandonment of "Python" for certain kinds of user, and the result will probably be a loss of confidence in both variants of the language. Although I believe that some of the recent attempts to lower the disruptiveness of Python 3.0 may have helped to maintain "Python" as a single narrow continuum, I think some people overlook how fortunate the relationship between Python's evolution and momentum has been, and how easily such a relationship can be broken.
Bjorn, I am not sure I see why my post is bull crap. I think all you are doing is agreeing with me. My post was entitled "Python 3.0 unfit for serious work", you just indicated that the Linux distros will agree with me, in order to be taken seriously, the distros will have to include 2.x python for a very long time. If 3.0 and 2.x have any serious degree of incompatibility, python will be a favorite subject for religious rants and heated arguments for many people. And if we don't manage to restrain our developers from using features that force us prematurely to move to 3.0 ... and don't underestimate what this means, because this means other things will have to move as well, which may have dependencies on yet other things like C++ library versions ... then I would have to, for reasons of maintainability, argue against continuing to allow python code development in the project. I love python, but not enough to make 20+ people's lives difficult.
There are already people making this sort of argument in our project.
JT
On 2/20/07, BJörn Lindqvist <bjou...@gmail.com> wrote:
> What a load of bull crap. Python is one of the simplest packages to > have multiple version of installed. When Python 3.0 is released, all > Linux distros will acquire a symlink at /usr/bin/python2 pointing to > the latest Python 2.x version installed. Or something equivalent. > Rest assured that Linux distributors will not drop Python 2.x support > in the nearest decade. They are not stupid.
Paul, thanks for this, I didn't realize the scope of the situation. I agree with your assessment to the extent that I understand what the whole python 3.0 thing is about.
Let's see if I can scare up something I wrote about ten years ago on a now-dead language that I really wanted to use (wound up sticking with python instead because "it was supported" ;-)
======================= to figure out how to work things. The fact that there are three (or four depending if you count Linz V4) different Oberon System implementations, and several different compilers, and even four or five separate dialects of Oberon with none of them appearing to be really "official", gives the impression of a fragmented, directionless development effort, and a probability bordering on 1.0000 that whatever you try to do will be incompatible with all but a small subset of what's available (unless you stick to writing small programs like in the books.) It does not matter if you tell people that this is not so; something has to clearly stand out as being THE STANDARD STUFF and all the other stuff as INTERESTING BUT NONTHREATENING SIDE PROJECTS. The STANDARD STUFF must include a sufficient number of =========================
Oberon is really really cool, seriously, ... but nobody is using it. People working on python development are of course free to do what they want, but so are the users ...
J "actie-reactie is what my ex-brother-in-law would say" T
Jay Tee wrote: > Let's see if I can scare up something I wrote about ten years ago on a > now-dead language that I really wanted to use (wound up sticking with > python instead because "it was supported" ;-)
> ======================= > to figure out how to work things. The fact that there are three (or > four depending if you count Linz V4) different Oberon System > implementations, and several different compilers, and even four or > five separate dialects of Oberon with none of them appearing to be > really "official", gives the impression of a fragmented, directionless > development effort, and a probability bordering on 1.0000 that > whatever you try to do will be incompatible with all but a small > subset of what's available (unless you stick to writing small programs > like in the books.) It does not matter if you tell people that this > is not so; something has to clearly stand out as being THE STANDARD > STUFF and all the other stuff as INTERESTING BUT NONTHREATENING SIDE > PROJECTS. The STANDARD STUFF must include a sufficient number of > =========================
Well, the problem of multiple standards shouldn't really apply in the same way to Python. Right now, Python 2.X is the standard. Python 2.6, 2.7 and any later 2.X versions are intended to be transitional versions while the standard is migrating to Python 3.X. At some point, the 2.X line will almost certainly be discontinued.
So as a Python programmer, the path is clear. As soon as possible, you should make your code compatible with Python 3.0. That will likely mean taking advantage of some new features in Python 2.6, so "as soon as possible" may still mean many years for projects that need to support older versions of Python. Still, once Python 2.6 is installed everywhere by default, it shouldn't be difficult to start making code compatible with the new standard, Python 3.0.
> Paul, thanks for this, I didn't realize the scope of the situation. I > agree with your assessment to the extent that I understand what the > whole python 3.0 thing is about.
I don't know if I've delimited the scope of any situation, really. However...
[...]
> The fact that there are three (or > four depending if you count Linz V4) different Oberon System > implementations, and several different compilers, and even four or > five separate dialects of Oberon with none of them appearing to be > really "official",
[...]
The fortunate thing about different Python implementations and in contrast to a lot of other languages and their implementations is that the most actively developed Python implementation, CPython, is very portable and is present on all major operating systems of consequence (capable of running it). Other languages have suffered because there'd be a UNIX version and then a version for Windows or the Mac which wasn't as well maintained, or perhaps no version at all for one or more of these platforms. So with Python, even if one implementation is lagging behind (eg. Jython) there's still likely to be some deployment solution on one's operating system of choice, given some level of flexibility.
Where incompatibilities may arise with Python implementations is in the level of support for recent language developments and additions. Again, CPython's portability prevents this from becoming an operating system issue, but we see rifts between implementations targeting different runtime platforms, and whilst CPython 2.x and CPython 3.x may continue to cover similar operating systems (although a desire to drop support for various operating systems was stated), it's the rift between them that presents the risk to any common notion of what Python actually is.
> Bjorn, I am not sure I see why my post is bull crap. I think all you > are doing is agreeing with me. My post was entitled "Python 3.0 unfit > for serious work", you just indicated that the Linux distros will > agree with me, in order to be taken seriously, the distros will have > to include 2.x python for a very long time. If 3.0 and 2.x have any > serious degree of incompatibility, python will be a favorite subject > for religious rants and heated arguments for many people. And if we > don't manage to restrain our developers from using features that force > us prematurely to move to 3.0 ... and don't underestimate what this > means, because this means other things will have to move as well, > which may have dependencies on yet other things like C++ library > versions ... then I would have to, for reasons of maintainability, > argue against continuing to allow python code development in the > project. I love python, but not enough to make 20+ people's lives > difficult.
> There are already people making this sort of argument in our project.
This is why I said that your post was a load of bull crap:
"Then Python is pretty much determined to remove itself from consideration from various kinds of international projects like the one I work on [unless py3k is backwards compatible with python 2.x]."
You did not explain why this is so.
"if 2.4 code doesn't run on 3.0, it's rather likely that strong pressure will be applied to port *away* from Python into something less capricious."
Who are these people that are applying the strong pressure? How can you run a international and seemingly very important project without knowing basic things about how to handle versioning problems?
I mean, they would rather port this big system, deployed on thousands of computers all over the world, to an entirely different programming language than to continue using Python 2.x because Python 3.x, when it is released, MIGHT cause them some problems several YEARS from now?
Steven Bethard wrote: > So as a Python programmer, the path is clear. As soon as possible, you > should make your code compatible with Python 3.0.
There's always the possiblity that Python 3 won't happen. Look at what happened with Perl 6. That's been talked about for seven years now. The user base just wasn't interested. Perl 5 was good enough, and users migrated to PHP for the little stuff and other languages for the bigger stuff. As Wikipedia says, "As of 2007, Perl 6 was still under development, with no planned completion date."
John Nagle <na...@animats.com> writes: > There's always the possiblity that Python 3 won't happen. Look at > what happened with Perl 6. That's been talked about for > seven years now. The user base just wasn't interested. > Perl 5 was good enough, and users migrated to PHP for the > little stuff and other languages for the bigger stuff. > As Wikipedia says, "As of 2007, Perl 6 was still under development, > with no planned completion date."
I like to think PyPy will replace CPython as the main Python implementation. Python 3.0 can then fork the language fairly radically, like C++ vs C (ok, not so attractive an example) or Scheme vs Lisp. Both dialects would stay active.
It seems to me that the flavor of Python programming has changed significantly over the past few releases. That trend will likely continue and even accelerate.
Paul Rubin wrote: > John Nagle <na...@animats.com> writes:
>> There's always the possiblity that Python 3 won't happen. Look at >>what happened with Perl 6. That's been talked about for >>seven years now. The user base just wasn't interested. >>Perl 5 was good enough, and users migrated to PHP for the >>little stuff and other languages for the bigger stuff. >>As Wikipedia says, "As of 2007, Perl 6 was still under development, >>with no planned completion date."
> I like to think PyPy will replace CPython as the main Python > implementation.
Well, something faster really should take over. It's a bit embarassing that the main implementation of Python is still a pure interpreter. Even Javascript has a JIT compiler now. And it's tiny, under 1MB.
John Nagle wrote: > It's a bit > embarassing that the main implementation of Python is still a > pure interpreter. Even Javascript has a JIT compiler now.
Pure interpreted Python has always seemed more responsive to me than any Java application I've tried to use. So I can't help feeling that this JIT business is over-hyped.
On Feb 21, 1:41 am, "BJörn Lindqvist" <bjou...@gmail.com> wrote:
[ citing me ]
> "if 2.4 code doesn't run on 3.0, it's rather likely that strong > pressure will be applied to port *away* from Python into something > less capricious."
> Who are these people that are applying the strong pressure? How can > you run a international and seemingly very important project without > knowing basic things about how to handle versioning problems?
This isn't versioning. At least not the way I see it. Versioning has to do with changes in your own product. Indeed one needs to know how to handle it. Lately our project has been doing OK on this front, a couple years ago was a different story.
Underlying technology is a different story. This should be reasonably stable. Small changes are inevitable but even these are a major pain, since we have dependency links like the following:
OS release links to Python release which changes an Third-party extension module which requires A third party library whose Version needs to be upgraded but which Is used by some other non-python means that Requires the earlier version.
Or the earlier problem, an OS upgrade comes with a new python version on which existing code breaks.
The fraction of code in our system that's written in python is something like 10% -- it's not a big pure-python system.
Now you're talking about major changes in the underlying technology, forcing, at some point in the future, an extensive rewrite of the python code. Yes, at that point, some people would make the comment that a language which changes to that extent by major versions is not fit for production work, and if one was going to have to rewrite, it would be better to rewrite in a more stable language.
And finally, remember the original post I replied to said that python 3.0 was determined not to be hampered by backwards compatibility. This is quite a bit different than what you say here ("MIGHT cause problems"):
> language than to continue using Python 2.x because Python 3.x, when it > is released, MIGHT cause them some problems several YEARS from now?
If backwards compatibility is not a consideration, then it would be a miracle if there were no problems.
On Tue, 20 Feb 2007 21:19:26 -0800, John Nagle wrote: > Well, something faster really should take over. It's a bit > embarassing that the main implementation of Python is still a > pure interpreter. Even Javascript has a JIT compiler now. > And it's tiny, under 1MB.
Python has a compiler, just like Java. That's where the .pyc files come from.
You might also notice the built-in function "compile", which compiles text strings into byte-code and puts it into a code object. The dis module may also be of interest.
>If backwards compatibility is not a consideration, then it would be a >miracle if there were no problems.
Backwards compatibility is a consideration AND there will be problems. That is, the goal of 3.0 is to lower the priority of backwards compatibility enough to make some incompatible changes, but not to reduce the priority of compatibility to zero. Just for example, "foo" will become a Unicode string.
Note that I believe it will be many years, perhaps even a decade, before "python" on a Unix system starts up Python 3.0. Python 2.x will have at least two releases after 3.0 gets released, and I can't imagine that any OS will have "python" refer to 3.0 while 2.x is still under active development or even for a while after. I'd expect any OS to provide a python3. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/
> Bjorn, I am not sure I see why my post is bull crap. I think all you > are doing is agreeing with me. My post was entitled "Python 3.0 unfit > for serious work", you just indicated that the Linux distros will > agree with me, in order to be taken seriously, the distros will have > to include 2.x python for a very long time. If 3.0 and 2.x have any > serious degree of incompatibility, python will be a favorite subject > for religious rants and heated arguments for many people. And if we > don't manage to restrain our d evelopers from using features that force > us prematurely to move to 3.0 ... and don't underestimate what this > means, because this means other things will have to move as well, > which may have dependencies on yet other things like C++ library > versions ... then I would have to, for reasons of maintainability, > argue against continuing to allow python code development in the > project. I love python, but not enough to make 20+ people's lives > difficult.
> There are already people making this sort of argument in our project.
> JT
I don't know the specifics of your app, but why does everyone insist that they need to use the 'system' python?
At least one commercial python app I work with installs it's own completely independant version of python. For many apps where predictible behaviour is required you can install 'your' python, under /opt/myapp or /usr/local/myapp or whatever instead of python, python2.2, python3, etc. The downside is that you'll waste another 15Mb harddrive space, and you'll need to update your internal source tree 4 or 5 times when maintenance releases come out.
Apologies if this sounds like a rant, I really mean it in a constructive way.
> I don't know the specifics of your app, but why does everyone insist > that they need to use the 'system' python?
Hey Grant, don't worry it's not a rant. A completely valid question. Again it's a problem of dependency management ... one of the things we've had to deal with is one of the applications : they have a framework largely built in python, and I think they were indeed at one point shipping their own python because they used features not present in the "system" python.
However, they did use the middleware installed on the system, and this middleware is also partially written in python ... except it was expecting the system python. So you get into very tricky things having to sanity check the PYTHONPATH, that the "user" python path is not getting exported into middleware land, nor is the application's desired PYTHONPATH being destroyed by middleware. We had just such an issue here last week, we had solved the problem for bourne shell users, but csh for some reason had a different behavior, and the user app could not longer find its python modules.
About the only code for which we don't seem to have these issues is compiled C. C++ is nasty because the compilers are still catching up to the standard; the last I heard, a big segment of C++ code was stuck because it was full of apparently illegal constructs that the previous compiler (the g++ shipped stock with RHEL3) accepted, but the RHEL-4 native version refused to compile.
A colleague of mine pointed out today that this is an old problem, and used to be handled by automake at compile time, with code full of ifdefs ... now we've moved the problem to run time. Which I think is harder, because sometimes we don't find the problem until our binary is halfway across the world ...
On Feb 21, 1:44 pm, a...@pythoncraft.com (Aahz) wrote:
> Note that I believe it will be many years, perhaps even a decade, before > "python" on a Unix system starts up Python 3.0.
That's a pretty safe bet considering that the factory-installed "python" on my Linux system is still 1.x and you run "python2" to get 2.x (I haven't done a new OS install in a couple of years, but 2.x had been out for years when I did the install). And 2.x is much less likely to break 1.x code than 3.x will be to break 2.x code.
Steven D'Aprano wrote: > On Tue, 20 Feb 2007 00:44:24 +0000, Peter mayne wrote:
>> Steven D'Aprano wrote: >>> If Python 3 dropped the print >>> statement and replaced it with official_print_function(), how would that >>> help you in your goal to have a single code base that will run on both >>> Python 2.3 and Python 3, while still using print? >> Is there any reason why official_print_function isn't sys.stdout.write?
> Why would you want a convenience function like print to take one import, > three look-ups and 16 characters instead of always available, one look-up > and five characters?
Because it's compatible between Python 2.x and Python 3.x? :-) Because without print as a keyword, I can say "print = sys.stdout.write" and still have (some) convenience? (Albeit still one import and one lookup, though given the probable time taken to do the I/O, why worry about the lookup?) Or, if your editor has an abbreviation facility like Eclipse, you can type sys.stdout.write with less than 5 keystrokes.
>> I can't remember the last time I used print in actual code (apart from >> short-lived debugging lines), so I'm bewildered as to why print seems to >> be so important.
> print is important for the convenience, for short-lived debugging, and for > use in the interactive interpreter.
Why use print in the interactive interpreter? Just type the expression.
Hmm, I was expecting that that wouldn't always work, but:
>>> x=3 >>> if x==3: x ... 3 >>> for i in range(x): ... i ... 0 1 2