Jump to content

Python, Making it tidy?

mattonfire

You have no checks if they enter something unexpected.

 

I would do something like have an input file that I feed all my choices into and then a for loop to print them out.  Might not save line space (which doesn't really matter IMO) but would make it so you can reconfigure it easier without changing code.

 

if again in ['y', 'Y', 'yes', 'Yes', 'YES', 'ye', 'Ye', 'YE']:

 

Just do a regular expression looking for "^y" case insensitive.  Or if you want to save execution cycles (maybe) just check the first character of their response for y or Y.

Workstation:  13700k @ 5.5Ghz || Gigabyte Z790 Ultra || MSI Gaming Trio 4090 Shunt || TeamGroup DDR5-7800 @ 7000 || Corsair AX1500i@240V || whole-house loop.

LANRig/GuestGamingBox: 9900nonK || Gigabyte Z390 Master || ASUS TUF 3090 650W shunt || Corsair SF600 || CPU+GPU watercooled 280 rad pull only || whole-house loop.

Server Router (Untangle): 13600k @ Stock || ASRock Z690 ITX || All 10Gbe || 2x8GB 3200 || PicoPSU 150W 24pin + AX1200i on CPU|| whole-house loop

Server Compute/Storage: 10850K @ 5.1Ghz || Gigabyte Z490 Ultra || EVGA FTW3 3090 1000W || LSI 9280i-24 port || 4TB Samsung 860 Evo, 5x10TB Seagate Enterprise Raid 6, 4x8TB Seagate Archive Backup ||  whole-house loop.

Laptop: HP Elitebook 840 G8 (Intel 1185G7) + 3080Ti Thunderbolt Dock, Razer Blade Stealth 13" 2017 (Intel 8550U)

Link to comment
Share on other sites

Link to post
Share on other sites

You have no checks if they enter something unexpected.

 

I would do something like have an input file that I feed all my choices into and then a for loop to print them out.  Might not save line space (which doesn't really matter IMO) but would make it so you can reconfigure it easier without changing code.

 

if again in ['y', 'Y', 'yes', 'Yes', 'YES', 'ye', 'Ye', 'YE']:

 

Just do a regular expression looking for "^y" case insensitive.  Or if you want to save execution cycles (maybe) just check the first character of their response for y or Y.

Still new, is there a way you can show me by editing my hastebin? I understand the code in visual form. Still getting used to the words. :P

 

You see any way of making this shorter?

    if tutor in ['A', 'a']:
        group=("10 Fraser")
    if tutor in ['B', 'b']:
        group=("10 Nisdale")
    if tutor in ['C', 'c']:
        group=("10 Douglas")
    if tutor in ['D', 'd']:
        group=("10 Darby")
    if tutor in ['E', 'e']:
        group=("10 Tudor")
    if tutor in ['F', 'f']:
        group=("10 Lincoln")
Link to comment
Share on other sites

Link to post
Share on other sites

 

Still new, is there a way you can show me by editing my hastebin? I understand the code in visual form. Still getting used to the words. :P

 

You see any way of making this shorter?

    if tutor in ['A', 'a']:
        group=("10 Fraser")
    if tutor in ['B', 'b']:
        group=("10 Nisdale")
    if tutor in ['C', 'c']:
        group=("10 Douglas")
    if tutor in ['D', 'd']:
        group=("10 Darby")
    if tutor in ['E', 'e']:
        group=("10 Tudor")
    if tutor in ['F', 'f']:
        group=("10 Lincoln")

 

Yes.  I'm working on it now.  I don't know Python so I'm learning the syntax for what I want to do.  Once you know one language (in my case Perl in addition to several others), you know them all.

Workstation:  13700k @ 5.5Ghz || Gigabyte Z790 Ultra || MSI Gaming Trio 4090 Shunt || TeamGroup DDR5-7800 @ 7000 || Corsair AX1500i@240V || whole-house loop.

LANRig/GuestGamingBox: 9900nonK || Gigabyte Z390 Master || ASUS TUF 3090 650W shunt || Corsair SF600 || CPU+GPU watercooled 280 rad pull only || whole-house loop.

Server Router (Untangle): 13600k @ Stock || ASRock Z690 ITX || All 10Gbe || 2x8GB 3200 || PicoPSU 150W 24pin + AX1200i on CPU|| whole-house loop

Server Compute/Storage: 10850K @ 5.1Ghz || Gigabyte Z490 Ultra || EVGA FTW3 3090 1000W || LSI 9280i-24 port || 4TB Samsung 860 Evo, 5x10TB Seagate Enterprise Raid 6, 4x8TB Seagate Archive Backup ||  whole-house loop.

Laptop: HP Elitebook 840 G8 (Intel 1185G7) + 3080Ti Thunderbolt Dock, Razer Blade Stealth 13" 2017 (Intel 8550U)

Link to comment
Share on other sites

Link to post
Share on other sites

Yes.  I'm working on it now.  I don't know Python so I'm learning the syntax for what I want to do.  Once you know one language (in my case Perl in addition to several others), you know them all.

Oh right, that's quite interesting. 

Thanks by the way.

Link to comment
Share on other sites

Link to post
Share on other sites

Oh right, that's quite interesting. 

Thanks by the way.

http://hastebin.com/ikacunazos.tex

 

Might not be working fully and I don't have any exception handling / default input if the for loop exits without a match.  Should give you an idea though of what's up.  Sometimes I swear exception handling takes up more codespace than the actual function you want to implement in the first place.

Workstation:  13700k @ 5.5Ghz || Gigabyte Z790 Ultra || MSI Gaming Trio 4090 Shunt || TeamGroup DDR5-7800 @ 7000 || Corsair AX1500i@240V || whole-house loop.

LANRig/GuestGamingBox: 9900nonK || Gigabyte Z390 Master || ASUS TUF 3090 650W shunt || Corsair SF600 || CPU+GPU watercooled 280 rad pull only || whole-house loop.

Server Router (Untangle): 13600k @ Stock || ASRock Z690 ITX || All 10Gbe || 2x8GB 3200 || PicoPSU 150W 24pin + AX1200i on CPU|| whole-house loop

Server Compute/Storage: 10850K @ 5.1Ghz || Gigabyte Z490 Ultra || EVGA FTW3 3090 1000W || LSI 9280i-24 port || 4TB Samsung 860 Evo, 5x10TB Seagate Enterprise Raid 6, 4x8TB Seagate Archive Backup ||  whole-house loop.

Laptop: HP Elitebook 840 G8 (Intel 1185G7) + 3080Ti Thunderbolt Dock, Razer Blade Stealth 13" 2017 (Intel 8550U)

Link to comment
Share on other sites

Link to post
Share on other sites

http://hastebin.com/ikacunazos.tex

 

Might not be working fully and I don't have any exception handling / default input if the for loop exits without a match.  Should give you an idea though of what's up.  Sometimes I swear exception handling takes up more codespace than the actual function you want to implement in the first place.

Alrighty I will have a look, even if it doesn't work. Thanks for your time.

Link to comment
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

×