Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-13 Thread Terry Reedy

On 8/13/2021 6:53 AM, Umang Goswami wrote:

Hi There, Hope you find this mail in good health.

I am Umang Goswami, a Python developer and student working on a huge
project for automation of music instruments. I am producing the musical
notes using the Beep function of Winsound Module(
https://docs.python.org/3/library/winsound.html) by passing frequency as a
argument to the function.

Now whenever i provide frequency of any note in decimal(for example
277.1826 for C4 note) it shows following error:
Traceback (most recent call last):
   File "C:\Users\Umang Goswami\Desktop\Umang  Goswami\test.py", line 2, in

 winsound.Beep(111.11,11)
TypeError: integer argument expected, got float

Now I have  to round up the frequencies. This is hurting the quality,
accuracy ,authenticity and future of the project. Almost all the notes have
the frequencies  in decimal parts. Rounding up means changing semitones and
quatertones thus whole note itself. This problem is technically making my
program useless.

Its my humble request to you all, I beg you, Please tell me how to overcome
this issue. I have consulted many sources both online and offline but I
remained unsatisfied. I can not make audio files of each note because there
are many many notes and so practically making so many files of different
time length wont help.

Please suggest to me the way to resolve this issue or is there any other
module to produce the sound of decimal frequency.


Without knowing what sources you have already looked at, anything anyone 
might say might be duplication.  However,...


If the builtin hardware sound generator only generates integral 
frequencies, you are stuck unless you get an add-in card that is more 
flexible.  If the Windows interface to the hardware only accepts 
integral frequencies, which I suspect might be true, ditto, unless you 
get custom software.  You could look at pygame and see what its sound 
functions do.  And search pypi for 'sound generator' or 'frequency 
generator'.


--
Terry Jan Reedy

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


Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-13 Thread Chris Angelico
On Sat, Aug 14, 2021 at 2:11 AM Terry Reedy  wrote:
>
> On 8/13/2021 6:53 AM, Umang Goswami wrote:
> > Hi There, Hope you find this mail in good health.
> >
> > I am Umang Goswami, a Python developer and student working on a huge
> > project for automation of music instruments. I am producing the musical
> > notes using the Beep function of Winsound Module(
> > https://docs.python.org/3/library/winsound.html) by passing frequency as a
> > argument to the function.
> >
> > Now whenever i provide frequency of any note in decimal(for example
> > 277.1826 for C4 note) it shows following error:
> > Traceback (most recent call last):
> >File "C:\Users\Umang Goswami\Desktop\Umang  Goswami\test.py", line 2, in
> > 
> >  winsound.Beep(111.11,11)
> > TypeError: integer argument expected, got float
> >
> > Now I have  to round up the frequencies. This is hurting the quality,
> > accuracy ,authenticity and future of the project. Almost all the notes have
> > the frequencies  in decimal parts. Rounding up means changing semitones and
> > quatertones thus whole note itself. This problem is technically making my
> > program useless.
> >

Is it really? In my experience, no human ear can distinguish 277Hz
from 277.1826Hz when it's played on a one-bit PC speaker, which the
Beep function will be using.

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


Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-13 Thread MRAB

On 2021-08-13 17:17, Chris Angelico wrote:

On Sat, Aug 14, 2021 at 2:11 AM Terry Reedy  wrote:


On 8/13/2021 6:53 AM, Umang Goswami wrote:
> Hi There, Hope you find this mail in good health.
>
> I am Umang Goswami, a Python developer and student working on a huge
> project for automation of music instruments. I am producing the musical
> notes using the Beep function of Winsound Module(
> https://docs.python.org/3/library/winsound.html) by passing frequency as a
> argument to the function.
>
> Now whenever i provide frequency of any note in decimal(for example
> 277.1826 for C4 note) it shows following error:
> Traceback (most recent call last):
>File "C:\Users\Umang Goswami\Desktop\Umang  Goswami\test.py", line 2, in
> 
>  winsound.Beep(111.11,11)
> TypeError: integer argument expected, got float
>
> Now I have  to round up the frequencies. This is hurting the quality,
> accuracy ,authenticity and future of the project. Almost all the notes have
> the frequencies  in decimal parts. Rounding up means changing semitones and
> quatertones thus whole note itself. This problem is technically making my
> program useless.
>


Is it really? In my experience, no human ear can distinguish 277Hz
from 277.1826Hz when it's played on a one-bit PC speaker, which the
Beep function will be using.

I've just tried it on my PC and I couldn't hear the difference, except 
that odd frequencies had a momentary break in them during longer notes 
whereas even frequencies didn't. Very odd...

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


Can't get rid of old version of python

2021-08-13 Thread Ciarán Ó Duibhín via Python-list

Hi,

On Windows 10, I uninstalled all previous versions of Python and 
installed v3.9.6.


When I use the start menu option Python 3.9 (64-bit), I get the prompt 
"Python 3.9.6" as expected.  The same happens when I type "py" at the 
DOS prompt.


But when I type "python" at the DOS prompt, I get "Python 3.8.10".  I 
don't understand this, as I uninstalled old versions, and I do not see a 
DOS environment variable called "python" anywhere.


The real problem comes when I install a package, e.g. germalemma.  
Python 3.8.10 can use it, but Python 3.9.6 can't find it.


I notice that "site-packages" containing germalemma and its dependencies 
is located in 
...Packages\PythonSoftwareFoundationPython.3.8.qbz5n2kfra8p0\LocalCache\local-packages\Python3.8


Also there is a load of python 3.8 stuff at C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0 
which directory is virtually inaccessible from Windows but can be listed 
in DOS.


How can I get rid of Python 3.8.10 , and install my packages to 3.9.6?

Ciarán Ó Duibhín
--
https://mail.python.org/mailman/listinfo/python-list


Re: pip doesn't work

2021-08-13 Thread Dennis Lee Bieber
On Fri, 13 Aug 2021 10:19:36 +0530, Ridit 
declaimed the following:

>   So, whoever gets this, when I try to download packages using pip, it shows
>   errors saying "'pip' is not recognized as an internal or external command,
>   operable program or batch file." Is there a way to solve this? I tried
>   modifying, even repairing three times, but still it doesn't work. If you
>   have a solution, thank you.

If you really want PIP as a stand-alone executable, you need to add its
location to the system PATH environment variable. {Which will also make
everything else in /Scripts available to the command line.

Alternatively, you invoke Python passing it a "-m pip 
" (without the ")


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

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


Re: on slices, negative indices, which are the equivalent procedures?

2021-08-13 Thread Michael F. Stemper

On 11/08/2021 20.17, dn wrote:



I've been trying to remember if we had negative-steps in FORTRAN
do-loops


My text for Fortran 77 (the last version that I ever used) says
that negative increments are supported.

Ref: _FORTRAN 77: Language and Style_; Michael J. Merchant;
Wadsworth Publishing Company; (c) 1981; Page 125

It also says that zero increments are not supported. (Whew!)

--
Michael F. Stemper
87.3% of all statistics are made up by the person giving them.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can't get rid of old version of python

2021-08-13 Thread Dennis Lee Bieber
On Fri, 13 Aug 2021 18:32:51 +, Ciarán Ó Duibhín via Python-list
 declaimed the following:

>
>Also there is a load of python 3.8 stuff at C:\Program 
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0
> 
>which directory is virtually inaccessible from Windows but can be listed 
>in DOS.
>
>How can I get rid of Python 3.8.10 , and install my packages to 3.9.6?
>
You probably can't... The keyword being "WindowApps".

That version likely was installed using the Win10 "app store" (aka:
"microsoft store"). You can open that, click the ... and pick "my library",
pick "installed" and likely find a Python entry. But the appstore does not
allow one to delete downloaded apps! It MIGHT be removable if you locate a
"Python" icon on the start-menu and right click "uninstall" -- but make
sure it is not YOUR Python...

The simplest method would be to ensure YOUR Python is at the top of the
PATH environment variable so it is found first when searching for
applications.


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

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


Re: Can't get rid of old version of python

2021-08-13 Thread Terry Reedy

On 8/13/2021 2:32 PM, Ciarán Ó Duibhín via Python-list wrote:

Hi,

On Windows 10, I uninstalled all previous versions of Python and 
installed v3.9.6.


When I use the start menu option Python 3.9 (64-bit), I get the prompt 
"Python 3.9.6" as expected.  The same happens when I type "py" at the 
DOS prompt.


But when I type "python" at the DOS prompt, I get "Python 3.8.10".  I 
don't understand this, as I uninstalled old versions, and I do not see a 
DOS environment variable called "python" anywhere.


The real problem comes when I install a package, e.g. germalemma. Python 
3.8.10 can use it, but Python 3.9.6 can't find it.


If 'py' starts 3.9, then

py -m pip install xyz

will install xyz for 3.9.  (In not, py -3.9 -m pip ... will)

The command 'python' takes one to the MS store unless one has already 
gotten the store python.


--
Terry Jan Reedy


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


Re: Can't get rid of old version of python

2021-08-13 Thread Eryk Sun
On 8/13/21, Ciarán Ó Duibhín via Python-list  wrote:
>
> But when I type "python" at the DOS prompt, I get "Python 3.8.10".  I
> don't understand this, as I uninstalled old versions, and I do not see a
> DOS environment variable called "python" anywhere.

The app distribution is probably installed. You can uninstall it in
the "Apps" view of the settings apps. The app should be named "Python
3.8" from "Python Software Foundation". Alternatively, if you want to
keep the app distribution, you can simply remove interfering aliases.
Towards the top, there's a link to set "App execution aliases". You
can disable all of the Python-related aliases, or keep specific
aliases such as "python3.8.exe", "pythonw3.8.exe", "pip3.8.exe", and
"idle3.8.exe".

---

FYI, back in the 1990s, when users opened a "DOS Box" in Windows 9x,
it was literally the 16-bit DOS kernel and "COMMAND.COM" shell
executing in a virtual DOS machine (VDM) using the CPU's virtual-86
mode. Various software interrupts were hooked to integrate with the
virtual machine manager (the 32-bit OS at the core of Windows 9x) and
connect the UI to a desktop window. The term "DOS Box" made perfect
sense back then.

In modern Windows systems, which are based on NT instead of DOS, the
classic command-line shell is called the "Command Prompt" or "CMD".
The CMD shell (cmd.exe) is a Windows console application. It supports
the batch language and a superset of the commands from the
"COMMAND.COM" DOS shell. Compatibility with the DOS shell was crucial
when CMD was designed for OS/2 in 1986 and subsequently ported to
Windows in 1993. But it's only high-level and superficial
compatibility. CMD directly consumes the Windows API. It is not a DOS
application executing in a VDM. 64-bit Windows systems don't even
include VDM support.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re[2]: Can't get rid of old version of python

2021-08-13 Thread Ciarán Ó Duibhín via Python-list

Many thanks for both replies.  Everything seems fine now.

Reinstalling the packages using "py" made them available in v3.9.6.  So 
I could delete them from 
C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundationPython.3.8.qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages
In fact I deleted the whole of 
C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8.qbz5n2kfra8p0


Asking where "python" finds its (supposed uninstalled) v3.8.10 
executable was sending me to

'C:\Users\…\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe'
but deleting as above meant there is no longer a "python" command to 
worry about.
I may try to remove that whole subdirectory of WindowsApps and the 
somewhat similar one in C:\Program Files\WindowsApps


I think any other applications that use python probably have their own 
copy of python.exe — LibreOffice and GIMP 2 certainly have, with version 
numbers which are different again.


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


Recoding Categorical to Numerical

2021-08-13 Thread John Griner
Hello, and thanks in advance,

 I am trying to recode categorical variable to numeric.  Despite using
lambda, If else, dummy-recoding, and so forth, what I get is from ONE
column that has 4 variables (City, Town, Suburb, Rural), I get FOUR columns:



localeDummy_City  localeDummy_Town  localeDummy_Suburb
localeDummy_Rural   locale_recode



with the corresponding numeric variable.



What I want is the recode to have ONE column that has the numeric
conversion.



For instance:


local_recode

2

4

4

6

2

8

6

2

8

2

2

4

6

4

8

and so forth, where I have set City to 2, and Town to 4, etc.


Again, thanks, John



loca




Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


Empty list as a default param - the problem, and my suggested solution

2021-08-13 Thread guruyaya
I am fairly sure all of us know about this python quirk:
>>> def no_new_func(a=[]):
...a.append('new')
...return a

>>> no_new_func()
['new']
>>> no_new_func()
['new', 'new']
>>>

For some time I was bothered about that there's no elegant way to use empty 
list or dict as a default parameter. While this can be solved like this:
>>> def no_new_func(a=None):
...if a == None:
a = []
...a.append('new')
...return a

I have to say I find this solution very far from the spirit of python. Kinda 
ugly, and not explicit. So I've decided to try and create a new module, that 
will try and make, what I think, is a more beautiful and explicit:

>>> from new import NEW
>>> @NEW.parse
... def new_func(a=NEW.new([])):
... a.append('new appended')
... return a
...
>>> new_func()
['new appended']
>>> new_func()
['new appended']

I'd like to hear your thoughts on my solution and code. You can find and give 
your feedback in this project
https://github.com/guruyaya/new
If I see that people like this, I will upload it to pip. I'm not fully sure 
about the name I choose (I thought about the "new" keyword used in JAVA, not 
sure it applies here as well)

Thanks in advance for your feedback
Yair
-- 
https://mail.python.org/mailman/listinfo/python-list


Re[2]: Can't get rid of old version of python

2021-08-13 Thread Ciarán Ó Duibhín via Python-list

Thanks for the two further clarifications, which I've just read.
Eryk's advice for uninstalling the app distribution got rid of those 
unwanted WindowsApps subdirectories painlessly.



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