#! /usr/bin/env python
#filename:pwd.py
# development environment:python2.51


import getpass
usr=getpass.getuser()


while True:
    pwd=getpass.getpass("passwd:%s:" % usr)
    if pwd=='123':
        print "welcome to python!!!!"
        break
    else:
        print "The password you entered is incorrect"

Notice getpass.getuser() which finds your login name (does it work on mac ?).

I'm not sure it work on mac
getpass.getuser() Return the “login name” of the user. Availability: Unix, Windows.