0

I'm developing a multi-platform python script that requires input from the user. We wanted a hidden password input that allows seeing *** as the user types and also allows clipboard paste (cmd+v / ctrl+v) functionality. Thus stdiomask is out of the picture. We implemented a custom function which uses getch().

Getch is not available on Windows, so instead if the os is windows, use msvcrt

if os.name == "posix":
    from getch import getch
    g = True
elif os.name == "nt":
    import msvcrt
    g = False

And in the custom function

...
    while True:
        if g:
            ch = getch().encode()
        else:
            ch = msvcrt.getch().encode()
...

This also means that Unix os users will need to install getch and windows users will only be using the inbuild msvcrt. Since I use a requirements.txt to install also the dependencies, is there a way to inject code after just running *pip install requirements.txt and starting to install the requirements themselves, instead of having two requirements files?

marvin_yorke
  • 3,279
  • 4
  • 24
  • 35
axelmukwena
  • 192
  • 2
  • 14
  • 1
    suggested duplicate: https://stackoverflow.com/questions/29222269/is-there-a-way-to-have-a-conditional-requirements-txt-file-for-my-python-applica (use `pip install` with a script instead?) – Green Cloak Guy Aug 10 '21 at 04:26

0 Answers0