On Wed, Feb 10, 2021 at 5:33 PM Paul Moore <p.f.moore@gmail.com> wrote:
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.
I am not sure this idea works fine. Is the activate script always called when venv is used on Windows? When I use venv on Unix, I often just execute .venv/bin/some-script without activating the venv.
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.
Students may need to learn about encoding at some point. But when they learn "how to read/write file" first time, they don't need to know what encoding is. VSCode, notepad, PyCharm use UTF-8 by default. Students don't need to learn how to use encoding other than UTF-8 until really need it.
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.
We can add "Enable the UTF-8 mode" checkbox to the installer. And we can have "Enable the UTF-8 mode" tool in the start menu. So students don't need to edit the ini file manually. The problem is; should we recommend to enable UTF-8 mode globally by setting environment variable, or provide a per-site UTF-8 mode setting?
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.
They may not want to promote UTF-8 mode until official Python promote UTF-8 mode. So I think venv should support UTF-8 mode first.
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.
Because it solves many real world problem that many Windows users suffer. -- Inada Naoki <songofacandy@gmail.com>