Jump to content

hi there i came up with this cool little program i made a little while back.you can use it if you want it's pretty cool and i was looking for some input or advice or cool little things to add. (don't go crazy i'm just starting out.) Thanks!

notes:

only windows 10

python 3.7 

made in idle

you can remove the shutdown prompt and it'll work on any other OS with python 3.7 i think

main.py

Link to comment
https://linustechtips.com/topic/971265-montys-bridge/
Share on other sites

Link to post
Share on other sites

for starters, 

import subprocess
subprocess.call(["shutdown", "/r"])

will restart the host operating system, not close the python script. You probably want 

import sys

sys.exit()

 

Also, it's good practice to put all your imports at the top of the file instead of throughout the middle. It can make tracking down dependency trees easier among other things.

 

Also, if you want the user to be able to see your fancy ascii bridgekeeper or the "you shall not pass" message in a shell window (e.g. if you run the .py script outside of idle or another IDE), you could put 

input("Press enter to close")

at the end to keep the window open until they close it. Otherwise as soon as you reach the end of the script it will close and they won't see it.

 

Finally using good variable names is a good habit to get into. dn and dx aren't very clear names. What are they? What do they represent? name and quest would be much clearer. Also, dat should probably be date. It's one extra letter, but it removes any confusion by being fully spelled out, instead of "Is it data? date? datsun?"

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
https://linustechtips.com/topic/971265-montys-bridge/#findComment-11746926
Share on other sites

Link to post
Share on other sites

5 hours ago, reniat said:

for starters, 


import subprocess
subprocess.call(["shutdown", "/r"])

will restart the host operating system, not close the python script. You probably want 


import sys

sys.exit()

 

Also, it's good practice to put all your imports at the top of the file instead of throughout the middle. It can make tracking down dependency trees easier among other things.

 

Also, if you want the user to be able to see your fancy ascii bridgekeeper or the "you shall not pass" message in a shell window (e.g. if you run the .py script outside of idle or another IDE), you could put 


input("Press enter to close")

at the end to keep the window open until they close it. Otherwise as soon as you reach the end of the script it will close and they won't see it.

 

Finally using good variable names is a good habit to get into. dn and dx aren't very clear names. What are they? What do they represent? name and quest would be much clearer. Also, dat should probably be date. It's one extra letter, but it removes any confusion by being fully spelled out, instead of "Is it data? date? datsun?"

wow thanks man! oh and the aim of the program is to shutdown the computer if awnsered incorrectly

oh and i was just using random variables cause it was so short and i had like 30 minutes and the wizard was eating up a lot of that.

Link to comment
https://linustechtips.com/topic/971265-montys-bridge/#findComment-11747801
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×