6
u/EyesOfTheConcord Jul 11 '26
You can just remove the else: block entirely to reduce the nesting and improve the readability of this
3
9
u/Jbolt3737
Jul 11 '26
•
While Python is typically an interpreted language, full compilers do exist like Nuitka and Pyinstaller
1
u/NiedsoLake Jul 15 '26
Nuitka yes, pyinstaller just bundles the python interpreter into your executable
3
u/Fit_Yogurtcloset8393 Jul 11 '26
Download auto-py-to-exe, it is nothing but a gui for pyinstaller, it would be easier for beginners
2
u/Classic-Rate-5104 Jul 11 '26
Do you really want it being compiled to an binary executable or do you just want to behave it as an executable?
1
u/SnotCodes Jul 11 '26
He just wants it to behave like an executable probably. I am just assuming that but it’s a very simple program idk why it would have to be an exe
0
u/Classic-Rate-5104 Jul 11 '26
To make it behave like an executable, it is enough to add this line as the first:
#!/usr/bin/python
Then make it executable by:
chmod +x filename
1
2
u/memeeloverr Jul 11 '26
I would suggest pyinstaller but that will be flaged a virus by major activiruses so make sure to sign the app with proper signing certificate.
1
u/TarnishedFox47 Jul 11 '26
"sign the app" you mean pay microsoft ridiculous fees?
1
u/memeeloverr Jul 11 '26
no way, by signing I mean To autheticate it via code singing certificate there are many agency which provide those certificates.
Currently I am using globalsign certificate which works with azure to sign your app locally.
1
u/TarnishedFox47 Jul 11 '26
A quick look shows that almost all of these agencies charge money? and the ones that dont only do so for open source projects and require applications
2
u/riklaunim Jul 11 '26
You can practice making an exe but you should not really distribute it - it will be an executable from unknown source and without any signatures - Windows will warn people from running it, even blocking it, while linkinking to executable on social media can be seen as distributing malicious software. Then you script is very trivial and has no value of trying to make it a desktop app. (and it could be written in JS and placed on a website; or move the Python code to a Jupyter notebook and share that).
And password strength is more than character checks. Worth adding dictionary checks for example.
1
u/Important-Grand4979 Jul 11 '26
By now you have also screening of occurance in leaked databases. Best thing to generate a secure password is a password generator
1
u/Zxhena Jul 11 '26
I personally use pyinstall which after inserting with pip (i don't remember what after because i haven't exported anything in a while) and then in your export folder you should make you have your exe and it's files (images sounds ect.)
1
u/dgc-8 Jul 11 '26
Packaging python programs into an exe is not what python was meant to do, so the exe will end up quite big and slow. When I was in your position when I started to program I used PyInstaller, however people suggest Nuitka now, which at first glance looks very promising to me. Try nuitka, pyinstaller works too
However if your end goal is having an exe, a language like python will not be the best fit for that. You can try to write those programs in a real compiled language, for example Go is pretty easy to work with while still being compiled, you don't have to use C/C++ with manual memory management and all.
1
u/Dear_Archer3931 Jul 11 '26
Just because you can… doesn’t mean you should. This is like digging a hole with a spoon.
1
1
1
1
1
1
u/strummed-strings Jul 12 '26
while you could do that, these kind of abstractions are what ruin your learning experience. like, no offence, but i don't think you should be doing that with code like this.
1
1
1
1
u/WestOk942 Jul 15 '26
in your cmd do "python -m pip install pyinstaller" then when it's downloaded run cmd in the location of the python file and run "python -m pyinstaller --onefile example.py"
boom it's an .exe
1
1
u/Anxious-Sport-8354 Jul 15 '26
pip install pyinstaller or python -m pip install pyinstaller To install it
1
1
1
1
u/Automatic_Gear1528 Jul 30 '26
Can't. Exe and Py have different directions. Exe has compiled files. While py is just a single code. But I took someones Idea and now. You should use nutika.
1
u/Francesco12o-Github Aug 04 '26
Use Pyinstaller (pip install pyinstaller) then python -m pyinstaller -onefile your_code_here.py
0
u/acakaacaka Jul 11 '26
How big do you want your .exe to be?
10MB? 100MB? Or just 10KB?
If you want a small program then just code un C++
If you use nuitka or other python "compiler" you end up "compiling" python it self and put your code on top of that
0
Jul 11 '26
[deleted]
8
u/KiLoYounited Jul 11 '26
+1 for Nuitka. I use it for all my TUI applications I make for myself and the other sys admins in my dept.
5
u/downerison Jul 11 '26
How easy is it to setup and use? I heard it can be pretty slow to compile things.
2
u/KiLoYounited Jul 11 '26
I’ll admit it was a bit tough to set up (atleast for my TUI projects). I think that is mainly due to how badly scope creep has affected them and the absence of time to refactor the code. It’s also due to some restrictions on our network as a whole.
I used a small project that was heavily modularized to build my just file with the goal of having one that I could drop in with minimal changes to the just file itself and just setting project specific stuff in a .env file. I do think it’s necessary to have a just file or script to use since the build commands can get pretty clunky pretty fast.
As for speed… I think it’s fine. I’ll start a compile on my work machine (optiplex 5000 sff - so not very powerful at all) and it’ll be done within 15 minutes. That might be slow to some people but honestly I don’t really care. Having everything translated to C is great for sharing the application around my environment while also getting the speed benefits over something like pyinstaller.
Having to use these tools makes me want to learn something compiled like Go, but I just don’t have the time to try and pick up a new language. Python is just so easy <3
0
Jul 11 '26
[deleted]
3
u/KiLoYounited Jul 11 '26
Wood chipper is definitely the best description haha. Setup is brutal - reward is 100% worth it
1
1
u/downerison Jul 11 '26
What does that 50 lines do? Setup the nuitka command to call? That 3 hours compile time sounds brutal.
-3
Jul 11 '26
[removed] — view removed comment
7
u/Ngtuanvy Jul 11 '26
it is not compiling, rather packaging, or bundling. In this context. PyInstaller for example will package everything including the interpreter, dependencies and create an executable
2
u/Sether_00 Jul 11 '26
Yeah, but if OP wants to share their program with someone who doesn't have Python installed on their machine?
6
u/realmauer01 Jul 11 '26
Pyinstaller with the option - - onefile or something like that. Depending on the os its run on it defaults to the executable. So because you are in Windows it will become an exe