Re: Implementing C++'s getch() in Python

2019-05-26 Thread eryk sun
On 5/25/19, Paul Moore  wrote:
>
> On Windows, the msvcrt module exposes getch:
> https://docs.python.org/3.7/library/msvcrt.html#msvcrt.getch

I suggest using msvcrt.getwch instead of msvcrt.getch. Both functions
are limited to the basic multilingual plane (BMP, i.e. U+ --
U+), but getch is additionally limited to the console input
codepage. In Windows, getpass.getpass is based on msvcrt.getwch and
msvcrt.putwch.

If you use getch and need the full BMP range, you can temporarily
change the console input codepage to UTF-8 (65001). It's a multibyte
encoding (i.e. 1-3 bytes per BMP code), so the initial getch call has
to be followed by a loop that calls it again while the sequence can't
be decoded and kbhit() is true.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-26 Thread Shakti Kumar
On Sun, 26 May 2019 at 20:23,  wrote:
>
> I've run getpass() on IDLE, Spyder, PyCharm and Mu. All with negative results.
>
>
As Random832 pointed out, these IDEs cannot handle the stdout/stdin with getpass
You should use a normal terminal (command prompt) on your windows for
running this program.

You can read more here, https://docs.python.org/3.1/library/getpass.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-26 Thread binoythomas1108
I've run getpass() on IDLE, Spyder, PyCharm and Mu. All with negative results.



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


Re: Implementing C++'s getch() in Python

2019-05-25 Thread Random832
On Sat, May 25, 2019, at 10:07, binoythomas1...@gmail.com wrote:
> Hi Shakti!
> 
> Thanks for your response. I have tried getpass() but got the following 
> warning:
> 
> Warning (from warnings module):
>   File 
> "C:\Users\Binoy\AppData\Local\Programs\Python\Python37-32\lib\getpass.py", 
> line 100
> return fallback_getpass(prompt, stream)
> GetPassWarning: Can not control echo on the terminal.
> Warning: Password input may be echoed.
> 
> And true enough, the input string is echoed. I saw a video where 
> getpass() worked on Linux. So, probably, its a Windows thing.

getpass works fine on the windows console. Are you running the script in an IDE 
such as IDLE, PyCharm, etc?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-25 Thread Paul Moore
On Sat, 25 May 2019 at 12:12,  wrote:
>
> I'm working on Python 3.7 under Windows. I need a way to input characters 
> without echoing them on screen, something that getch() did effectively in 
> C++. I read about the unicurses, ncurses and curses modules, which I was not 
> able to install using pip.
>
> Is there any way of getting this done?

On Windows, the msvcrt module exposes getch:
https://docs.python.org/3.7/library/msvcrt.html#msvcrt.getch
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-25 Thread binoythomas1108
Hi Shakti!

Thanks for your response. I have tried getpass() but got the following warning:

Warning (from warnings module):
  File 
"C:\Users\Binoy\AppData\Local\Programs\Python\Python37-32\lib\getpass.py", line 
100
return fallback_getpass(prompt, stream)
GetPassWarning: Can not control echo on the terminal.
Warning: Password input may be echoed.

And true enough, the input string is echoed. I saw a video where getpass() 
worked on Linux. So, probably, its a Windows thing.

Still looking for a solution to the same on Windows. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-25 Thread Shakti Kumar
On Sat, 25 May 2019 at 4:43 PM  wrote:

> I'm working on Python 3.7 under Windows. I need a way to input characters
> without echoing them on screen, something that getch() did effectively in
> C++.


try getpass module.
Typically this would be,

import getpass
variable = getpass.getpass('your prompt')


> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Implementing C++'s getch() in Python

2019-05-25 Thread binoythomas1108
I'm working on Python 3.7 under Windows. I need a way to input characters 
without echoing them on screen, something that getch() did effectively in C++. 
I read about the unicurses, ncurses and curses modules, which I was not able to 
install using pip.

Is there any way of getting this done?
-- 
https://mail.python.org/mailman/listinfo/python-list