本文整理汇总了Python中users.User.genIdNum方法的典型用法代码示例。如果您正苦于以下问题:Python User.genIdNum方法的具体用法?Python User.genIdNum怎么用?Python User.genIdNum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.genIdNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newUser
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import genIdNum [as 别名]
def newUser():
t_list = [name.username for name in usr_list]
while True:
usr_name = raw_input('Enter your desired username: ')
while True:
if usr_name not in t_list:
usr_pwd = getpass.getpass('Enter in your password: ')
usr_pwd_conf = getpass.getpass('Confirm your password: ')
if usr_pwd != usr_pwd_conf:
print 'Passwords did not match. Please try again.'
else:
print '%s was added to the database.' % (usr_name)
player = User(usr_name,usr_pwd)
player.genIdNum()
player.f_name = player.username + '_wordlist.txt'
return player
else:
print 'User name is already taken. Please choose a different name.'
break
示例2: Wall
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import genIdNum [as 别名]
class Wall():
"""
Creates a new wall engine that will handle data
"""
def __init__(self):
"""
Instantiate all defaults for the instance. A new ordered dict word list
is created that will hold all words the user enters. A new User instance
from our User class will create a new player. The user list will hold
all the users who use this program. File open objects will also be
created to handle the file objects that will be being read to and
written to during program execution
"""
self.word_list = OrderedDict()
self.player = User()
self.user_list = []
self.fo_ul = ''
self.fo_wl = ''
def display_menu(self):
"""
Displays the menu for the use
"""
print 57 * '#'
print '# WELCOME TO THE PYTHON/WEBDEV WALL #'
print '# ---------------------------------------------- #'
print '# Here, we will dial in on your python skills by #'
print '# providing an interactive and fun way to really #'
print '# understand how this language functions. #'
print 57 * '#'
print ''
def old_user(self, u_name, u_pword):
"""
Checks to see if the log in information that the user enters has the
right credentials. Username and password are taken as parameters. Return
true if the player is in the dB, false otherwise
"""
for i in self.user_list:
if i.username == u_name and i.psswrd == u_pword:
self.player = i
return True
print 'Password/Username did not match.'
return False
def new_user(self):
"""
Creates a new user. Make a temporary list of the current usernames. Get
the desired username of the player and if the username is not currently
taken, save the desired password for the user. There is a confirmation
check for password. Once username and password have been created, add
the user to the userlist, create a wordlist text for them, generate a
user id for them, and save the user list.
"""
t_list = [name.username for name in self.user_list]
self.player.username = raw_input('Enter your desired username: ')
if self.player.username not in t_list:
self.player.psswrd = getpass.getpass('Enter in your password: ')
usr_pwd_conf = getpass.getpass('Confirm your password: ')
if self.player.psswrd != usr_pwd_conf:
print 'Passwords did not match. Please try again.'
else:
print '%s was added to the database.' % self.player.username
self.player.genIdNum()
self.player.f_name = self.player.username + '_wordlist.txt'
self.user_list.append(self.player)
if self.fo_ul.closed:
self.fo_ul = open('user_list.txt', 'wb')
pickle.dump(self.user_list, self.fo_ul)
self.fo_ul.close()
return True
else:
print 'User name is already taken. Please choose a different name.'
return False
def display_words(self):
"""
Print all the words in the users wordlist with all the definitions. If
the word list is empty, notify the user.
"""
if len(self.word_list) == 0:
print 'The word list is already empty.'
else:
print ''
print '%s\'s word list:' % self.player.username
print len(self.player.username) * '-' + '-------------'
for word, meaning in self.word_list.items():
print '{0:>14}: {1}'.format(word, meaning)
def enter_word(self, new_word):
"""
Function to add a new word to the users word list. The new word along with
the definition is taken as a parameter. The new word is split into a
length 2 tuple (word and definition). If the length of the new word is
more than 2 (meaning there was incorrect input), the user will be
prompted the input was incorrect. Next we check if the index of the
tuple (word) is in the word list and if its not, add it to the word list.
"""
if len(new_word) > 2:
print 'Too many colons in your input.'
#.........这里部分代码省略.........