User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Python 3.x as standard

Mon Sep 24, 2018 10:36 am

Is it possible to make Python 3.x the standard python version? At the moment is set to python 2.7 is rather an old hat.

DirkS
Posts: 10651
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Python 3.x as standard

Mon Sep 24, 2018 10:46 am

Use a shebang pointing to python 3?
Or use an alias?

Code: Select all

alias python=python3
You can add this to ~/.bashrc or ~/.bash_aliases

klricks
Posts: 7833
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Python 3.x as standard

Mon Sep 24, 2018 12:10 pm

bonzadog wrote:
Mon Sep 24, 2018 10:36 am
Is it possible to make Python 3.x the standard python version? At the moment is set to python 2.7 is rather an old hat.
Not a good idea as other scripts in your system may require Python 2.
For Python 3 scripts use:

Code: Select all

python3 /path/script.py
Or as mentioned make sure you have a proper 'shebang' as first line.

Code: Select all

#!/usr/bin/python3
If the file is then made executable the script can be started like this:

Code: Select all

/path/script.py
or

Code: Select all

./script.py
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

hippy
Posts: 10208
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python 3.x as standard

Mon Sep 24, 2018 1:51 pm

klricks wrote:
Mon Sep 24, 2018 12:10 pm
bonzadog wrote:
Mon Sep 24, 2018 10:36 am
Is it possible to make Python 3.x the standard python version? At the moment is set to python 2.7 is rather an old hat.
Not a good idea as other scripts in your system may require Python 2.
Indeed.; it's going to be a tricky problem to solve, and not just for Raspbian. Before a move to a default Python 3 can really be entertained; all Python 2 code will have to be updated to Python 3 or coded to explicitly use the Python 2 interpreter.

That may sounds like a fairly simply, straight forward, even if labour intensive, task but even the people behind the package installer for Python ("pip") have managed to royally screw that up and cause no end of problems for Python users.

Ironically that's blamed on "user error", incorrectly using "from pip import main", even though the "pip" command which gets installed with pip, is fundamental to using pip, uses that. Apparently no one should be using "/usr/bin/pip", so not sure why it's provided or even exists -

https://github.com/pypa/pip/issues/5240 ... -381662679

pfletch101
Posts: 661
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Python 3.x as standard

Mon Sep 24, 2018 2:38 pm

bonzadog wrote:
Mon Sep 24, 2018 10:36 am
Is it possible to make Python 3.x the standard python version? At the moment is set to python 2.7 is rather an old hat.
As others have said, there are a number of ways of doing this, but until all significant software and utilities that you may want to use are (at least) compatible with Python 3, doing this is likely to cause you far more trouble than it is worth.

User avatar
scruss
Posts: 4172
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Python 3.x as standard

Mon Sep 24, 2018 3:02 pm

hippy wrote:
Mon Sep 24, 2018 1:51 pm
Before a move to a default Python 3 can really be entertained; all Python 2 code will have to be updated to Python 3 or coded to explicitly use the Python 2 interpreter.
I guess it's a sign that it's a mature language. You have a bunch of "legacy code" that many people rely on but no-one wants (or has time/money) to dig into. The maintainers come out with edicts, but it's the users running the show.

There was an interesting paper last year¹ about the surprisingly slow uptake of Python 2 → 3 in popular packages. The authors conclude that most package maintainers are only “… confining themselves to a language subset, governed by the diminishing intersection of Python 2, … and Python 3”.

Not surprised about the pip problems. Debian is all about a package only being able to modify its own files, so playing with pip (and CPAN for Perl) on a Debian system may risk doing bad things. Though I'm a dedicated perlbrew user, I've never quite got the hang of using venv in Python to set up my own local interpreter that I can upgrade/break as I see fit.

--
¹: Malloy, Brian A., and James F. Power. "Quantifying the transition from python 2 to 3: an empirical study of python applications." Empirical Software Engineering and Measurement (ESEM), 2017 ACM/IEEE International Symposium on. IEEE, 2017. (preprint here)
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Mon Sep 24, 2018 4:35 pm

scruss,
I guess it's a sign that it's a mature language.
I take the opposite view.

Certainly Python has been around for a good long time. But it's still a toy language. It has no formally recognized standard, like C, C++, Javascript, Fortran, COBOL, Algol etc. Does it even have a formal specification? It breaks backwards compatibility on a whim.

This situation is far from being a "mature language"

Python is not to be trusted for anything serious.
Memory in C++ is a leaky abstraction .

User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Python 3.x as standard

Mon Sep 24, 2018 4:58 pm

Heater wrote:
Mon Sep 24, 2018 4:35 pm
scruss,
I guess it's a sign that it's a mature language.
I take the opposite view.

