"py.ini" question

Ralf M. Ralf_M at t-online.de
Sun Apr 25 15:05:41 EDT 2021


Am 25.04.2021 um 16:30 schrieb Mats Wichmann:
> 
> On 4/24/21 2:57 PM, Chris Angelico wrote:
>> On Sun, Apr 25, 2021 at 5:57 AM Gisle Vanem <gisle.vanem at gmail.com> 
>> wrote:
>>>
>>> With 'py -3.6' or 'py 3.8' I get the expected.
>>> But with 'py -3':
>>>     Python 3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit 
>>> (AMD64)] on win32
>>>
>> I believe that's because you're asking for "the latest in the 3.x 
>> series".
> 
> unless differently described by the ini file, which is what the OP is 
> trying to do.
> 
> I just added a 3.10 alpha to my Windows setup (I don't do my programming 
> there, so there hadn't been any need), and set up an ini file to leave 
> 3.9 as the default and all works as expected - py -0, py, py -3, py 
> -3.10 all given me the one I would expect to get based on that setup (-0 
> shows 3.9-64 starred, despite 3.10-64 being "the latest).
> 
> Personally stumped why it's not working for Gisle.

I think the problem / misunderstanding is that Gisle put in py.ini only
  [defaults]
  python=3.6

and expected this to make py -3 start 3.6. However py -3 looks for a key 
named 'python3' and, not finding it, uses default behaviour (ignoring 
the 'python' key), i.e. starts the most modern stable 3.x.

The py.ini documentation is a bit hard to find in the help file and hard 
to understand as the interesting part talks about environment variables 
and shebang line commands, not py.ini settings and py.exe parameters. 
However, the behaviour is the same in both cases and the relevant 
example is:

"If PY_PYTHON=3.1-32, the command python will use the 32-bit 
implementation of 3.1 whereas the command python3 will use the latest 
installed Python (PY_PYTHON was not considered at all as a major version 
was specified.)"

I tried the (rather insane) py.ini
  [defaults]
  python=3.7
  python2=3.8
  python4=2.7
and it works as documented (py -3 shows default behaviour as there is no 
'python3' in py.ini):

C:\>py
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 
64 bit(AMD64)] on win32
C:\>py -2
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 
bit (AMD64)] on win32
C:\>py -3
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 
bit (AMD64)] on win32
C:\>py -4
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:19:08) [MSC v.1500 32 
bit (Intel)] on win32






More information about the Python-list mailing list