requests-html 0.10.0 stopped rendering

2020-09-12 Thread nhpython
Windows 10 x64 Pro v10.0.19041.488 build 19041
2020-09 Cumulative Update for Win 10 Ver 2004 for x64 KB4571756
2020-09 Cumulative Update for .NET Framework 3.5 & 4.8 for Win 10 Ver 2004 for 
x64 KB4576478
requests-html 0.10.0
pyppeteer 0.2.2
python 3.7+
requests 2.24

I've been using requests-html 0.10.0 (with requests) for a little over a week 
and it has been working perfectly until yesterday after windows updates.
The problem is that will not render.
I verified that requests-html fetches the webpage and returns HTTP status_code 
200, successful response.
The rendering process, just hangs.

I've uninstalled and reinstalled the modules to force the reinstallation of the 
chrome engine.
requests-html 
pyppeteer

And it still didn't render.

Who knows where to post issues with requests-html?

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


Why doesn't collections.Counter support a "key" argument in its constructor?

2020-09-12 Thread Saurav Chirania
I really like that python's sort method accepts a key function as a
parameter which can be used to specify how elements should be compared.

Similarly, we could have a "key" argument which specifies how elements
should be counted. Let's say we have a list of a million students. I would
like to do something like:
c = Counter(students, key = lambda student: student.marks)

which would return a Counter which maps marks to the number of students
with that marks. Let's say 29 students in the list had scored 100 marks, so
one entry in the counter would be key=100, val=29.

So, why doesn't Counter's constructor support this argument? Are there
other pythonic ways to do this?

Regards,
Saurav Chirania
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Audacity and pipe_test.py

2020-09-12 Thread Chris Angelico
On Sun, Sep 13, 2020 at 2:33 AM Dennis Lee Bieber  wrote:
>
> On Thu, 10 Sep 2020 18:22:29 -0400, "Steve"  declaimed
> the following:
>
> >Your line worked except that I used copy/paste to place it in the program.
> >I kept on getting something like "improper indentation or tab" and pointing
> >to the end of that line.  I guess hidden characters were imbedded and when I
> >deleted all spaces before and after the paste, then placed them in again,
> >those hiddens went away.
> >
> Most likely your source had a series of spaces, my post had a leading
> .
>
> In Python, a  is counted as EIGHT spaces, even if an editor only
> moved in by four spaces.

Only in legacy versions of Python. In current versions, a tab is
counted as a tab.

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


Re: Why doesn't collections.Counter support a "key" argument in its constructor?

2020-09-12 Thread Chris Angelico
On Sun, Sep 13, 2020 at 2:29 AM Saurav Chirania
 wrote:
>
> I really like that python's sort method accepts a key function as a
> parameter which can be used to specify how elements should be compared.
>
> Similarly, we could have a "key" argument which specifies how elements
> should be counted. Let's say we have a list of a million students. I would
> like to do something like:
> c = Counter(students, key = lambda student: student.marks)
>
> which would return a Counter which maps marks to the number of students
> with that marks. Let's say 29 students in the list had scored 100 marks, so
> one entry in the counter would be key=100, val=29.
>
> So, why doesn't Counter's constructor support this argument? Are there
> other pythonic ways to do this?
>

If I'm interpreting this correctly, a comprehension should work for you:

c = Counter(student.marks for student in students)

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


Re: Why doesn't collections.Counter support a "key" argument in its constructor?

2020-09-12 Thread Peter Otten
Saurav Chirania wrote:

> I really like that python's sort method accepts a key function as a
> parameter which can be used to specify how elements should be compared.
> 
> Similarly, we could have a "key" argument which specifies how elements
> should be counted. Let's say we have a list of a million students. I would
> like to do something like:
> c = Counter(students, key = lambda student: student.marks)
> 
> which would return a Counter which maps marks to the number of students
> with that marks. Let's say 29 students in the list had scored 100 marks,
> so one entry in the counter would be key=100, val=29.
> 
> So, why doesn't Counter's constructor support this argument? Are there
> other pythonic ways to do this?

Yes, as the counter won't store the original student there is no advantage 
over the direct translation of your code

Counter(map(lambda: student.marks, students))

or the more elegant variant with a generator expression

Counter(student.marks for student in students)

Functions like max() which do offer a key arg are a bit different as

max(student.marks for student in students)

returns the highest marks whereas

max(students, key=lambda: student.marks)

returns the student with the highest marks. To spell the latter without a 
key arg would require something more complicated like

max((s.marks, i, s) for i, s in enumerate(students))[-1]

If you need to count the marks while remembering the students you would use 
a dict or defaultdict instead of a counter,

d = defaultdict(list)
for s in students:
d[s.marks] = s

or, if the students are sorted by marks, itertools.groupby().

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


Re: requests-html 0.10.0 stopped rendering

2020-09-12 Thread nhpython


