Beginners help with password program!

Discussion in 'Python' started by tjland@iserv.net, Jul 26, 2003.

  1. Guest

    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(password, username):
    outfile = file(username, "w")
    outfile.write(password)
    outfile.close()
    print "Your are now registered"

    def Getfile(username):
    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_password, new_username)
    else:
    print "Please Login, Enter username, then wait for prompt!"
    username = input("Username: ")
    sleep(5)
    password = input("Password: ")

    Getfile(username)
    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!
    , Jul 26, 2003
    #1
    1. Advertising

  2. Ben Finney Guest

    On Sat, 26 Jul 2003 18:08:39 -0400 (EDT), wrote:
    > Their are some errors that i
    > just cant find,


    Please show the errors you get, so we know what you're talking about.

    > and i want some advice on how to do some of these things easier.


    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
    Ben Finney, Jul 27, 2003
    #2
    1. Advertising

  3. Keith Jones Guest

    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#29>", 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.
    Keith Jones, Jul 27, 2003
    #3
  4. Guest


    > 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#29>", 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
    >



    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!
    , Jul 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. beginners program

    , Mar 30, 2005, in forum: C++
    Replies:
    6
    Views:
    436
    Boboo
    Apr 6, 2005
  2. Replies:
    2
    Views:
    999
    Nick Keighley
    May 6, 2008
  3. AAaron123
    Replies:
    2
    Views:
    2,104
    AAaron123
    Jan 16, 2009
  4. AAaron123
    Replies:
    1
    Views:
    1,320
    Oriane
    Jan 16, 2009
  5. Lenny Challis

    Beginners Program

    Lenny Challis, Dec 10, 2003, in forum: Perl Misc
    Replies:
    17
    Views:
    200
    Matt Garrish
    Dec 11, 2003
Loading...

Share This Page