def interactive_add(): """Interactively add contacts.""" print('\nWelcome to contacts ADD\n') while True: name = input('Name: ') if not name: break phone = input('Phone: ') if not phone: break add_contact(name, phone) print('Bye from interactive_add!')
def field_return(self): """Grabs contact form data and sends it to add_contact() in phonebook.py. """ # List to hold form data field_list = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '] # Get form data first = self.first_name.get() last = self.last_name.get() st1 = self.address1.get() st2 = self.address2.get() city = self.city.get() state = self.state.get() zip = self.zip.get() home = self.home.get() mobile = self.mobile.get() email = self.email.get() bday = self.birthday.get() notes = self.notes.get() photo= self.photo.get field_vars = [first, last, st1, st2, city, state, zip, home, mobile, email, bday, notes,photo] # Add form data to field_list for i in range(12): field_list[i] = field_vars[i] # If contact entry has a first name, add the entry. # Else, warn user there is no first name. if field_list[0] != '': ab.add_contact(field_list) else: self.c = cw.ConfirmationWindow(self.master) gui.mainWindow(self.master).search_query(gui.mainWindow(self.master).sort.get()) self.close_window()
import phonebook import logger import sys program = True args = sys.argv while program: new_contact = phonebook.create_contact() phonebook.add_contact(phonebook.repertoire, new_contact) next_name = input("Rentré un nouveau numéro ? ") if next_name == "Non": program = False phonebook.console_print() for i in range(0, len(args)): if (args[i] == "-display") and (len(args) > i + 1): phonebook.get_contact(args[i + 1], phonebook.repertoire) for i in range(0, len(args)): if args[i] == "-log": logger.dump_log()
import phonebook as p import logger as l k = "defkjenkf" c = p.create_contact('Kilian', '0769062552', True) p.add_contact(c) c = p.create_contact('Max', '0145935203', False) p.add_contact(c) c = p.create_contact('Lucie', '0967203628', False) p.add_contact(c) c = p.create_contact('Faycal', '0783429508', True) p.add_contact(c) c = p.create_contact('Charles', None, False) p.add_contact(c) print(p.annuaire) print(p.get_names()) p.display_all() try: p.get_contact(k) except KeyError as ke: print(ke) try: l.dump_log() except FileNotFoundError as fnfe: print(fnfe)
import sys import phonebook args = sys.argv # récup les args for i in range(0, len(args)): # boucle pour arg de 0 à la longueur des args. if args[i] == "-log": print("il est présent") programme = True while programme: names = input("Entrez nom du nouveau contact") phones = input("Entrez le nouveau numéro de tel") fav = input("est il favoris ?") c = phonebook.create_contact(names, phones, fav) phonebook.add_contact(c) print(phonebook.annuaire)