Trian Gular Ramblings

Sign in to follow this  
Followers 0
  • entries
    50
  • comments
    217
  • views
    22,623

Pick-A-Mod Source Code

Sign in to follow this  
Followers 0

Entry posted

308 views

Since I had one interested party in the Pick-A-Mod source code, and since there really is no harm in releasing it (and any programmer can figure out how to remake it in any language they know), the Pick-A-Mod source code is in a spoiler below. . I made some minor changes to it, such as converting it for both Python 2.7.3 and 3.3, and added the ability to quit the while loop by pressing q. The code is pretty self-explanatory, so I did not leave any comments. Enjoy.

Pick-A-Mod

# Pick-A-Mod, by le717.

import random, webbrowser, sys

def main():
    sys.stdout.write("Welcome to Pick-A-Mod!")
    start = get_input("Press 'b' to begin: ")

    if start.lower() == "b":
        PickMe()

    else:
        raise SystemExit

staff = ["Cyrem", "Addictgamer", "antillies", "Cirevam", "Amauros", "apemax", "Oboe Shoes"]

def PickMe():
    sys.stdout.write("\n\n")
    sys.stdout.write(random.choice(staff))
    sys.stdout.write("\n")

    answer = get_input("Does this selection please you? " + r"y\N ")

    if answer.lower() == "y":
        webbrowser.open("http://www.rockraidersunited.org/index.php?app=members&module=messaging&section=send&do=form", new=2, autoraise=True)

    elif answer.lower() == "q":
        raise SystemExit
    else:
        PickMe()

if __name__ == "__main__":
    if sys.version_info >= (3,0):
        # Use Python 3 input
        get_input = input
        main()
    else:
        # Use Python 2 input
        get_input = raw_input
        main()


Sign in to follow this  
Followers 0


6 Comments

Posted

Well, since we're playing at how many lines we can do this in...

import random, webbrowser

#you really don't need to alias an import if you're only using it once


raw_input("Welcome to Pick-A-Mod!\nPress anything to begin: ")

staff = ("Cyrem", "Addictgamer", "antillies", "Cirevam", "Amauros", "apemax", "Oboe Shoes")

while True:

   if  raw_input(random.choice(staff)+"\nThis is good, yes?").lower() in ['', 'y', 'yes']: break

   else: pass

webbrowser.open_new_tab("http://www.rockraidersunited.org/index.php?app=members&module=messaging&section=send&do=form")

Share this comment


Link to comment
Share on other sites

Posted

You can use &fromMemberID=IDNUMBERHERE to add the name into the Recipient Name field.

Of course, you'd need to add their user ID numbers into it to do that.

Share this comment


Link to comment
Share on other sites

Posted

You can use &fromMemberID=IDNUMBERHERE to add the name into the Recipient Name field.

Of course, you'd need to add their user ID numbers into it to do that.

I knew there was some URL trick to do that, just couldn't figure it out!

Share this comment


Link to comment
Share on other sites

Posted

I knew there was some URL trick to do that, just couldn't figure it out!

Oh look, the perfect opportunity to use a dictionary.

Share this comment


Link to comment
Share on other sites

Posted

Well, since we're playing at how many lines we can do this in...

*code snip*

import this


The Zen of Python


//Lines 2 and 3 only

Explicit is better than implicit.

Simple is better than complex.

You line all your code up on a few lines, I spread it out. You have a few implied statements, I have explicitly stated them. When I write code, a tutorial, or anything, I strive for neat, understandable text that can be read easily. My source shows that. However, I'm not going to bonk you over the head saying to code the same way as I, since we are all different, and everyone has their own style. ;)

Share this comment


Link to comment
Share on other sites

Posted

Sometimes less is more :P

Edit: It's also not that the code is complex, it's that the code is condensed.

Share this comment


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