Beginners help with password program!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tjland@iserv.net

    Beginners help with password program!

    This is my first version of this program, im kinda new to python and i was
    wondering if someone could help me with this. Their are some errors that i
    just cant find, and i want some advice on how to do some of these things
    easier. Thanx for the help!
    ----------------------------------------------------------------------------
    from time import sleep

    def Sendfile(passwo rd, username):
    outfile = file(username, "w")
    outfile.write(p assword)
    outfile.close()
    print "Your are now registered"

    def Getfile(usernam e):
    infile = file(username, "r")
    content = infile.readline (1)
    global content
    infile.close()


    login = input("Are u registered? ")
    if login == no:
    new_username = input("What do you want for a username, please letters
    only: ")
    new_password = input("What do you wish for a password: ")
    Sendfile(new_pa ssword, new_username)
    else:
    print "Please Login, Enter username, then wait for prompt!"
    username = input("Username : ")
    sleep(5)
    password = input("Password : ")

    Getfile(usernam e)
    if password != content:
    print """Im sorry but you are not a registered user,
    If you would like to become a user contact the server admin for
    user privelges"""
    else:
    print "Welcome"
    ----------------------------------------------------------------------------

    When you see the net take the shot
    When you miss your shot shoot again
    When you make your shot you win!

    Just remember
    Offense sells tickets
    But defense wins championships!

  • Ben Finney

    #2
    Re: Beginners help with password program!

    On Sat, 26 Jul 2003 18:08:39 -0400 (EDT), tjland@iserv.ne t wrote:[color=blue]
    > Their are some errors that i
    > just cant find,[/color]

    Please show the errors you get, so we know what you're talking about.
    [color=blue]
    > and i want some advice on how to do some of these things easier.[/color]

    Here's advice on finding errors:

    When you encounter an error you don't understand, *don't* try to deal
    with the whole program. Take a copy, or make a new program (whichever
    seems simpler at the time) and get to the smallest possible program you
    can make that still exhibits the error.

    This will result in several things:

    you may end up solving the error; otherwise:

    you may understand the error much better

    you will know exactly which lines of code are related to the error

    you will have something suitable to post to this newsgroup.

    Please don't just post the whole program and say "find my error".
    That's *your* task.

    --
    \ "I watched the Indy 500, and I was thinking that if they left |
    `\ earlier they wouldn't have to go so fast." -- Steven Wright |
    _o__) |
    http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B

    Comment

    • Keith Jones

      #3
      Re: Beginners help with password program!

      For starters, I suggest you install pychecker and use it on any programs
      you create.

      Second, every error in python should give you some information as to what
      line it occurred on. For example:

      : a = b
      :Traceback (most recent call last):
      : File "<pyshell#2 9>", line 1, in ?
      : a = b
      :NameError: name 'b' is not defined

      Here it says line 1, because this occurred in Idle. Start by going to that
      line... 90% of the time, your error will be right there.

      As for your file... well the line if "login == no:" looks wrong, unless
      you have a variable named 'no'.. you probably want the string 'no' there.
      As was mentioned, you probably won't get much help if you ask people to
      debug for you. Debugging is a major part of programming, and you can't
      avoid it. So get used to it and get good at it. :D (and learn to test your
      code thoroughly). Finally, I recommend you use raw_input(...), rather
      than input(...), and then convert the return value from a string to
      whatever you need it to be.

      Comment

      • tjland@iserv.net

        #4
        Re: Beginners help with password program!

        [color=blue]
        > For starters, I suggest you install pychecker and use it on any programs
        > you create.
        >
        > Second, every error in python should give you some information as to what
        > line it occurred on. For example:
        >
        > : a = b
        > :Traceback (most recent call last):
        > : File "<pyshell#2 9>", line 1, in ?
        > : a = b
        > :NameError: name 'b' is not defined
        >
        > Here it says line 1, because this occurred in Idle. Start by going to that
        > line... 90% of the time, your error will be right there.
        >
        > As for your file... well the line if "login == no:" looks wrong, unless
        > you have a variable named 'no'.. you probably want the string 'no' there.
        > As was mentioned, you probably won't get much help if you ask people to
        > debug for you. Debugging is a major part of programming, and you can't
        > avoid it. So get used to it and get good at it. :D (and learn to test your
        > code thoroughly). Finally, I recommend you use raw_input(...), rather
        > than input(...), and then convert the return value from a string to
        > whatever you need it to be.
        > --
        > http://mail.python.org/mailman/listinfo/python-list
        >[/color]


        When you see the net take the shot
        When you miss your shot shoot again
        When you make your shot you win!

        Just remember
        Offense sells tickets
        But defense wins championships!

        Comment

        Working...