[RELEASE] Python 3.9.1 is now available, together with 3.10.0a3 and 3.8.7rc1

2020-12-07 Thread Pablo Galindo Salgado
It's starting to get very cold (at least on the Northern hemisphere) so we have been carefully packaging a total of three new Python releases to keep you warm these days! Python 3.9.1 is the first maintenance release of Python 3.9, and also the first version of Python to support macOS 11 Big Sur n

Re: Letter replacer - suggestions?

2020-12-07 Thread dn via Python-list
On 08/12/2020 12:15, Marco Sulla wrote: On Tue, 8 Dec 2020 at 00:10, dn via Python-list wrote: The translation phase is most easily achieved with the built-in str.translate() I forgot it :-) That's down to the rich-ness of the Python eco-system! IIRC (from previous posts) the OP is teachi

Re: list of dictionaries search using kwargs

2020-12-07 Thread Marco Sulla
On Mon, 7 Dec 2020 at 23:35, Larry Martell wrote: > > On Mon, Dec 7, 2020 at 5:29 PM Marco Sulla > wrote: > > > > You can return dictionaries that returns True if > > > > (a.items() & kwargs.items()) == kwargs.items() > > > > when `a` is one of your dicts. > > But what is passed in kwargs will n

Re: Letter replacer - suggestions?

2020-12-07 Thread Marco Sulla
On Tue, 8 Dec 2020 at 00:10, dn via Python-list wrote: > The translation phase is most easily achieved with the built-in > str.translate() I forgot it :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Letter replacer - suggestions?

