Selenium py3.8+ DepreciationWarnings - where to find doc to update code?
Selenium 3.141+
python 3.8+
ubuntu 20.04 or windows 10
I'm trying to upgrade code from py3.6+ to py3.8+ and I'm getting several
DepreciationWarnings.
Can someone point me to where I can find the documentation that explains how to
to remedy these warnings. What are the new preferred coding practices?
For example, here is a "DepreciationWarning" that I figured out:
py3.6+
from selenium import webdriver
browser = browser = webdriver.Firefox()
browser.get(url)
tables = browser.find_elements_by_tag_name("table")
py3.8+
from selenium import webdriver
from selenium.webdriver.common.by import By
browser = browser = webdriver.Firefox()
browser.get(url)
tables = browser.find_elements(By.TAG_NAME, "table")
or
tables = browser.find_elements(By.XPATH, "//table")
--
https://mail.python.org/mailman/listinfo/python-list
Re: sum() vs. loop
On Mon, 11 Oct 2021 at 23:00, Christian Gollwitzer wrote: > > Am 10.10.21 um 10:49 schrieb Steve Keller: > > I have found the sum() function to be much slower than to loop over the > > operands myself: > > > > def sum_products(seq1, seq2): > > return sum([a * b for a, b in zip(seq1, seq2)]) > > > > def sum_products2(seq1, seq2): > > sum = 0 > > for a, b in zip(seq1, seq2): > > sum += a * b > > return sum > > > > In a program I generate about 14 million pairs of sequences of ints each > > of length 15 which need to be summed. The first version with sum() needs > > 44 seconds while the second version runs in 37 seconds. > > The first version constructs a list, sums it up and throws the list > away, while the second version only keeps the running sum in memory. How > about a generator expression instead, i.e. > > > sum((a * b for a, b in zip(seq1, seq2))) What really matters in cases like this is interpreter overhead. Typically a generator expression has slightly more overhead compared to a list comprehension. You get a slightly slower per-item speed in exchange for O(1) memory consumption. A list comprehension like result = sum([expr for foo in bar]) Translates internally to something like: def _func(): data = [] for foo in bar: data.append(foo) return foo _stuff = _func() result = sum(_stuff) Running this really does bring in the overhead of a function call _func() because it needs to create a frame with locals and so on. However it is only the cost of a single function call. Afterwards if the elements in the list _stuff are built in types like int etc with builtin __add__ methods then sum(_stuff) does not involve the interpreter at all: it's a built-in function operating on a built-in container of built-in objects. With a generator expression like result = sum(expr for foo in bar) This translates internally to def _genfunc(): for foo in bar: yield foo _gen = _genfunc() result = sum(_gen) Now the _genfunc() function call simply creates the generator and sets up its frame which I think is more or less equivalent to the overhead of the _func() function call. However the sum(_gen) line is no longer a pure built-in operation. Internally each time sum calls _gen.__next__() the execution frame for _genfunc() is reactivated so that the interpreter can execute the bytecodes taking the frame from one yield to the next. This is almost the overhead of a function call for each item in bar although this is often unnoticeable in practice and other factors can affect this. The fastest version eliminates the interpreter altogether at least when operating on pure built-in elements: In [7]: nums1 = nums2 = list(range(10**5)) In [10]: %timeit sum([a*b for a, b in zip(nums1, nums2)]) 9.83 ms ± 21.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) In [11]: %timeit sum((a*b for a, b in zip(nums1, nums2))) 10.3 ms ± 109 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) In [12]: from operator import mul In [13]: %timeit sum(map(mul, nums1, nums2)) 7.25 ms ± 33 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) Of course if the elements being multiplied and summed have pure-Python __add__/__mul__ methods or the container has a pure Python __iter__/__next__ then any of those methods will typically dominate the runtime over any of the overheads considered here. -- Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: Mailing list activity low
Maybe bounced by your mail provider. Try changing to another ESP such as gmail. On Wed, Oct 13, 2021 at 1:45 AM Antoon Pardon wrote: > Have I missed something and has the maillinglist been moved. Activity is > very low here, about one message every five days. > > Antoon Pardon. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
RE: sum() vs. loop
Yes, Stefan, I realized that and did not test more thoroughly. Chris pointed it out too. I indeed deleted the names but a second reference remained so I may be wrong and the function may just keep track of the position and return one tuple at a time. That would be a good design, unless there was a worry the original might be changed out from under. My apologies if it was understood to mean I had shown it was copied. -Original Message- From: Python-list On Behalf Of Stefan Ram Sent: Tuesday, October 12, 2021 9:49 PM To: [email protected] Subject: Re: sum() vs. loop "Avi Gross" writes: >I did a test where I made two list called A and B and used zip to make >an object holding the two and then removed A and B. I was able to print >the list of tuples just fine with print(list(C)) so clearly it is not >so much a pure iterator as one that holds yet another copy of both lists! You may have "deleted the names", but not the lists. a =[ 10, 11, 12 ] b =[ 20, 21, 22 ] c = zip( a, b ) del a[ 0 ], a[ 0 ], a[ 0 ] del b[ 0 ], b[ 0 ], b[ 0 ] print( a, b, list( c )) prints [] [] [] here. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: spyder does not work under root! [linux]
Às 22:54 de 11/10/21, Chris Angelico escreveu: > On Tue, Oct 12, 2021 at 8:52 AM Paulo da Silva > wrote: >> >> Hi! >> >> I need to debug a python3 script under root. I tried spyder but it does >> not work. >> >> Running as root without --no-sandbox is not supported. See >> https://crbug.com/638180. >> >> Thanks for any comments including alternative solutions to debug as root. >> > > Did you try reading the linked bug report? Or running it with --no-sandbox? > Yes. It is about a web browser! Why are 2 python debuggers related with a web browser?! As per spyder, there is no such switch --no-sandbox! Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: spyder does not work under root! [linux]
Às 02:08 de 12/10/21, Michael Torrie escreveu: > On 10/8/21 4:32 PM, Paulo da Silva wrote: >> Às 22:56 de 08/10/21, Paulo da Silva escreveu: >>> Hi! >>> >>> I need to debug a python3 script under root. I tried spyder but it does >>> not work. >>> >>> Running as root without --no-sandbox is not supported. See >>> https://crbug.com/638180. >>> >>> Thanks for any comments including alternative solutions to debug as root. >>> >> I also tried with eric and curiously it gave the same message!! >> >> This seems crazy. > > Not so crazy. It's incredibly dangerous to run a web browser as root. > There's no reason I can think of for running a python script driving a > web browser as root. spyder and eric are both python editors/debuggers! Why are they related with web browsers?! Thanks -- https://mail.python.org/mailman/listinfo/python-list
[ANN] PyYAML-6.0 Released
=
Announcing PyYAML-6.0
=
A new release of PyYAML is now available:
https://github.com/yaml/pyyaml/releases/tag/6.0
The previously-deprecated default loader selection in `yaml.load()` has
been removed; `Loader` is now a required argument.
Support for Python 2.7 and 3.5 has been dropped, and support for Python 3.10
added. It now includes libyaml 0.2.5 extension wheels for MacOS M1
(Apple Silicon/arm64), Linux s390x and Linux aarch64.
Numerous other bugfixes and code cleanups are included in this release.
Changes
===
* https://github.com/yaml/pyyaml/pull/327 -- Change README format to
Markdown
* https://github.com/yaml/pyyaml/pull/483 -- Add a test for YAML 1.1 types
* https://github.com/yaml/pyyaml/pull/497 -- fix float resolver to ignore
`.` and `._`
* https://github.com/yaml/pyyaml/pull/550 -- drop Python 2.7
* https://github.com/yaml/pyyaml/pull/553 -- Fix spelling of “hexadecimal”
* https://github.com/yaml/pyyaml/pull/556 -- fix representation of Enum
subclasses
* https://github.com/yaml/pyyaml/pull/557 -- fix libyaml extension compiler
warnings
* https://github.com/yaml/pyyaml/pull/560 -- fix ResourceWarning on leaked
file descriptors
* https://github.com/yaml/pyyaml/pull/561 -- always require `Loader` arg to
`yaml.load()`
* https://github.com/yaml/pyyaml/pull/564 -- remove remaining direct
distutils usage
Resources
=
PyYAML Matrix: https://matrix.to/#/#pyyaml:yaml.io
PyYAML IRC Channel: #pyyaml on irc.libera.chat
PyYAML homepage: https://github.com/yaml/pyyaml
PyYAML documentation: http://pyyaml.org/wiki/PyYAMLDocumentation
Source and binary installers: https://pypi.org/project/PyYAML/
GitHub repository: https://github.com/yaml/pyyaml/
Bug tracking: https://github.com/yaml/pyyaml/issues
YAML homepage: http://yaml.org/
YAML-core mailing list:
http://lists.sourceforge.net/lists/listinfo/yaml-core
About PyYAML
YAML is a data serialization format designed for human readability and
interaction with scripting languages. PyYAML is a YAML parser and emitter
for
Python.
PyYAML features a complete YAML 1.1 parser, Unicode support, pickle support,
capable extension API, and sensible error messages. PyYAML supports standard
YAML tags and provides Python-specific tags that allow to represent an
arbitrary Python object.
PyYAML is applicable for a broad range of tasks from complex configuration
files to object serialization and persistence.
Example
===
```
>>> import yaml
>>> yaml.full_load("""
... name: PyYAML
... description: YAML parser and emitter for Python
... homepage: https://github.com/yaml/pyyaml
... keywords: [YAML, serialization, configuration, persistence, pickle]
... """)
{'keywords': ['YAML', 'serialization', 'configuration', 'persistence',
'pickle'], 'homepage': 'https://github.com/yaml/pyyaml', 'description':
'YAML parser and emitter for Python', 'name': 'PyYAML'}
>>> print(yaml.dump(_))
name: PyYAML
homepage: https://github.com/yaml/pyyaml
description: YAML parser and emitter for Python
keywords: [YAML, serialization, configuration, persistence, pickle]
```
Maintainers
===
The following people are currently responsible for maintaining PyYAML:
* Ingy döt Net
* Matt Davis
and many thanks to all who have contributed!
See: https://github.com/yaml/pyyaml/pulls
Copyright
=
Copyright (c) 2017-2021 Ingy döt Net
Copyright (c) 2006-2016 Kirill Simonov
The PyYAML module was written by Kirill Simonov .
It is currently maintained by the YAML and Python communities.
PyYAML is released under the MIT license.
See the file LICENSE for more details.
--
https://mail.python.org/mailman/listinfo/python-list
Re: spyder does not work under root! [linux]
On 2021-10-13 19:09:43 +0100, Paulo da Silva wrote: > Às 02:08 de 12/10/21, Michael Torrie escreveu: > > On 10/8/21 4:32 PM, Paulo da Silva wrote: > >> Às 22:56 de 08/10/21, Paulo da Silva escreveu: > >>> I need to debug a python3 script under root. I tried spyder but it does > >>> not work. > >>> > >>> Running as root without --no-sandbox is not supported. See > >>> https://crbug.com/638180. > >>> > >>> Thanks for any comments including alternative solutions to debug as root. > >>> > >> I also tried with eric and curiously it gave the same message!! > >> > >> This seems crazy. > > > > Not so crazy. It's incredibly dangerous to run a web browser as root. Mostly because a web browser is usually used to interpret untrusted content from other sites ... > > There's no reason I can think of for running a python script driving > > a web browser as root. ... but this doesn't apply if the browser is just a display for a locally running script. The script is already running as root. It can do all the evil stuff without the help of a browser. > spyder and eric are both python editors/debuggers! Why are they > related with web browsers?! They probably use a browser engine to implement the GUI. This isn't uncommon. See Electron (https://www.electronjs.org/) for example. I didn't see anything on the Spyder website about how it is implemented (I didn't look very hard) but the error message hints that there's a Chromium hidden somewhere. And Eric uses Qt5, and Chromium is derived from WebKit which is Qt's browser engine. It's a bit weird that this also refers to Chromium's bug tracker and not Qt's, but there's certainly a common ancestry here. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | [email protected] |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: spyder does not work under root! [linux]
On 10/13/21 12:09 PM, Paulo da Silva wrote: > spyder and eric are both python editors/debuggers! Why are they related > with web browsers?! Good point. I was going off of the chromium bug report. My bad. I mistook Spyder for Selenium, which is a web scraping scripting engine that does use a real browser. Oops. However, for better or worse, browser engines power all kinds of apps these days, including IDEs. I do not know if Spyder is powered by Chromium or not. VS Code, for example, is powered by a web browser engine. As to Eric and Qt, I can't speak to that. -- https://mail.python.org/mailman/listinfo/python-list
Re: Selenium py3.8+ DepreciationWarnings - where to find doc to update code?
On Wednesday, 13 October 2021 at 16:16:46 UTC+1, jkk wrote:
> Selenium 3.141+
> python 3.8+
> ubuntu 20.04 or windows 10
>
> I'm trying to upgrade code from py3.6+ to py3.8+ and I'm getting several
> DepreciationWarnings.
>
> Can someone point me to where I can find the documentation that explains how
> to to remedy these warnings. What are the new preferred coding practices?
>
> For example, here is a "DepreciationWarning" that I figured out:
>
> py3.6+
> from selenium import webdriver
> browser = browser = webdriver.Firefox()
> browser.get(url)
> tables = browser.find_elements_by_tag_name("table")
>
>
> py3.8+
> from selenium import webdriver
> from selenium.webdriver.common.by import By
> browser = browser = webdriver.Firefox()
> browser.get(url)
> tables = browser.find_elements(By.TAG_NAME, "table")
> or
> tables = browser.find_elements(By.XPATH, "//table")
I cannot help you with your immediate problem but am intrigued to discover what
your “browser = browser = “ idiom does that differs from “browser =
“.
--
https://mail.python.org/mailman/listinfo/python-list
