Audacity and pipe_test.py
I am trying to adapt this short file to be used for simple control of the Audacity audio recording program. I can get the following does to work: do_command("Record1stChoice") #Creates a new track and starts recording do_command("AddLabel:") #Places a label in the label track do_command("Stop") # stops the recording But not this one: do_command("SetLabel:Label='1' Text='Hello' ") This is supposed to place "Hello" into the label. Steve Foonote: The patient shall strive to suffer the symptoms of the disease that has been diagnosed by the doctor. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: PYTHON BUG. deleting elements of list.
Peter Otten wrote: > If the list is huge you can also delete in reverse order: > > for i in reversed(len(_list)): Make that reversed(range(len(_list))). > if discard(_list[i]): > del _list[i] Example: >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i, item in enumerate(items): ... if item in "bcd": ... del items[i] ... >>> items ['a', 'c', 'e'] >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i in reversed(range(len(items))): ... if items[i] in "bcd": ... del items[i] ... >>> items ['a', 'e'] -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: PYTHON BUG. deleting elements of list.
On Wed, Sep 9, 2020 at 5:45 PM Peter Otten <__pete...@web.de> wrote: > > Peter Otten wrote: > > > If the list is huge you can also delete in reverse order: > > > > for i in reversed(len(_list)): > > Make that reversed(range(len(_list))). > > > if discard(_list[i]): > > del _list[i] > > Example: > > >>> items = ['a', 'b', 'c', 'd', 'e'] > >>> for i, item in enumerate(items): > ... if item in "bcd": > ... del items[i] > ... > >>> items > ['a', 'c', 'e'] > >>> items = ['a', 'b', 'c', 'd', 'e'] > >>> for i in reversed(range(len(items))): > ... if items[i] in "bcd": > ... del items[i] > ... > >>> items > ['a', 'e'] > But that's still pretty clunky AND inefficient (deleting from the middle of a list is a slow operation). Filtering is far better. items = [i for i in items if i not in "bcd"] And if you absolutely have to mutate in place: items[:] = [i for i in items if i not in "bcd"] ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: PYTHON BUG. deleting elements of list.
On Wed, Sep 9, 2020 at 8:52 AM Chris Angelico wrote: [snip] > And if you absolutely have to mutate in place: > > items[:] = [i for i in items if i not in "bcd"] How does that work to mutate in place? -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: PYTHON BUG. deleting elements of list.
On Wed, Sep 9, 2020 at 6:18 PM Nicholas Cole wro > > On Wed, Sep 9, 2020 at 8:52 AM Chris Angelico wrote: > > [snip] > > And if you absolutely have to mutate in place: > > > > items[:] = [i for i in items if i not in "bcd"] > > How does that work to mutate in place? Technically it constructs a new filtered list, and then replaces the contents of the original list with the filtered one. That's effectively an in-place mutation; any other reference to that same list will see the change. Compare: a = list(range(20)) b = a a = [n for n in a if n % 3] print(a) print(b) You'll see that a and b now differ. But if you use slice assignment: a[:] = [n for n in a if n % 3] you'll see that the two are still the same list (and "a is b" will still be True). It's replacing the contents, rather than rebinding the name. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: PYTHON BUG. deleting elements of list.
On 9/8/20 5:18 PM, Richard Damon wrote: > On 9/8/20 7:06 PM, Mats Wichmann wrote: >> On 9/7/20 5:01 PM, Driuma Nikita wrote: >> for i, el in enumerate(_list[:]): >> del _list[i] >> > The issue isn't so much that he is modifying the list that he is > iterating over, but also when he deletes _list[0], all the other > elements move down, yes, quite right, brain fail here, ignore me -- https://mail.python.org/mailman/listinfo/python-list
Re: Module exists and cannot be found
> On 9 Sep 2020, at 06:35, James Moe via Python-list > wrote: > > python 3.6.10 > opensuse tumbleweed > linux 5.8.4 > > An old program based on Python (BackInTime) has recently been having > difficulties functioning. See below. > > Module PyQt5 is most definitely installed. Apparently there is more to getting > modules loaded than there used to be. How did you check you have PyQt5 is installed like this? $ python3.6 >>> import PyQt5 If that works then. How do you run the app? > > (Also, I am not familiar with Python.) > > [ error message (verbose option) ] > Traceback (most recent call last): > File "/home/jmoe/diy/backintime-master/qt/app.py", line 35, in >import qttools > File "", line 971, in _find_and_load > File "", line 955, in _find_and_load_unlocked > File "", line 665, in _load_unlocked > File "", line 678, in exec_module > File "", line 219, in _call_with_frames_removed > File "/home/jmoe/diy/backintime-master/qt/qttools.py", line 21, in >from PyQt5.QtGui import (QFont, QColor, QKeySequence) > File "", line 971, in _find_and_load > File "", line 941, in _find_and_load_unlocked > File "", line 219, in _call_with_frames_removed > File "", line 971, in _find_and_load > File "", line 953, in _find_and_load_unlocked > ModuleNotFoundError: No module named 'PyQt5' > [ end ] I forget what does seeing frozen importlib imply? A free stand app with embedded python maybe? > > [ the 1st code lines causing the above ] > qttools.py: > import os > import sys > import gettext > from PyQt5.QtGui import (QFont, QColor, QKeySequence) <<<-- line 21 > ... > > app.py: > import os > import sys > > if not os.getenv('DISPLAY', ''): >os.putenv('DISPLAY', ':0.0') > > import datetime > import gettext > import re > import subprocess > import shutil > import signal > from contextlib import contextmanager > from tempfile import TemporaryDirectory > > import qttools<<<--- line 35 > qttools.registerBackintimePath('common') > ... > [ end ] > > -- > James Moe > jmm-list at sohnen-moe dot com > Think. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Python download problem
Good evening, I would like to ask for help regarding Python installation , I'm a beginner and I would like to challenge myself to start coding using Python language , but unfortunately I'm having problems while installing it , I used python.org to install the latest Windows version of Python ( 3.8.5) on my Windows 10 64 bit computer , after clicking on this link to download the file Windows (x86-64 executable installer) I opened it and check the boxes , I continued with the steps until it was successfully downloaded . After that I opened CMD and this screen appeared for me I wrote python --version then enter and I got error 'python' is not recognized as an internal or external command,operable program or batch file. I tried to fix it following these steps as the following Edit the system environment variables>>environment variables >>Path >>edit>>browse .exe path C:\Program Files\Python38>>ok (this is the link that I paste in the path) C:\Program Files\Python38 and same problem occurred . I opened Python IDLE , then I wrote Print("HI") >> enter , and I got HI as a result Does that mean that it is python is working fine on my PC and if yes , can I use IDLE to run the future scripts instead of CMD or I need to fix the CMD ? Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: newbie
On 9/8/20 7:24 PM, Grant Edwards wrote: > On 2020-09-08, Don Edwards wrote: > >> I may need. My aim is to write a program >> that simulates croquet - 2 balls colliding with the strikers (cue) ball >> going into the hoop (pocket), not the target ball. I want to be able to >> move the balls around and draw trajectory lines to evaluate different >> positions. Is there a package for this or maybe one to draw and one to >> move? Any help much appreciated. > > Is pygame still a thing? Yes. https://www.pygame.org/. Should be in most Linux distributions' repositories. -- https://mail.python.org/mailman/listinfo/python-list
Re: Module exists and cannot be found
Op 09-09-2020 om 07:35 schreef James Moe via Python-list: python 3.6.10 opensuse tumbleweed Tumbleweed is a rolling distro, so that is extremely old for Tumbleweed. I would expect Python 3.8.4 or 3.8.5 to be current there. If you want to use another version, you would have to run in a virtual environment. Did you do that? linux 5.8.4 Module PyQt5 is most definitely installed. How did you check? You want to be in the same virtual environment the program runs in. From my installation (openSuse Leap, so there I run Python 3.6): Python 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import PyQt5 Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'PyQt5' >>> No PyQt5 as I do not have a Qt program in the environment :=) Vriendelijke groet/Kind regards, Menno Hölscher -- https://mail.python.org/mailman/listinfo/python-list
Re: Python download problem
On 2020-09-09 10:23, Talin Alnaber wrote: Good evening, I would like to ask for help regarding Python installation , I'm a beginner and I would like to challenge myself to start coding using Python language , but unfortunately I'm having problems while installing it , I used python.org to install the latest Windows version of Python ( 3.8.5) on my Windows 10 64 bit computer , after clicking on this link to download the file Windows (x86-64 executable installer) I opened it and check the boxes , I continued with the steps until it was successfully downloaded . After that I opened CMD and this screen appeared for me I wrote python --version then enter and I got error 'python' is not recognized as an internal or external command,operable program or batch file. I tried to fix it following these steps as the following Edit the system environment variables>>environment variables >>Path >>edit>>browse .exe path C:\Program Files\Python38>>ok (this is the link that I paste in the path) C:\Program Files\Python38 and same problem occurred . I opened Python IDLE , then I wrote Print("HI") >> enter , and I got HI as a result Does that mean that it is python is working fine on my PC and if yes , can I use IDLE to run the future scripts instead of CMD or I need to fix the CMD ? These days it's recommended to use the Python launcher: py --version -- https://mail.python.org/mailman/listinfo/python-list