Re: If you have Python Cookbook, 3rd ed.

2021-05-21 Thread Terry Reedy

On 5/19/2021 2:57 PM, Terry Reedy wrote:
can you verify that the Algorithm chapter (near end in 2nd ed.) does 
*NOT* have an introduction by Tim Peters?

(Info needed to verify timeit doc correction
https://github.com/python/cpython/pull/21744)


Thank you to 2 respondents.  I have gone ahead with the patch.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Use Chrome's / Firefox's dev-tools in python

2021-05-21 Thread Chris Angelico
On Sat, May 22, 2021 at 3:55 AM max pothier  wrote:
>
> Hello,
> Thanks for you answer!
> Actually my goal is not to automatically get the file once I open the page, 
> but more to periodically check the site and get a notification when there's 
> new homework or, at the morning, know when an hour is cancelled, so I don't 
> want to have to open the browser every time.
> I have pretty good javascript knowledge so if you could better explain that 
> idea, it would be a great help.
>

Ahh, now I better understand your purpose. Hmm.

First and by far the best option would be to see if there's any sort
of (documented or undocumented) API. See if you can figure out how the
requests are being done, and try to find a pre-request request that is
hinting at the download address. (You might have to do some
exploration here.)

Secondly, it may be possible to do an occasional manual check, but
then keep your login cookie alive by periodic queries by your
automated script. No idea how well that would work.

Third, your worst case might be to do most of the work in JavaScript,
maybe as a Chrome extension, but then have it call a Python script
(via an HTTP request, since that's how JavaScript in a browser can
best notify anything) to do whatever extra work you need Python for.
Not sure how well that would work.

Unfortunately it depends a LOT on the homework server you're working
with, so it's hard to be specific. On the plus side, though, you're
going to learn all kinds of things along the way! Or maybe that's
another downside, depending on how Daily WTF-worthy the site is

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Instantiating abstract classes

2021-05-21 Thread Peter Otten

Usually an abstract class cannot be instantiated:

>>> from abc import ABCMeta, abstractmethod
>>> from fractions import Fraction
>>> class A(Fraction, metaclass=ABCMeta):
@abstractmethod
def frobnicate(self): pass


>>> A()
Traceback (most recent call last):
  File "", line 1, in 
A()
  File "C:\Program Files\Python39-32\lib\fractions.py", line 93, in __new__
self = super(Fraction, cls).__new__(cls)
TypeError: Can't instantiate abstract class A with abstract method 
frobnicate



However, if I derive from a builtin class that mechanism doesn't work:

>>> class A(int, metaclass=ABCMeta):
@abstractmethod
def frobnicate(self): pass


>>> A()
0

Is this a bug, or an implementation accident, or the expected behavior?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Use Chrome's / Firefox's dev-tools in python

2021-05-21 Thread max pothier
Hello,
Thanks for you answer!
Actually my goal is not to automatically get the file once I open the page, but 
more to periodically check the site and get a notification when there's new 
homework or, at the morning, know when an hour is cancelled, so I don't want to 
have to open the browser every time.
I have pretty good javascript knowledge so if you could better explain that 
idea, it would be a great help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: If you have Python Cookbook, 3rd ed.

2021-05-21 Thread Bischoop
On 2021-05-19, Terry Reedy  wrote:
> can you verify that the Algorithm chapter (near end in 2nd ed.) does 
> *NOT* have an introduction by Tim Peters?
> (Info needed to verify timeit doc correction
> https://github.com/python/cpython/pull/21744)

Preface .. xi
1.Data Structure adn Algorithms.1
1.1 Unpacking a Sequence into Separate Variables1
1.2 Unpacking Elements from Iterables of Arbitrary Lenght   3
1.2 Keeping the Last N items5
1.3 Finding the Largest or Smallest N itemst7

Third Edition.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python at SpaceX

2021-05-21 Thread Terry Reedy

https://stackoverflow.blog/tag/software-in-space/
has 4 links to interviews.  2 specifically mention Python.

https://stackoverflow.blog/2021/05/11/testing-software-so-its-reliable-enough-for-space/
"Python “is for backend test running, build orchestration, and all our 
web servers are python-based. It’s a lot of little scripts and a lot of 
big web services. "


https://stackoverflow.blog/2021/05/11/building-a-space-based-isp/
"Starlink software, both in satellites and on the ground, is written 
almost exclusively in C++, with some prototyping development in Python."


“For development and test of these algorithms, we have a full-scale 
network simulation running in continuous integration on a 
high-performance computing cluster. This simulation is capable of 
running the C++ production code as well as running against prototype 
code written in Python,”


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Re: Unexpected Inheritance Problem

2021-05-21 Thread Grant Edwards
On 2021-05-20, Terry Reedy  wrote:
> On 5/20/2021 2:53 PM, Grant Edwards wrote:
>> On 2021-05-20, Mats Wichmann  wrote:
>>
>>> many fonts squish together repeated underscores in the display so it's
>>> hard to see this visually,
>> 
>> Is it just me, or does it seem foolish to use such fonts for
>> editing/browsing source code...
>
> Windows [...]

Ah, I think I see the underlying problem. ;)

--
Grant



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python install failing. Install log is available.

2021-05-21 Thread Michael Torrie
On 5/21/21 8:25 AM, Mats Wichmann wrote:
> An install for all users will drop it into someplace different - by 
> default at the top of the drive, so e.g. C:\Python39.

I just did an install of 3.9 on Windows 10. There was an option to
install the launcher for all users but no option for installing Python
for all users if you go through with the default install options.  When
I chose to install the launcher for all users, it still installed Python
in the my user local AppData... path.

In order to select to install for all users, I had to choose custom
options during the install. Then I could choose to install for all
users, and it let me select a path which defaulted to C:\Program
Files\Python39.  As well I selected to place Python in the path, which
it did.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python install failing. Install log is available.

2021-05-21 Thread Mats Wichmann

On 5/21/21 4:21 AM, jan via Python-list wrote:

OK, but

1. should the installer work for administrator + all users or not?

2. if not, should the installer work for me (a non-admin) and install
python correctly and successfully for my account if I run it in my
account, not the admin?


It should, and for many, it does.

An ordinary install, not "for all users", defaults to your own
AppData\Local\Programs\Python  - the pattern you see in your 
Administrator install. So you don't seem to have installed that one for 
all users.


I don't think you want to do a user-install using the administrator 
account. If you tell it to add to PATH, I believe it adds to the user 
variables in this case, so other accounts won't see that.  The Python 
launcher should help with this part of the problem, as Terry said, but 
only if other users are able to work with things installed in admin's 
account-local locations.


An install for all users will drop it into someplace different - by 
default at the top of the drive, so e.g. C:\Python39.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python install failing. Install log is available.

2021-05-21 Thread jan via Python-list
OK, but

1. should the installer work for administrator + all users or not?

2. if not, should the installer work for me (a non-admin) and install
python correctly and successfully for my account if I run it in my
account, not the admin?

thanks

jan

On 20/05/2021, Terry Reedy  wrote:
> On 5/20/2021 7:06 AM, jan via Python-list wrote:
>
>> This time it's simply not installing correctly when run as
>> administrator, and not at all when run as non-administrator.
>>
>> As administrator, it's not installing for other users as I believe it
>> should.
>>
>> It's certainly not adding the python path correctly *for all users*
>
>> C:\WINDOWS\system32>whoami
> ...
>> Any thoughts?
>
> On Windows, use the py launcher to launch python.  It was added as the
> solution to problems with adding python paths, including problems with
> multiple installs and those with removing them.
>
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list