def __init__(self, iterable=[], nrow=1, ncol=1, storage='rows'): self.data = List(max_length=nrow * ncol) self.storage = storage self.shape = (nrow, ncol) if len(iterable) > 0: if isinstance(iterable[0], (int, float)): if len(iterable) != ncol * nrow: raise ValueError( 'the size of the initial values does not match array dimensions' ) for i in range(nrow * ncol): if not isinstance(iterable[i], (int, float)): raise ValueError('initial value must be numeric') self.data.append(iterable[i]) elif isinstance(iterable[0], (list, tuple, List)): nrow, ncol = len(iterable), len(iterable[0]) self.shape = (nrow, ncol) self.data = List(max_length=nrow * ncol) for i in range(nrow): for j in range(ncol): self.data.append(iterable[i][j]) else: for i in range(nrow * ncol): self.data.append(0)
def __init__(self, parent_widget, resource, response=None, messageBar=None, parent_object=None): Frame.__init__(self, parent_widget) self.parent_widget = parent_widget self.parent_object = parent_object self.response = response self.resource = resource self.mb = messageBar self.opts = Options.program_options # Global alias self.locations = List.List() self.navList = List.List() self._createPopup() self.currentContent = None # Go wherever the user intended us to go. self.goElsewhere(resource) return None
def diag(self): l = List() n = min(self.shape) for i in range(n): l.append(self.data[i][i]) return l
def add_list(): if request.method == "POST": title = request.form["title"] description = request.form["about"] items = request.form['items'] new_list = List(title, description, 0) new_items = List_Item(items) list_created = False items_created = False new_items.content new_list.items.append(new_items) if new_list.title and new_list.description: db_session.add(new_list) list_created = True else: flash("your list must have a title and a desciption") if new_items.content: list_items = True db_session.add(new_items) else: flash("your list must have some items") if list_created and items_created: try: db_session.commit() except Exception as e: print(e) db_session.rollback() db_session.flush() created_list = db_session.query(List).filter(List.title == title).first() redirect_id = created_list.id redirect_title = created_list.title return redirect(url_for('routes.list', title=redirect_title, id=redirect_id)) return render_template('add_list.html')
def __main__(): check_files_and_folders() socket = Socket.ServerSocket() connection = socket.Socket() sr = Server(connection, Cryptography.session_crypto(None), Registery.Registery(), Login.serverLogin(), Download.Download(), Upload.Upload(), List.List(), Read.Read(), Write.Write(), SessionKeyExchange.ServerSession(None), DACCommands.DACCommands(), Auditor.Auditor()) sr.Handler()
def __init__(self, *args, **kwargs): global reg, enum, bdd tk.Frame.__init__(self, *args, **kwargs) # Setup 4 frames for the 4 pages of the application reg = Register(self) enum = List(self) stat = Stats(self) admin = Admin(self) call.id_call.enum = enum bdd = Page.get_bdd(enum) call.id_call.bdd = bdd button_frame = tk.Frame(self) container = tk.Frame(self) button_frame.pack(side="top", fill='x', expand=False) container.pack(side="top", fill="both", expand=True) # Place all the 4 frames on the main windows, they are superimposed reg.place(in_=container, x=0, y=0, relwidth=1, relheight=1) enum.place(in_=container, x=0, y=0, relwidth=1, relheight=1) stat.place(in_=container, x=0, y=0, relwidth=1, relheight=1) admin.place(in_=container, x=0, y=0, relwidth=1, relheight=1) # Setup all the 4 buttons to switch between the 4 pages reg_b = tk.Button(button_frame, text="Inscription", width=19, height=1, command=reg.lift, font=BIG_FONT) enum_b = tk.Button(button_frame, text="Liste", width=19, height=1, command=enum.lift_list, font=BIG_FONT) stat_b = tk.Button(button_frame, text="Statistiques", width=20, height=1, command=stat.lift_stats, font=BIG_FONT) admin_b = tk.Button(button_frame, text="Administration", width=20, height=1, command=admin.ask_password, font=BIG_FONT) # Place all the buttons on the main windows reg_b.grid(row=0, column=0) enum_b.grid(row=0, column=1) stat_b.grid(row=0, column=2) admin_b.grid(row=0, column=3) reg.show()
def getnext(pattern): next = List([0] * len(pattern)) next[0] = -1 count = 0 for i in range(2, len(pattern)): for j in range(1, i): #print(i, j, pattern[:j], pattern[:i][-j:]) if pattern[:j] == pattern[:i][-j:]: next[i] = j count += 1 print('count 1:', count) return next
def Save(program, fname): temp = Typ.Program() for p in program.Code.keys(): temp.Code[p] = program.Code[p] if 65535 in temp.Code.keys(): temp.Code[65535].append(['THING', ":"]) else: temp.Code[65535] = [] temp.Code[65535].append(['TOKEN', RW.TokToNum("REM")]) temp.Code[65535].append(['THING', "B@#" + str(program.BasicStart.GetValue())]) with open(fname, 'w') as f: for l in L.List(temp): f.write(l + "\n") f.close()
def rehash(self): indice = Indice() N = 2 * len(self.buckets) + 1 indice.buckets = [List() for i in range(N)] for k in range(len(self.buckets)): actual = self.buckets[k].head while actual is not None: cancionActual = actual.canciones.cabeza while True: indice.agregar(actual.s, cancionActual.cancion) cancionActual = cancionActual.next if cancionActual is actual.canciones.cabeza: break actual = actual.next self.buckets = indice.buckets
async def create(ctx, name: str, date: str, time: str='0:00am'): '''Creates an list with specified name and date example: ?create party 12/22/2017 1:40pm ''' server = ctx.message.server.name date_time = '{} {}'.format(date, time) try: list_date = datetime.strptime(date_time, '%m/%d/%Y %I:%M%p') list = List(name=name, server=server, date=list_date) session.add(list) session.commit() await bot.say('List {} created successfully for {}'.format(name, list.date)) except Exception as e: await bot.say('Could not complete your command') print(e)
def getnext_dp(pattern): next = List([0] * len(pattern)) next[0] = -1 count = 0 i = -1 j = 0 while j < len(pattern) - 1: if i == -1 or pattern[i] == pattern[j]: i += 1 j += 1 next[j] = i else: i = next[i] count += 1 print('count 2:', count) return next
def main(): out = False listPacientes = ls.List() while not out: u.clear() option = menu() u.clear() if option <= "0" or option >= "7": print("\nINGRESE UNA OPCION VALIDA...\n") elif option == "1": registrar_pacientes(listPacientes) elif option == "2": if listPacientes.is_empty(): u.emptyData() else: eliminar_paciente(listPacientes) elif option == "3": print(option) if listPacientes.is_empty(): u.emptyData() else: actualizar_paciente(listPacientes) elif option == "4": if listPacientes.is_empty(): u.emptyData() else: listPacientes.print_list() elif option == "5": print(option) if listPacientes.is_empty(): u.emptyData() else: print("Proximamente...") #copiar_datos_paciente(listPacientes) if option != "6": u.pause() else: print("Saliendo...") out = True
def Englyph(program): import Glyphs as G, List as L listing = L.List(program) output = [] for line in listing: glyphs = [] pos = 0 gl = -1 while pos < len(line): if line[pos] != "{": gl = G.GetGlyph(line[pos]) pos += 1 elif line[pos] == "{": sym = "" while line[pos] != "}": sym += line[pos] pos += 1 sym += "}" gl = G.GetGlyph(sym) if gl > -1: glyphs.append(gl) output.append(glyphs) return output
# Quick module to test the List and ListNode classes. from List import * from ListNode import * def p(x): print x.getData() def makenode(y): return ListNode("The number is: %d" % y) nodes = map(makenode, [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) lst = List() for node in nodes: lst.insert(node) try: lst.getNext() lst.getNext() lst.getNext() lst.getNext() lst.getNext() except: pass try: lst.getPrev() lst.getPrev() lst.getPrev() except:
ProgName = "Flightpath737Vic" OutDir = "Out" # Load our program into memory... prog = SPRG.Load(ProgDir + "/" + ProgName + ".prg") # ... and show its internal tokenised form. for l in prog.Code: print(l, prog.Code[l]) # Generate a text listing of it, and display it as we do so. listing = L.List(prog, True) # Renumber our program. Default is start 10, step 10. RN.Renumber(prog) # ... and list it again. L.List(prog, True) # Save it as a text file. STXT.Save(prog, OutDir + "/" + ProgName + ".txt") # Load it again from this text file...
def step_impl(context): context.list = List()
def __init__(self): self.size = 0 self.buckets = [List() for i in range(5)]
# main window main_window = Tk() main_window.title("Лаба 1, ЛОС, Литвиненко Борис, ИКБО-06-18") main_window.geometry("1100x1000") # create tabs tab_control = ttk.Notebook(main_window) """ functions and objects to perform task 1 (list) """ tab_List = ttk.Frame(tab_control) tab_control.add(tab_List, text='Список') tab_control.pack(expand=1, fill='both') list_number = List() # global tab_List # command to input_button def new_list(): # if the list has already been added if list_number.length() != 0: label.configure(text="Список уже заполнен") return # else adding new list try: array_numb = input_field.get().replace(', ', ',').replace(',', ' ').split() for i in array_numb: list_number.append(i) label.configure(text="Успешно добавлено!") input_field.delete(0, END) except Exception:
from tkinter import * import List myList = List.List() def showList(): show.set(myList) def add(): myList.addToEnd(List.Node(int(entry.get()))) def Delchisl(): current = myList.head while current.next is not None: if (current.value < 0): myList.remove(current) break root = Tk() root.title("List") root.geometry("300x300") show = StringVar() entry = StringVar() addButton = Button(root, text="добавить элемент", command=add) addButton.place(x=0, y=0, width=150, height=50)
#!/user/bin/env python #_*_ coding:utf-8 _*_ import unittest import GetYTXAccountLoginStatus import List import GetConcernDoctorList from xml.etree import ElementTree as ET import HTMLTestReportCN import pymysql import client if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(GetYTXAccountLoginStatus.GetYTXAccountLoginStatus('test_getYTXAccountLoginStatus')) suite.addTest(List.List('test_list')) suite.addTest(GetConcernDoctorList.GetConcernDoctorList('test_getConcernDoctorList')) unittest.TextTestRunner().run(suite) suite = unittest.defaultTestLoader.discover(start_dir= './') print suite runner = unittest.TextTestRunner() runner.run(suite) unittest.TextTestRunner().run(suite)
import List import Node def check_index( ret_val, correct_val ): # Function to check if the functions I call in the test are returning the correct indicies if ret_val == correct_val: print("Index check passed.") else: print("ERROR: Index check FAILED") list = List.List() # Testing add_node list.add_node("SEAS GWU", 10.5, 100.1) list.add_node("Eiffel Tower", 11.9, 100.0) list.print_list() # Testing clear_list list.clear_list() list.print_list() # Testing add_sorted_node check_index(list.add_sorted_node("New location 1", 10.7, 50.5), 0) check_index(list.add_sorted_node("New location 2", 10.8, 100), 1) check_index(list.add_sorted_node("New location 3", 20, 75), 1) # Testing append_node check_index(list.append_node("New Location 4", 20, 74), 3)
# Description: # This is the contact manager's main driver function/file. ################################################################################ import Person import List import Menus fname = "contacts.dat" try: file = open(fname, 'r') except IOError: file = open(fname, 'w') quit = False # global variable to exiting the application easier contactList = List.List() def readInContacts(): # Read in the default contact list file file = open(fname, 'r') for line in file: fields = line.split(',') peep = Person.Person(fields[0].strip(), fields[1].strip(), fields[2].strip(), fields[3].strip()) contactList.addPerson(peep) def printContactsToFile(): # Print the contacts to a file. Will loop until the application finds a good file name while True: