1

I need help with a password issue.

I'm trying to create a simple password program, but the problem I am having is that I cannot replace the input with '*'s without importing anything.

Does anyone have any solutions?

meda
  • 45,103
  • 14
  • 92
  • 122
randomsheep21
  • 11
  • 1
  • 2
  • 1
    https://stackoverflow.com/questions/21533539/input-raw-input-echoing-input-as-asterisks – Cory Kramer Feb 01 '15 at 14:32
  • If you really don't want to import a module, You might want to copy the code of the getpass.getpass function, you can find it in the python directory – no_name Feb 01 '15 at 14:37

2 Answers2

3
import getpass
password = getpass.getpass('Password:')

Note that getpass is a part of the standard library.

But if you are not doing any imports then you have a big problem as the only other ways all involve control of the terminal such as getting each key and replacing the output with * but that sort of control of the terminal is itself an import.

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
0

If you really can't do imports, then do this:

Enter the python directory in your computer, search for the getpass module, open the source code and search for the getpass function/class/whatever, copy-paste It in your code, Done.

no_name
  • 742
  • 3
  • 10