Certainly Python has been around for a good long time. But it's still a toy language. It has no formally recognized standard, like C, C++, Javascript, Fortran, COBOL, Algol etc. Does it even have a formal specification? It breaks backwards compatibility on a whim.

This situation is far from being a "mature language"

Python is not to be trusted for anything serious.
Well, I bet your statement will not find very much resonance. Very often programming languages (and operating systems) are treated very
much as a religion.

Python seems to offer a lot - see pypi. I need to look into a method of creating a GUI with the usual buttons etc. TKinter
looks a bit elementary.

User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Python 3.x as standard

Mon Sep 24, 2018 5:08 pm

klricks wrote:
Mon Sep 24, 2018 12:10 pm
bonzadog wrote:
Mon Sep 24, 2018 10:36 am
Is it possible to make Python 3.x the standard python version? At the moment is set to python 2.7 is rather an old hat.
Not a good idea as other scripts in your system may require Python 2.
For Python 3 scripts use:

Code: Select all

python3 /path/script.py
Or as mentioned make sure you have a proper 'shebang' as first line.

Code: Select all

#!/usr/bin/python3
If the file is then made executable the script can be started like this:

Code: Select all

/path/script.py
or

Code: Select all

./script.py
Thank you, I did know that. My point was setting the standard python to python3.
What I read elsewhere here is a bit disturbing -- python2 still rules although python 3 has been around for some time and
the situation does not appear to change soon. a pity really...

User avatar
jahboater
Posts: 7158
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Python 3.x as standard

Mon Sep 24, 2018 5:28 pm

bonzadog wrote:
Mon Sep 24, 2018 4:58 pm
Well, I bet your statement will not find very much resonance.
Well I agree with Heater.
C has been around for 45 years.
It has changed a lot over that time and been used for more than half the software in the world.
At no time has there been anything comparable to the Python2/Python3 debacle.

User avatar
scruss
Posts: 4172
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Python 3.x as standard

Mon Sep 24, 2018 7:03 pm

jahboater wrote:
Mon Sep 24, 2018 5:28 pm
C has been around for 45 years.
It has changed a lot over that time and been used for more than half the software in the world.
At no time has there been anything comparable to the Python2/Python3 debacle.
I dunno, though: K&R → ANSI felt fairly painful in the late 80s. Some old/small systems are stuck with K&R compilers, which makes modern C less compatible than it could be. Not that I'm saying modern enterprise-grade C should run on old/small systems unaltered, but it's an issue.

Not all the standardized languages are standardized the same way. Fortran and especially JavaScript are defined descriptively: mostly to capture what people are doing, with a little bit of guidance towards what people should be doing. Other languages have much more prescriptive standards. And then there's BASIC, which has had a descriptive ANSI standard since the 1970s yet almost no-one used or uses ANSI Full BASIC as it's quite unlike Microsoft's version.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Mon Sep 24, 2018 7:26 pm

scruss,
I dunno, though: K&R → ANSI felt fairly painful in the late 80s.
Yes, and that was my point.

C made the transition from a toy language created by a couple of hackers from Bell Labs to a mature language during that time. Starting in 1983 and reaching an standard international standard in 1989.

Python has yet to make that step to maturity.

You are right. Standardization is complicated. Seems to me the most successful standards codify best practice at the time, an agreement among stake holders (compiler vendors, users etc). They don't try to dictate what has not been implemented.

The BASIC standard never stood a chance. ANSI could write what they like but Microsoft owned the game and was not interested in standardization. BASIC is of course another toy language as a result.
Memory in C++ is a leaky abstraction .

User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Python 3.x as standard

Mon Sep 24, 2018 7:37 pm

jahboater wrote:
Mon Sep 24, 2018 5:28 pm
bonzadog wrote:
Mon Sep 24, 2018 4:58 pm
Well, I bet your statement will not find very much resonance.
Well I agree with Heater.
C has been around for 45 years.
It has changed a lot over that time and been used for more than half the software in the world.
At no time has there been anything comparable to the Python2/Python3 debacle.
Personally, I like C.....and still use it.

User avatar
jahboater
Posts: 7158
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Python 3.x as standard

Mon Sep 24, 2018 9:19 pm