> On 09/12/2020 11:28 AM nhpython  wrote:
> 
>  
> Windows 10 x64 Pro v10.0.19041.488 build 19041
> 2020-09 Cumulative Update for Win 10 Ver 2004 for x64 KB4571756
> 2020-09 Cumulative Update for .NET Framework 3.5 & 4.8 for Win 10 Ver 2004 
> for x64 KB4576478
> requests-html 0.10.0
> pyppeteer 0.2.2
> python 3.7+
> requests 2.24
> 
> I've been using requests-html 0.10.0 (with requests) for a little over a week 
> and it has been working perfectly until yesterday after windows updates.
> The problem is that will not render.
> I verified that requests-html fetches the webpage and returns HTTP 
> status_code 200, successful response.
> The rendering process, just hangs.
> 
> I've uninstalled and reinstalled the modules to force the reinstallation of 
> the chrome engine.
> requests-html 
> pyppeteer
> 
> And it still didn't render.
> 
> Who knows where to post issues with requests-html?
> 
> -- 


Despite not knowing where to post issues, I solved my own problem. Steps taken.

1. uninstalled module: requests-html
2. uninstalled module: pyppeteer
3. deleted DIR: C:\Users\ME\AppData\Local\pyppeteer

Step 2 removed: 
C:\Users\ME\AppData\Local\Programs\Python\Python37\Lib\site-packages\pyppeteer
However it did not remove the existing chrome engine. To delete the Chrome 
Engine I had to delete its top folder.
Step 3 deleted the top folder which contained the chrome engine. 
. 
(C:\Users\ME\AppData\Local\pyppeteer\pyppeteer\local-chromium\588429\chrome-win32\chrome.exe)

Then when I reinstalled the requests-html module, the deletion of 
.\Local\pyppeteer\ forced the download & reinstallation of the chrome engine. 
This action brought down a new copy of the chrome engine which now works 
perfectly.

Apparently, the new windows updates unregistered the former copy of chrome.exe 
and replacing it was necessary. However, simply uninstalling the pyppeteer 
module did not remove the version of chrome associated with it. I had to find 
its(.\588429\chrome-win32\chrome.exe) location and delete it manually before 
re-installing the module requests-html.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Audacity and pipe_test.py

2020-09-12 Thread Steve
>>My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  
>>lines

>   The first does nothing for Audacity processing -- it only blocks the
>Python script itself. And you haven't provided the Audacity command
>completely -- since I can't find that on the script reference page.

You are correct.  I use the py timer to pause the commands being sent to the
pipe.  There seems to be something fluky about that too.  It looks as if
when I have four or more do_commands, it doesn't run as a timer.  Takes more
scrutiny...

I am not sure how I lost the entire Audacity command for the Audacity time
control. Still, I need a timer in there somewhere. 
Time will tell (-:

"ENDIF, ENDFOR, ENDWHILE statements" do exist in my python program.  I place
them as comments to document the end of the operations. It makes it easier
for me to follow the logic especially if they are nested.

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Friday, September 11, 2020 1:32 PM
To: [email protected]
Subject: Re: Audacity and pipe_test.py

On Thu, 10 Sep 2020 18:22:29 -0400, "Steve"  declaimed
the following:

>Your line worked except that I used copy/paste to place it in the program.
>I kept on getting something like "improper indentation or tab" and 
>pointing to the end of that line.  I guess hidden characters were 
>imbedded and when I deleted all spaces before and after the paste, then 
>placed them in again, those hiddens went away.
>
Most likely your source had a series of spaces, my post had a
leading .

In Python, a  is counted as EIGHT spaces, even if an editor
only moved in by four spaces.

Python uses indentation to indicate the block structure of the
language
-- you'll note there are no { } (C or Java), nor ENDIF, ENDFOR, ENDWHILE
statements.

>Also, this language certainly does not like spaces at all except where 
>IT wants them. The values for ThisList[T] entries were two words, words 
>with spaces between. No go  I removed spaces and replaced them with 
>- where I wanted them, and it is working really nicely.
>

If this is in response to my /first/ post, I forgot to include the '
'
delimiters around the string argument. That meant the command you were
sending to Audacity was seeing three or more parameters, not two. Python
didn't care at that point. If you have the ' ' in place, then Audacity is
the application that is complaining.

>My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150")  
>lines

The first does nothing for Audacity processing -- it only blocks the
Python script itself. And you haven't provided the Audacity command
completely -- since I can't find that on the script reference page.



-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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

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


Re: Why doesn't collections.Counter support a "key" argument in its constructor?

2020-09-12 Thread Random832
On Fri, Sep 11, 2020, at 12:01, Saurav Chirania wrote:
> I really like that python's sort method accepts a key function as a
> parameter which can be used to specify how elements should be compared.
> 
> Similarly, we could have a "key" argument which specifies how elements
> should be counted. Let's say we have a list of a million students. I would
> like to do something like:
> c = Counter(students, key = lambda student: student.marks)
> 
> which would return a Counter which maps marks to the number of students
> with that marks. Let's say 29 students in the list had scored 100 marks, so
> one entry in the counter would be key=100, val=29.
> 
> So, why doesn't Counter's constructor support this argument? Are there
> other pythonic ways to do this?

I'd like to add to this discussion that a feature like this would not be 
unreasonable to have on all dictionaries, and when I have wanted it in the past 
it has been on WeakKeyDictionary, for which the obvious workaround of making a 
wrapper class that uses the key function for __eq__ and __hash__ isn't usable
-- 
https://mail.python.org/mailman/listinfo/python-list