On Wed, 10 Feb 2021 at 07:14, Christopher Barker firstname.lastname@example.org wrote:
On Tue, Feb 9, 2021 at 1:04 PM Paul Moore email@example.com wrote:
Why is that an issue? In the first instance, do the sorts of "beginner" we're discussing here have multiple python installs? Would they need per-interpreter configuration of UTF-8 mode?
yes -- many, many tutorials, particularly about web frameworks, start with "make a new virtual environment". To the point that many of my students have thought that was a requirement to use, e.g. flask.
So get PYTHONUTF8 added to the environment activate script. That's a simple change to venv. And virtualenv, and conda - yes, it need to happen in multiple places, but that's still easier IMO than proposing a change to Python's already complex (and slower than many of us would like) startup process.
Personally, I do not start out with environments with my beginning students -- they really only need one at the early stages. But other instructors do.
Others have to work with a locked down system provided by their employer that might be an older version of Python, or need some particular configuration that they don't want to override.
And all the examples given here of how to set environment variables and shortcuts, etc on Windows is EXACTLY the kind of information I don't want to have to provide for my students :-( -- I'm teaching Python, not Windows administration.
So teach Python as it actually is, surely? If you teach people how to use "Python-with-UTF8-mode", won't they struggle when introduced to the real world where UTF8 mode isn't set? Won't they assume the default encoding for open() is UTF-8, and be confused when they are wrong? Yes, I know your job as an instructor is to omit confusing details, and UTF8 mode would help with that. I get that. But that's just one case.
And anyway, would you not have to explain how to set UTF-8 mode for the training environment one way or another anyway? Sure, you may not have to explain how to set an environment variable. But you have to explain how to configure an ini file instead. Unless UTF-8 mode is the default, you have to explain how to configure the training environment one way or another - unless you provide a pre-packaged environment (in which case we're back to why not just set an env variable).
I don't want to recommend env vars and registry for conda and portable Python users...
and a lot of newbies learning Python for data science are starting out with conda as well ...
So conda could set UTF-8 mode with "conda env --new --utf8". No changes to core Python interpreter startup needed.
I'm not sure what you mean here. Why is this different from (say) PYTHONPATH? How would conda and portable python users configure PYTHONPATH? Why is UTF-8 mode any different?
It's not -- using PYTHONPATH is a "bad idea" I never recommend it to anyone. It was a nightmare when folks have Python 2 and 3 on the same machine, but now, in the age of environments, it's still a really bad idea.
Sure, PYTHONPATH was just an example. Environment variables are how you configure Python in many ways. I'm asking why UTF-8 mode is so special it needs a different configuration mechanism than every other setting for Python.
It's really important to support configuration per environment these days. Ideally with any of the "environment" tools.
That's a completely different discussion, and as you stated it, doesn't just apply to UTF-8 mode. It should be a different thread. And my immediate answer would be that you can do this by changing the activation scripts. Yes, that means each environment tool needs to be updated individually, but that would be a reasonable start. If the feature proves important, it could later be migrated into a core feature.