2020-12-07 Thread dn via Python-list
word = input('input word you want to change letters in: ') chars = tuple(word) change_this = input('Enter the letters you want to change: ') replace_with = input('Enter the letters to replace with: ') if len(change_this) != len(replace_with): raise RuntimeError( "Letters to replace

Re: list of dictionaries search using kwargs

2020-12-07 Thread MRAB
On 2020-12-07 22:06, Larry Martell wrote: I have a class that has an object that contains a list of dicts. I want to have a class method that takes a variable number of key/value pairs and searches the list and returns the item that matches the arguments. If I know the key value pairs I can do s

Re: Error

2020-12-07 Thread Michael Torrie
On 12/7/20 11:30 AM, MRAB wrote: > There's no need to remove Python 3.9 first; Python 3.8 can be installed > alongside it. Since the original poster is invoking python.exe directly, probably as per the instructions in the book he's following, I fear having two versions of python installed will ju

Re: list of dictionaries search using kwargs

2020-12-07 Thread Larry Martell
On Mon, Dec 7, 2020 at 5:42 PM Matt Wheeler wrote: > > for item in self.data: > if all(item[k] == v for k,v in kwargs.items()): > return item > > Or > > return [item for item in self.data if all(item[k] == v for k,v in > kwargs.items())] > > to return all matches > > Beware though tha

Re: list of dictionaries search using kwargs

2020-12-07 Thread Matt Wheeler
for item in self.data:     if all(item[k] == v for k,v in kwargs.items()):         return item Or return [item for item in self.data if all(item[k] == v for k,v in kwargs.items())] to return all matches Beware though that either of these will be slow if your list of dicts is large. If the list

Re: list of dictionaries search using kwargs

2020-12-07 Thread Larry Martell
On Mon, Dec 7, 2020 at 5:29 PM Marco Sulla wrote: > > You can return dictionaries that returns True if > > (a.items() & kwargs.items()) == kwargs.items() > > when `a` is one of your dicts. But what is passed in kwargs will not necessarily have values for all of the keys and I only want to check f

Re: list of dictionaries search using kwargs

2020-12-07 Thread Marco Sulla
You can return dictionaries that returns True if (a.items() & kwargs.items()) == kwargs.items() when `a` is one of your dicts. -- https://mail.python.org/mailman/listinfo/python-list

Re: Letter replacer - suggestions?

2020-12-07 Thread Marco Sulla
Not sure why you want to do this (it's schoolwork)? Anyway, this is my version: word = input('input word you want to change letters in: ') chars = tuple(word) change_this = input('Enter the letters you want to change: ') replace_with = input('Enter the letters to replace with: ') if len(change_t

list of dictionaries search using kwargs

2020-12-07 Thread Larry Martell
I have a class that has an object that contains a list of dicts. I want to have a class method that takes a variable number of key/value pairs and searches the list and returns the item that matches the arguments. If I know the key value pairs I can do something like this: instance = next(item fo

Re: linear algebric equations

2020-12-07 Thread Dan Stromberg
On Mon, Dec 7, 2020 at 11:36 AM Tito Sanò wrote: > Regarding the solution of linear algebraic equations I noticed a big > difference in the computation > > time in Python compared to the old fortran language. > > I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with > the for

Re: Letter replacer - suggestions?

2020-12-07 Thread Chris Angelico
On Tue, Dec 8, 2020 at 7:11 AM Jon Ribbens via Python-list wrote: > > On 2020-12-07, Chris Angelico wrote: > > On Tue, Dec 8, 2020 at 6:41 AM Grant Edwards > > wrote: > >> On 2020-12-07, MRAB wrote: > >> > Avoid a 'bare' except unless you _really_ mean it, which is > >> > virtually never. Catc

Re: Letter replacer - suggestions?

2020-12-07 Thread Jon Ribbens via Python-list
On 2020-12-07, Chris Angelico wrote: > On Tue, Dec 8, 2020 at 6:41 AM Grant Edwards > wrote: >> On 2020-12-07, MRAB wrote: >> > Avoid a 'bare' except unless you _really_ mean it, which is >> > virtually never. Catch only those exceptions that you're going to >> > handle. >> >> And sometimes "ha

Re: Letter replacer - suggestions?

2020-12-07 Thread inhahe
Besides what others have said (especially re using a dict instead), I think it's unpythonic/can result in unexpected behavior to change a list as it's being iterated over. Your modified word_list should be a separate list, I think. Also, if you use enumerate(), you won't have to use .index and it w

Re: Letter replacer - suggestions?

2020-12-07 Thread Chris Angelico
On Tue, Dec 8, 2020 at 6:51 AM Schachner, Joseph wrote: > > The only comment I have is that you didn't check the inputs at all. Suppose > the word I type in is "1234". 1234 will turn into an int, not a string. > You can't index through an int, it's one thing. So the program will probably > t

Re: Letter replacer - suggestions?

2020-12-07 Thread Chris Angelico
On Tue, Dec 8, 2020 at 6:41 AM Grant Edwards wrote: > > On 2020-12-07, MRAB wrote: > > > Avoid a 'bare' except unless you _really_ mean it, which is > > virtually never. Catch only those exceptions that you're going to > > handle. > > And sometimes "handling" is just printing some extra stuff and

RE: Letter replacer - suggestions?

2020-12-07 Thread Schachner, Joseph
The only comment I have is that you didn't check the inputs at all. Suppose the word I type in is "1234". 1234 will turn into an int, not a string. You can't index through an int, it's one thing. So the program will probably throw an error. If the word at least starts with a letter, then it

Re: Letter replacer - suggestions?

2020-12-07 Thread Grant Edwards
On 2020-12-07, MRAB wrote: > Avoid a 'bare' except unless you _really_ mean it, which is > virtually never. Catch only those exceptions that you're going to > handle. And sometimes "handling" is just printing some extra stuff and then re-raising the original exception: try: somethin

linear algebric equations

2020-12-07 Thread Tito Sanò
Regarding the solution of linear algebraic equations I noticed a big difference in the computation time in Python compared to the old fortran language. I have compared both the linelg and lapack.dgesv-lapack.zgesv modules with the fortan: dgelg and f04adf. The difference in computation time is

Re: Learning tkinter - a grid problem

2020-12-07 Thread Terry Reedy
On 12/6/2020 5:59 AM, Terry Reedy wrote: On 12/6/2020 3:11 AM, Sibylle Koczian wrote: Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop()

Re: Error

2020-12-07 Thread MRAB
On 2020-12-07 18:29, Mats Wichmann wrote: On 12/7/20 11:13 AM, Michael Torrie wrote: On 12/7/20 11:07 AM, Barry Fitzgerald wrote: I did the pip install I did the pip install pygameThe pip install pgzero I get this error C:\Users\barol>pip install pgzeroDefaulting to user installation because no

Re: Error

2020-12-07 Thread MRAB
On 2020-12-07 18:13, Michael Torrie wrote: On 12/7/20 11:07 AM, Barry Fitzgerald wrote: I did the pip install I did the pip install pygameThe pip install pgzero I get this error C:\Users\barol>pip install pgzeroDefaulting to user installation because normal site-packages is not writeableCollecti

Re: Error

2020-12-07 Thread Mats Wichmann
On 12/7/20 11:13 AM, Michael Torrie wrote: On 12/7/20 11:07 AM, Barry Fitzgerald wrote: I did the pip install I did the pip install pygameThe pip install pgzero I get this error C:\Users\barol>pip install pgzeroDefaulting to user installation because normal site-packages is not writeableCollecti

Re: Error

2020-12-07 Thread Michael Torrie
On 12/7/20 11:07 AM, Barry Fitzgerald wrote: > I did the pip install I did the pip install pygameThe pip install > pgzero I get this error C:\Users\barol>pip install pgzeroDefaulting > to user installation because normal site-packages is not > writeableCollecting pgzero Using cached pgzero-1.2-py3

Re: Letter replacer - suggestions?

2020-12-07 Thread MRAB
On 2020-12-07 15:48, Bischoop wrote: I worked on my wee script that replaces a letters: https://bpa.st/OYBQ . I would like to have some suggestions about the code from more experienced programmers, the code does work and do its job but perhaps could work in a better way. Thanks > word = inpu

Letter replacer - suggestions?

2020-12-07 Thread Bischoop
I worked on my wee script that replaces a letters: https://bpa.st/OYBQ . I would like to have some suggestions about the code from more experienced programmers, the code does work and do its job but perhaps could work in a better way. Thanks -- https://mail.python.org/mailman/listinfo/python-li

Re: how to plot the FFT of a list of values

2020-12-07 Thread Thomas Jollans
On 05/12/2020 23:08, Christian Gollwitzer wrote: Am 05.12.20 um 18:16 schrieb Boris Dorestand: I have 16 values of the period sequence 1, 2, 4, 8, 1, 2, 4, 8, ...  I compute its fourier transform using from scipy import fft, ifft x = [1,2,4,8,1,2,4,8] fft(x) array([ 30. +0.j,   0. +0.j,  -6.+

Re: Best-practice for formatted string literals and localization?

2020-12-07 Thread Hartmut Goebel
Am 01.12.20 um 19:40 schrieb Dieter Maurer: Usually, the translation machinery has special ways to provide parameters for translations. For example with `zope.i18nmessageid`, you can use `_(msg, mapping=)` to provide parameters to the translations -- as in your case `count`). Check, what paramete

Re: Best-practice for formatted string literals and localization?

2020-12-07 Thread Hartmut Goebel
Am 30.11.20 um 19:58 schrieb Chris Angelico: Not really, no. Thanks for confirming my apprehension. -- Regards Hartmut Goebel | Hartmut Goebel | h.goe...@crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible | -- https://mail.pyth