scruss wrote:
Mon Sep 24, 2018 7:03 pm
I dunno, though: K&R → ANSI felt fairly painful in the late 80s.
Yes, big changes. I used C professionally all through that.
But the compilers that I used happily worked with both, even in the same program if my memory serves me correctly (it was a long time ago!).
I don't ever remember this hard divide that Python has now.
That is, I never had to choose between using a K&R compiler, or a C89 compiler, or a C99 compiler.
Heater wrote:
Mon Sep 24, 2018 7:26 pm
C made the transition from a toy language created by a couple of hackers from Bell Labs to a mature language during that time. Starting in 1983 and reaching an standard international standard in 1989.
You were probably speaking figuratively, but I have to comment that C was never a toy language - it was after all created to rewrite UNIX in its modern multi-user form.
It started off from day one being able to produce compilers, operating systems, editors, phototypesetting software etc. The languages that it was derived from were also in the same league.
... and "a couple of hackers" is a unworthy description of Dennis Ritchie et al.
It started in 1972 by the way, not 1983 (according to this anyway https://en.wikipedia.org/wiki/C_(programming_language) ).

hippy
Posts: 10208
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python 3.x as standard

Mon Sep 24, 2018 10:56 pm

jahboater wrote:
Mon Sep 24, 2018 9:19 pm
scruss wrote:
Mon Sep 24, 2018 7:03 pm
I dunno, though: K&R → ANSI felt fairly painful in the late 80s.
Yes, big changes. I used C professionally all through that.
But the compilers that I used happily worked with both, even in the same program if my memory serves me correctly (it was a long time ago!).
I don't ever remember this hard divide that Python has now.
That is, I never had to choose between using a K&R compiler, or a C89 compiler, or a C99 compiler.
You were lucky. Some time after I was having to write C code which would compile no matter what our customers were using and that was quite an effort. Thankfully that was before anyone imagined-up C++.

What surprised me most was that nearly all of our customers believed that was impossible having fallen foul of their own efforts to migrate code to other compilers, most believed they were effectively locked-in to their initial choice.

I'll admit I did have the advantage of coding from the ground up, was developing incrementally so could develop, test, tweak, which is a whole lot better than trying to get an entire code base ported in one hit.

I don't subscribe to the belief that Python or K&R C are toy languages. Toy languages are those designed with specific intent with known but acceptable deficiencies. They aren't intended to be general purpose production languages. Python and C were intended to be general purpose and production quality and achieved that.

But it's not worth arguing with those determined to denigrate other programming languages.

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Tue Sep 25, 2018 2:37 am

jahboater,

Yes, I was speaking figuratively when I said "toy" and perhaps a bit to playfully. I did not mean to demean C but rather indicate the change from a new language, undergoing changes and used by few to a "grown up" language with as standard, a standards committee, multiple vendors and a large user base building critical systems with it.

Also I don't mean "couple of hackers" as a slur on Ritchie and co. They were world class hackers. Much respected and an inspiration to all. But the whole Unix/C thing was a quick hack, skunk works, project compared to the likes of the Multics project they worked on.

Certainly C started way before 1983. I was referring to the beginning of the ANSI standardization process. When C started to mature.
Memory in C++ is a leaky abstraction .

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Tue Sep 25, 2018 2:44 am

Hippy,
Toy languages are those designed with specific intent with known but acceptable deficiencies.
Hmm... So C is a "toy" language then.

Designed with the specific intent to be a low level systems programming language that could make Unix portable.

C has many deficiencies designed in that were deemed acceptable for it's purpose. See "undefined behavior" in the standards.

This definition of "toy" does not work for me.
Memory in C++ is a leaky abstraction .

hippy
Posts: 10208
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python 3.x as standard

Tue Sep 25, 2018 10:18 am

Heater wrote:
Tue Sep 25, 2018 2:44 am
This definition of "toy" does not work for me.
That's fine. Perhaps you could define exactly what makes a language a mature or a toy language for you. It seems to me you are suggesting any language not on the path to becoming an officially recognised standard is merely a toy language.

I have a programming language which I use to code VC4 Bare Metal programs which is extremely limited, allows only the simplest of constructs and operations which I genuinely consider a toy language because its purpose and intent is purely to allow me to do what I want, doesn't allow what anyone would want from a general purpose language. That has evolved without any care or consideration for usability, consistency or even ease of use. It's good for "playing with VC4" but not good for anything else. Hence "toy".

I cannot consider Python, K&R C, nor any of the other commonly used languages which have not been standardised, toy languages in the same way.

User avatar
bonzadog
Posts: 272
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Python 3.x as standard

Tue Sep 25, 2018 10:46 am

We are now way off topic but I must say that the discussion is interesting.

I dislike the use of the word toy because it has no real meaning. A lot
of people who read this are not native English speakers.

Python 3 is a very powerful language with a huge amount of import possibility (pypi)
I would like to see a bitter GUI maker than tkinker, I am trying wxpython but am having
installation problem on the RPi, but the output in the docs. looks professional.

regards to all

NT

hippy
Posts: 10208
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python 3.x as standard

Tue Sep 25, 2018 12:21 pm

bonzadog wrote:
Tue Sep 25, 2018 10:46 am
I dislike the use of the word toy because it has no real meaning. A lot of people who read this are not native English speakers.
My take on it is that "toy" in context means something one might "play with" but is not the preference beyond that. Like the zany tie one might wear to the office party but not to a board meeting, the skateboard one might whiz around the park on but wouldn't use for distance commuting, the small hammer one might use to knock tacks in but would not use on a construction site. They are things which are usable but not necessarily appropriate for use, good for amateurs or okay in an emergency but not what professionals would choose for day-in and day-out use.

I don't find the term "toy" derogatory when legitimately applied, but it does become a slur when not legitimately applied.

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Tue Sep 25, 2018 12:53 pm

hippy,
Perhaps you could define exactly what makes a language a mature or a toy language for you.
Perhaps I should not have used the word "toy". I tried to spell out what I meant by it in this context a couple of times here already. For example: https://www.raspberrypi.org/forums/view ... 7#p1369603 but it seems people are still taking it the wrong way.
It seems to me you are suggesting any language not on the path to becoming an officially recognised standard is merely a toy language.
I have no idea if Python is on the path to standardization or not. Or even if the Python community cares about such things. As long as it has no standard, is still evolving, breaks backwards compatibility etc then it is in toy land. A wobbly toddler among the grown ups. As was C in it's early days.

Note: My use of "toy" here does not say anything about the actual merits of the language itself, only it's state of development. Its a perfectly fine and powerful language. Not my cup of tea but that is another story.

Note: "toy" is often used to refer to a little languages students create in their compiler writing classes, just an exercise never intended to be used by anyone. I have created a couple of such toy languages myself. I don't mean that either.
Memory in C++ is a leaky abstraction .

hippy
Posts: 10208
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python 3.x as standard

Tue Sep 25, 2018 1:08 pm

Heater wrote:
Tue Sep 25, 2018 12:53 pm
My use of "toy" here does not say anything about the actual merits of the language itself, only it's state of development.
And that is perhaps the crux of the problem; using "toy" in a manner which will be perceived other than in the way you are using it or intended.

Using "mature", "immature", "developed", "under-developed", "standardised", "non-standardised", or something which accurately reflects what the state of development is would avoid the negative and derogatory overtones that labelling something a "toy" has.

We have seen the same issue when applied to Pi itself. That the early Pi's were less mature, less capable, less developed, than the later models, does not make them "toys" as some have suggested they are. As you seem to be doing yourself by your definition of what exists in "toy land".
Heater wrote:
Tue Sep 25, 2018 12:53 pm
Note: "toy" is often used to refer to a little languages students create in their compiler writing classes, just an exercise never intended to be used by anyone. I have created a couple of such toy languages myself. I don't mean that either.
Maybe not, but people will most often assume you mean it how they would mean it, exactly as you describe, particularly when theirs is the generally accepted meaning. That's why we have to be careful with the words we choose to use. If you define one thing as a toy language you can't really blame people when they think that is what you mean when you call something else a toy language.

Heater
Posts: 18344
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 3.x as standard

Tue Sep 25, 2018 1:37 pm

I do understand the confusion hippy. "Toy" is ambiguous. Hence my carefully defining what I meant by the word the first time I used it here:
https://www.raspberrypi.org/forums/view ... 7#p1369460 and subsequently reiterating that.

I even did what you suggest in that first post: "This situation is far from being a "mature language""



"When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean—neither more nor less."
Memory in C++ is a leaky abstraction .

pootle
Posts: 410
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: Python 3.x as standard

Wed Sep 26, 2018 8:11 am

Ignore the letters used and any similarity between single letters or sequences of letters as in "python" and "python3" They are different languages, with quite a lot of superficial similarities.

Yes it is irritating when you find some hacker has used (recently) python to write a library and you want to write in python3, but then the same applies when the library has been written in C or anything else that isn't python3. At least is is usually very simple to convert python to python3.

At least it is trivially easy to have both languages running side by side, unlike (say) different versions of excel where having to be able to run spreadsheets with (at least) 3 different versions of excel on the same windows 4 desktop was quite challenging.

I just wish we'd hurry up and get to Python3.7 which has some really useful extra goodies.

Paul Hutch
Posts: 577
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: Python 3.x as standard

Thu Sep 27, 2018 6:02 pm

bonzadog wrote:
Tue Sep 25, 2018 10:46 am
I would like to see a bitter GUI maker than tkinker, I am trying wxpython but am having
installation problem on the RPi, but the output in the docs. looks professional.
I started using Python only about a year ago and very quickly abandoned Tkinter and wxPython. I like PyQt best for writing cross platform GUI programs.

Return to “Python”