In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos janos for correcting me on error exit codes.
I believe that it is fairly difficult to make this more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
However, as BlueRaja - Danny Pflughoeft BlueRaja - Danny Pflughoeft commented,
-1 for "impossible to make this more secure" - since he's storing passwords in plain-text, I'd argue it's impossible to make this less secure. Even if you need the passwords to be reversible (which is usually not the case), you should be encrypting them in a way that makes them unreadable even with the Python source (see eg. LastPass, which encrypts all passwords using a single master password)
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is fairly difficult to make this more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
However, as BlueRaja - Danny Pflughoeft commented,
-1 for "impossible to make this more secure" - since he's storing passwords in plain-text, I'd argue it's impossible to make this less secure. Even if you need the passwords to be reversible (which is usually not the case), you should be encrypting them in a way that makes them unreadable even with the Python source (see eg. LastPass, which encrypts all passwords using a single master password)
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is fairly difficult to make this more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
However, as BlueRaja - Danny Pflughoeft commented,
-1 for "impossible to make this more secure" - since he's storing passwords in plain-text, I'd argue it's impossible to make this less secure. Even if you need the passwords to be reversible (which is usually not the case), you should be encrypting them in a way that makes them unreadable even with the Python source (see eg. LastPass, which encrypts all passwords using a single master password)
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is impossiblefairly difficult to make this any more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
However, as BlueRaja - Danny Pflughoeft commented,
-1 for "impossible to make this more secure" - since he's storing passwords in plain-text, I'd argue it's impossible to make this less secure. Even if you need the passwords to be reversible (which is usually not the case), you should be encrypting them in a way that makes them unreadable even with the Python source (see eg. LastPass, which encrypts all passwords using a single master password)
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is impossible to make this any more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is fairly difficult to make this more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
However, as BlueRaja - Danny Pflughoeft commented,
-1 for "impossible to make this more secure" - since he's storing passwords in plain-text, I'd argue it's impossible to make this less secure. Even if you need the passwords to be reversible (which is usually not the case), you should be encrypting them in a way that makes them unreadable even with the Python source (see eg. LastPass, which encrypts all passwords using a single master password)
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an executionexit code of 1any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is impossible to make this any more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an execution of 1 means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
I believe that it is impossible to make this any more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.
In your function pick_password
, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with that file.
For some reason, at the end of that function, you commented out the line
f.close()
You should un-comment this.
In python, it is good practice to open a file using the with
keyword. Using with
, you can easily access the file object and the file is automatically closed at the end of the with
statement.
Here is how you should open the file:
with open(file, "w") as f:
# whatever you want to do to the file f
In your code, you have three separate variables that are all set to
'/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
You should create a single global constant variable that holds this value. Here is what that would look like:
PASSWORDS = '/home/vhx/Documents/code/pydata_test/password_dbs/pswd.txt'
I put the variable name in all-caps because constants are usually all capital letters.
In your function password_check
, you make an exit
call in a few places. However, you don't pass anything to it.
The number you pass to an exit
call is called the exit code. This number is to show how execution went when the program was running to external processes.
Most commonly, an exit code of 0 means that execution was perfect, and an exit code of any non-zero number means that something went wrong.
I think that you should exit your program with 1 to show that something went wrong the user was entering their password (they entered the password incorrectly).
An advantage to doing it this way would be say, for example, you wrote another program and you only wanted to give access to it if the user entered the password correctly. In this program, you could read the exit code of this password program and if it's a 1, than your new program now knows that the user entered the password incorrectly.
P.S. Your interpreter is probably already doing this for you, but at the top of your code you should have from sys import exit
because the sys
library holds the exit
function that you are calling.
Thanks to janos for correcting me on error exit codes.
I believe that it is impossible to make this any more secure.
The user can view the passwords file
If you do encrypt the file, this voids the above reason but the user will always be able to see your python source.