![]() ![]() This seems less applicable to OP imo because their project is an application only, not intended to be used as a library. Use main() + if _name_ = "_main_" and preferably ``sys.exit(main())` to safeguard from accidental runs (importing the script won't run the script, just get the usable things) A few of the reasonings are off, but they're still good habits to keep. And you will know when you have to optimize something (website loads in 30 seconds instead of 1, you know you did something backwards). Optimization will come by itself as well as you get more into it. Focus on readability and maintainability only for the first few years. Todays computers are so fast and the tasks we generally make them do are so small that it very rarely matters how optimized your program is. Good job =) It's a great start on the journey!Īlso, inefficiency will not matter, probably ever in most programming careers. Otherwise you import 9000 extra things, polluting your script and might run things that were not wrapped in if _name_ = "_main_" Prefer import x and from x import thing_you_actually_only_need. You can also do requested_password_length = int(Input.get()).Īvoid magic strings ( 'Helvetica 12' and Passwordsy for example) and magic numbers (App minsize/ maxsize) and use variables instead ( APP_NAME = "Passwordsy", FONT_NAME = "Helvetica 12", WINDOW_MAX_WIDTH, WINDOW_MAX_HEIGHT = 854, 240) to allow changing that one variable to affect every copy of the same value while also giving a meaning behind the otherwise meaningless value and also preventing missed edits in a refactor causing mysterious bugs.Īlways avoid using from x import *. already documents itself) or at some point you forget to update a comment and make things hard to read + add useless text to read. Look into type annotations ( def click() -> None:)ĭon't comment self-commenting lines ( lengthStr = Input.get() + lengthInt = int(lengthStr) # Gets the length the user requested. Use main() + if _name_ = "_main_" and preferably ``sys.exit(main())` to safeguard from accidental runs (importing the script won't run the script, just get the usable things) and prevents polluting the global namespace (avoid anything global or you overwrite other peoples things) Whitespace breaks things in random places, such as the command line and makes program painful to use when you have to remember to quote things.Įvery repo must have a README.md that explains what it is in one or two lines, basic startup/usage with for example 3 simple steps ( pip install -r requirements.txt, python3 passwordsy.py -supersecure) and example code snippets for library usage ("Generate a password: pw = passwordsy.generate()") Dash and underscore ( -, _) are the better choices. Snake_case for almost everything (files, functions, class instances, project name. Setting aside all the math theory regarding password strength based on entropy, please consider making the web interface and app interfaces align.Some feedback aside from logical implementation:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |