Book,Codesnippet,Codetype,Page Python 3 for Absolute Beginners,result = [i + j for i in int variables for j in float variables],listCompNested,168 Python 3 for Absolute Beginners,zip(),zip,84 Python 3 for Absolute Beginners,zip(),zip,295 Python 3 for Absolute Beginners,map(),map,84 Python 3 for Absolute Beginners,map(),map,289 Python 3 for Absolute Beginners,super().,superfunc,193 Python 3 for Absolute Beginners,super().,superfunc,215 Python 3 for Absolute Beginners,enumerate(),enumfunc,83 Python 3 for Absolute Beginners,enumerate(),enumfunc,92 Python 3 for Absolute Beginners,enumerate(),enumfunc,286 Python 3 for Absolute Beginners,armour stats = [stock[item] for item in profile['inventory'],simpleListComp,111 Python 3 for Absolute Beginners,flatlist = [str(item) for item in self.inv],simpleListComp,205 Python 3 for Absolute Beginners,"stuff = [str(item) for item in self.inv if issubclass(type(item), Thing)]",simpleListComp,211 Python 3 for Absolute Beginners,objects = [str(i) for i in self.inv],simpleListComp,211 Python 3 for Absolute Beginners,sequence = [str(item) for item in sequence],simpleListComp,216 Python 3 for Absolute Beginners,"matches = [(actor, target) for actor in sides for target in opponents if target != actor]",listCompIf,113 Python 3 for Absolute Beginners,"matches = [(actor, target) for actor in seq for target in opponents if target != actor]",listCompIf,116 Python 3 for Absolute Beginners,"matches = [(actor, target) for target in opponents for actor in seq if target != actor]",listCompIf,217 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,136 Python 3 for Absolute Beginners,re.split() method instead of string.split(),re,136 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,136 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,136 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,137 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,137 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,137 Python 3 for Absolute Beginners,re.escape(pattern),re,138 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,138 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,138 Python 3 for Absolute Beginners,"re.split(pattern, string)",re,139 Python 3 for Absolute Beginners,"re.compile(pattern[, flags])",re,139 Python 3 for Absolute Beginners,re.escape(pattern),re,139 Python 3 for Absolute Beginners,re.escape(string),re,139 Python 3 for Absolute Beginners,"re.split(pattern, string[, maxsplit])",re,139 Python 3 for Absolute Beginners,"re.sub(""«a.»"", ""data:"", string)",re,140 Python 3 for Absolute Beginners,"re.sub(""«a.»"", ""data:"", string, 2)",re,140 Python 3 for Absolute Beginners,"re.subn(pattern, repl, string[, count])",re,140 Python 3 for Absolute Beginners,"re.sub() but also returns the number of substitutions made in a tuple (new string, number)",re,140 Python 3 for Absolute Beginners,"re.subn(""«a.»"", ""data:"", string)",re,140 Python 3 for Absolute Beginners,"re.findall(pattern, string[, flags])",re,140 Python 3 for Absolute Beginners,"re.findall(""«a.»"", string)",re,140 Python 3 for Absolute Beginners,re.sub(),re,145 Python 3 for Absolute Beginners,"re.compile(pattern[, flags])",re,291 Python 3 for Absolute Beginners,re.escape(pattern),re,291 Python 3 for Absolute Beginners,"re.findall(pattern, string[, flags])",re,291 Python 3 for Absolute Beginners,re.split(),re,292 Python 3 for Absolute Beginners,"re.split(pattern, string[, maxsplit])",re,292 Python 3 for Absolute Beginners,re.sub(),re,292 Python 3 for Absolute Beginners,"re.subn(pattern, repl, string[, count])",re,292 Python 3 for Absolute Beginners,import re,importre,136 Python 3 for Absolute Beginners,import re,importre,145 Python 3 for Absolute Beginners,import re,importre,149 Python 3 for Absolute Beginners,import re,importre,167 Python 3 for Absolute Beginners,import re,importre,227 Python 3 for Absolute Beginners,"property([fget][, fset][, fdel][, doc])",classprop,196 Python 3 for Absolute Beginners,property(),classprop,196 Python 3 for Absolute Beginners,"try: print(""TRYING : beginning division of {0} / {1}"".format(x,y)) result = x / y except ZeroDivisionError: print(""HANDLED: division by zero!"") else: print(""SUCCESS: result is {0:g}"".format(result)) finally:",tryexceptelsefinally,233 Python 3 for Absolute Beginners,"try: f = open('finally log.txt', 'a') f.write(""{0:g} / {1:g} = {2:g}\n"".format(x,y, (x/y))) # If there's a problem, log it, but then re-raise the error # Don't handle it locally except ZeroDivisionError: f.write(""Error: tried to divide by zero\n"") raise # Whatever happens, close the file finally:",tryexceptfinally,232 Python 3 for Absolute Beginners,"stock list = ["" {0!s:10}{1: >3}"".format(item, stock[item][0]",listwithdict,155 Python 3 for Absolute Beginners,"while len(players) < max players: print() print(""New Character"") print() # Create empty profile dictionary profile = {'Name':"""", 'Desc':"""", 'Gender':"""", 'Race':"""", 'Muscle':0, 'Brainz':0, 'Speed':0, 'Charm':0, 'life':0, 'magic':0, 'prot':0, 'gold':0, 'inventory':[]} # Prompt user for user-defined information (Name, Desc, Gender, Race) name = input('What is your name? ') desc = input('Describe yourself: ') gender = input('What Gender are you? (male/female/unsure): ') race = input('What Race are you? - (Pixie/Vulcan/Gelfling/Troll): ') # Validate user input profile['Name'] = name.capitalize() profile['Desc'] = desc.capitalize() gender = gender.lower() if gender.startswith('f'): profile['Gender'] = 'female' elif gender.startswith('m'): profile['Gender'] = 'male' else: profile['Gender'] = 'neuter' race = race.capitalize() if race.startswith('P'): profile['Race'] = 'Pixie' elif race.startswith('V'): profile['Race'] = 'Vulcan' elif race.startswith('G'): profile['Race'] = 'Gelfling' elif race.startswith('T'): profile['Race'] = 'Troll' else:",whileelse,94 Python 3 for Absolute Beginners,"while len(players) < max players: # Call character generation function. profile = generate rpc() # Go shopping if the inventory is empty shopping = profile['inventory'] == [] while shopping: shopping = buy equipment() handbag = join with and(profile['inventory']) print(""You own a"", handbag) # Choose a weapon print(profile['Name'] + "", prepare for mortal combat!!!"") # See if player has any weapons weapon stats = [stock[item] for item in profile['inventory'] if item not in armour types] if len(weapon stats) == 1: profile['weapon'] = weapon stats[0] elif len(weapon stats) < 1: profile['weapon'] = (0,20,50) else: weapon = input(""And choose your weapon: "") # The weapon must be in player's inventory. # Default to fist if weapon not available. weapon = weapon.lower() if weapon in profile['inventory']: profile['weapon'] = stock[weapon] else: profile['weapon'] = (0,20,50) # See if player has any armor armour stats = [stock[item] for item in profile['inventory'] if item in armour types] if armour stats: profile['armour'] = armour stats[0] else:",whileelse,120 Python 3 for Absolute Beginners,"while len(players) > 1: # create list of matches using ziply function matches = ziply(range(0,len(players))) if trace: print(matches) for attacker, target in matches: life left = players[target]['life'] # Calculate velocity of blow velocity = calc velocity(attacker, target) if trace: print(""\tvel\thit\tdam\tchange"") print(""\t"", velocity) if velocity > 0: # Print sutable Hit message if velocity > vel max: vel max = velocity hit type = int(7 * velocity / vel max) if hit type > 7: hit type = 7 if trace: print(""\t\tHit#"", hit type) print(players[attacker]['Name'], hits[hit type], \ players[target]['Name'], end="""") else:",whileelse,121 Python 3 for Absolute Beginners,"while True: this input = float(input('#? :~> ')) if this input < 0: if counter == 0: print(""You haven't entered any numbers yet!"") continue break",whilebreak,68 Python 3 for Absolute Beginners,"while attacker[health] > 0 and target[health] > 0: #3.1 for player in players: #3.1.1 Calculate velocity of blow #3.1.2 Calculate damage inflicted by blow #3.1.3 Print damage report #3.1.4 if attacker[health] > 0 and target[health] > 0: break",whilebreak,91 Python 3 for Absolute Beginners,while result < 1000:,whilesimple,65 Python 3 for Absolute Beginners,while number >= 0:,whilesimple,66 Python 3 for Absolute Beginners,while True:,whilesimple,67 Python 3 for Absolute Beginners,while statements. Its construction is for element in sequence:,whilesimple,69 Python 3 for Absolute Beginners,while purchase != 'done':,whilesimple,95 Python 3 for Absolute Beginners,while players[0]['life'] > 0 and players[1]['life'] > 0:,whilesimple,96 Python 3 for Absolute Beginners,while len(players) < max players:,whilesimple,110 Python 3 for Absolute Beginners,while loop wrapping the function call now looked like this:,whilesimple,110 Python 3 for Absolute Beginners,while shopping:,whilesimple,110 Python 3 for Absolute Beginners,while len(players) > 1:,whilesimple,114 Python 3 for Absolute Beginners,while not filename:,whilesimple,150 Python 3 for Absolute Beginners,while command != 'exit':,whilesimple,212 Python 3 for Absolute Beginners,while len(players) > 1:,whilesimple,214 Python 3 for Absolute Beginners,while len(players) < max players:,whilesimple,219 Python 3 for Absolute Beginners,from strings import *,fromstarstatements,243 Python 3 for Absolute Beginners,from modulename import *,fromstarstatements,244 Python 3 for Absolute Beginners,from convert import *,fromstarstatements,245 Python 3 for Absolute Beginners,from modulename import *,fromstarstatements,245 Python 3 for Absolute Beginners,from modulename import *,fromstarstatements,246 Python 3 for Absolute Beginners,from internals import *,fromstarstatements,247 Python 3 for Absolute Beginners,"from pirate import *",fromstarstatements,253 Python 3 for Absolute Beginners,from pirate import *,fromstarstatements,253 Python 3 for Absolute Beginners,from sys import argv as arguments,asextension,170 Python 3 for Absolute Beginners,"try: {}[""foo""] except KeyError as e: store.append(e) try: 1 / 0 except ZeroDivisionError as e: store.append(e) try: """".bar() except AttributeError as e: store.append(e) # Loop over the store of errors and print out their class hierarchy for exception object in store: ec = exception object. print(ec. name indent = "" +-"" while ec. bases # Assign ec's superclass to itself and increase ec = ec. print(indent + ec. name indent = "" "" + indent class bases [0] : ) ) 224 www.it-ebooks.info",trytry,224 Python 3 for Absolute Beginners,"try: f = open(file) lines = f.readlines() f.close() except IOError: raise SecurityError(""Cannot open status file {0}"".format(file)) # For each line, trim whitespace, split it at the colon and make a dict return dict([re.split("":\s*"", l.strip(), 1) for l in lines ]) def check report(report): """"""Check a house report dict, that everything is secure"""""" to check = (""door open front"", ""door open rear"", ""motion in living room"", ""motion in kitchen"", ""motion in attic"") for check in to check: # See if the value is what we expect for security try: if report[check] != ""no"": if check[0:9] == ""door open"": raise BuildingIntegrityError(""Door open: {0}"".format(check)) elif check[0:9] == ""motion in"": raise MotionDetectedError(""Motion detected: {0}"".format(check)) # If we can't find the item to check, security isn't certain! except (KeyError, SecurityNotCertain): raise SecurityNotCertain(""Can't check security for {0}"".format(check)) # Main program - in real life this would be scheduled to run e.g. every minute report = get report() check report(report) The program begins by checking for a security report in the file report.txt, and when it can’t find this file, it raises the SecurityError you may have already seen. This file is where you can tell the program whether or not the front or back door is open, and whether there’s any movement in any of the rooms. Listing 10-6 is a complete report.txt, indicating a secure house: save it to the current directory and run the program. Listing 10-6. A Complete Security Report for Listing 10-5 to Parse door open front: no door open rear: no 228 www.it-ebooks.info",trytry,228 Python 3 for Absolute Beginners,"try: str = """" + 5 except TypeError as ex: log error(ex) # NameError: referring to a variable that does not exist # (Note that neither e nor ex exist outside their ""except"" clauses above) try: print(ex) except NameError as exc: log error(exc) Listing 10-7 prints the following message to the screen: LOG:: KeyError: 'quux' LOG:: TypeError: Can't convert 'int' object to str implicitly LOG:: NameError: name 'ex' is not defined We have been able in the preceding code to interrogate each exception object and then log its type—its class name—and the message associated with it. But what if we want to raise more information alongside the exception? You will see later that Python attaches a lot of diagnostic messages to exceptions, so that they can be traced through the code by the programmer. But there might be extra information in the exception’s original environment that, for example, helps us clean up after it or otherwise recover from it, helps us track down the precise problem in a configuration file, or helps us decide whether or not to ignore the error. Along with the message, you can store extra parameters in the exception object by including them as arguments to the Exception() constructor. The parameters are stored in the args attribute of the object. In Listing 10-8, we store an extra parameter on the exception and access it later on during exception handling. Listing 10-8. Storing Extra State Information in an Exception for ignore in (True, False): try: # Pass a second parameter into the exception constructor raise Exception(""Ignore is {0}"".format(ignore), ignore) except Exception as e: # Based on that second parameter, # work out if the error can be ignored or not if(e.args[1]): print(""I can ignore this error!"") else: print(""I canNOT ignore this error!"") The preceding script produces the following results: 230 www.it-ebooks.info",trytry,230 Python 3 for Absolute Beginners,"try: dict['foo'] except KeyError: pass # dictionary-specific lookup problem try: dict['bar'] except LookupError: pass # lookup problems in dictionaries, tuples and lists try: dict['quux'] except Exception: pass # any problem, of any sort except KeyError: raise Exception(""Should have been handled by the first match"") Almost all exceptions you encounter could be handled by explicitly handling the Exception class; similarly, any dictionary or sequence lookups can be handled with LookupError rather than explicitly handling both KeyError and IndexError. Note again in the last example in Listing 10-9 that they are handled by the first matching except clause found, not the closest match. Using finally to Clean Up After a Problem If you don’t handle an exception locally, that’s generally a signal to the rest of your program that there might be some cleaning up to do. However, sometimes an exception can interrupt your program at such a point that there are other unfinished tasks that are far more easily cleaned up locally, even if the primary exception needs to be handled at a higher level. An example is closing a file that you’ve opened in the current method. Your current method might want to write a log to a file. If an exception is raised while the file is still open, only that method has direct access to the file object in order to close it. Leaving the file open could cause problems much later in your program should it try to access that potentially locked file. It’s best to be certain that the file object will be closed, whether or not an exception is raised and whether or not it is handled. www.it-ebooks.info 231",trytry,231 Python 3 for Absolute Beginners,"try: # Catch a NameError, and raise a new error ""from"" it try: foo except Exception as e: raise Exception(""Explicitly raised"") from e # Re-catch the new exception except Exception as e2: return e2 def return implicit chain(): try: # Catch a NameError, but accidentally raise a KeyError try: foo except Exception as e: {}['bar'] # Re-catch the new exception except Exception as e2: return e2 # The explicitly raised exception, and its ""cause"" ex ch = return explicit chain() print(""Explicit chain:"") ()) print(ex ch. print(ex ch. ) # The implicitly raised error, and its ""context"" print(""Implicit chain:"") im ch = return implicit chain() print(im ch. print(im ch. # Re-raise, to see the corresponding traceback # raise im ch # Uncomment this to see the implicit chain raise ex ch repr context repr cause ()) ) When you run the preceding code, you’ll get these results: 236 www.it-ebooks.info",trytry,236 Python 3 for Absolute Beginners,"try: foo NameError: global name 'foo' is not defined The above exception was the direct cause of the following exception: Traceback (most recent call last): File ""./chaining.py"", line 35, in <module> raise ex ch File ""./chaining.py"", line 6, in return explicit chain raise Exception(""Explicitly raised"") from e Exception: Explicitly raised Now, comment out the next-to-last line to see the traceback from an implicit chain: Explicit chain: Exception('Explicitly raised',) global name 'foo' is not defined Implicit chain: KeyError('bar',) global name 'foo' is not defined Traceback (most recent call last): File ""./chaining.py"", line 14, in return implicit chain try: foo NameError: global name 'foo' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File ""./chaining.py"", line 34, in <module> raise im ch # Uncomment this to see the implicit chain File ""./chaining.py"", line 16, in return implicit chain {}['bar'] KeyError: 'bar' As you can see, more complex tracebacks will distinguish between explicit and implicit chaining by leaving a newline and then referring to the next exception that was raised en route to the eventual traceback. www.it-ebooks.info 237",trytry,237 Python 3 for Absolute Beginners,"try: return divide by(x, y) except ZeroDivisionError:",tryexcept,223 Python 3 for Absolute Beginners,"try: d = {""foo"": ""bar""} d[""quux""] except KeyError as e:",tryexcept,229 Python 3 for Absolute Beginners,"try: return some object.result() except AttributeError:",tryexcept,238 Python 3 for Absolute Beginners,def collect kwargs(**kwargs):,funcwith2star,103 Python 3 for Absolute Beginners,"def collect args(b, e, a = 432, c = 512, *args, **kwargs):",funcwith2star,104 Python 3 for Absolute Beginners,def collect args(*args):,funcwithstar,103 Python 3 for Absolute Beginners,def trace(*text):,funcwithstar,216 Python 3 for Absolute Beginners,"def on about(self, widget, *args):",funcwithstar,278 Python 3 for Absolute Beginners,"def on treeview1 cursor changed(self, widget, *args):",funcwithstar,278 Python 3 for Absolute Beginners,"def on window1 delete event(self, widget, *args):",funcwithstar,280 Python 3 for Absolute Beginners,"def on new1 activate(self, widget, *args):",funcwithstar,280 Python 3 for Absolute Beginners,"def on open1 activate(self, widget, *args):",funcwithstar,280 Python 3 for Absolute Beginners,"def on save1 activate(self, widget, *args):",funcwithstar,280 Python 3 for Absolute Beginners,"def on save as1 activate(self, widget, *args):",funcwithstar,280 Python 3 for Absolute Beginners,"def on quit1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on cut1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on copy1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on paste1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on delete1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on about1 activate(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on treeview1 cursor changed(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,"def on button1 clicked(self, widget, *args):",funcwithstar,281 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,190 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,190 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,191 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,192 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,193 Python 3 for Absolute Beginners,class Player(GameObject):,simpleclass,205 Python 3 for Absolute Beginners,class Thing(GameObject):,simpleclass,209 Python 3 for Absolute Beginners,class Weapon(Thing):,simpleclass,210 Python 3 for Absolute Beginners,class Armour(Thing):,simpleclass,210 Python 3 for Absolute Beginners,class Location(GameObject):,simpleclass,210 Python 3 for Absolute Beginners,class SecurityError(Exception):,simpleclass,227 Python 3 for Absolute Beginners,class SecurityNotCertain(SecurityError):,simpleclass,227 Python 3 for Absolute Beginners,class BuildingIntegrityError(SecurityError):,simpleclass,227 Python 3 for Absolute Beginners,class MotionDetectedError(SecurityError):,simpleclass,228 Python 3 for Absolute Beginners,class Window1(SimpleGladeApp):,simpleclass,280 Python 3 for Absolute Beginners,raise KeyError('foo'),raise,225 Python 3 for Absolute Beginners,"matrix = [[11,12,13],[21,22,23],[31,32,33]]",nestedList,83 Python 3 for Absolute Beginners,"matrix = [['data', 'data', 'data'], ['data', 'data', 'data']",nestedList,85 Python 3 for Absolute Beginners,"msgs = ['[soso ...]', '[ok]', '[you know ...]', '[terrible]",nestedList,131 Python 3 for Absolute Beginners,"result = ['\t'.join([str(i), str(arg)]) for i, arg in enumerate(sys.argv)]",nestedList,171 Python 3 for Absolute Beginners,"kwargs = {'first': 729, 'second':546, 'third':819}",simpleDict,104 Python 3 for Absolute Beginners,self.commands = {'look':'print({0!s},simpleDict,210 Python 3 for Absolute Beginners,self.commands = {'look':'print({0!s},simpleDict,216 Python 3 for Absolute Beginners,"print(""Safe 3 / 2 = {0:g}",simpleDict,223 Python 3 for Absolute Beginners,"print(""Unsafe 3 / 2 = {0:g}",simpleDict,223 Python 3 for Absolute Beginners,"print(""Safe 3 / 0 = {0:g}",simpleDict,223 Python 3 for Absolute Beginners,"print(""Unsafe 3 / 0 = {0:g}",simpleDict,223 Python 3 for Absolute Beginners,"print(""Unsafe 3 / 0 = {0:g}",simpleDict,223 Python 3 for Absolute Beginners,config = {'where': 'local'},simpleDict,247 Python 3 for Absolute Beginners,config = {'new': True},simpleDict,247 Python 3 for Absolute Beginners,"File objects can be created with the built-in open(filename[, mode[, buffering]])",openfunc,141 Python 3 for Absolute Beginners,Opening the file by just passing the filename to open(),openfunc,142 Python 3 for Absolute Beginners,text = open('story.txt'),openfunc,142 Python 3 for Absolute Beginners,text = open('story.txt'),openfunc,142 Python 3 for Absolute Beginners,"out file = open('story.html', 'w')",openfunc,143 Python 3 for Absolute Beginners,"out file = open('story.html', 'a')",openfunc,143 Python 3 for Absolute Beginners,"out file = open('story.html', 'a')",openfunc,144 Python 3 for Absolute Beginners,input file = open(input filename),openfunc,146 Python 3 for Absolute Beginners,"output file = open(output filename, 'w')",openfunc,146 Python 3 for Absolute Beginners,script = open(filename),openfunc,151 Python 3 for Absolute Beginners,"data file = open('rpcharacters.rpg', 'w')",openfunc,157 Python 3 for Absolute Beginners,data file = open('rpcharacters.rpg'),openfunc,158 Python 3 for Absolute Beginners,"data file = open('rpcharacters.rpg', 'w')",openfunc,217 Python 3 for Absolute Beginners,data file = open('rpcharacters.rpg'),openfunc,218 Python 3 for Absolute Beginners,return convert string(open(filename).read()),openfunc,244 Python 3 for Absolute Beginners,r = csv.reader(open('purchases.csv')),openfunc,256 Python 3 for Absolute Beginners,r = urllib.request.urlopen('http://python.org/'),openfunc,258 Python 3 for Absolute Beginners,"output file = open(outfile name,'w')",openfunc,277 Python 3 for Absolute Beginners,"Writing to the file is simple. As long as you opened the file in w or a mode, file.write(str)",write,143 Python 3 for Absolute Beginners,out file.write(content),write,143 Python 3 for Absolute Beginners,out file.write(content),write,143 Python 3 for Absolute Beginners,out file.write(content),write,144 Python 3 for Absolute Beginners,"closing it is cleaner. Often, the data in a file.write()",write,144 Python 3 for Absolute Beginners,output file.write(text),write,146 Python 3 for Absolute Beginners,sys.stdout.write(output string),write,171 Python 3 for Absolute Beginners,output file.write(a out),write,277 Python 3 for Absolute Beginners,file.write(),write,286 Python 3 for Absolute Beginners,You can also write a list of strings to the file using file.writelines(sequence),writelines,143 Python 3 for Absolute Beginners,"any iterable object producing strings, though typically it’s a list of strings; writelines()",writelines,143 Python 3 for Absolute Beginners,data file.writelines(lines),writelines,157 Python 3 for Absolute Beginners,data file.writelines(lines),writelines,218 Python 3 for Absolute Beginners,file.writelines(sequence),writelines,286 Python 3 for Absolute Beginners,The most basic method you can use to access the file’s contents is file.read([size]),read,142 Python 3 for Absolute Beginners,text.read(),read,142 Python 3 for Absolute Beginners,text = input file.read(),read,146 Python 3 for Absolute Beginners,"read in data from stdin, you would write sys.stdin.read(), which calls the read()",read,170 Python 3 for Absolute Beginners,result = sys.stdin.read(),read,171 Python 3 for Absolute Beginners,open('example.txt').read(),read,244 Python 3 for Absolute Beginners,print(convert string(sys.stdin.read())),read,248 Python 3 for Absolute Beginners,text = r.read(),read,258 Python 3 for Absolute Beginners,smaller pieces. file.readline([size]),readline,142 Python 3 for Absolute Beginners,text.readline(),readline,143 Python 3 for Absolute Beginners,"iteration returns the same result as file.readline(), and the loop ends when the readline()",readline,143 Python 3 for Absolute Beginners,file.readline(),readline,286 Python 3 for Absolute Beginners,file.readline([size]),readline,286 Python 3 for Absolute Beginners,import the,importfunc,22 Python 3 for Absolute Beginners,import hello,importfunc,22 Python 3 for Absolute Beginners,import random,importfunc,91 Python 3 for Absolute Beginners,import random,importfunc,93 Python 3 for Absolute Beginners,import random,importfunc,102 Python 3 for Absolute Beginners,import random,importfunc,115 Python 3 for Absolute Beginners,import rpcombat,importfunc,123 Python 3 for Absolute Beginners,import the,importfunc,136 Python 3 for Absolute Beginners,import time,importfunc,149 Python 3 for Absolute Beginners,import should,importfunc,166 Python 3 for Absolute Beginners,import os,importfunc,167 Python 3 for Absolute Beginners,import style,importfunc,169 Python 3 for Absolute Beginners,import statement,importfunc,170 Python 3 for Absolute Beginners,import foo,importfunc,170 Python 3 for Absolute Beginners,import sys,importfunc,170 Python 3 for Absolute Beginners,import everything,importfunc,170 Python 3 for Absolute Beginners,import statement,importfunc,170 Python 3 for Absolute Beginners,import the,importfunc,170 Python 3 for Absolute Beginners,import statement,importfunc,170 Python 3 for Absolute Beginners,import functions,importfunc,170 Python 3 for Absolute Beginners,import sys,importfunc,171 Python 3 for Absolute Beginners,import time,importfunc,171 Python 3 for Absolute Beginners,import time,importfunc,174 Python 3 for Absolute Beginners,import cgitb,importfunc,176 Python 3 for Absolute Beginners,import cgi,importfunc,177 Python 3 for Absolute Beginners,import cgitb,importfunc,177 Python 3 for Absolute Beginners,import time,importfunc,177 Python 3 for Absolute Beginners,import a,importfunc,185 Python 3 for Absolute Beginners,import random,importfunc,202 Python 3 for Absolute Beginners,import time,importfunc,202 Python 3 for Absolute Beginners,import rpcombat,importfunc,219 Python 3 for Absolute Beginners,import a,importfunc,227 Python 3 for Absolute Beginners,import strings,importfunc,242 Python 3 for Absolute Beginners,import statement,importfunc,243 Python 3 for Absolute Beginners,import convert,importfunc,244 Python 3 for Absolute Beginners,import them,importfunc,244 Python 3 for Absolute Beginners,"import keyword",importfunc,244 Python 3 for Absolute Beginners,import only,importfunc,244 Python 3 for Absolute Beginners,import everything,importfunc,244 Python 3 for Absolute Beginners,import convert,importfunc,245 Python 3 for Absolute Beginners,import each,importfunc,245 Python 3 for Absolute Beginners,import it,importfunc,245 Python 3 for Absolute Beginners,import the,importfunc,245 Python 3 for Absolute Beginners,import from,importfunc,245 Python 3 for Absolute Beginners,import within,importfunc,245 Python 3 for Absolute Beginners,import never,importfunc,245 Python 3 for Absolute Beginners,import syntax,importfunc,245 Python 3 for Absolute Beginners,import keyword,importfunc,245 Python 3 for Absolute Beginners,import convert,importfunc,245 Python 3 for Absolute Beginners,"import is",importfunc,246 Python 3 for Absolute Beginners,"import a",importfunc,246 Python 3 for Absolute Beginners,import statements,importfunc,246 Python 3 for Absolute Beginners,import statements,importfunc,246 Python 3 for Absolute Beginners,import the,importfunc,246 Python 3 for Absolute Beginners,import it,importfunc,247 Python 3 for Absolute Beginners,import strings,importfunc,248 Python 3 for Absolute Beginners,import sys,importfunc,248 Python 3 for Absolute Beginners,import statement,importfunc,249 Python 3 for Absolute Beginners,import statements,importfunc,249 Python 3 for Absolute Beginners,import statements,importfunc,249 Python 3 for Absolute Beginners,import convert,importfunc,249 Python 3 for Absolute Beginners,import imp,importfunc,249 Python 3 for Absolute Beginners,import convert,importfunc,249 Python 3 for Absolute Beginners,import keyword,importfunc,250 Python 3 for Absolute Beginners,import a,importfunc,250 Python 3 for Absolute Beginners,import statement,importfunc,251 Python 3 for Absolute Beginners,import from,importfunc,251 Python 3 for Absolute Beginners,"import name",importfunc,251 Python 3 for Absolute Beginners,import pirate,importfunc,252 Python 3 for Absolute Beginners,import a,importfunc,252 Python 3 for Absolute Beginners,import that,importfunc,252 Python 3 for Absolute Beginners,import it,importfunc,252 Python 3 for Absolute Beginners,import statements,importfunc,253 Python 3 for Absolute Beginners,import pirate,importfunc,253 Python 3 for Absolute Beginners,import statements,importfunc,253 Python 3 for Absolute Beginners,import pirate,importfunc,253 Python 3 for Absolute Beginners,import imp,importfunc,253 Python 3 for Absolute Beginners,import statements,importfunc,254 Python 3 for Absolute Beginners,import csv,importfunc,256 Python 3 for Absolute Beginners,import datetime,importfunc,257 Python 3 for Absolute Beginners,import statement,importfunc,260 Python 3 for Absolute Beginners,import and,importfunc,260 Python 3 for Absolute Beginners,import Tkinter,importfunc,262 Python 3 for Absolute Beginners,import the,importfunc,265 Python 3 for Absolute Beginners,import gtk,importfunc,265 Python 3 for Absolute Beginners,import gtk,importfunc,272 Python 3 for Absolute Beginners,import pango,importfunc,272 Python 3 for Absolute Beginners,import os,importfunc,279 Python 3 for Absolute Beginners,import gtk,importfunc,279 Python 3 for Absolute Beginners,"from the project directory and import the",importfromsimple,123 Python 3 for Absolute Beginners,from sys import argv,importfromsimple,170 Python 3 for Absolute Beginners,"from the standard library import random",importfromsimple,243 Python 3 for Absolute Beginners,"from a module, you can use one of two Python constructs. import modulename",importfromsimple,244 Python 3 for Absolute Beginners,from convert import piratify,importfromsimple,245 Python 3 for Absolute Beginners,"from convert import convert",importfromsimple,245 Python 3 for Absolute Beginners,from convert import random,importfromsimple,245 Python 3 for Absolute Beginners,from internals import config,importfromsimple,247 Python 3 for Absolute Beginners,from pirate import convert,importfromsimple,252 Python 3 for Absolute Beginners,from pirate import convert,importfromsimple,253 Python 3 for Absolute Beginners,from pirate import convert,importfromsimple,254 Python 3 for Absolute Beginners,from SimpleGladeApp import SimpleGladeApp,importfromsimple,279 Python 3 for Absolute Beginners,from SimpleGladeApp import bindtextdomain,importfromsimple,279 Python 3 for Absolute Beginners,self.name = name.title(),simpleattr,182 Python 3 for Absolute Beginners,self.desc = desc.capitalize(),simpleattr,182 Python 3 for Absolute Beginners,self.name = name.title(),simpleattr,182 Python 3 for Absolute Beginners,self.name = name.title(),simpleattr,186 Python 3 for Absolute Beginners,self.desc = desc.capitalize(),simpleattr,186 Python 3 for Absolute Beginners,self.gender = 'female',simpleattr,186 Python 3 for Absolute Beginners,self.gender = 'male',simpleattr,187 Python 3 for Absolute Beginners,self.gender = 'neuter',simpleattr,187 Python 3 for Absolute Beginners,self.race = 'Pixie',simpleattr,187 Python 3 for Absolute Beginners,self.race = 'Vulcan',simpleattr,187 Python 3 for Absolute Beginners,self.race = 'Gelfling',simpleattr,187 Python 3 for Absolute Beginners,self.race = 'Troll',simpleattr,187 Python 3 for Absolute Beginners,self.race = 'Goblin',simpleattr,187 Python 3 for Absolute Beginners,"self.muscle = roll(33,3)",simpleattr,187 Python 3 for Absolute Beginners,"self.brainz = roll(33,3)",simpleattr,187 Python 3 for Absolute Beginners,"self.speed = roll(33,3)",simpleattr,187 Python 3 for Absolute Beginners,"self.charm = roll(33,3)",simpleattr,187 Python 3 for Absolute Beginners,"self.life = int((self.getMuscle() + (self.getSpeed()/2) + roll(49,1))/2)",simpleattr,187 Python 3 for Absolute Beginners,"self.life = int(roll(33,3))",simpleattr,187 Python 3 for Absolute Beginners,"self.magic = int((self.getBrainz() + (self.getCharm()/2) + roll(49,1))/2)",simpleattr,188 Python 3 for Absolute Beginners,"self.magic = int(roll(33,3))",simpleattr,188 Python 3 for Absolute Beginners,"self.prot = int((self.getSpeed() + (self.getBrainz()/2) + roll(49,1))/2)",simpleattr,188 Python 3 for Absolute Beginners,"self.prot = int(roll(33,3))",simpleattr,188 Python 3 for Absolute Beginners,"self.gold = int(roll(40,4))",simpleattr,188 Python 3 for Absolute Beginners,self.inv = [],simpleattr,188 Python 3 for Absolute Beginners,self.price = price,simpleattr,190 Python 3 for Absolute Beginners,self.strength = strength,simpleattr,190 Python 3 for Absolute Beginners,self.speed = speed,simpleattr,190 Python 3 for Absolute Beginners,self.price = price,simpleattr,191 Python 3 for Absolute Beginners,self.strength = strength,simpleattr,191 Python 3 for Absolute Beginners,self.damage = strength,simpleattr,191 Python 3 for Absolute Beginners,self.speed = speed,simpleattr,191 Python 3 for Absolute Beginners,self.price = price,simpleattr,192 Python 3 for Absolute Beginners,self.strength = strength,simpleattr,192 Python 3 for Absolute Beginners,self.speed = speed,simpleattr,192 Python 3 for Absolute Beginners,self.damage = strength,simpleattr,192 Python 3 for Absolute Beginners,self.damage = strength,simpleattr,193 Python 3 for Absolute Beginners,self. name = name.title(),simpleattr,203 Python 3 for Absolute Beginners,self. desc = desc.capitalize(),simpleattr,203 Python 3 for Absolute Beginners,self. gender = 'female',simpleattr,203 Python 3 for Absolute Beginners,self. gender = 'male',simpleattr,203 Python 3 for Absolute Beginners,self. gender = 'neuter',simpleattr,203 Python 3 for Absolute Beginners,self. race = 'Pixie',simpleattr,204 Python 3 for Absolute Beginners,self. race = 'Vulcan',simpleattr,204 Python 3 for Absolute Beginners,self. race = 'Gelfling',simpleattr,204 Python 3 for Absolute Beginners,self. race = 'Troll',simpleattr,204 Python 3 for Absolute Beginners,self. race = 'Goblin',simpleattr,204 Python 3 for Absolute Beginners,"self. strength = roll(33,3)",simpleattr,204 Python 3 for Absolute Beginners,"self. brainz = roll(33,3)",simpleattr,204 Python 3 for Absolute Beginners,"self. speed = roll(33,3)",simpleattr,204 Python 3 for Absolute Beginners,"self. charm = roll(33,3)",simpleattr,204 Python 3 for Absolute Beginners,self. life = int(value),simpleattr,205 Python 3 for Absolute Beginners,self. magic = int(value),simpleattr,205 Python 3 for Absolute Beginners,self. prot = int(value),simpleattr,205 Python 3 for Absolute Beginners,self. gold = int(value),simpleattr,205 Python 3 for Absolute Beginners,self.inv = contents,simpleattr,205 Python 3 for Absolute Beginners,self. life = int((self.strength + (self.speed / 2) + \,simpleattr,206 Python 3 for Absolute Beginners,"self. life = int(roll(33,3))",simpleattr,206 Python 3 for Absolute Beginners,"self. magic = int((self.brainz + (self.charm / 2) + roll(49,1))/2)",simpleattr,206 Python 3 for Absolute Beginners,"self. magic = int(roll(33,3))",simpleattr,206 Python 3 for Absolute Beginners,"self. prot = int((self.speed + (self.brainz / 2) + roll(49,1))/2)",simpleattr,206 Python 3 for Absolute Beginners,"self. prot = int(roll(33,3))",simpleattr,206 Python 3 for Absolute Beginners,"self. gold = int(roll(40,4))",simpleattr,206 Python 3 for Absolute Beginners,self.weapon = available weapons[0],simpleattr,207 Python 3 for Absolute Beginners,self.armour = available armour[0],simpleattr,207 Python 3 for Absolute Beginners,self.gold -= item.gold,simpleattr,208 Python 3 for Absolute Beginners,self. strength = value,simpleattr,209 Python 3 for Absolute Beginners,self. speed = value,simpleattr,209 Python 3 for Absolute Beginners,self. name = name.capitalize(),simpleattr,210 Python 3 for Absolute Beginners,"self. desc = ""It looks like a building site, nothing to see.""",simpleattr,210 Python 3 for Absolute Beginners,self. vel max = velocity,simpleattr,213 Python 3 for Absolute Beginners,self. vel min = velocity,simpleattr,213 Python 3 for Absolute Beginners,self. dam max = damage,simpleattr,213 Python 3 for Absolute Beginners,self. dam min = damage,simpleattr,213 Python 3 for Absolute Beginners,self. vel max = self. dam max = 23,simpleattr,214 Python 3 for Absolute Beginners,self. vel min = self. dam min = 1,simpleattr,214 Python 3 for Absolute Beginners,self.inventory = players,simpleattr,215 Python 3 for Absolute Beginners,"self.hello button = Tkinter.Button(frame, text=""Hello"",",simpleattr,262 Python 3 for Absolute Beginners,self.hello button.pack(side=Tkinter.LEFT),simpleattr,262 Python 3 for Absolute Beginners,"self.quit button = Tkinter.Button(frame, text=""QUIT"", fg=""red"",",simpleattr,262 Python 3 for Absolute Beginners,self.quit button.pack(side=Tkinter.LEFT),simpleattr,262 Python 3 for Absolute Beginners,self.window = gtk.Window(gtk.WINDOW TOPLEVEL),simpleattr,265 Python 3 for Absolute Beginners,"self.box1 = gtk.HBox(False, 0)",simpleattr,266 Python 3 for Absolute Beginners,"self.button1 = gtk.Button(""Hello"")",simpleattr,266 Python 3 for Absolute Beginners,"self.button2 = gtk.Button(""Quit"")",simpleattr,266 Python 3 for Absolute Beginners,self.window = gtk.Window(gtk.WINDOW TOPLEVEL),simpleattr,272 Python 3 for Absolute Beginners,"self.vbox1 = gtk.VBox(False, 0)",simpleattr,272 Python 3 for Absolute Beginners,self.menubar1 = gtk.MenuBar(),simpleattr,272 Python 3 for Absolute Beginners,"self.file = gtk.MenuItem(label="" File"", use underline=True)",simpleattr,273 Python 3 for Absolute Beginners,self.file menu = gtk.Menu(),simpleattr,273 Python 3 for Absolute Beginners,"self.save as = gtk.ImageMenuItem(stock id=""gtk-save"")",simpleattr,273 Python 3 for Absolute Beginners,"self.quit = gtk.ImageMenuItem(stock id=""gtk-quit"")",simpleattr,273 Python 3 for Absolute Beginners,"self.edit = gtk.MenuItem(label="" Edit"", use underline=True)",simpleattr,273 Python 3 for Absolute Beginners,self.edit menu = gtk.Menu(),simpleattr,273 Python 3 for Absolute Beginners,"self.copy = gtk.ImageMenuItem(stock id=""gtk-copy"")",simpleattr,273 Python 3 for Absolute Beginners,"self.help = gtk.MenuItem(label="" Help"", use underline=True)",simpleattr,273 Python 3 for Absolute Beginners,self.help menu = gtk.Menu(),simpleattr,273 Python 3 for Absolute Beginners,"self.about = gtk.ImageMenuItem(stock id=""gtk-about"")",simpleattr,273 Python 3 for Absolute Beginners,"self.hhelp = gtk.ImageMenuItem(stock id=""gtk-help"")",simpleattr,273 Python 3 for Absolute Beginners,"self.hbox1 = gtk.HBox(False, 0)",simpleattr,274 Python 3 for Absolute Beginners,self.scrolledwindow1 = gtk.ScrolledWindow(),simpleattr,274 Python 3 for Absolute Beginners,self.treeview1 = gtk.TreeView(),simpleattr,274 Python 3 for Absolute Beginners,self.scrolledwindow2 = gtk.ScrolledWindow(),simpleattr,274 Python 3 for Absolute Beginners,self.textview1 = gtk.TextView(self.textbuffer),simpleattr,274 Python 3 for Absolute Beginners,"self.button2 = gtk.Button(""Quit"")",simpleattr,274 Python 3 for Absolute Beginners,self.choice = self.treeview1.get selection(),simpleattr,275 Python 3 for Absolute Beginners,"self.model, self.row reference = self.choice.get selected()",simpleattr,275 Python 3 for Absolute Beginners,"self.choice = self.liststore.get value(self.row reference, 0)",simpleattr,275 Python 3 for Absolute Beginners,self.textbuffer = gtk.TextBuffer(None),simpleattr,275 Python 3 for Absolute Beginners,"self.headline = self.textbuffer.create tag('headline',",simpleattr,275 Python 3 for Absolute Beginners,self.textbuffer = gtk.TextBuffer(None),simpleattr,277 Python 3 for Absolute Beginners,"self.headline = self.textbuffer.create tag('headline',",simpleattr,277 Python 3 for Absolute Beginners,counter += 1,assignIncrement,54 Python 3 for Absolute Beginners,c += 1,assignIncrement,56 Python 3 for Absolute Beginners,width +=1,assignIncrement,61 Python 3 for Absolute Beginners,width +=2,assignIncrement,61 Python 3 for Absolute Beginners,widths +=1,assignIncrement,63 Python 3 for Absolute Beginners,widths +=2,assignIncrement,63 Python 3 for Absolute Beginners,total += number,assignIncrement,66 Python 3 for Absolute Beginners,counter += 1,assignIncrement,66 Python 3 for Absolute Beginners,sum += this input,assignIncrement,68 Python 3 for Absolute Beginners,counter += 1,assignIncrement,68 Python 3 for Absolute Beginners,output string += char,assignIncrement,72 Python 3 for Absolute Beginners,"result += random.randint(1,sides)",assignIncrement,102 Python 3 for Absolute Beginners,"result += random.randint(1,sides)",assignIncrement,109 Python 3 for Absolute Beginners,"result += random.randint(1,sides)",assignIncrement,116 Python 3 for Absolute Beginners,read += 4,assignIncrement,162 Python 3 for Absolute Beginners,write += 2,assignIncrement,162 Python 3 for Absolute Beginners,execute += 1,assignIncrement,162 Python 3 for Absolute Beginners,self += other,assignIncrement,199 Python 3 for Absolute Beginners,miss counter += 1,assignIncrement,215 Python 3 for Absolute Beginners,"result += random.randint(1,sides)",assignIncrement,217 Python 3 for Absolute Beginners,"total += expected gains(bet[1], bet[2], perc to prob(bet[0]))",assignIncrement,227 Python 3 for Absolute Beginners,total += cost,assignIncrement,256 Python 3 for Absolute Beginners,"def roll(sides = 6, dice = 1):",funcdefault,103 Python 3 for Absolute Beginners,"def roll(sides, dice = 1):",funcdefault,108 Python 3 for Absolute Beginners,def ziply(sides=None):,funcdefault,113 Python 3 for Absolute Beginners,"def roll(sides, dice = 1):",funcdefault,115 Python 3 for Absolute Beginners,def ziply(seq=None):,funcdefault,116 Python 3 for Absolute Beginners,"def roll(sides, dice = 1):",funcdefault,216 Python 3 for Absolute Beginners,def ziply(seq=None):,funcdefault,217 Python 3 for Absolute Beginners,"def expected gains(amount bet = 10, amount to win = 10, frac = 0.5):",funcdefault,226 Python 3 for Absolute Beginners,def get report(file = 'report.txt'):,funcdefault,228 Python 3 for Absolute Beginners,"def delete event(self, widget, event, data=None):",funcdefault,265 Python 3 for Absolute Beginners,"def delete event(self, widget, event, data=None):",funcdefault,270 Python 3 for Absolute Beginners,"def delete event(self, widget, event, data=None):",funcdefault,279 Python 3 for Absolute Beginners,return to the text file to complete the first stage of the software,return,13 Python 3 for Absolute Beginners,return to this,return,14 Python 3 for Absolute Beginners,"return a value of some kind, so it is usual to catch this value by assigning it to a",return,19 Python 3 for Absolute Beginners,"return statement can also pass a value back to the main program for use in further",return,25 Python 3 for Absolute Beginners,"return • try",return,28 Python 3 for Absolute Beginners,"return (CR): On a mechanical typewriter, the linefeed would just give you a new line, while",return,34 Python 3 for Absolute Beginners,return would properly start a new paragraph. One of the instances where you might need to,return,34 Python 3 for Absolute Beginners,return (CR),return,34 Python 3 for Absolute Beginners,return to Cloud-Cuckoo,return,43 Python 3 for Absolute Beginners,"return some crazy values, which",return,44 Python 3 for Absolute Beginners,return type for a,return,45 Python 3 for Absolute Beginners,return value to report whether some condition holds or not.,return,45 Python 3 for Absolute Beginners,return True if either variable is true. If I wanted to narrow my search to find out,return,52 Python 3 for Absolute Beginners,return True. If you want to be totally contrary and test,return,52 Python 3 for Absolute Beginners,return True if the value you are testing,return,52 Python 3 for Absolute Beginners,return False.,return,52 Python 3 for Absolute Beginners,return True only if var1 is less than 6 and var2 is greater than 7. We can also use or:,return,53 Python 3 for Absolute Beginners,return False if you test them as shown previously.,return,56 Python 3 for Absolute Beginners,"return True if x is in sequence s; otherwise, it will return False.",return,77 Python 3 for Absolute Beginners,return False in when tested in Boolean expressions.,return,79 Python 3 for Absolute Beginners,return a value from the list at the same time. This can be,return,81 Python 3 for Absolute Beginners,return another,return,83 Python 3 for Absolute Beginners,return a list of the results. Think of,return,84 Python 3 for Absolute Beginners,"return the keys, the values, and the key-value pairs respectively. You’ll notice that the",return,87 Python 3 for Absolute Beginners,return views instead of lists. Views can be iterated over and support membership,return,88 Python 3 for Absolute Beginners,"return a pseudorandom integer between the start and end of the specified range, much like",return,92 Python 3 for Absolute Beginners,return profile,return,102 Python 3 for Absolute Beginners,return some data using a return statement. The function’s last line specifies,return,102 Python 3 for Absolute Beginners,"return statement, and Python will assume None as the default return value.",return,102 Python 3 for Absolute Beginners,return result,return,102 Python 3 for Absolute Beginners,return a random number,return,103 Python 3 for Absolute Beginners,return values. You might also want to include,return,104 Python 3 for Absolute Beginners,"return the result, which will be collected",return,105 Python 3 for Absolute Beginners,return vars(),return,105 Python 3 for Absolute Beginners,"return a symbol table, for which you need to provide the name of the object",return,107 Python 3 for Absolute Beginners,return vars(),return,107 Python 3 for Absolute Beginners,"return value or indeed, any input parameters.",return,108 Python 3 for Absolute Beginners,return immutable values from,return,108 Python 3 for Absolute Beginners,return any either.,return,108 Python 3 for Absolute Beginners,return result,return,109 Python 3 for Absolute Beginners,return profile to the end:,return,109 Python 3 for Absolute Beginners,return profile,return,110 Python 3 for Absolute Beginners,"return statement that returns the value False. It could just as well return any value that evaluates to False, so",return,110 Python 3 for Absolute Beginners,return at the end of the function has to return something; it doesn’t really,return,110 Python 3 for Absolute Beginners,return values to control the loop,return,110 Python 3 for Absolute Beginners,return any values for any other reason.,return,110 Python 3 for Absolute Beginners,return False statement in the buy equipment() function to return,return,110 Python 3 for Absolute Beginners,return profile['inventory'] == [] and profile['gold'] > 10,return,111 Python 3 for Absolute Beginners,return purchase,return,111 Python 3 for Absolute Beginners,return the members of profile['inventory'] not in,return,111 Python 3 for Absolute Beginners,"return Next, I inserted a dummy call in the main body:",return,112 Python 3 for Absolute Beginners,"return As the chances of the actual phrase coming up naturally were rather small, I inserted a dummy call",return,112 Python 3 for Absolute Beginners,return sentence,return,112 Python 3 for Absolute Beginners,return velocity,return,113 Python 3 for Absolute Beginners,return damage,return,113 Python 3 for Absolute Beginners,return tuple(matches),return,113 Python 3 for Absolute Beginners,return the data in,return,113 Python 3 for Absolute Beginners,return result,return,116 Python 3 for Absolute Beginners,return tuple(matches),return,116 Python 3 for Absolute Beginners,return sentence,return,116 Python 3 for Absolute Beginners,return sentence,return,117 Python 3 for Absolute Beginners,return profile,return,118 Python 3 for Absolute Beginners,return profile['inventory'] == [] and profile['gold'] > 10,return,119 Python 3 for Absolute Beginners,return purchase,return,119 Python 3 for Absolute Beginners,return velocity,return,119 Python 3 for Absolute Beginners,"return damage, potential damage",return,120 Python 3 for Absolute Beginners,return values.,return,124 Python 3 for Absolute Beginners,return value of the function.,return,124 Python 3 for Absolute Beginners,return the original string and two empty strings.,return,126 Python 3 for Absolute Beginners,return a string that,return,127 Python 3 for Absolute Beginners,return a new edited version of the string.,return,134 Python 3 for Absolute Beginners,return the string obtained by substituting the leftmost nonoverlapping,return,139 Python 3 for Absolute Beginners,return a string.,return,140 Python 3 for Absolute Beginners,return a,return,140 Python 3 for Absolute Beginners,return illegal values when reading files with Unix-style line endings. Use,return,144 Python 3 for Absolute Beginners,return filename,return,150 Python 3 for Absolute Beginners,return out str,return,150 Python 3 for Absolute Beginners,return profile,return,155 Python 3 for Absolute Beginners,"return And here’s the data file itself (rpcharacters.rpg):",return,157 Python 3 for Absolute Beginners,"return Just to complete things for this chapter, I’ll run fix style.py on rpcombat.py again to check I got rid",return,158 Python 3 for Absolute Beginners,"return def naming conventions(functions = ""lower case with underscores""):",return,168 Python 3 for Absolute Beginners,return result,return,168 Python 3 for Absolute Beginners,return result,return,169 Python 3 for Absolute Beginners,return result,return,171 Python 3 for Absolute Beginners,return result,return,171 Python 3 for Absolute Beginners,"return if",return,171 Python 3 for Absolute Beginners,return self.name,return,182 Python 3 for Absolute Beginners,return self.desc,return,182 Python 3 for Absolute Beginners,return self.name,return,182 Python 3 for Absolute Beginners,return a list of names available within the namespace of that,return,184 Python 3 for Absolute Beginners,return self.name,return,186 Python 3 for Absolute Beginners,return self.desc,return,186 Python 3 for Absolute Beginners,return self.gender,return,187 Python 3 for Absolute Beginners,return self.race,return,187 Python 3 for Absolute Beginners,return self.muscle,return,187 Python 3 for Absolute Beginners,return self.brainz,return,187 Python 3 for Absolute Beginners,return self.speed,return,187 Python 3 for Absolute Beginners,return self.charm,return,187 Python 3 for Absolute Beginners,return self.life,return,188 Python 3 for Absolute Beginners,return self.magic,return,188 Python 3 for Absolute Beginners,return self.prot,return,188 Python 3 for Absolute Beginners,return self.gold,return,188 Python 3 for Absolute Beginners,"return "", "".join(self.inv)",return,188 Python 3 for Absolute Beginners,return value would be meaningless anyway. My base,return,192 Python 3 for Absolute Beginners,return a string object. Thing.printValues(self) could,return,193 Python 3 for Absolute Beginners,return stats,return,193 Python 3 for Absolute Beginners,return value in either case must be a string object. If no str,return,193 Python 3 for Absolute Beginners,return stats,return,193 Python 3 for Absolute Beginners,"return the length of the object, that is the",return,194 Python 3 for Absolute Beginners,return False in a Boolean context.,return,194 Python 3 for Absolute Beginners,return the value corresponding to the,return,194 Python 3 for Absolute Beginners,return len(vars(self)),return,195 Python 3 for Absolute Beginners,return item,return,195 Python 3 for Absolute Beginners,"return (self, key, value):",return,195 Python 3 for Absolute Beginners,return a new iterator object that can iterate over all the objects in the container. For,return,195 Python 3 for Absolute Beginners,return a new iterator object,return,195 Python 3 for Absolute Beginners,"return True if the item is in self, False otherwise. For mapping objects, it should consider the keys of",return,195 Python 3 for Absolute Beginners,return self.,return,196 Python 3 for Absolute Beginners,return the (computed) attribute value or raise an AttributeError exception.,return,197 Python 3 for Absolute Beginners,return the singleton NotImplemented if the method does not,return,197 Python 3 for Absolute Beginners,"return any value, so if the comparison operator is",return,197 Python 3 for Absolute Beginners,"return False or True. When this method is not defined, len ()",return,198 Python 3 for Absolute Beginners,return NotImplemented.,return,199 Python 3 for Absolute Beginners,return the result,return,199 Python 3 for Absolute Beginners,return an integer.,return,200 Python 3 for Absolute Beginners,return self. name,return,203 Python 3 for Absolute Beginners,return self. desc,return,203 Python 3 for Absolute Beginners,return self. gender,return,203 Python 3 for Absolute Beginners,return self. race,return,204 Python 3 for Absolute Beginners,return self. strength,return,204 Python 3 for Absolute Beginners,return self. brainz,return,204 Python 3 for Absolute Beginners,return self. speed,return,204 Python 3 for Absolute Beginners,return self. charm,return,204 Python 3 for Absolute Beginners,return self. life,return,205 Python 3 for Absolute Beginners,return self. magic,return,205 Python 3 for Absolute Beginners,return self. prot,return,205 Python 3 for Absolute Beginners,return self. gold,return,205 Python 3 for Absolute Beginners,return self.inv,return,205 Python 3 for Absolute Beginners,return text,return,205 Python 3 for Absolute Beginners,return stats,return,207 Python 3 for Absolute Beginners,return rpcharacter sheet,return,207 Python 3 for Absolute Beginners,return len(vars(self)),return,208 Python 3 for Absolute Beginners,return item,return,208 Python 3 for Absolute Beginners,"return def buy(self, purchase):",return,208 Python 3 for Absolute Beginners,return purchase,return,208 Python 3 for Absolute Beginners,return int(velocity),return,209 Python 3 for Absolute Beginners,return self. strength,return,209 Python 3 for Absolute Beginners,return self. speed,return,209 Python 3 for Absolute Beginners,return str(self.name),return,209 Python 3 for Absolute Beginners,return stats,return,209 Python 3 for Absolute Beginners,return len(vars(self)),return,209 Python 3 for Absolute Beginners,return item,return,210 Python 3 for Absolute Beginners,return stats,return,210 Python 3 for Absolute Beginners,return stats,return,210 Python 3 for Absolute Beginners,return view,return,211 Python 3 for Absolute Beginners,return stats,return,211 Python 3 for Absolute Beginners,return True,return,211 Python 3 for Absolute Beginners,return True,return,211 Python 3 for Absolute Beginners,return False,return,211 Python 3 for Absolute Beginners,"return def enter(self, player):",return,212 Python 3 for Absolute Beginners,return value.,return,212 Python 3 for Absolute Beginners,"return def damage(self, attacker, target, velocity):",return,212 Python 3 for Absolute Beginners,"return int(damage), int(potential damage)",return,212 Python 3 for Absolute Beginners,return False,return,213 Python 3 for Absolute Beginners,return True,return,214 Python 3 for Absolute Beginners,return False,return,215 Python 3 for Absolute Beginners,"return def exit(self, player):",return,215 Python 3 for Absolute Beginners,return anything either.,return,215 Python 3 for Absolute Beginners,"return class Shop(Location):",return,215 Python 3 for Absolute Beginners,return view,return,216 Python 3 for Absolute Beginners,"return def join with and(sequence):",return,216 Python 3 for Absolute Beginners,return sentence,return,216 Python 3 for Absolute Beginners,return result,return,217 Python 3 for Absolute Beginners,return tuple(matches),return,217 Python 3 for Absolute Beginners,return phrase,return,217 Python 3 for Absolute Beginners,"return def read in():",return,218 Python 3 for Absolute Beginners,"return ##",return,218 Python 3 for Absolute Beginners,return x / y,return,223 Python 3 for Absolute Beginners,return 10000000000000000,return,223 Python 3 for Absolute Beginners,return x / y,return,223 Python 3 for Absolute Beginners,"return a standard big number when the divisor is zero; in fact, they would expect an exception! So we’ll now",return,224 Python 3 for Absolute Beginners,return results that look like this:,return,225 Python 3 for Absolute Beginners,return (percentage > 50),return,226 Python 3 for Absolute Beginners,"return the most likely gains""""""",return,226 Python 3 for Absolute Beginners,return (amount to win * frac) - amount bet,return,226 Python 3 for Absolute Beginners,return pr * 100,return,226 Python 3 for Absolute Beginners,return pc / 100,return,226 Python 3 for Absolute Beginners,return explicit chain():,return,236 Python 3 for Absolute Beginners,return explicit chain,return,237 Python 3 for Absolute Beginners,return some object.result(),return,238 Python 3 for Absolute Beginners,return None,return,238 Python 3 for Absolute Beginners,return None,return,238 Python 3 for Absolute Beginners,"return sentence.strip().rstrip(""!."")",return,242 Python 3 for Absolute Beginners,"return (str + "" "").replace("". "", ""! "").replace("".\n"", ""!\n"").strip()",return,242 Python 3 for Absolute Beginners,"return stub.strip() + "", me hearties! """,return,242 Python 3 for Absolute Beginners,"return ""Yarr, "" + stub[0].lower() + stub[1:] + ""! """,return,242 Python 3 for Absolute Beginners,return yarr(stub),return,243 Python 3 for Absolute Beginners,return me hearties(stub),return,243 Python 3 for Absolute Beginners,"return stub + ""! """,return,243 Python 3 for Absolute Beginners,"return [ s for s in (sen.strip() for sen in text.split(""!"")) if s != """"]",return,243 Python 3 for Absolute Beginners,"return """".join([ random pirate(txt) for txt in to stubs(content) ])",return,244 Python 3 for Absolute Beginners,return config():,return,246 Python 3 for Absolute Beginners,return config,return,246 Python 3 for Absolute Beginners,return config(),return,247 Python 3 for Absolute Beginners,return config(),return,247 Python 3 for Absolute Beginners,return config(),return,247 Python 3 for Absolute Beginners,return config(),return,247 Python 3 for Absolute Beginners,return config(),return,247 Python 3 for Absolute Beginners,return False,return,265 Python 3 for Absolute Beginners,return False,return,270 Python 3 for Absolute Beginners,"return def make pixbuf(self, tvcolumn, cell, model, tier):",return,275 Python 3 for Absolute Beginners,"return The get selection() method catches selections in the options list and displays the system",return,275 Python 3 for Absolute Beginners,"return The menu item File ® Save is connected to the on save as() method, which is supposed to create a",return,276 Python 3 for Absolute Beginners,"return The code for on quit() is easy. As I have already defined a delete event() method, this method can",return,277 Python 3 for Absolute Beginners,"return Edit ® Copy turns out to be a one-liner also. The textbuffer has a built-in method to transfer its",return,277 Python 3 for Absolute Beginners,"return Gtk has another preformed dialog for the About dialog box, so I can fill in the on about() stub using",return,278 Python 3 for Absolute Beginners,"return def on help(self, widget, *args):",return,278 Python 3 for Absolute Beginners,"return ])",return,278 Python 3 for Absolute Beginners,return False,return,279 Python 3 for Absolute Beginners,"return (CR), 34",return,284 Python 3 for Absolute Beginners,"return statement, 102",return,292 Python 3 for Absolute Beginners,print(),printfunc,18 Python 3 for Absolute Beginners,"print(""Hello World!"")",printfunc,19 Python 3 for Absolute Beginners,"print(""Hello World!"")",printfunc,19 Python 3 for Absolute Beginners,print(),printfunc,19 Python 3 for Absolute Beginners,print(),printfunc,19 Python 3 for Absolute Beginners,"print(""Hello World!"")",printfunc,20 Python 3 for Absolute Beginners,print(some text),printfunc,20 Python 3 for Absolute Beginners,"print(""Hello World!)",printfunc,21 Python 3 for Absolute Beginners,print(some text),printfunc,21 Python 3 for Absolute Beginners,print(),printfunc,31 Python 3 for Absolute Beginners,print(),printfunc,31 Python 3 for Absolute Beginners,"print(Gender, Race)",printfunc,31 Python 3 for Absolute Beginners,"print(""Male"" ""Gnome"")",printfunc,31 Python 3 for Absolute Beginners,"print(""Male"" Race)",printfunc,32 Python 3 for Absolute Beginners,"print(""Male"" Race)",printfunc,32 Python 3 for Absolute Beginners,print(boilerplate),printfunc,33 Python 3 for Absolute Beginners,print(variable),printfunc,34 Python 3 for Absolute Beginners,print(),printfunc,35 Python 3 for Absolute Beginners,"print(""\n"", fancy line)",printfunc,36 Python 3 for Absolute Beginners,"print(""\t"", Name)",printfunc,36 Python 3 for Absolute Beginners,"print(""\t"", Race, Gender)",printfunc,36 Python 3 for Absolute Beginners,"print(""\t"", Desc)",printfunc,36 Python 3 for Absolute Beginners,"print(fancy line, ""\n"")",printfunc,36 Python 3 for Absolute Beginners,print(),printfunc,38 Python 3 for Absolute Beginners,print(),printfunc,38 Python 3 for Absolute Beginners,print(13 // 5),printfunc,39 Python 3 for Absolute Beginners,print(13 % 5),printfunc,39 Python 3 for Absolute Beginners,print(-13 // 5),printfunc,39 Python 3 for Absolute Beginners,print(-13 % 5),printfunc,39 Python 3 for Absolute Beginners,print(13 / 5),printfunc,39 Python 3 for Absolute Beginners,print(13.75 / 4.25),printfunc,39 Python 3 for Absolute Beginners,print(-13 // -5),printfunc,40 Python 3 for Absolute Beginners,print(-13 % -5),printfunc,40 Python 3 for Absolute Beginners,print(octal number),printfunc,41 Python 3 for Absolute Beginners,print(hexadecimal number),printfunc,41 Python 3 for Absolute Beginners,"print(""You need"", total length, ""meters of cloth for "", price)",printfunc,44 Python 3 for Absolute Beginners,print(c),printfunc,56 Python 3 for Absolute Beginners,print(),printfunc,58 Python 3 for Absolute Beginners,print('\twidth\theight\twidths\ttotal\tprice'),printfunc,58 Python 3 for Absolute Beginners,"print('\t', curtain width)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t', curtain length)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t\t', widths)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t\t\t', total length)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t\t\t', total length)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t\t\t\t', price)",printfunc,59 Python 3 for Absolute Beginners,"print('\t\t\t\t', round(total length, 2))",printfunc,60 Python 3 for Absolute Beginners,"print('\t\t\t\t\t', round(price, 2))",printfunc,60 Python 3 for Absolute Beginners,"print(""You need"", round(total length, 2), ""meters of cloth for "", round(price, 2))",printfunc,60 Python 3 for Absolute Beginners,print(),printfunc,62 Python 3 for Absolute Beginners,print('\twidth\theight\twidths\ttotal\tprice\tshorter?\twider?'),printfunc,62 Python 3 for Absolute Beginners,"print('\t', round(curtain width, 2))",printfunc,62 Python 3 for Absolute Beginners,"print('\t\t', round(curtain length, 2))",printfunc,62 Python 3 for Absolute Beginners,"print('\t\t\t\t\t\t', curtain length < roll width)",printfunc,63 Python 3 for Absolute Beginners,"print('\t\t\t\t\t\t\t', curtain width > roll width)",printfunc,63 Python 3 for Absolute Beginners,"print('\t\t\t', widths)",printfunc,63 Python 3 for Absolute Beginners,"print('\t\t\t\t', round(total length, 2))",printfunc,63 Python 3 for Absolute Beginners,"print('\t\t\t\t\t', round(price, 2))",printfunc,63 Python 3 for Absolute Beginners,"print(""You need"", round(total length, 2)",printfunc,63 Python 3 for Absolute Beginners,print(average),printfunc,66 Python 3 for Absolute Beginners,"print(""Input is negative"")",printfunc,68 Python 3 for Absolute Beginners,"print(counter, ':', sum)",printfunc,68 Python 3 for Absolute Beginners,print(banana),printfunc,69 Python 3 for Absolute Beginners,print(character),printfunc,70 Python 3 for Absolute Beginners,print(word),printfunc,70 Python 3 for Absolute Beginners,print(),printfunc,72 Python 3 for Absolute Beginners,"print(""***"")",printfunc,72 Python 3 for Absolute Beginners,print(),printfunc,72 Python 3 for Absolute Beginners,print(output string),printfunc,72 Python 3 for Absolute Beginners,print(output string),printfunc,72 Python 3 for Absolute Beginners,print(),printfunc,72 Python 3 for Absolute Beginners,"print(""***"")",printfunc,72 Python 3 for Absolute Beginners,print(),printfunc,72 Python 3 for Absolute Beginners,print(),printfunc,95 Python 3 for Absolute Beginners,print(fancy line),printfunc,95 Python 3 for Absolute Beginners,"print(""\t"", profile['Name'])",printfunc,95 Python 3 for Absolute Beginners,"print(""\t"", profile['Race'], profile['Gender'])",printfunc,95 Python 3 for Absolute Beginners,"print(""\t"", profile['Desc'])",printfunc,95 Python 3 for Absolute Beginners,print(fancy line),printfunc,95 Python 3 for Absolute Beginners,print(),printfunc,95 Python 3 for Absolute Beginners,"print(""\tMuscle: "", profile['Muscle'], ""\tlife: "", profile['life'])",printfunc,95 Python 3 for Absolute Beginners,"print(""\tBrainz: "", profile['Brainz'], ""\tmagic: "", profile['magic'])",printfunc,95 Python 3 for Absolute Beginners,"print(""\tSpeed: "", profile['Speed'], ""\tprotection: "", profile['prot'])",printfunc,95 Python 3 for Absolute Beginners,"print(""\tCharm: "", profile['Charm'], ""\tgold: "", profile['gold'])",printfunc,95 Python 3 for Absolute Beginners,print(),printfunc,95 Python 3 for Absolute Beginners,print(),printfunc,95 Python 3 for Absolute Beginners,"print(""<==|#|==\SHOP/==|#|==>"")",printfunc,95 Python 3 for Absolute Beginners,"print(""\t"", item, stock[item][0])",printfunc,95 Python 3 for Absolute Beginners,"print(""<==|#|==\@@@@/==|#|==>"")",printfunc,95 Python 3 for Absolute Beginners,print(),printfunc,95 Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""gold."")",printfunc,95 Python 3 for Absolute Beginners,"print(""You have a"", "" "".join(profile['inventory'])",printfunc,96 Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""left."")",printfunc,96 Python 3 for Absolute Beginners,"print(""You don't have enough gold to buy that."")",printfunc,96 Python 3 for Absolute Beginners,"print(""We don't have"", purchase, ""in stock."")",printfunc,96 Python 3 for Absolute Beginners,"print(""You own a"", "" "".join(profile['inventory']))",printfunc,96 Python 3 for Absolute Beginners,"print(profile['Name'], ""Are you ready for mortal combat?"")",printfunc,96 Python 3 for Absolute Beginners,"print(profile['Name'], ""is now ready for battle."")",printfunc,96 Python 3 for Absolute Beginners,print(),printfunc,96 Python 3 for Absolute Beginners,"print(""Then let the combat begin!"")",printfunc,96 Python 3 for Absolute Beginners,print(),printfunc,96 Python 3 for Absolute Beginners,"print(""\t"", velocity)",printfunc,97 Python 3 for Absolute Beginners,"print(""\t\tHit#"", hit type)",printfunc,97 Python 3 for Absolute Beginners,"print(""\t\tMiss#"", miss type)",printfunc,97 Python 3 for Absolute Beginners,print(),printfunc,97 Python 3 for Absolute Beginners,"print(""\t\tDamage:"", damage)",printfunc,97 Python 3 for Absolute Beginners,"print(""\t\t\tDamage#"", damage type)",printfunc,98 Python 3 for Absolute Beginners,"print(""\t\t\t\tChange#"", change type)",printfunc,98 Python 3 for Absolute Beginners,print(),printfunc,98 Python 3 for Absolute Beginners,"print(players[target]['Name'], ""collapses in a pool of blood"")",printfunc,98 Python 3 for Absolute Beginners,"print(players[attacker]['Name'], ""wins the fight."")",printfunc,98 Python 3 for Absolute Beginners,print(),printfunc,98 Python 3 for Absolute Beginners,print(),printfunc,98 Python 3 for Absolute Beginners,"print(""\t\tmax"", dam max, vel max, "":: min"", vel min)",printfunc,98 Python 3 for Absolute Beginners,print(),printfunc,98 Python 3 for Absolute Beginners,"print(""Outside the box:"")",printfunc,106 Python 3 for Absolute Beginners,print(vars()),printfunc,106 Python 3 for Absolute Beginners,"print(""Inside the box"")",printfunc,106 Python 3 for Absolute Beginners,print(cardboard box()),printfunc,106 Python 3 for Absolute Beginners,"print(""Inside the box:"")",printfunc,106 Python 3 for Absolute Beginners,"print(dave, '\t', fred, '\t', pete)",printfunc,106 Python 3 for Absolute Beginners,"print(""Outside the box:"")",printfunc,106 Python 3 for Absolute Beginners,"print(dave, '\t', fred, '\t', pete)",printfunc,106 Python 3 for Absolute Beginners,"print(""Inside the box"")",printfunc,107 Python 3 for Absolute Beginners,print(cardboard box()),printfunc,107 Python 3 for Absolute Beginners,"print(""Outside the box:"")",printfunc,107 Python 3 for Absolute Beginners,print(vars()),printfunc,107 Python 3 for Absolute Beginners,print(global list),printfunc,108 Python 3 for Absolute Beginners,print(result),printfunc,108 Python 3 for Absolute Beginners,print(),printfunc,109 Python 3 for Absolute Beginners,"print(""New Character"")",printfunc,109 Python 3 for Absolute Beginners,print(),printfunc,109 Python 3 for Absolute Beginners,"print(""We don't have"", purchase, ""in stock."")",printfunc,111 Python 3 for Absolute Beginners,"print(""fix gender() called with arguments:"", gender, phrase)",printfunc,112 Python 3 for Absolute Beginners,"print(fix gender(profile['Gender'],test phrase))",printfunc,112 Python 3 for Absolute Beginners,print(),printfunc,117 Python 3 for Absolute Beginners,"print(""New Character"")",printfunc,117 Python 3 for Absolute Beginners,print(),printfunc,117 Python 3 for Absolute Beginners,print(),printfunc,118 Python 3 for Absolute Beginners,print(fancy line),printfunc,118 Python 3 for Absolute Beginners,"print(""\t"", profile['Name'])",printfunc,118 Python 3 for Absolute Beginners,"print(""\t"", profile['Race'], profile['Gender'])",printfunc,118 Python 3 for Absolute Beginners,"print(""\t"", profile['Desc'])",printfunc,118 Python 3 for Absolute Beginners,print(fancy line),printfunc,118 Python 3 for Absolute Beginners,print(),printfunc,118 Python 3 for Absolute Beginners,"print(""\tMuscle: "", profile['Muscle'], ""\tlife: "", profile['life'])",printfunc,118 Python 3 for Absolute Beginners,"print(""\tBrainz: "", profile['Brainz'], ""\tmagic: "", profile['magic'])",printfunc,118 Python 3 for Absolute Beginners,"print(""\tSpeed: "", profile['Speed'], ""\tprotection: "", profile['prot'])",printfunc,118 Python 3 for Absolute Beginners,"print(""\tCharm: "", profile['Charm'], ""\tgold: "", profile['gold'])",printfunc,118 Python 3 for Absolute Beginners,print(),printfunc,118 Python 3 for Absolute Beginners,print(),printfunc,118 Python 3 for Absolute Beginners,"print(""<==|#|==\SHOP/==|#|==>"")",printfunc,118 Python 3 for Absolute Beginners,"print(""\t"", item, stock[item][0])",printfunc,118 Python 3 for Absolute Beginners,"print(""<==|#|==\@@@@/==|#|==>"")",printfunc,118 Python 3 for Absolute Beginners,print(),printfunc,118 Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""gold."")",printfunc,118 Python 3 for Absolute Beginners,"print(fix gender(profile['Gender'],test phrase))",printfunc,119 Python 3 for Absolute Beginners,"print(""You have a"", join with and(profile['inventory'])",printfunc,119 Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""left."")",printfunc,119 Python 3 for Absolute Beginners,"print(""You don't have enough gold to buy that."")",printfunc,119 Python 3 for Absolute Beginners,"print(""We don't have"", purchase, ""in stock."")",printfunc,119 Python 3 for Absolute Beginners,"print(profile['Name'], ""is now ready for battle. "")",printfunc,121 Python 3 for Absolute Beginners,print(),printfunc,121 Python 3 for Absolute Beginners,"print(""Then let the combat begin!"")",printfunc,121 Python 3 for Absolute Beginners,print(),printfunc,121 Python 3 for Absolute Beginners,"print(""\t\tMiss#"", miss type)",printfunc,121 Python 3 for Absolute Beginners,print(),printfunc,122 Python 3 for Absolute Beginners,"print(""\t\tDamage:"", damage, potential damage)",printfunc,122 Python 3 for Absolute Beginners,"print(""\t\t\tDamage#"", damage type)",printfunc,122 Python 3 for Absolute Beginners,"print(""\t\t\t\tChange#"", change type)",printfunc,122 Python 3 for Absolute Beginners,print(),printfunc,122 Python 3 for Absolute Beginners,"print(players[target]['Name'], ""collapses in a pool of blood"")",printfunc,122 Python 3 for Absolute Beginners,print(),printfunc,122 Python 3 for Absolute Beginners,print(),printfunc,122 Python 3 for Absolute Beginners,"print(""\t\tmax damage | velocity"", dam max, vel max, "":: min"", vel min)",printfunc,122 Python 3 for Absolute Beginners,print(),printfunc,122 Python 3 for Absolute Beginners,"print(players[0]['Name'], ""wins the fight."")",printfunc,122 Python 3 for Absolute Beginners,print(),printfunc,126 Python 3 for Absolute Beginners,print() function (or statement in Python 2),printfunc,127 Python 3 for Absolute Beginners,"print(string.format(letters[i],float(numbers[i]),message = msgs[i]))",printfunc,131 Python 3 for Absolute Beginners,print(),printfunc,141 Python 3 for Absolute Beginners,print(line),printfunc,143 Python 3 for Absolute Beginners,"print((output filename, ""written out.""))",printfunc,146 Python 3 for Absolute Beginners,"print(""Looks like a Python file. [OK]"")",printfunc,150 Python 3 for Absolute Beginners,"print(""This file does not have a .py extension."")",printfunc,150 Python 3 for Absolute Beginners,"print(""\n#===(*)===# TODO #===(*)===#\n"")",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: wrong interpreter invoked"")",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: no text encoding declaration"")",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: dodgy"", label)",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: dodgy"", label)",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: dodgy"", label)",printfunc,151 Python 3 for Absolute Beginners,"print(""Warning: dodgy"", label)",printfunc,151 Python 3 for Absolute Beginners,print(todo text),printfunc,152 Python 3 for Absolute Beginners,print(format info(spellbook)),printfunc,152 Python 3 for Absolute Beginners,print(),printfunc,154 Python 3 for Absolute Beginners,print(fancy line),printfunc,154 Python 3 for Absolute Beginners,"print(""\t"", profile['Name'])",printfunc,154 Python 3 for Absolute Beginners,"print(""\t"", profile['Race'], profile['Gender'])",printfunc,154 Python 3 for Absolute Beginners,"print(""\t"", profile['Desc'])",printfunc,154 Python 3 for Absolute Beginners,print(fancy line),printfunc,154 Python 3 for Absolute Beginners,print(),printfunc,154 Python 3 for Absolute Beginners,"print(""\tMuscle: "", profile['Muscle'], ""\tlife: "", profile['life'])",printfunc,154 Python 3 for Absolute Beginners,"print(""\tBrainz: "", profile['Brainz'], ""\tmagic: "", profile['magic'])",printfunc,154 Python 3 for Absolute Beginners,"print(""\tSpeed: "", profile['Speed'], ""\tprotection: "", profile['prot'])",printfunc,155 Python 3 for Absolute Beginners,"print(""\tCharm: "", profile['Charm'], ""\tgold: "", profile['gold'])",printfunc,155 Python 3 for Absolute Beginners,print(),printfunc,155 Python 3 for Absolute Beginners,print(rpcharacter sheet),printfunc,155 Python 3 for Absolute Beginners,print(),printfunc,155 Python 3 for Absolute Beginners,print(),printfunc,155 Python 3 for Absolute Beginners,"print(""<==|#|==\SHOP/==|#|==>"")",printfunc,155 Python 3 for Absolute Beginners,"print(""\t"", item, stock[item][0])",printfunc,155 Python 3 for Absolute Beginners,"print(""<==|#|==\@@@@/==|#|==>"")",printfunc,155 Python 3 for Absolute Beginners,print(),printfunc,155 Python 3 for Absolute Beginners,"print(""You have"", profile['gold'], ""gold."")",printfunc,155 Python 3 for Absolute Beginners,print(shop),printfunc,156 Python 3 for Absolute Beginners,"print(). In other words, repr()",printfunc,157 Python 3 for Absolute Beginners,"print(""Saving character sheets"")",printfunc,157 Python 3 for Absolute Beginners,"print(""Reading in data"")",printfunc,158 Python 3 for Absolute Beginners,print(players),printfunc,158 Python 3 for Absolute Beginners,"print(""\nPoints awarded for style: "")",printfunc,169 Python 3 for Absolute Beginners,"print('\t', result)",printfunc,169 Python 3 for Absolute Beginners,print(),printfunc,169 Python 3 for Absolute Beginners,print(),printfunc,170 Python 3 for Absolute Beginners,print(),printfunc,172 Python 3 for Absolute Beginners,"print(number)"")",printfunc,172 Python 3 for Absolute Beginners,print(number),printfunc,172 Python 3 for Absolute Beginners,"print(""Content-type: text/html"")",printfunc,174 Python 3 for Absolute Beginners,print(),printfunc,174 Python 3 for Absolute Beginners,"print(""</body></html>"")",printfunc,175 Python 3 for Absolute Beginners,"print(""Content-type: text/html"")",printfunc,177 Python 3 for Absolute Beginners,print(),printfunc,177 Python 3 for Absolute Beginners,"print(""</body></html>"")",printfunc,178 Python 3 for Absolute Beginners,print(person1.getName()),printfunc,182 Python 3 for Absolute Beginners,print(character sheet),printfunc,183 Python 3 for Absolute Beginners,print(),printfunc,188 Python 3 for Absolute Beginners,"print(""New [Test] Character"")",printfunc,188 Python 3 for Absolute Beginners,print(),printfunc,188 Python 3 for Absolute Beginners,"print(""Weapon made."")",printfunc,190 Python 3 for Absolute Beginners,"print(""new weapon made"")",printfunc,190 Python 3 for Absolute Beginners,print(object),printfunc,193 Python 3 for Absolute Beginners,"print(""\n::Inventory::\n-------------"")",printfunc,193 Python 3 for Absolute Beginners,"print(key, item, repr(item))",printfunc,193 Python 3 for Absolute Beginners,print(),printfunc,193 Python 3 for Absolute Beginners,print(),printfunc,201 Python 3 for Absolute Beginners,"print(""\nNew Character\n"")",printfunc,206 Python 3 for Absolute Beginners,"print(""You have"", self.gold, ""gold."")",printfunc,207 Python 3 for Absolute Beginners,"print(""You own a"", handbag)",printfunc,207 Python 3 for Absolute Beginners,"print(self.name + "", prepare for mortal combat!!!"")",printfunc,207 Python 3 for Absolute Beginners,"print(self.name, ""is now ready for battle. "")",printfunc,207 Python 3 for Absolute Beginners,"print(""We don't have a"", purchase, ""for sale."")",printfunc,208 Python 3 for Absolute Beginners,print(msg),printfunc,208 Python 3 for Absolute Beginners,"print(""You buy a"", purchase, ""for"",item.gold, ""gold pieces."")",printfunc,208 Python 3 for Absolute Beginners,"print(""You have a"", self.strInv(), ""in your bag."")",printfunc,208 Python 3 for Absolute Beginners,"print(""You have"", self.gold, ""gold left."")",printfunc,208 Python 3 for Absolute Beginners,"print(""You don't have enough gold to buy that."")",printfunc,208 Python 3 for Absolute Beginners,"print(""No can do."")",printfunc,212 Python 3 for Absolute Beginners,print(self),printfunc,212 Python 3 for Absolute Beginners,"print(""You enter the"", self.name)",printfunc,212 Python 3 for Absolute Beginners,print(output),printfunc,214 Python 3 for Absolute Beginners,"print('\n', target.name, ""collapses in a pool of blood"", '\n')",printfunc,214 Python 3 for Absolute Beginners,"print('\n', ""Let the combat begin!"", '\n')",printfunc,214 Python 3 for Absolute Beginners,"print(players[0].name, ""is victorious!"")",printfunc,215 Python 3 for Absolute Beginners,"print(""You leave the"", self.name)",printfunc,215 Python 3 for Absolute Beginners,"print(""Game Over"")",printfunc,215 Python 3 for Absolute Beginners,print(),printfunc,216 Python 3 for Absolute Beginners,"print("" <<-::"", *text)",printfunc,216 Python 3 for Absolute Beginners,"print(""Saving character sheets"")",printfunc,217 Python 3 for Absolute Beginners,"print(""Reading in data"")",printfunc,218 Python 3 for Absolute Beginners,print(Boilerplate),printfunc,218 Python 3 for Absolute Beginners,"print(""Total gains: {0:g}"".format(total))",printfunc,227 Python 3 for Absolute Beginners,"print(""FINALLY: cleaning up"")",printfunc,233 Python 3 for Absolute Beginners,print(),printfunc,233 Python 3 for Absolute Beginners,print(),printfunc,234 Python 3 for Absolute Beginners,"print(""RAISING: exception {0} not handled; (cid:171)",printfunc,234 Python 3 for Absolute Beginners,"print(strings.piratify(""Hello, world.""))",printfunc,242 Python 3 for Absolute Beginners,"print(strings.yarr(""This is a test.""))",printfunc,242 Python 3 for Absolute Beginners,"print(strings.me hearties(""It uses the strings module!""))",printfunc,242 Python 3 for Absolute Beginners,print(),printfunc,243 Python 3 for Absolute Beginners,print(convert file(sys.argv[1])),printfunc,248 Python 3 for Absolute Beginners,print(sys.path),printfunc,250 Python 3 for Absolute Beginners,print(sys.path),printfunc,251 Python 3 for Absolute Beginners,"print(""foo"")",printfunc,253 Python 3 for Absolute Beginners,"print(""You spent {0}"".format(total))",printfunc,257 Python 3 for Absolute Beginners,"print(""Python thinks that '{0}' is '{1}'"".format(guess,time obj))",printfunc,257 Python 3 for Absolute Beginners,"print(""{0} days ago was {1}"".format(i*5,day))",printfunc,257 Python 3 for Absolute Beginners,print(),printfunc,290 Python 3 for Absolute Beginners,"sequence1 = (1, 2, 3)",simpleTuple,69 Python 3 for Absolute Beginners,"single tuple = ('item',)",simpleTuple,80 Python 3 for Absolute Beginners,"hits = (), misses = (), damage report = (), life changing = ()",simpleTuple,91 Python 3 for Absolute Beginners,"life = (profile['Muscle'] + (profile['Speed']/2) + random.randint(9,49))",simpleTuple,94 Python 3 for Absolute Beginners,"magic = (profile['Brainz'] + (profile['Charm']/2) + random.randint(9,49))",simpleTuple,94 Python 3 for Absolute Beginners,"prot = (profile['Speed'] + (profile['Brainz']/2) + random.randint(9,49))",simpleTuple,95 Python 3 for Absolute Beginners,"profile['weapon'] = (0,20,50)",simpleTuple,96 Python 3 for Absolute Beginners,"profile['armour'] = (0,0,50)",simpleTuple,96 Python 3 for Absolute Beginners,"args = (486, 648, 432, 512, 576, 682, 768)",simpleTuple,104 Python 3 for Absolute Beginners,"profile['armour'] = (0,0,50)",simpleTuple,111 Python 3 for Absolute Beginners,"life = (profile['Muscle'] + (profile['Speed']/2) + roll(49,1))",simpleTuple,117 Python 3 for Absolute Beginners,"magic = (profile['Brainz'] + (profile['Charm']/2) + roll(49,1))",simpleTuple,117 Python 3 for Absolute Beginners,"prot = (profile['Speed'] + (profile['Brainz']/2) + roll(49,1))",simpleTuple,118 Python 3 for Absolute Beginners,"profile['armour'] = (0,0,50)",simpleTuple,120 Python 3 for Absolute Beginners,"weightings = (0.2, 0.3)",simpleTuple,243 Python 3 for Absolute Beginners,"priciest = ('',0,0,0)",simpleTuple,256 Python 3 for Absolute Beginners,"sequence2 = [1, 2, 3]",simpleList,69 Python 3 for Absolute Beginners,"splits = ['Fleagle', 'Beagle', 'Drooper', 'Snorky']",simpleList,69 Python 3 for Absolute Beginners,"sequence = ['Just','a','list','of','words']",simpleList,70 Python 3 for Absolute Beginners,"fruits = ['avocados', 'bananas', 'oranges', 'grapes', 'mangos']",simpleList,76 Python 3 for Absolute Beginners,"fruits = ['avocados', 'bananas', 'oranges', 'grapes', 'mangos']",simpleList,76 Python 3 for Absolute Beginners,"inventory = ['pole', ['another', 'list']",simpleList,80 Python 3 for Absolute Beginners,"inventory[::2] = ['shield', 'scroll', 'oil']",simpleList,80 Python 3 for Absolute Beginners,"int list = [0, 1]",simpleList,84 Python 3 for Absolute Beginners,"char list = ['a', 'b', 'c']",simpleList,84 Python 3 for Absolute Beginners,players = [],simpleList,93 Python 3 for Absolute Beginners,global list = [],simpleList,108 Python 3 for Absolute Beginners,profile['inventory'] == [],simpleList,110 Python 3 for Absolute Beginners,shopping = profile['inventory'] == [],simpleList,110 Python 3 for Absolute Beginners,profile['inventory'] == [],simpleList,110 Python 3 for Absolute Beginners,to buy anything. I made one further alteration to the breakout return: profile['inventory'] == [],simpleList,110 Python 3 for Absolute Beginners,players = [],simpleList,115 Python 3 for Absolute Beginners,"numbers = ['23.5', 42, '37', '-1.234567', -98754.320999999996]",simpleList,131 Python 3 for Absolute Beginners,"letters = ['v', 'w', 'x', 'y', 'z']",simpleList,131 Python 3 for Absolute Beginners,lines = [],simpleList,157 Python 3 for Absolute Beginners,"int variables = [a, b, c]",simpleList,168 Python 3 for Absolute Beginners,"float variables = [x, y, z]",simpleList,168 Python 3 for Absolute Beginners,"list numbers=[1,2,3,4]",simpleList,172 Python 3 for Absolute Beginners,"list numbers=[1,2,3,4]",simpleList,172 Python 3 for Absolute Beginners,players = [],simpleList,202 Python 3 for Absolute Beginners,shopping = self.inventory == [],simpleList,207 Python 3 for Absolute Beginners,if items == [],simpleList,208 Python 3 for Absolute Beginners,lines = [],simpleList,217 Python 3 for Absolute Beginners,arena.inventory = [],simpleList,218 Python 3 for Absolute Beginners,store = [],simpleList,224 Python 3 for Absolute Beginners,config['test'] = ['success'],simpleList,247 Python 3 for Absolute Beginners,"Just import ""convert"" with the * wildcard form = [""convert""]",simpleList,253 Python 3 for Absolute Beginners,a list = [a out],simpleList,276 Python 3 for Absolute Beginners,for banana in splits:,forsimple,69 Python 3 for Absolute Beginners,for character in text:,forsimple,70 Python 3 for Absolute Beginners,for word in sequence:,forsimple,70 Python 3 for Absolute Beginners,for char in input string:,forsimple,72 Python 3 for Absolute Beginners,for item in reversed(inventory):,forsimple,83 Python 3 for Absolute Beginners,"for i, value in enumerate(fruits):",forsimple,83 Python 3 for Absolute Beginners,for row in matrix:,forsimple,83 Python 3 for Absolute Beginners,"for i, value in enumerate(row):",forsimple,83 Python 3 for Absolute Beginners,"for fru, veg in zip(fruits, vegetables):",forsimple,84 Python 3 for Absolute Beginners,for key in profile:,forsimple,87 Python 3 for Absolute Beginners,for item in profile:,forsimple,87 Python 3 for Absolute Beginners,for character in sentence:,forsimple,89 Python 3 for Absolute Beginners,for item in stock:,forsimple,95 Python 3 for Absolute Beginners,for armour type in armour types:,forsimple,96 Python 3 for Absolute Beginners,"for attacker, player in enumerate(players):",forsimple,96 Python 3 for Absolute Beginners,"for rolls in range(0,dice):",forsimple,102 Python 3 for Absolute Beginners,for your parameters in the function definition:,forsimple,103 Python 3 for Absolute Beginners,"for rolls in range(1,dice):",forsimple,109 Python 3 for Absolute Beginners,for armour type in armour types:,forsimple,111 Python 3 for Absolute Beginners,"for attacker, player in enumerate(players):",forsimple,114 Python 3 for Absolute Beginners,"for attacker, target in matches:",forsimple,114 Python 3 for Absolute Beginners,"for rolls in range(1,dice):",forsimple,116 Python 3 for Absolute Beginners,for item in stock:,forsimple,118 Python 3 for Absolute Beginners,"for i in range(0,5):",forsimple,131 Python 3 for Absolute Beginners,for line in text:,forsimple,143 Python 3 for Absolute Beginners,"for line no, line in enumerate(script):",forsimple,151 Python 3 for Absolute Beginners,for item in stock:,forsimple,155 Python 3 for Absolute Beginners,for player in players:,forsimple,157 Python 3 for Absolute Beginners,for line in data file:,forsimple,158 Python 3 for Absolute Beginners,for result in reversed(sorted(results)):,forsimple,169 Python 3 for Absolute Beginners,for number in list numbers:,forsimple,172 Python 3 for Absolute Beginners,for number in list numbers:,forsimple,172 Python 3 for Absolute Beginners,"for key, item in inventory.items():",forsimple,193 Python 3 for Absolute Beginners,"for attack, targ in matches:",forsimple,215 Python 3 for Absolute Beginners,"for rolls in range(1,dice):",forsimple,217 Python 3 for Absolute Beginners,for player in players:,forsimple,217 Python 3 for Absolute Beginners,for line in data file:,forsimple,218 Python 3 for Absolute Beginners,for bet in data:,forsimple,227 Python 3 for Absolute Beginners,for naming variables in Python are just that:,forsimple,246 Python 3 for Absolute Beginners,for row in r:,forsimple,256 Python 3 for Absolute Beginners,"for i in range(1,10):",forsimple,257 Python 3 for Absolute Beginners,for heading in headings:,forsimple,276 Python 3 for Absolute Beginners,muscle = 2 + 3,assignwithSum,38 Python 3 for Absolute Beginners,strangeness = muscle + brainz * speed,assignwithSum,38 Python 3 for Absolute Beginners,13 = 2 * -5 + remainder,assignwithSum,40 Python 3 for Absolute Beginners,x = 0xaa + 0x33,assignwithSum,42 Python 3 for Absolute Beginners,o = 0o77 + 0o33,assignwithSum,42 Python 3 for Absolute Beginners,curtain width = float(window width) * 0.75 + 20,assignwithSum,44 Python 3 for Absolute Beginners,curtain length = float(window height) + 15,assignwithSum,44 Python 3 for Absolute Beginners,"which is the same as counter = counter + 1. Some other possible combinations are -=, *=, /=, which",assignwithSum,54 Python 3 for Absolute Beginners,curtain length = float(window height) + 15,assignwithSum,59 Python 3 for Absolute Beginners,curtain length = float(window height) + 15,assignwithSum,62 Python 3 for Absolute Beginners,"characters[character] = characters.get(character,0) + 1",assignwithSum,89 Python 3 for Absolute Beginners,"profile['Muscle'] = random.randint(3,33) + random.randint(3,33) \",assignwithSum,94 Python 3 for Absolute Beginners,"profile['Brainz'] = random.randint(3,33) + random.randint(3,33) \",assignwithSum,94 Python 3 for Absolute Beginners,"profile['Speed'] = random.randint(3,33) + random.randint(3,33) \",assignwithSum,94 Python 3 for Absolute Beginners,"profile['Charm'] = random.randint(3,33) + random.randint(3,33) \",assignwithSum,94 Python 3 for Absolute Beginners,"gold = random.randint(9,49) + random.randint(9,49) + random.randint(9,49)",assignwithSum,95 Python 3 for Absolute Beginners,attack velocity = attack speed + weapon speed + attack chance,assignwithSum,97 Python 3 for Absolute Beginners,target velocity = target prot + armour speed,assignwithSum,97 Python 3 for Absolute Beginners,attack damage = attack strength + weapon damage + velocity,assignwithSum,97 Python 3 for Absolute Beginners,target defence = target strength + armour strength + target chance,assignwithSum,97 Python 3 for Absolute Beginners,dave = fred + pete,assignwithSum,105 Python 3 for Absolute Beginners,dave = fred + pete,assignwithSum,106 Python 3 for Absolute Beginners,dave = fred + pete,assignwithSum,107 Python 3 for Absolute Beginners,"sentence = sentence + "" and "" + last item",assignwithSum,112 Python 3 for Absolute Beginners,"test phrase = profile['Name'] + "" buys themself some equipment""",assignwithSum,112 Python 3 for Absolute Beginners,"sentence = sentence + "" and "" + last item",assignwithSum,116 Python 3 for Absolute Beginners,"test phrase = profile['Name'] + "" buys themself some equipment""",assignwithSum,119 Python 3 for Absolute Beginners,attack velocity = attack speed + weapon speed + attack chance,assignwithSum,119 Python 3 for Absolute Beginners,target velocity = target prot + armour speed,assignwithSum,119 Python 3 for Absolute Beginners,attack damage = attack strength + weapon damage + velocity,assignwithSum,119 Python 3 for Absolute Beginners,target defence = target strength + armour strength + target chance,assignwithSum,120 Python 3 for Absolute Beginners,"text = re.sub('("".+?"")', '<i>\\1</i>', text)",assignwithSum,146 Python 3 for Absolute Beginners,"text = re.sub('(\W)\*([a-z A-Z]+?)\*(\W)', '\\1<b>\\2</b>\\3', text)",assignwithSum,146 Python 3 for Absolute Beginners,"text = re.sub('( \w+? )', '<u>\\1</u>', text)",assignwithSum,146 Python 3 for Absolute Beginners,"filename format = re.compile("".+?\.py"")",assignwithSum,149 Python 3 for Absolute Beginners,"version format = re.compile(""[\""']?(?:[0-9]+?\.)?[0-9]+?\.[0-9]+?[\""']?"")",assignwithSum,149 Python 3 for Absolute Beginners,"email format = re.compile(""[\""'].+?@.+\..+?[\""']"")",assignwithSum,149 Python 3 for Absolute Beginners,"todo format = re.compile(""^\s*?#\s*?(TODO|todo|FIXME|fixme):?\s*?(.+)"")",assignwithSum,149 Python 3 for Absolute Beginners,"msg = fix gender(self.gender, self.name + "" buys themself \",assignwithSum,208 Python 3 for Absolute Beginners,attack velocity = self.speed + weapon.speed + attack chance,assignwithSum,209 Python 3 for Absolute Beginners,target velocity = target.prot + armour.speed + roll(target.brainz),assignwithSum,209 Python 3 for Absolute Beginners,attack damage = attack strength + weapon damage + int(velocity) - roll(172),assignwithSum,212 Python 3 for Absolute Beginners,target defence = target strength + armour strength + target chance,assignwithSum,212 Python 3 for Absolute Beginners,"sentence = sentence + "" and "" + last item",assignwithSum,216 Python 3 for Absolute Beginners,elif choice <= weightings[0] + weightings[1]:,assignwithSum,243 Python 3 for Absolute Beginners,priciest = row + [cost],assignwithSum,256 Python 3 for Absolute Beginners,"icon = eval(""self."" + self.choice.replace(' ',' ') + "" image"")",assignwithSum,276 Python 3 for Absolute Beginners,"command = eval(""self."" + heading + "" func"")",assignwithSum,277 Python 3 for Absolute Beginners,"performed using the = sign like this: variable = value. One of the specific features of Python is that,",simpleAssign,18 Python 3 for Absolute Beginners,expecting: message == input text,simpleAssign,18 Python 3 for Absolute Beginners,variable like this: variable = function().,simpleAssign,19 Python 3 for Absolute Beginners,expecting: message == input text,simpleAssign,20 Python 3 for Absolute Beginners,some text = input('Type in some words: '),simpleAssign,20 Python 3 for Absolute Beginners,some text = input(Type in some words: ),simpleAssign,21 Python 3 for Absolute Beginners,expecting: message == input text,simpleAssign,23 Python 3 for Absolute Beginners,"Python, using the = sign. So, you would assign a value to a variable by typing the following:",simpleAssign,28 Python 3 for Absolute Beginners,variable = value,simpleAssign,28 Python 3 for Absolute Beginners,number = 0,simpleAssign,29 Python 3 for Absolute Beginners,roll width = 1.4,simpleAssign,29 Python 3 for Absolute Beginners,price per metre = 5,simpleAssign,29 Python 3 for Absolute Beginners,trace = False,simpleAssign,29 Python 3 for Absolute Beginners,total price = roll width * price per metre,simpleAssign,29 Python 3 for Absolute Beginners,eggs = 2,simpleAssign,29 Python 3 for Absolute Beginners,butter = 0.5oz,simpleAssign,29 Python 3 for Absolute Beginners,salt = pinch,simpleAssign,29 Python 3 for Absolute Beginners,pepper = pinch,simpleAssign,29 Python 3 for Absolute Beginners,b = 3,simpleAssign,30 Python 3 for Absolute Beginners,trace = False,simpleAssign,30 Python 3 for Absolute Beginners,information = None,simpleAssign,31 Python 3 for Absolute Beginners,variable = input('Type something in: '),simpleAssign,34 Python 3 for Absolute Beginners,"version = 0.1",simpleAssign,36 Python 3 for Absolute Beginners,Name = input('What is your Name? '),simpleAssign,36 Python 3 for Absolute Beginners,Desc = input('Describe yourself: '),simpleAssign,36 Python 3 for Absolute Beginners,Gender = input('What Gender are you? (male / female / unsure): '),simpleAssign,36 Python 3 for Absolute Beginners,Race = input('What fantasy Race are you? - (Pixie / Vulcan / Gelfling / Troll): '),simpleAssign,36 Python 3 for Absolute Beginners,"The one new thing I’ve added is the line version = 0.1 at the beginning. This is a magic",simpleAssign,37 Python 3 for Absolute Beginners,muscle = 10,simpleAssign,37 Python 3 for Absolute Beginners,brainz = 4,simpleAssign,37 Python 3 for Absolute Beginners,beauty = True,simpleAssign,38 Python 3 for Absolute Beginners,illusion = False,simpleAssign,38 Python 3 for Absolute Beginners,brainz = 7 - 3,simpleAssign,38 Python 3 for Absolute Beginners,speed = 5 * -4,simpleAssign,38 Python 3 for Absolute Beginners,"happen? Surely 5 + 4 = 9, multiplied by –20 would give –180? But no, what happens here is this:",simpleAssign,38 Python 3 for Absolute Beginners,muscle = 2.9,simpleAssign,40 Python 3 for Absolute Beginners,speed = 0.0,simpleAssign,40 Python 3 for Absolute Beginners,octal number = 0o12,simpleAssign,41 Python 3 for Absolute Beginners,hexadecimal number = 0xFC6,simpleAssign,41 Python 3 for Absolute Beginners,"7 = 2037 (decimal)",simpleAssign,41 Python 3 for Absolute Beginners,"5 = 2037 (decimal)",simpleAssign,42 Python 3 for Absolute Beginners,permissions = 0o755,simpleAssign,42 Python 3 for Absolute Beginners,gold = 0xFFCC00,simpleAssign,42 Python 3 for Absolute Beginners,"version = 0.1",simpleAssign,44 Python 3 for Absolute Beginners,roll width = 140,simpleAssign,44 Python 3 for Absolute Beginners,price per metre = 5,simpleAssign,44 Python 3 for Absolute Beginners,window height = input('Enter the height of the window (cm): '),simpleAssign,44 Python 3 for Absolute Beginners,window width = input('Enter the width of the window (cm): '),simpleAssign,44 Python 3 for Absolute Beginners,widths = curtain width / roll width,simpleAssign,44 Python 3 for Absolute Beginners,total length = curtain length * widths,simpleAssign,44 Python 3 for Absolute Beginners,price = total length * price per metre,simpleAssign,44 Python 3 for Absolute Beginners,7.65 != 6.0,simpleAssign,50 Python 3 for Absolute Beginners,5 >= 5,simpleAssign,50 Python 3 for Absolute Beginners,3.2 != 3.2,simpleAssign,50 Python 3 for Absolute Beginners,variable = 3.0,simpleAssign,50 Python 3 for Absolute Beginners,variable == 3,simpleAssign,50 Python 3 for Absolute Beginners,"len(""case"") == len(""Case"")",simpleAssign,52 Python 3 for Absolute Beginners,"len(""Same"") != len(""Same"")",simpleAssign,52 Python 3 for Absolute Beginners,is emo = True,simpleAssign,52 Python 3 for Absolute Beginners,is country = False,simpleAssign,52 Python 3 for Absolute Beginners,is techno = False,simpleAssign,52 Python 3 for Absolute Beginners,is CD = True,simpleAssign,52 Python 3 for Absolute Beginners,is DVD = False,simpleAssign,52 Python 3 for Absolute Beginners,is cool = not is techno and not is country and not is emo,simpleAssign,53 Python 3 for Absolute Beginners,"height, length = length, height",simpleAssign,54 Python 3 for Absolute Beginners,x = y = z = 1,simpleAssign,54 Python 3 for Absolute Beginners,"x<y, x<=y, x>y, x>=y, x==y, and x!=y Makes comparisons",simpleAssign,55 Python 3 for Absolute Beginners,elif condition != True:,simpleAssign,55 Python 3 for Absolute Beginners,It is not usually considered good style to explicitly state condition == True; if whatever condition is,simpleAssign,56 Python 3 for Absolute Beginners,widths = curtain width / roll width,simpleAssign,59 Python 3 for Absolute Beginners,total length = curtain length * widths,simpleAssign,59 Python 3 for Absolute Beginners,price = total length * price per metre,simpleAssign,59 Python 3 for Absolute Beginners,price = total length * price per metre,simpleAssign,60 Python 3 for Absolute Beginners,total length = curtain width,simpleAssign,61 Python 3 for Absolute Beginners,total length = curtain length,simpleAssign,61 Python 3 for Absolute Beginners,widths = int(curtain width/roll width),simpleAssign,61 Python 3 for Absolute Beginners,extra material = curtain width%roll width,simpleAssign,61 Python 3 for Absolute Beginners,"Prototype"" = 0.2",simpleAssign,62 Python 3 for Absolute Beginners,roll width = 140,simpleAssign,62 Python 3 for Absolute Beginners,price per metre = 5,simpleAssign,62 Python 3 for Absolute Beginners,window height = input('Enter the height of the window (cm): '),simpleAssign,62 Python 3 for Absolute Beginners,window width = input('Enter the width of the window (cm): '),simpleAssign,62 Python 3 for Absolute Beginners,widths = int(curtain width/roll width),simpleAssign,63 Python 3 for Absolute Beginners,extra material = curtain width%roll width,simpleAssign,63 Python 3 for Absolute Beginners,price = total length * price per metre,simpleAssign,63 Python 3 for Absolute Beginners,result = 1,simpleAssign,65 Python 3 for Absolute Beginners,result *= 2,simpleAssign,65 Python 3 for Absolute Beginners,"Recall that result *= 2 is the same as result = result*2, so the number printed is doubled during",simpleAssign,65 Python 3 for Absolute Beginners,"input number. While it is positive (i.e., >= 0) the loop processes as normal, but as soon as a negative",simpleAssign,66 Python 3 for Absolute Beginners,counter = 0,simpleAssign,66 Python 3 for Absolute Beginners,total = 0,simpleAssign,66 Python 3 for Absolute Beginners,number = 0,simpleAssign,66 Python 3 for Absolute Beginners,"number = int(input(""Enter a positive number\nor a negative to exit: ""))",simpleAssign,66 Python 3 for Absolute Beginners,average = total / counter,simpleAssign,66 Python 3 for Absolute Beginners,"this input = int(raw input(""#? :-> ""))",simpleAssign,67 Python 3 for Absolute Beginners,counter = 0,simpleAssign,68 Python 3 for Absolute Beginners,sum = 0,simpleAssign,68 Python 3 for Absolute Beginners,"text = input(""Type in some words: "")",simpleAssign,70 Python 3 for Absolute Beginners,"arithmetic = and comparison symbols> including, dubious? email@addresses and",simpleAssign,70 Python 3 for Absolute Beginners,space flag = True,simpleAssign,71 Python 3 for Absolute Beginners,space flag = False,simpleAssign,71 Python 3 for Absolute Beginners,if space flag = False,simpleAssign,71 Python 3 for Absolute Beginners,space flag = True,simpleAssign,71 Python 3 for Absolute Beginners,space flag = False,simpleAssign,71 Python 3 for Absolute Beginners,space flag = True,simpleAssign,71 Python 3 for Absolute Beginners,"arithmetic = and comparison symbols> including, dubious? email@addresses and",simpleAssign,72 Python 3 for Absolute Beginners,"input string = input(""Enter a text string: "")",simpleAssign,72 Python 3 for Absolute Beginners,space flagged = False,simpleAssign,72 Python 3 for Absolute Beginners,space flagged = False,simpleAssign,72 Python 3 for Absolute Beginners,space flagged = True,simpleAssign,72 Python 3 for Absolute Beginners,"I Note list alias = sequence does not make a copy of the list. Instead, list alias and sequence are the",simpleAssign,77 Python 3 for Absolute Beginners,"list alias, you will see the change in sequence as well. If you do new sequence = sequence[:], then",simpleAssign,77 Python 3 for Absolute Beginners,"vegetables = vegetables.split("", "")",simpleAssign,78 Python 3 for Absolute Beginners,"In other words, it counts each item where x == item is true.",simpleAssign,78 Python 3 for Absolute Beginners,vegetables == fruits,simpleAssign,79 Python 3 for Absolute Beginners,"blah1, blah2, blah3 = t",simpleAssign,80 Python 3 for Absolute Beginners,New values can be assigned to list items using the assignment operator sequence[i] = x.,simpleAssign,80 Python 3 for Absolute Beginners,You can replace a slice of your list with another sequence using list[i:j:step] = sequence.,simpleAssign,80 Python 3 for Absolute Beginners,"a = set(['apples', 'oranges', 'bananas', 'apples', 'oranges'])",simpleAssign,85 Python 3 for Absolute Beginners,"b = set(['avocados', 'mangos', 'apples', 'grapes', 'mangos'])",simpleAssign,85 Python 3 for Absolute Beginners,access its corresponding value in the dictionary: dictionary[key] = value. Don’t forget to enclose the,simpleAssign,86 Python 3 for Absolute Beginners,"a blank copy of a dictionary using the dict.fromkeys(iterable, value=None) method.",simpleAssign,88 Python 3 for Absolute Beginners,new profile = profile.fromkeys(profile),simpleAssign,88 Python 3 for Absolute Beginners,"armour types = set(['shield','cuirass','armour'])",simpleAssign,93 Python 3 for Absolute Beginners,trace = False,simpleAssign,93 Python 3 for Absolute Beginners,max players = 2,simpleAssign,93 Python 3 for Absolute Beginners,profile['life'] = life,simpleAssign,95 Python 3 for Absolute Beginners,"life = random.randint(9,99)",simpleAssign,95 Python 3 for Absolute Beginners,profile['magic'] = magic,simpleAssign,95 Python 3 for Absolute Beginners,"magic = random.randint(9,99)",simpleAssign,95 Python 3 for Absolute Beginners,profile['prot'] = prot,simpleAssign,95 Python 3 for Absolute Beginners,"prot = random.randint(9,99)",simpleAssign,95 Python 3 for Absolute Beginners,profile['gold'] = gold,simpleAssign,95 Python 3 for Absolute Beginners,"gold = random.randint(9,99)",simpleAssign,95 Python 3 for Absolute Beginners,purchase = input('Would you like to buy some equipment? '),simpleAssign,95 Python 3 for Absolute Beginners,"purchase = input('Please choose an item or type ""done"" to quit. ')",simpleAssign,95 Python 3 for Absolute Beginners,if stock[purchase][0] <= profile['gold']:,simpleAssign,96 Python 3 for Absolute Beginners,profile['gold'] -= stock[purchase][0],simpleAssign,96 Python 3 for Absolute Beginners,"weapon = input(""Then choose your weapon: "")",simpleAssign,96 Python 3 for Absolute Beginners,weapon = weapon.lower(),simpleAssign,96 Python 3 for Absolute Beginners,profile['weapon'] = stock[weapon],simpleAssign,96 Python 3 for Absolute Beginners,profile['armour'] = stock[armour type],simpleAssign,96 Python 3 for Absolute Beginners,vel max = 23,simpleAssign,96 Python 3 for Absolute Beginners,vel min = 1,simpleAssign,96 Python 3 for Absolute Beginners,dam max = 23,simpleAssign,96 Python 3 for Absolute Beginners,target = int(not bool(attacker)),simpleAssign,96 Python 3 for Absolute Beginners,life left = players[target]['life'],simpleAssign,96 Python 3 for Absolute Beginners,attack speed = players[attacker]['Speed'],simpleAssign,97 Python 3 for Absolute Beginners,weapon speed = players[attacker]['weapon'][2],simpleAssign,97 Python 3 for Absolute Beginners,"attack chance = random.randint(1,players[attacker]['Brainz'])",simpleAssign,97 Python 3 for Absolute Beginners,target prot = players[target]['prot'],simpleAssign,97 Python 3 for Absolute Beginners,armour speed = players[target]['armour'][2],simpleAssign,97 Python 3 for Absolute Beginners,vel max = velocity,simpleAssign,97 Python 3 for Absolute Beginners,hit type = int(7 * velocity / vel max),simpleAssign,97 Python 3 for Absolute Beginners,hit type = 7,simpleAssign,97 Python 3 for Absolute Beginners,vel min = velocity,simpleAssign,97 Python 3 for Absolute Beginners,miss type = int(velocity / vel max),simpleAssign,97 Python 3 for Absolute Beginners,miss type = 7,simpleAssign,97 Python 3 for Absolute Beginners,attack strength = players[attacker]['Muscle'],simpleAssign,97 Python 3 for Absolute Beginners,weapon damage = players[attacker]['weapon'][1],simpleAssign,97 Python 3 for Absolute Beginners,target strength = players[target]['Muscle'],simpleAssign,97 Python 3 for Absolute Beginners,armour strength = players[target]['armour'][1],simpleAssign,97 Python 3 for Absolute Beginners,"target chance = random.randint(9,players[target]['Brainz'])",simpleAssign,97 Python 3 for Absolute Beginners,potential damage = 2,simpleAssign,97 Python 3 for Absolute Beginners,"damage = random.randint(1,potential damage)",simpleAssign,97 Python 3 for Absolute Beginners,dam max = damage,simpleAssign,97 Python 3 for Absolute Beginners,damage type = int(7 * damage/dam max),simpleAssign,98 Python 3 for Absolute Beginners,damage type = 7,simpleAssign,98 Python 3 for Absolute Beginners,change type = int(5 * damage/life left),simpleAssign,98 Python 3 for Absolute Beginners,change type = 7,simpleAssign,98 Python 3 for Absolute Beginners,players[target]['life'] -= damage,simpleAssign,98 Python 3 for Absolute Beginners,if players[target]['life'] <= 0:,simpleAssign,98 Python 3 for Absolute Beginners,result = 0,simpleAssign,102 Python 3 for Absolute Beginners,"muscle = roll(33,3)",simpleAssign,103 Python 3 for Absolute Beginners,"roll(dice = 3, sides = 33)",simpleAssign,103 Python 3 for Absolute Beginners,"collect kwargs(one = 1, two = 2, three = 3)",simpleAssign,104 Python 3 for Absolute Beginners,"collect args(486, 648, 432, 512, 576, 682, 768, first = 729, second = 546, third = 819)",simpleAssign,104 Python 3 for Absolute Beginners,fred = 1,simpleAssign,105 Python 3 for Absolute Beginners,pete = 2,simpleAssign,105 Python 3 for Absolute Beginners,dave = 0,simpleAssign,106 Python 3 for Absolute Beginners,fred = 1,simpleAssign,106 Python 3 for Absolute Beginners,pete = 2,simpleAssign,106 Python 3 for Absolute Beginners,fred = 1,simpleAssign,107 Python 3 for Absolute Beginners,pete = 2,simpleAssign,107 Python 3 for Absolute Beginners,fred = dave,simpleAssign,107 Python 3 for Absolute Beginners,you had written local list = global list. Please review Chapter 5 if you’ve forgotten how this works.,simpleAssign,108 Python 3 for Absolute Beginners,result = modify list(global list),simpleAssign,108 Python 3 for Absolute Beginners,result = 0,simpleAssign,109 Python 3 for Absolute Beginners,I then replaced the copied section of code from the main section with profile = generate rpc().,simpleAssign,110 Python 3 for Absolute Beginners,profile = generate_rpc(),simpleAssign,110 Python 3 for Absolute Beginners,shopping = buy equipment(),simpleAssign,110 Python 3 for Absolute Beginners,"purchase = input('Please choose an item or type ""done"" to quit. ')",simpleAssign,110 Python 3 for Absolute Beginners,profile['armour'] = stock[armour type],simpleAssign,111 Python 3 for Absolute Beginners,profile['armour'] = armour stats[0],simpleAssign,111 Python 3 for Absolute Beginners,handbag = join with and(profile['inventory']),simpleAssign,112 Python 3 for Absolute Beginners,last item = sequence[-1],simpleAssign,112 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','herself')",simpleAssign,112 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','himself')",simpleAssign,112 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','itself')",simpleAssign,112 Python 3 for Absolute Beginners,opponents = list(sides[:]),simpleAssign,113 Python 3 for Absolute Beginners,target = int(not bool(attacker)),simpleAssign,114 Python 3 for Absolute Beginners,"matches = ziply(range(0,len(players)))",simpleAssign,114 Python 3 for Absolute Beginners,"armour types = set(['shield','cuirass','armour'])",simpleAssign,115 Python 3 for Absolute Beginners,trace = False,simpleAssign,115 Python 3 for Absolute Beginners,reply = input('How many players?: ') or 2,simpleAssign,115 Python 3 for Absolute Beginners,max players = int(reply),simpleAssign,115 Python 3 for Absolute Beginners,result = 0,simpleAssign,116 Python 3 for Absolute Beginners,opponents = list(seq[:]),simpleAssign,116 Python 3 for Absolute Beginners,last item = sequence[-1],simpleAssign,116 Python 3 for Absolute Beginners,sentence = sequence[0],simpleAssign,116 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','herself')",simpleAssign,116 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','himself')",simpleAssign,116 Python 3 for Absolute Beginners,"sentence = phrase.replace('themself','itself')",simpleAssign,116 Python 3 for Absolute Beginners,name = input('What is your name? '),simpleAssign,117 Python 3 for Absolute Beginners,desc = input('Describe yourself: '),simpleAssign,117 Python 3 for Absolute Beginners,gender = input('What Gender are you? (male/female/unsure): '),simpleAssign,117 Python 3 for Absolute Beginners,race = input('What Race are you? - (Pixie/Vulcan/Gelfling/Troll): '),simpleAssign,117 Python 3 for Absolute Beginners,profile['Name'] = name.capitalize(),simpleAssign,117 Python 3 for Absolute Beginners,profile['Desc'] = desc.capitalize(),simpleAssign,117 Python 3 for Absolute Beginners,gender = gender.lower(),simpleAssign,117 Python 3 for Absolute Beginners,race = race.capitalize(),simpleAssign,117 Python 3 for Absolute Beginners,"profile['Muscle'] = roll(33,3)",simpleAssign,117 Python 3 for Absolute Beginners,"profile['Brainz'] = roll(33,3)",simpleAssign,117 Python 3 for Absolute Beginners,"profile['Speed'] = roll(33,3)",simpleAssign,117 Python 3 for Absolute Beginners,"profile['Charm'] = roll(33,3)",simpleAssign,117 Python 3 for Absolute Beginners,"gold = roll(40,4)",simpleAssign,118 Python 3 for Absolute Beginners,profile['life'] = life,simpleAssign,118 Python 3 for Absolute Beginners,"profile['life'] = roll(33,3)",simpleAssign,118 Python 3 for Absolute Beginners,profile['magic'] = magic,simpleAssign,118 Python 3 for Absolute Beginners,"profile['magic'] = roll(33,3)",simpleAssign,118 Python 3 for Absolute Beginners,profile['prot'] = prot,simpleAssign,118 Python 3 for Absolute Beginners,"profile['prot'] = roll(33,3)",simpleAssign,118 Python 3 for Absolute Beginners,profile['gold'] = gold,simpleAssign,118 Python 3 for Absolute Beginners,"purchase = input('Please choose an item or type ""done"" to quit. ')",simpleAssign,119 Python 3 for Absolute Beginners,if stock[purchase][0] <= profile['gold']:,simpleAssign,119 Python 3 for Absolute Beginners,profile['gold'] -= stock[purchase][0],simpleAssign,119 Python 3 for Absolute Beginners,attack speed = players[attacker]['Speed'],simpleAssign,119 Python 3 for Absolute Beginners,weapon speed = players[attacker]['weapon'][2],simpleAssign,119 Python 3 for Absolute Beginners,attack chance = roll(players[attacker]['Brainz']),simpleAssign,119 Python 3 for Absolute Beginners,target prot = players[target]['prot'],simpleAssign,119 Python 3 for Absolute Beginners,armour speed = players[target]['armour'][2],simpleAssign,119 Python 3 for Absolute Beginners,attack strength = players[attacker]['Muscle'],simpleAssign,119 Python 3 for Absolute Beginners,weapon damage = players[attacker]['weapon'][1],simpleAssign,119 Python 3 for Absolute Beginners,target strength = players[target]['Muscle'],simpleAssign,120 Python 3 for Absolute Beginners,armour strength = players[target]['armour'][1],simpleAssign,120 Python 3 for Absolute Beginners,target chance = roll(players[target]['Brainz']),simpleAssign,120 Python 3 for Absolute Beginners,potential damage = 2,simpleAssign,120 Python 3 for Absolute Beginners,"damage = random.randint(1,potential damage)",simpleAssign,120 Python 3 for Absolute Beginners,vel max = 23,simpleAssign,121 Python 3 for Absolute Beginners,vel min = 1,simpleAssign,121 Python 3 for Absolute Beginners,dam max = 23,simpleAssign,121 Python 3 for Absolute Beginners,vel min = velocity,simpleAssign,121 Python 3 for Absolute Beginners,miss type = int(velocity / vel max),simpleAssign,121 Python 3 for Absolute Beginners,miss type = 7,simpleAssign,121 Python 3 for Absolute Beginners,"damage, potential damage = calc damage(attacker, target, velocity)",simpleAssign,122 Python 3 for Absolute Beginners,dam max = damage,simpleAssign,122 Python 3 for Absolute Beginners,damage type = int(7 * damage/dam max),simpleAssign,122 Python 3 for Absolute Beginners,damage type = 7,simpleAssign,122 Python 3 for Absolute Beginners,change type = int(5 * damage/life left),simpleAssign,122 Python 3 for Absolute Beginners,change type = 7,simpleAssign,122 Python 3 for Absolute Beginners,players[target]['life'] -= damage,simpleAssign,122 Python 3 for Absolute Beginners,if players[target]['life'] <= 0:,simpleAssign,122 Python 3 for Absolute Beginners,a = 1,simpleAssign,127 Python 3 for Absolute Beginners,b = 2.37,simpleAssign,127 Python 3 for Absolute Beginners,"ab = sep.join([str(a),str(b)])",simpleAssign,128 Python 3 for Absolute Beginners,x = s3.lower(),simpleAssign,129 Python 3 for Absolute Beginners,regex object = re.compile(pattern),simpleAssign,139 Python 3 for Absolute Beginners,input filename = eval(input('Enter a filename:-> ')),simpleAssign,145 Python 3 for Absolute Beginners,"output filename = input filename.replace('.txt', '.html')",simpleAssign,145 Python 3 for Absolute Beginners,title = input filename.split('/'),simpleAssign,145 Python 3 for Absolute Beginners,title = title[-1].rstrip('.txt').title(),simpleAssign,145 Python 3 for Absolute Beginners,"text = re.sub('[Aa]sh.*?[Pp](etl|etal)', '<b>Cinderella</b>', text)",simpleAssign,146 Python 3 for Absolute Beginners,"text = re.sub('([\]\"".:?!-])\n', '\\1</p>\n<p>', text)",simpleAssign,146 Python 3 for Absolute Beginners,"text = re.sub('([a-z,;])\n', '\\1<br />\n', text)",simpleAssign,146 Python 3 for Absolute Beginners,"Now = time.strftime(""%d-%m-%Y"")",simpleAssign,149 Python 3 for Absolute Beginners,"status format = re.compile(""[\""'](Prototype|Alpha|Beta|RC|Stable)[\""']"")",simpleAssign,149 Python 3 for Absolute Beginners,"date format = re.compile(""[\""'][0-3][0-9]-[01][0-9]-[0-9]{4}[\""']"")",simpleAssign,149 Python 3 for Absolute Beginners,filename = input('Python script to be checked:-> '),simpleAssign,150 Python 3 for Absolute Beginners,filename = get file(),simpleAssign,150 Python 3 for Absolute Beginners,spellbook['file'] = filename,simpleAssign,150 Python 3 for Absolute Beginners,"if line no == 0 and line != ""#! /usr/bin/env python\n"":",simpleAssign,151 Python 3 for Absolute Beginners,"if line no == 1 and line != ""# -*- coding: UTF8 -*-\n"":",simpleAssign,151 Python 3 for Absolute Beginners,"label, value = line.split(' = ')",simpleAssign,151 Python 3 for Absolute Beginners,task = todo format.match(line),simpleAssign,152 Python 3 for Absolute Beginners,"label, desc = task.groups(1)",simpleAssign,152 Python 3 for Absolute Beginners,spellbook['date'] = Now,simpleAssign,152 Python 3 for Absolute Beginners,spellbook['author'] = spellbook['maintainer'],simpleAssign,152 Python 3 for Absolute Beginners,player = eval(line),simpleAssign,158 Python 3 for Absolute Beginners,"are 'magic' objects, which should only be used as documented. = 0.1",simpleAssign,167 Python 3 for Absolute Beginners,"a, b, c = 0, 1, 2",simpleAssign,168 Python 3 for Absolute Beginners,"x, y ,z = 0.5, 1.65, 2.42",simpleAssign,168 Python 3 for Absolute Beginners,result = naming conventions(),simpleAssign,169 Python 3 for Absolute Beginners,results = main func(),simpleAssign,169 Python 3 for Absolute Beginners,"now = time.strftime(""%Y-%m-%d"") # the time function yields system time, date, etc.",simpleAssign,171 Python 3 for Absolute Beginners,arguments = get args(),simpleAssign,172 Python 3 for Absolute Beginners,data = get input(),simpleAssign,172 Python 3 for Absolute Beginners,t=3,simpleAssign,173 Python 3 for Absolute Beginners,"result=eval(""t > 5"") # 3 is not greater than 5",simpleAssign,173 Python 3 for Absolute Beginners,"now = time.strftime(""%A %d %B %Y"")",simpleAssign,174 Python 3 for Absolute Beginners,"now = time.strftime(""%A %d %B %Y"")",simpleAssign,177 Python 3 for Absolute Beginners,form = cgi.FieldStorage(),simpleAssign,177 Python 3 for Absolute Beginners,"name = form.getvalue('name', 'new user')",simpleAssign,177 Python 3 for Absolute Beginners,person1 = Person() #create instance of class,simpleAssign,182 Python 3 for Absolute Beginners,player1 = Player(),simpleAssign,183 Python 3 for Absolute Beginners,player1 = Player(),simpleAssign,184 Python 3 for Absolute Beginners,player2 = Player(),simpleAssign,184 Python 3 for Absolute Beginners,"and == with your custom classes, and you can replicate the behavior of other existing types, such as",simpleAssign,184 Python 3 for Absolute Beginners,"binding. This is what happens when you first assign a value to a variable using the = operator, or when",simpleAssign,185 Python 3 for Absolute Beginners,gender = gender.lower(),simpleAssign,186 Python 3 for Absolute Beginners,race = race.capitalize(),simpleAssign,187 Python 3 for Absolute Beginners,name = input('What is your name? '),simpleAssign,188 Python 3 for Absolute Beginners,desc = input('Describe yourself: '),simpleAssign,188 Python 3 for Absolute Beginners,gender = input('What Gender are you? (male/female/unsure): '),simpleAssign,188 Python 3 for Absolute Beginners,race = input('What Race are you? - (Pixie/Vulcan/Gelfling/Troll): '),simpleAssign,188 Python 3 for Absolute Beginners,player1 = Player(),simpleAssign,189 Python 3 for Absolute Beginners,price = 0,simpleAssign,189 Python 3 for Absolute Beginners,strength = 0,simpleAssign,189 Python 3 for Absolute Beginners,speed = 0,simpleAssign,189 Python 3 for Absolute Beginners,box = Thing(),simpleAssign,189 Python 3 for Absolute Beginners,axe = Weapon(),simpleAssign,190 Python 3 for Absolute Beginners,axe.price = 75,simpleAssign,190 Python 3 for Absolute Beginners,axe.strength = 60,simpleAssign,190 Python 3 for Absolute Beginners,axe.speed = 50,simpleAssign,190 Python 3 for Absolute Beginners,axe = Weapon(),simpleAssign,190 Python 3 for Absolute Beginners,axe = Weapon(),simpleAssign,191 Python 3 for Absolute Beginners,box = Thing(),simpleAssign,191 Python 3 for Absolute Beginners,"box = Thing(0, 0, 0)",simpleAssign,192 Python 3 for Absolute Beginners,"axe = Weapon(75, 60, 50)",simpleAssign,193 Python 3 for Absolute Beginners,number of items contained within the object expressed as an integer >= 0. This integer is,simpleAssign,194 Python 3 for Absolute Beginners,names = vars(self),simpleAssign,195 Python 3 for Absolute Beginners,item = names[key],simpleAssign,195 Python 3 for Absolute Beginners,item = 0,simpleAssign,195 Python 3 for Absolute Beginners,key] = value,simpleAssign,195 Python 3 for Absolute Beginners,name = name.capitalize() #double underscores in front,simpleAssign,196 Python 3 for Absolute Beginners,"name = property(getName, setName)",simpleAssign,196 Python 3 for Absolute Beginners,player1 = Player(),simpleAssign,196 Python 3 for Absolute Beginners,self <= other,simpleAssign,197 Python 3 for Absolute Beginners,self == other,simpleAssign,197 Python 3 for Absolute Beginners,self != other,simpleAssign,197 Python 3 for Absolute Beginners,self >= other,simpleAssign,197 Python 3 for Absolute Beginners,I Note There are no implied relationships among the comparison operators. The truth of x==y does not imply that,simpleAssign,198 Python 3 for Absolute Beginners,"x!=y is False. Therefore, you need to define all of these methods so that all forms of comparison work correctly.",simpleAssign,198 Python 3 for Absolute Beginners,"comparison is not defined. It should return a negative integer if self < other, zero if self == other, and a positive integer if self > other.",simpleAssign,198 Python 3 for Absolute Beginners,self -= other,simpleAssign,199 Python 3 for Absolute Beginners,self *= other,simpleAssign,199 Python 3 for Absolute Beginners,self /= other,simpleAssign,199 Python 3 for Absolute Beginners,self /= other,simpleAssign,199 Python 3 for Absolute Beginners,self //= other,simpleAssign,199 Python 3 for Absolute Beginners,self %= other,simpleAssign,199 Python 3 for Absolute Beginners,self **= other,simpleAssign,199 Python 3 for Absolute Beginners,self <<= other,simpleAssign,199 Python 3 for Absolute Beginners,self >>= other,simpleAssign,199 Python 3 for Absolute Beginners,self &= other,simpleAssign,199 Python 3 for Absolute Beginners,self ^= other,simpleAssign,199 Python 3 for Absolute Beginners,self |= other,simpleAssign,199 Python 3 for Absolute Beginners,"CHAPTER 9 I CLASSES = 0.6",simpleAssign,202 Python 3 for Absolute Beginners,trace on = False,simpleAssign,202 Python 3 for Absolute Beginners,drag = 23,simpleAssign,202 Python 3 for Absolute Beginners,"armour types = set(['shield','cuirass','armour'])",simpleAssign,202 Python 3 for Absolute Beginners,"name = property(getName, setName)",simpleAssign,203 Python 3 for Absolute Beginners,"desc = property(getDesc, setDesc)",simpleAssign,203 Python 3 for Absolute Beginners,gender = gender.lower(),simpleAssign,203 Python 3 for Absolute Beginners,"gender = property(getGender, setGender)",simpleAssign,203 Python 3 for Absolute Beginners,race = race.capitalize(),simpleAssign,204 Python 3 for Absolute Beginners,"race = property(getRace, setRace)",simpleAssign,204 Python 3 for Absolute Beginners,strength = property(getStrength),simpleAssign,204 Python 3 for Absolute Beginners,brainz = property(getBrainz),simpleAssign,204 Python 3 for Absolute Beginners,speed = property(getSpeed),simpleAssign,204 Python 3 for Absolute Beginners,charm = property(getCharm),simpleAssign,204 Python 3 for Absolute Beginners,"life = property(getLife, setLife)",simpleAssign,205 Python 3 for Absolute Beginners,"magic = property(getMagic, setMagic)",simpleAssign,205 Python 3 for Absolute Beginners,"prot = property(getProt, setProt)",simpleAssign,205 Python 3 for Absolute Beginners,"gold = property(getGold, setGold)",simpleAssign,205 Python 3 for Absolute Beginners,text = join with and(flatlist),simpleAssign,205 Python 3 for Absolute Beginners,"inventory = property(getInv, setInv)",simpleAssign,205 Python 3 for Absolute Beginners,name = input('What is your name? '),simpleAssign,206 Python 3 for Absolute Beginners,desc = input('Describe yourself: '),simpleAssign,206 Python 3 for Absolute Beginners,gender = input('What Gender are you? (male/female/unsure): '),simpleAssign,206 Python 3 for Absolute Beginners,race = input('Race? (Pixie/Vulcan/Gelfling/Troll): '),simpleAssign,206 Python 3 for Absolute Beginners,handbag = join with and(self.inventory),simpleAssign,207 Python 3 for Absolute Beginners,key] = value,simpleAssign,208 Python 3 for Absolute Beginners,names = vars(self),simpleAssign,208 Python 3 for Absolute Beginners,item = names[key],simpleAssign,208 Python 3 for Absolute Beginners,item.name == purchase.capitalize()],simpleAssign,208 Python 3 for Absolute Beginners,elif 0 < items[0].gold <= self.gold:,simpleAssign,208 Python 3 for Absolute Beginners,item = items[0],simpleAssign,208 Python 3 for Absolute Beginners,weapon = self.weapon,simpleAssign,208 Python 3 for Absolute Beginners,armour = target.armour,simpleAssign,209 Python 3 for Absolute Beginners,attack chance = roll(99),simpleAssign,209 Python 3 for Absolute Beginners,strength = property(getStrength),simpleAssign,209 Python 3 for Absolute Beginners,speed = property(getSpeed),simpleAssign,209 Python 3 for Absolute Beginners,names = vars(self),simpleAssign,210 Python 3 for Absolute Beginners,item = names[key],simpleAssign,210 Python 3 for Absolute Beginners,item = 0,simpleAssign,210 Python 3 for Absolute Beginners,"self, name = 'Somewhere', store = {}): = store",simpleAssign,210 Python 3 for Absolute Beginners,here = self,simpleAssign,211 Python 3 for Absolute Beginners,me = player,simpleAssign,211 Python 3 for Absolute Beginners,command list = command.split(),simpleAssign,211 Python 3 for Absolute Beginners,command = self.commands[command list[0]],simpleAssign,211 Python 3 for Absolute Beginners,command = command.format(' '.\,simpleAssign,211 Python 3 for Absolute Beginners,"join(command list[1:]),target = player)",simpleAssign,211 Python 3 for Absolute Beginners,"command = command.format('self', \",simpleAssign,212 Python 3 for Absolute Beginners,target = player),simpleAssign,212 Python 3 for Absolute Beginners,"command = input("":-> "")",simpleAssign,212 Python 3 for Absolute Beginners,attack strength = int(attacker.strength),simpleAssign,212 Python 3 for Absolute Beginners,weapon damage = int(attacker['weapon'].strength),simpleAssign,212 Python 3 for Absolute Beginners,target strength = int(target.strength),simpleAssign,212 Python 3 for Absolute Beginners,armour strength = int(target['armour'].strength),simpleAssign,212 Python 3 for Absolute Beginners,target chance = roll(int(target.brainz) * 3),simpleAssign,212 Python 3 for Absolute Beginners,potential damage = int((attack damage - target defence) * 0.3),simpleAssign,212 Python 3 for Absolute Beginners,potential damage = 2,simpleAssign,212 Python 3 for Absolute Beginners,"damage = random.randint(1,potential damage)",simpleAssign,212 Python 3 for Absolute Beginners,life left = target.life,simpleAssign,213 Python 3 for Absolute Beginners,velocity = attacker.strike(target),simpleAssign,213 Python 3 for Absolute Beginners,size = len(hits) - 1,simpleAssign,213 Python 3 for Absolute Beginners,hit type = int(size * velocity / self. vel max),simpleAssign,213 Python 3 for Absolute Beginners,hit type = size,simpleAssign,213 Python 3 for Absolute Beginners,size = len(misses) - 1,simpleAssign,213 Python 3 for Absolute Beginners,miss type = int(size * velocity / self. vel max),simpleAssign,213 Python 3 for Absolute Beginners,miss type = roll(7),simpleAssign,213 Python 3 for Absolute Beginners,miss type = roll(7) - 1,simpleAssign,213 Python 3 for Absolute Beginners,"damage, potential damage = self.damage(attacker, target, velocity)",simpleAssign,213 Python 3 for Absolute Beginners,size = len(damage report) - 1,simpleAssign,213 Python 3 for Absolute Beginners,damage type = int(size * damage / self. dam max),simpleAssign,213 Python 3 for Absolute Beginners,damage type = size,simpleAssign,213 Python 3 for Absolute Beginners,damage type = 0,simpleAssign,214 Python 3 for Absolute Beginners,size = len(life changing) - 1,simpleAssign,214 Python 3 for Absolute Beginners,change type = int(size * damage / life left),simpleAssign,214 Python 3 for Absolute Beginners,change type = size,simpleAssign,214 Python 3 for Absolute Beginners,change type = 0,simpleAssign,214 Python 3 for Absolute Beginners,"output = fix gender(attacker.gender, outstring)",simpleAssign,214 Python 3 for Absolute Beginners,target.life -= damage,simpleAssign,214 Python 3 for Absolute Beginners,if target.life <= 0:,simpleAssign,214 Python 3 for Absolute Beginners,miss counter = 0,simpleAssign,214 Python 3 for Absolute Beginners,"matches = ziply(list(range(0,len(players))))",simpleAssign,214 Python 3 for Absolute Beginners,"winner = self.resolve conflict(players[attack],\",simpleAssign,215 Python 3 for Absolute Beginners,if winner == False:,simpleAssign,215 Python 3 for Absolute Beginners,miss counter = 0,simpleAssign,215 Python 3 for Absolute Beginners,last item = sequence[-1],simpleAssign,216 Python 3 for Absolute Beginners,sentence = sequence[0],simpleAssign,216 Python 3 for Absolute Beginners,result = 0,simpleAssign,217 Python 3 for Absolute Beginners,opponents = list(seq[:]),simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('them','her')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('their','her')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('themself','herself')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('them','him')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('their','his')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('themself','himself')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('them','it')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('their','its')",simpleAssign,217 Python 3 for Absolute Beginners,"phrase = phrase.replace('themself','itself')",simpleAssign,217 Python 3 for Absolute Beginners,player = eval(line),simpleAssign,218 Python 3 for Absolute Beginners,reply = input('How many players?: ') or 2,simpleAssign,218 Python 3 for Absolute Beginners,max players = int(reply),simpleAssign,218 Python 3 for Absolute Beginners,arena = Location('Main Arena'),simpleAssign,218 Python 3 for Absolute Beginners,shop = Shop('The Emporium'),simpleAssign,218 Python 3 for Absolute Beginners,players = players[:max players],simpleAssign,219 Python 3 for Absolute Beginners,profile = Player(),simpleAssign,219 Python 3 for Absolute Beginners,arena.inventory = players,simpleAssign,219 Python 3 for Absolute Beginners,"r = dangerous method(a, b, c)",simpleAssign,222 Python 3 for Absolute Beginners,"r = something else(a, b, c)",simpleAssign,223 Python 3 for Absolute Beginners,"r = something else again(a, b, c)",simpleAssign,223 Python 3 for Absolute Beginners,Safe 3 / 2 = 1.5,simpleAssign,223 Python 3 for Absolute Beginners,Unsafe 3 / 2 = 1.5,simpleAssign,223 Python 3 for Absolute Beginners,Safe 3 / 0 = 1e16,simpleAssign,223 Python 3 for Absolute Beginners,total = 0,simpleAssign,227 Python 3 for Absolute Beginners,stub = strip punctuation(str),simpleAssign,242 Python 3 for Absolute Beginners,stub = strip punctuation(str),simpleAssign,242 Python 3 for Absolute Beginners,choice = random.random(),simpleAssign,243 Python 3 for Absolute Beginners,if choice <= weightings[0]:,simpleAssign,243 Python 3 for Absolute Beginners,text = piratify(text),simpleAssign,243 Python 3 for Absolute Beginners,"foo = import",simpleAssign,245 Python 3 for Absolute Beginners,"foo = import",simpleAssign,246 Python 3 for Absolute Beginners,config = True,simpleAssign,246 Python 3 for Absolute Beginners,config = val,simpleAssign,246 Python 3 for Absolute Beginners,total = 0,simpleAssign,256 Python 3 for Absolute Beginners,cost = float(row[1]) * float(row[2]),simpleAssign,256 Python 3 for Absolute Beginners,"time obj = datetime.datetime.strptime(guess, ""%d %b %Y, %H:%M"")",simpleAssign,257 Python 3 for Absolute Beginners,interval = datetime.timedelta(5),simpleAssign,257 Python 3 for Absolute Beginners,day = datetime.date.today(),simpleAssign,257 Python 3 for Absolute Beginners,day -= interval,simpleAssign,257 Python 3 for Absolute Beginners,soup = BeautifulSoup.BeautifulSoup(text),simpleAssign,258 Python 3 for Absolute Beginners,"maintainer@website.com"" = 0.1",simpleAssign,262 Python 3 for Absolute Beginners,frame = Tkinter.Frame(master),simpleAssign,262 Python 3 for Absolute Beginners,command=self.say hi),simpleAssign,262 Python 3 for Absolute Beginners,command=frame.quit),simpleAssign,262 Python 3 for Absolute Beginners,root = Tkinter.Tk(),simpleAssign,263 Python 3 for Absolute Beginners,app = HelloTk(root),simpleAssign,263 Python 3 for Absolute Beginners,"maintainer@website.com"" = 0.1",simpleAssign,265 Python 3 for Absolute Beginners,hello = HelloGtk(),simpleAssign,266 Python 3 for Absolute Beginners,with treeview1 using the treeview1.set model(model=self.liststore) method.,simpleAssign,271 Python 3 for Absolute Beginners,command = eval(command ref),simpleAssign,275 Python 3 for Absolute Beginners,"weight=700, scale=pango.SCALE LARGE)",simpleAssign,275 Python 3 for Absolute Beginners,place = self.textbuffer.get start iter(),simpleAssign,275 Python 3 for Absolute Beginners,iter0 = self.textbuffer.get iter at line(0),simpleAssign,276 Python 3 for Absolute Beginners,iter1 = self.textbuffer.get iter at line(1),simpleAssign,276 Python 3 for Absolute Beginners,"dialog = gtk.FileChooserDialog(title='Save Multimedia Info to file',",simpleAssign,276 Python 3 for Absolute Beginners,"action=gtk.FILE CHOOSER ACTION SAVE,",simpleAssign,276 Python 3 for Absolute Beginners,response = dialog.run(),simpleAssign,276 Python 3 for Absolute Beginners,outfile name = dialog.get filename(),simpleAssign,276 Python 3 for Absolute Beginners,if response == gtk.RESPONSE OK:,simpleAssign,276 Python 3 for Absolute Beginners,"weight=700, scale=pango.SCALE LARGE)",simpleAssign,277 Python 3 for Absolute Beginners,place = self.textbuffer.get start iter(),simpleAssign,277 Python 3 for Absolute Beginners,"icon = eval(""self.save image"")",simpleAssign,277 Python 3 for Absolute Beginners,iter0 = self.textbuffer.get iter at line(0),simpleAssign,277 Python 3 for Absolute Beginners,iter1 = self.textbuffer.get iter at line(1),simpleAssign,277 Python 3 for Absolute Beginners,elif response == gtk.RESPONSE CANCEL:,simpleAssign,277 Python 3 for Absolute Beginners,logo = self.icon,simpleAssign,278 Python 3 for Absolute Beginners,dialog = gtk.AboutDialog(),simpleAssign,278 Python 3 for Absolute Beginners,response = dialog.run(),simpleAssign,278 Python 3 for Absolute Beginners,application = GtkInfo(),simpleAssign,279 Python 3 for Absolute Beginners,"domain=app name, **kwargs):",simpleAssign,280 Python 3 for Absolute Beginners,"path = os.path.join(glade dir, path)",simpleAssign,280 Python 3 for Absolute Beginners,window1 = Window1(),simpleAssign,281 Python 3 for Absolute Beginners,"dict.fromkeys(iterable, value=None)",simpleAssign,285 Python Projects for Kids,"while loop. At the bottom of the code, we will simply write this:",whilesimple,52 Python Projects for Kids,while calc_on == 1:,whilesimple,52 Python Projects for Kids,while game_on:,whilesimple,63 Python Projects for Kids,while game_on:,whilesimple,64 Python Projects for Kids,while gameOn == 'true':,whilesimple,65 Python Projects for Kids,"while loop back in Chapters 4, Making Decisions:",whilesimple,106 Python Projects for Kids,while game_on:,whilesimple,106 Python Projects for Kids,while game_on:,whilesimple,106 Python Projects for Kids,while loop:,whilesimple,124 Python Projects for Kids,while loop to line 17 of the sample.py file:,whilesimple,125 Python Projects for Kids,while True:,whilesimple,125 Python Projects for Kids,while do_main:,whilesimple,142 Python Projects for Kids,while loop:,whilesimple,142 Python Projects for Kids,while loop:,whilesimple,151 Python Projects for Kids,while loop stops running:,whilesimple,152 Python Projects for Kids,"numbers = {'one': 1, 'two': 2, 'three': 3}",simpleDict,86 Python Projects for Kids,"items = {'arrows' : 200, 'rocks' : 25, 'food' : 15, 'lives' : 2}",simpleDict,87 Python Projects for Kids,import the,importfunc,61 Python Projects for Kids,import a,importfunc,61 Python Projects for Kids,import statement,importfunc,61 Python Projects for Kids,import random,importfunc,61 Python Projects for Kids,import pygame,importfunc,117 Python Projects for Kids,import pygame,importfunc,119 Python Projects for Kids,import pygame,importfunc,120 Python Projects for Kids,import the,importfunc,120 Python Projects for Kids,import pygame,importfunc,120 Python Projects for Kids,import and,importfunc,129 Python Projects for Kids,import the,importfunc,133 Python Projects for Kids,import pygame,importfunc,133 Python Projects for Kids,import random,importfunc,133 Python Projects for Kids,import time,importfunc,133 Python Projects for Kids,"players[i][""score""] += 1",assignIncrement,108 Python Projects for Kids,"You will notice a new symbol, +=. The += symbol is a shortcut that lets us take a",assignIncrement,108 Python Projects for Kids,"player backpack, then the new score for the first player is score += 1. You will",assignIncrement,108 Python Projects for Kids,"zero in the dictionary. Now, we are updating that score to be score += 1. Each time",assignIncrement,108 Python Projects for Kids,You will notice the -= and += symbols in this code. These symbols are used as,assignIncrement,145 Python Projects for Kids,pressed. Both the -= and += symbols are very important for setting the proper paddle,assignIncrement,145 Python Projects for Kids,ball_x += ball_xv,assignIncrement,146 Python Projects for Kids,ball_y += ball_yv,assignIncrement,146 Python Projects for Kids,player1_score += 1,assignIncrement,150 Python Projects for Kids,"range(1, 11)",rangefunc,54 Python Projects for Kids,range(),rangefunc,54 Python Projects for Kids,range(),rangefunc,54 Python Projects for Kids,"range(0,100))",rangefunc,63 Python Projects for Kids,range(),rangefunc,100 Python Projects for Kids,range(),rangefunc,100 Python Projects for Kids,range(2),rangefunc,103 Python Projects for Kids,range(2),rangefunc,103 Python Projects for Kids,range(4),rangefunc,103 Python Projects for Kids,range(2),rangefunc,106 Python Projects for Kids,def addition():,simplefunc,20 Python Projects for Kids,def addition():,simplefunc,21 Python Projects for Kids,def name():,simplefunc,25 Python Projects for Kids,def name():,simplefunc,25 Python Projects for Kids,def name():,simplefunc,25 Python Projects for Kids,def name():,simplefunc,26 Python Projects for Kids,def name():,simplefunc,26 Python Projects for Kids,def addition():,simplefunc,33 Python Projects for Kids,def addition():,simplefunc,36 Python Projects for Kids,def subtraction():,simplefunc,38 Python Projects for Kids,def multiplication():,simplefunc,39 Python Projects for Kids,def division():,simplefunc,39 Python Projects for Kids,def modulo():,simplefunc,41 Python Projects for Kids,def calc_run():,simplefunc,47 Python Projects for Kids,def calc_run():,simplefunc,47 Python Projects for Kids,def calc_run():,simplefunc,49 Python Projects for Kids,def quit():,simplefunc,51 Python Projects for Kids,def calc_run():,simplefunc,51 Python Projects for Kids,def difficulty_level_easy():,simplefunc,63 Python Projects for Kids,def difficulty_level_easy():,simplefunc,63 Python Projects for Kids,def difficulty_level_easy():,simplefunc,63 Python Projects for Kids,def difficulty_level_easy():,simplefunc,64 Python Projects for Kids,def difficulty_level_easy():,simplefunc,65 Python Projects for Kids,def start_game():,simplefunc,67 Python Projects for Kids,def start_game():,simplefunc,67 Python Projects for Kids,def start_game():,simplefunc,67 Python Projects for Kids,def start_game():,simplefunc,68 Python Projects for Kids,def play_again():,simplefunc,69 Python Projects for Kids,def play_again():,simplefunc,69 Python Projects for Kids,def difficulty_level_hard():,simplefunc,71 Python Projects for Kids,def difficulty_level_hard():,simplefunc,71 Python Projects for Kids,def difficulty_level_hard():,simplefunc,72 Python Projects for Kids,def difficulty_level_hard():,simplefunc,73 Python Projects for Kids,"return to our example of the addition function in Chapter 2, Variables, Functions,",return,32 Python Projects for Kids,return the remainder. Why is this even,return,40 Python Projects for Kids,return a message to,return,49 Python Projects for Kids,return the value of arrows:,return,87 Python Projects for Kids,return to and start again.,return,154 Python Projects for Kids,if you like:,simpleif,25 Python Projects for Kids,if it matches up:,simpleif,39 Python Projects for Kids,"if op == 'add': addition()",simpleif,47 Python Projects for Kids,if to give the user choices for each mathematical operation:,simpleif,47 Python Projects for Kids,"if op == 'add': addition()",simpleif,47 Python Projects for Kids,"if op == 'subtract': subtraction()",simpleif,47 Python Projects for Kids,if op == 'multiply':,simpleif,47 Python Projects for Kids,"if op == 'divide': division()",simpleif,48 Python Projects for Kids,"if op == 'modulo': modulo()",simpleif,48 Python Projects for Kids,"if they do NOT choose add, subtract, multiply, divide, or modulo:",simpleif,49 Python Projects for Kids,"if op == 'add': addition()",simpleif,49 Python Projects for Kids,"if op == 'subtract': subtraction()",simpleif,49 Python Projects for Kids,"if op == 'multiply': multiplication()",simpleif,49 Python Projects for Kids,"if op == 'divide': division()",simpleif,49 Python Projects for Kids,"if op == 'modulo': modulo()",simpleif,49 Python Projects for Kids,"if op == 'add': addition()",simpleif,51 Python Projects for Kids,"if op == 'subtract': subtraction()",simpleif,51 Python Projects for Kids,"if op == 'multiply': multiplication()",simpleif,51 Python Projects for Kids,"if op == 'divide': division()",simpleif,51 Python Projects for Kids,"if op == 'modulo': modulo()",simpleif,52 Python Projects for Kids,if for ten to your control flow of if/elif/else:,simpleif,55 Python Projects for Kids,"if op == 'ten': count_to_ten()",simpleif,55 Python Projects for Kids,"if guess > secret: print('your guess is too high. Try again.')",simpleif,65 Python Projects for Kids,"if guess < secret: print('your guess is too low. Try again.')",simpleif,65 Python Projects for Kids,"if level == 'easy': difficulty_level_easy()",simpleif,68 Python Projects for Kids,"if level == 'hard': difficulty_level_hard()",simpleif,68 Python Projects for Kids,"if level == 'quit': game_on = False",simpleif,68 Python Projects for Kids,"if play == 'Yes': start_game()",simpleif,69 Python Projects for Kids,"if i == 2: print('Game over. Too many guesses.')",simpleif,73 Python Projects for Kids,"if guess > secret: print('your guess is too high. Try again.')",simpleif,73 Python Projects for Kids,"if guess < secret: print('your guess is too low. Try again.')",simpleif,73 Python Projects for Kids,if it is not installed already:,simpleif,120 Python Projects for Kids,"if event.type == pygame.QUIT: do_main = False",simpleif,143 Python Projects for Kids,"if pressed[pygame.K_ESCAPE]: do_main = False",simpleif,144 Python Projects for Kids,"if pressed[pygame.K_w]: paddle1_y -= 5",simpleif,144 Python Projects for Kids,"if pressed[pygame.K_s]: paddle1_y += 5",simpleif,144 Python Projects for Kids,"if pressed[pygame.K_UP]: paddle2_y -= 5",simpleif,144 Python Projects for Kids,"if pressed[pygame.K_DOWN]: paddle2_y += 5",simpleif,144 Python Projects for Kids,"if ball_y - ball_r <= 0 or ball_y + ball_r >= screen_height: ball_yv *= -1",simpleif,146 Python Projects for Kids,"if paddle1_y < 0: paddle1_y = 0",simpleif,147 Python Projects for Kids,"if paddle1_y + paddle1_h > screen_height: paddle1_y = screen_height - paddle1_h",simpleif,148 Python Projects for Kids,"if paddle2_y < 0: paddle2_y = 0",simpleif,148 Python Projects for Kids,"if paddle2_y + paddle2_h > screen_height: paddle2_y = screen_height - paddle2_h",simpleif,148 Python Projects for Kids,"if ball_x <= 0: player2_score += 1",simpleif,150 Python Projects for Kids,"print(""Hello, world!"")",printfunc,7 Python Projects for Kids,print(),printfunc,11 Python Projects for Kids,print(name) or print(height),printfunc,14 Python Projects for Kids,print(first_number + second_number),printfunc,15 Python Projects for Kids,print(first_number + second_number),printfunc,16 Python Projects for Kids,print(first_number + second_number),printfunc,17 Python Projects for Kids,print(first_number + second_number),printfunc,18 Python Projects for Kids,print(first_number + second_number),printfunc,20 Python Projects for Kids,print(first_number + second_number),printfunc,21 Python Projects for Kids,print(name),printfunc,22 Python Projects for Kids,"print('So nice to meet you, ' + first_name)",printfunc,26 Python Projects for Kids,"print('So nice to meet you, ' + first_name)",printfunc,26 Python Projects for Kids,"print('So nice to meet you, ' + first_name)",printfunc,26 Python Projects for Kids,print(first + second),printfunc,33 Python Projects for Kids,print(a),printfunc,34 Python Projects for Kids,print(b),printfunc,34 Python Projects for Kids,print(a),printfunc,35 Python Projects for Kids,print(b),printfunc,35 Python Projects for Kids,print(first + second),printfunc,36 Python Projects for Kids,print(first - second),printfunc,38 Python Projects for Kids,print(first * second),printfunc,39 Python Projects for Kids,print(first / second),printfunc,39 Python Projects for Kids,print(first % second),printfunc,41 Python Projects for Kids,print('Thank you. Goodbye'),printfunc,49 Python Projects for Kids,print(1),printfunc,53 Python Projects for Kids,print(2),printfunc,53 Python Projects for Kids,print(3),printfunc,53 Python Projects for Kids,print(4),printfunc,53 Python Projects for Kids,print(5),printfunc,53 Python Projects for Kids,print(6),printfunc,53 Python Projects for Kids,print(7),printfunc,53 Python Projects for Kids,print(8),printfunc,53 Python Projects for Kids,print(9),printfunc,53 Python Projects for Kids,print(10),printfunc,53 Python Projects for Kids,print(n),printfunc,54 Python Projects for Kids,print(number),printfunc,55 Python Projects for Kids,print('You win!'),printfunc,65 Python Projects for Kids,print('You win!'),printfunc,73 Python Projects for Kids,print(fruit[0]),printfunc,81 Python Projects for Kids,print(fruit[3]),printfunc,82 Python Projects for Kids,print(fruit),printfunc,83 Python Projects for Kids,print(fruit),printfunc,84 Python Projects for Kids,print('I see ' + color + '.'),printfunc,85 Python Projects for Kids,print(items),printfunc,87 Python Projects for Kids,print(items['arrows']),printfunc,87 Python Projects for Kids,print(items),printfunc,89 Python Projects for Kids,print(items),printfunc,90 Python Projects for Kids,print(items),printfunc,90 Python Projects for Kids,print(items),printfunc,90 Python Projects for Kids,"black = (0, 0, 0)",simpleTuple,122 Python Projects for Kids,"white = (255, 255, 255)",simpleTuple,122 Python Projects for Kids,"red = (255, 0, 0)",simpleTuple,122 Python Projects for Kids,"green = (0, 255, 0)",simpleTuple,122 Python Projects for Kids,"blue = (0, 0, 255)",simpleTuple,122 Python Projects for Kids,"red = (255, 0, 0)",simpleTuple,134 Python Projects for Kids,"orange = (255, 127, 0)",simpleTuple,134 Python Projects for Kids,"yellow = (255, 255, 0)",simpleTuple,134 Python Projects for Kids,"blue = (0, 0, 255)",simpleTuple,134 Python Projects for Kids,"violet = (127, 0, 255)",simpleTuple,134 Python Projects for Kids,"brown = (102, 51, 0)",simpleTuple,134 Python Projects for Kids,"black = (0, 0, 0)",simpleTuple,134 Python Projects for Kids,"white = (255, 255, 255)",simpleTuple,134 Python Projects for Kids,"fruit = ['apple', 'banana', 'kiwi', 'dragonfruit']",simpleList,80 Python Projects for Kids,"years = [2012, 2013, 2014, 2015]",simpleList,80 Python Projects for Kids,"students_in_class = [30, 22, 28, 33]",simpleList,80 Python Projects for Kids,"colors = ['green', 'yellow', 'red']",simpleList,85 Python Projects for Kids,players = [],simpleList,98 Python Projects for Kids,"for n in range(1, 11):",forsimple,54 Python Projects for Kids,"for number in range(1, 11):",forsimple,55 Python Projects for Kids,for i in range(guesses):,forsimple,72 Python Projects for Kids,"for i in range(guesses), we are really saying this:",forsimple,72 Python Projects for Kids,for loop in our difficulty_level_hard() function:,forsimple,73 Python Projects for Kids,for i in range(guesses):,forsimple,73 Python Projects for Kids,for loop in your Python shell:,forsimple,85 Python Projects for Kids,for color in colors:,forsimple,85 Python Projects for Kids,for this behavior in pygame:,forsimple,141 Python Projects for Kids,for event in pygame.event.get():,forsimple,143 Python Projects for Kids,other_player = players[(i+1) % 2],assignwithSum,107 Python Projects for Kids,"score_text = font.render(str(player1_score) + "" "" + str(player2_",assignwithSum,152 Python Projects for Kids,and-64-bit-windows#1TC=windows-7.,simpleAssign,5 Python Projects for Kids,"128 cm, tall. I will say height_inches = 64 or height_centimeters = 128. The",simpleAssign,13 Python Projects for Kids,first_number = 10,simpleAssign,16 Python Projects for Kids,second_number = 20,simpleAssign,16 Python Projects for Kids,first_number = 10.3,simpleAssign,17 Python Projects for Kids,second_number = 20.3,simpleAssign,17 Python Projects for Kids,second_number = 20,simpleAssign,18 Python Projects for Kids,html?highlight=built%20functions#.,simpleAssign,20 Python Projects for Kids,first_number = 30,simpleAssign,20 Python Projects for Kids,second_number = 60,simpleAssign,20 Python Projects for Kids,first_number = 30,simpleAssign,21 Python Projects for Kids,second_number = 60,simpleAssign,21 Python Projects for Kids,name = raw_input('What is your name?'),simpleAssign,22 Python Projects for Kids,"first_name = The first_name variable will store the answer to the question, What is your first",simpleAssign,25 Python Projects for Kids,first_name = input('What is your first name?'),simpleAssign,25 Python Projects for Kids,first_name = input('What is your first name?'),simpleAssign,26 Python Projects for Kids,first_name = input('What is your first name?'),simpleAssign,26 Python Projects for Kids,5. The user presses the = key.,simpleAssign,31 Python Projects for Kids,first = raw_input('I will add two numbers. Enter the first number'),simpleAssign,33 Python Projects for Kids,second = raw_input('Now enter the second number.'),simpleAssign,33 Python Projects for Kids,a = int(44.5),simpleAssign,34 Python Projects for Kids,b = float(44.5),simpleAssign,34 Python Projects for Kids,a = int(24),simpleAssign,35 Python Projects for Kids,b = float(24),simpleAssign,35 Python Projects for Kids,first = float(input('What is your first number?')),simpleAssign,36 Python Projects for Kids,second = float(input('What is your second number?')),simpleAssign,36 Python Projects for Kids,first = int(raw_input('What is your first number?')),simpleAssign,38 Python Projects for Kids,second = int(raw_input('What is your second number?')),simpleAssign,38 Python Projects for Kids,first = int(raw_input('What is your first number?')),simpleAssign,39 Python Projects for Kids,second = int(raw_input('What is your second number?')),simpleAssign,39 Python Projects for Kids,first = int(raw_input('What is your first number?')),simpleAssign,39 Python Projects for Kids,second = int(raw_input('What is your second number?')),simpleAssign,39 Python Projects for Kids,first = int(raw_input('What is your first number?')),simpleAssign,41 Python Projects for Kids,second = int(raw_input('What is your second number?')),simpleAssign,41 Python Projects for Kids,1 <= 1,simpleAssign,44 Python Projects for Kids,1 >= 1,simpleAssign,44 Python Projects for Kids,1 == 1,simpleAssign,44 Python Projects for Kids,1 != 1,simpleAssign,44 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, or modulo?')",simpleAssign,47 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, or modulo? ')",simpleAssign,47 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, or modulo? ')",simpleAssign,49 Python Projects for Kids,calc_on = 1,simpleAssign,51 Python Projects for Kids,calc_on = 0,simpleAssign,51 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, or modulo? ')",simpleAssign,51 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, modulo, quit?')",simpleAssign,52 Python Projects for Kids,"op = raw_input('add, subtract, multiply, divide, modulo, ten, or",simpleAssign,55 Python Projects for Kids,game_on = None,simpleAssign,62 Python Projects for Kids,guesses = None,simpleAssign,62 Python Projects for Kids,secret = None,simpleAssign,62 Python Projects for Kids,"secret = int(random.randrange(0,100))",simpleAssign,63 Python Projects for Kids,"game_on = True. For the easy game, we are going to assume that game_on is True.",simpleAssign,63 Python Projects for Kids,"secret = float(random.randrange(0,100))",simpleAssign,63 Python Projects for Kids,"secret = float(random.randrange(0,100))",simpleAssign,64 Python Projects for Kids,guess = int(input('Guess a number. ')),simpleAssign,64 Python Projects for Kids,statement: guess = int(input('Guess a number. ')). Adding a space after the,simpleAssign,64 Python Projects for Kids,guess = float(input('Guess a number. ')),simpleAssign,65 Python Projects for Kids,elif guess == secret:,simpleAssign,65 Python Projects for Kids,game_on = True,simpleAssign,67 Python Projects for Kids,"game_on = True level = input('Welcome. Type easy, hard, or quit",simpleAssign,67 Python Projects for Kids,"level = input('Welcome. Type easy, hard, or quit. ')",simpleAssign,68 Python Projects for Kids,game_on = True,simpleAssign,69 Python Projects for Kids,play = input('Play again? Yes or No. '),simpleAssign,69 Python Projects for Kids,play = input('Play again? Yes or No.'),simpleAssign,69 Python Projects for Kids,guesses = 3,simpleAssign,71 Python Projects for Kids,guesses = 3,simpleAssign,72 Python Projects for Kids,guess = float(input('Guess a number. ')),simpleAssign,73 Python Projects for Kids,elif guess == secret:,simpleAssign,73 Python Projects for Kids,tutorial/datastructures.html?highlight=lists#more-on-,simpleAssign,80 Python Projects for Kids,items['fireball'] = 10,simpleAssign,88 Python Projects for Kids,will end only when game_on = False.,simpleAssign,106 Python Projects for Kids,Erin (player 1) = 0 and Tanvir (player 2) = 1.,simpleAssign,107 Python Projects for Kids,Tanvir = 1.,simpleAssign,107 Python Projects for Kids,0 + 1) % 2 = 1.,simpleAssign,107 Python Projects for Kids,This formula says (Erin + 1) modulo 2 = Tanvir's backpack.,simpleAssign,107 Python Projects for Kids,"Tanvir needs to guess what is in Erin's backpack. Remember, Erin = 0.",simpleAssign,108 Python Projects for Kids,1 + 1) % 2 = 0.,simpleAssign,108 Python Projects for Kids,This formula says (Tanvir + 1) modulo 2 = Erin's backpack.,simpleAssign,108 Python Projects for Kids,game_on = False appears in the code to stop the while loop. As soon as the loop,simpleAssign,108 Python Projects for Kids,screen_width = 400,simpleAssign,121 Python Projects for Kids,screen_height = 600,simpleAssign,121 Python Projects for Kids,of the background. We will make the game_screen = pygame.display.set_,simpleAssign,122 Python Projects for Kids,"game_screen = pygame.display.set_mode((screen_width, screen_height))",simpleAssign,122 Python Projects for Kids,screen_width = 600,simpleAssign,135 Python Projects for Kids,screen_height = 400,simpleAssign,135 Python Projects for Kids,"game_screen = pygame.display.set_mode((screen_width, screen_height))",simpleAssign,136 Python Projects for Kids,"font = pygame.font.SysFont(""monospace"", 75)",simpleAssign,136 Python Projects for Kids,ball_x = int(screen_width / 2),simpleAssign,137 Python Projects for Kids,ball_y = int(screen_height / 2),simpleAssign,137 Python Projects for Kids,ball_xv = 3,simpleAssign,137 Python Projects for Kids,ball_yv = 3,simpleAssign,137 Python Projects for Kids,The ball_xv = 3 means that the ball will move 3 pixels along the x axis each time it,simpleAssign,137 Python Projects for Kids,is redrawn. The ball_yv = 3 means that the ball will move 3 pixels along the y axis,simpleAssign,137 Python Projects for Kids,"speed and direction that we like. Here, v = velocity which is the magnitude (speed)",simpleAssign,137 Python Projects for Kids,"and direction (x,y) of the ball. So, when we say ball_xv = 3, we are really saying",simpleAssign,137 Python Projects for Kids,ball_r = 20,simpleAssign,137 Python Projects for Kids,paddle1_x = 10,simpleAssign,138 Python Projects for Kids,paddle1_y = 10,simpleAssign,138 Python Projects for Kids,paddle1_w = 25,simpleAssign,138 Python Projects for Kids,paddle1_h = 100,simpleAssign,138 Python Projects for Kids,paddle2_x = screen_width - 35,simpleAssign,138 Python Projects for Kids,paddle2_y = 10,simpleAssign,138 Python Projects for Kids,paddle2_w = 25,simpleAssign,138 Python Projects for Kids,paddle2_h = 100,simpleAssign,138 Python Projects for Kids,player1_score = 0,simpleAssign,139 Python Projects for Kids,player2_score = 0,simpleAssign,139 Python Projects for Kids,call our main game loop variable do_main. We will set do_main = True:,simpleAssign,142 Python Projects for Kids,do_main = True,simpleAssign,142 Python Projects for Kids,pressed = pygame.key.get_pressed(),simpleAssign,143 Python Projects for Kids,if ball_x < paddle1_x + paddle1_w and ball_y >= paddle1_y and ball_y,simpleAssign,148 Python Projects for Kids,if ball_x > paddle2_x and ball_y >= paddle2_y and ball_y <= paddle2_y,simpleAssign,148 Python Projects for Kids,ball_x = int(screen_width / 2),simpleAssign,150 Python Projects for Kids,ball_y = int(screen_height / 2),simpleAssign,150 Python Projects for Kids,elif ball_x >= screen_width:,simpleAssign,150 Python Projects for Kids,ball_x = int(screen_width / 2),simpleAssign,150 Python Projects for Kids,ball_y = int(screen_height / 2),simpleAssign,150 Python Projects for Kids,"paddle_1 = pygame.draw.rect(game_screen, white, (paddle1_x, paddle1_y,",simpleAssign,151 Python Projects for Kids,"paddle_2 = pygame.draw.rect(game_screen, white, (paddle2_x, paddle2_y,",simpleAssign,151 Python Projects for Kids,"net = pygame.draw.line(game_screen, yellow, (300,5), (300,400))",simpleAssign,151 Python Projects for Kids,"ball = pygame.draw.circle(game_screen, red, (ball_x, ball_y), ball_r,",simpleAssign,151 Python Projects for Kids,py?fileviewer=file-view-default,simpleAssign,159 Python Projects for Kids,php?file=snake.py,simpleAssign,159 Head First Python,"@property def",decaratorfunc,250 Head First Python,"@property def",decaratorfunc,286 Head First Python,"@property decorator allows the top3() method to appear like an attribute to users of the class",decaratorclass,250 Head First Python,"@property” - a decorator that lets you arrange for a class",decaratorclass,253 Head First Python,"@property, so that it appears to be a new attribute to users of your class",decaratorclass,285 Head First Python,"@property thing again? A: The @property decorator lets you specify that a method is to be presented to users of your class",decaratorclass,285 Head First Python,"@property decorator let’s you indicate this. Users of your class",decaratorclass,285 Head First Python,"@property, so that it appears to be a new attribute to users of your class",decaratorclass,286 Head First Python,enumerate(),enumfunc,53 Head First Python,enumerate(),enumfunc,54 Head First Python,enumerate(),enumfunc,450 Head First Python,clean_mikey = [sanitize(each_t) for each_t in mikey],simpleListComp,155 Head First Python,secs = [m * 60 for m in mins],simpleListComp,156 Head First Python,feet = [m * 3.281 for m in meters],simpleListComp,156 Head First Python,upper = [s.upper() for s in lower],simpleListComp,156 Head First Python,clean = [sanitize(t) for t in dirty],simpleListComp,156 Head First Python,clean = [float(s) for s in clean],simpleListComp,156 Head First Python,response = [athletes[each_ath].name for each_ath in athletes],simpleListComp,270 Head First Python,response = [athletes[each_ath].name for each_ath in athletes],simpleListComp,329 Head First Python,response = [athletes[each_ath].name for each_ath in athletes],simpleListComp,331 Head First Python,response = [row[0] for row in results.fetchall()],simpleListComp,332 Head First Python,data = [row[0] for row in results.fetchall()],simpleListComp,333 Head First Python,response = [row[0] for row in results.fetchall()],simpleListComp,335 Head First Python,response = [row[0] for row in results.fetchall()],simpleListComp,336 Head First Python,athlete_names = [ath[0] for ath in athletes],simpleListComp,344 Head First Python,prediction = [k for k in row_data['20k'].keys() if row_data['20k'][k] == column_heading],simpleListComp,408 Head First Python,prediction = [k for k in row_data['20k'].keys() if row_data['20k'][k] == column_heading],simpleListComp,409 Head First Python,times = [t for t in row_data['Marathon'].keys()],simpleListComp,411 Head First Python,"headings = [h for h in sorted(row_data['10mi'].values(), reverse=True)]",simpleListComp,411 Head First Python,time = [t for t in row_data['20k'].keys() if row_data['20k'][t] == '79.3'],simpleListComp,411 Head First Python,times = [t for t in row_data['Marathon'].keys()],simpleListComp,412 Head First Python,"headings = [h for h in sorted(row_data['10mi'].values(), reverse=True)]",simpleListComp,412 Head First Python,time = [t for t in row_data['20k'].keys() if row_data['20k'][t] == '79.3'],simpleListComp,412 Head First Python,where = [time2secs(t) for t in target_data],simpleListComp,420 Head First Python,prediction = [k for k in row_data[predicted_distance],simpleListComp,427 Head First Python,prediction = [k for k in row_data[predicted_distance],simpleListComp,428 Head First Python,"time = [] for each_t in row_data[‘20k’].keys(): if row_data[‘20k’][each_t]",listCompIf,412 Head First Python,"pickle.dump([1, 2, 'three'], mysavedata)",pickle,133 Head First Python,"pickle.dump(man, man_file)",pickle,134 Head First Python,"pickle.dump(other, other_file)",pickle,134 Head First Python,pickle.dump(),pickle,134 Head First Python,pickle.dump(),pickle,138 Head First Python,pickle.load(),pickle,138 Head First Python,if __name__ == '__main__':,__name__,370 Head First Python,if __name__ == '__main__':,__name__,371 Head First Python,if __name__ == '__main__':,__name__,372 Head First Python,"if __name__ == ""__main__"":",__name__,438 Head First Python,"__add__', '__class__",__class__,206 Head First Python,"__contains__', '__delattr__', '__delitem__', '__dict__",__dict__,206 Head First Python,"try: man_file = open('man_data.txt', 'w') other_file = open('other_data.txt', 'w') print(man, file=man_file) print(other, file=other_file) except IOError: print('File error.') …the calls to “close()” are moved to here. finally:",tryexceptfinally,115 Head First Python,"try: except IOError: finally: data.close() print('File error') There’s your error message, but… File error Traceback (most recent call last): File ""<pyshell#8>"", line 7, in <module> data.close() NameError: name 'data' is not defined …what’s this?!? Another exception was raised and it killed your code. As the file doesn’t exist, the data file object wasn’t created, which subsequently makes it impossible to call the close() method on it, so you end up with a NameError. A quick fix is to add a small test to the finally suite to see if the data name exists before you try to call close(). The locals() BIF returns a collection of names defined in the current scope. Let’s exploit this BIF to only invoke close() when it is safe to do so: The “in” operator tests for membership. This is just the bit of code that needs to change. Press Alt-P to edit your code at IDLE’s shell. if 'data' in locals(): data.close() finally:",tryexceptfinally,118 Head First Python,"try: except IOError as err: finally:",tryexceptfinally,120 Head First Python,"try: man_file = open('man_data.txt', 'w') other_file = open('other_data.txt', 'w') print(man, file=man_file) print(other, file=other_file) except IOError as err: print('File error: ' + str(err)) finally:",tryexceptfinally,121 Head First Python,"try: man_file = open('man_data.txt', 'w') other_file = open('other_data.txt', 'w') print(man, file=man_file) print(other, file=other_file) except IOError as err: print('File error: ' + str(err)) finally:",tryexceptfinally,122 Head First Python,"palin = {'Name': 'Michael Palin', 'Occupations': ['comedian', 'actor', 'writer', 'tv']}",dictwithList,180 Head First Python,"with open(‘man_data.txt', ‘w') as man_file:",withfunc,122 Head First Python,"with open(‘other_data.txt', ‘w') as other_file:",withfunc,122 Head First Python,"with open('man_data.txt', 'w') as man_file, open('other_data.txt’, 'w’) as other_file:",withfunc,122 Head First Python,with open('man_data.txt') as mdf:,withfunc,124 Head First Python,"with open('mydata.pickle', 'wb') as mysavedata:",withfunc,133 Head First Python,"with open('mydata.pickle', 'rb') as myrestoredata:",withfunc,133 Head First Python,"with open('man_data.txt', 'w') as man_file, open('other_data.txt', 'w') as other_file:",withfunc,134 Head First Python,"with open('man_data.txt', 'rb') as man_file:",withfunc,136 Head First Python,with open(‘james.txt’) as jaf:,withfunc,142 Head First Python,with open(‘julie.txt’) as juf:,withfunc,142 Head First Python,with open(‘mikey.txt’) as mif:,withfunc,142 Head First Python,with open(‘sarah.txt’) as saf:,withfunc,142 Head First Python,with open('james.txt') as jaf:,withfunc,151 Head First Python,with open('julie.txt') as juf:,withfunc,151 Head First Python,with open('mikey.txt') as mif:,withfunc,151 Head First Python,with open('sarah.txt') as saf:,withfunc,151 Head First Python,with open('james.txt') as jaf:,withfunc,152 Head First Python,with open('julie.txt') as juf:,withfunc,152 Head First Python,with open('mikey.txt') as mif:,withfunc,152 Head First Python,with open('sarah.txt') as saf:,withfunc,152 Head First Python,with open('james.txt') as jaf:,withfunc,168 Head First Python,with open('julie.txt') as juf:,withfunc,168 Head First Python,with open('mikey.txt') as mif:,withfunc,168 Head First Python,with open('sarah.txt') as saf:,withfunc,168 Head First Python,with open('james.txt') as jaf:,withfunc,169 Head First Python,with open('julie.txt') as juf:,withfunc,169 Head First Python,with open('mikey.txt') as mif:,withfunc,169 Head First Python,with open('sarah.txt') as saf:,withfunc,169 Head First Python,with open('james.txt') as jaf:,withfunc,170 Head First Python,with open('julie.txt') as juf:,withfunc,170 Head First Python,with open('mikey.txt') as mif:,withfunc,170 Head First Python,with open('sarah.txt') as saf:,withfunc,170 Head First Python,with open(filename) as f:,withfunc,170 Head First Python,with open('templates/header.html') as headf:,withfunc,227 Head First Python,with open('templates/footer.html') as footf:,withfunc,227 Head First Python,with open('templates/header.html') as headf:,withfunc,228 Head First Python,with open('templates/footer.html') as footf:,withfunc,228 Head First Python,with open('templates/header.html') as headf:,withfunc,230 Head First Python,with open('templates/footer.html') as footf:,withfunc,230 Head First Python,with open(‘templates/form.html') as formf:,withfunc,298 Head First Python,with open('PaceData.csv') as paces:,withfunc,403 Head First Python,with open('PaceData.csv') as paces:,withfunc,404 Head First Python,with open('PaceData.csv') as paces:,withfunc,407 Head First Python,"if isinstance(each_item, list): else:",ifelse,35 Head First Python,while count < len(movies):,whilesimple,16 Head First Python,while splitting each line. Type the following code into IDLE’s shell:,whilesimple,78 Head First Python,called __init__(),__init__,191 Head First Python,def __init__(self),__init__,191 Head First Python,the __init__() method),__init__,191 Head First Python,the __init__(),__init__,191 Head First Python,to __init__()),__init__,192 Head First Python,the __init__(),__init__,192 Head First Python,def __init__(self),__init__,192 Head First Python,the __init__(),__init__,193 Head First Python,"def __init__(self, value=0)",__init__,193 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,194 Head First Python,the __init__(),__init__,195 Head First Python,the __init__(),__init__,196 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,196 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,199 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,200 Head First Python,"def __init__(self, a_name)",__init__,206 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,207 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,208 Head First Python,"def __init__(self, a_name, a_dob=None, a_times=[])",__init__,208 Head First Python,The __init__(),__init__,212 Head First Python,"212 __init__()",__init__,452 Head First Python,"try: This code is protected from runtime errors. data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except: If a runtime error occurs, this code is pass executed. data.close() Now, no matter what happens when the split() method is invoked, the try statement catches any and all exceptions and handles them by ignoring the error with pass. Let’s see this code in action. Do this! Make the required changes to your code in the IDLE edit window. you are here 4 93",trytry,93 Head First Python,"try: data = open('sketch.txt') As with the other program, all of this code remains unchanged. Give the user the bad news. for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except: pass data.close() except: print('The data file is missing!') Another quick test is required, this time with the version of your program that uses exception handling. Press F5 to give it a spin. >>> ================================ RESTART ================================ >>> As expected, this version of the program handles the missing file, too. The data file is missing! >>> 98 Chapter 3",trytry,98 Head First Python,"try: pass data.close() except: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except: Th i s c o d e a n d t h i s c o d e r u n s w h e n A N Y r u n t i m e e r r o r o c c u rs w it h i n t h e c o d e t h at i s b e i n g t rie d . print('The data file is missing!') As your code is currently written, it is too generic. Any runtime error that occurs is handled by one of the except suites. This is unlikely to be what you want, because this code has the potential to silently ignore runtime errors. You need to somehow use except in a less generic way. you are here 4 101",trytry,101 Head First Python,"try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except ValueError: pass Specify the type of runtime error you are handling. data.close() except IOError: print('The data file is missing!') Of course, if an different type of runtime error occurs, it is no longer handled by your code, but at least now you’ll get to hear about it. When you are specific about the runtime errors your code handles, your programs no longer silently ignore some runtime errors. ...and it lets you avoid adding unnecessary code and logic to your programs. That works for me! Using “try/except” lets you concentrate on what your code needs to do... 102 Chapter 3",trytry,102 Head First Python,"try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) except ValueError: pass data.close() except IOError: print('The datafile is missing!') Here are your magnets. if role == 'Man': elif role == 'Other Man': man = [] line_spoken = line_spoken.strip() other = [] other.append(line_spoken) print(other) man.append(line_spoken) print(man) you are here 4 107",trytry,107 Head First Python,"try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) Assign the stripped string back onto itself. “elif” means “else if.” line_spoken = line_spoken.strip() if role == 'Man': man.append(line_spoken) elif role == 'Other Man': other.append(line_spoken) The “strip()” method removes unwanted whitespace from a string. Update one of the lists based on who said what. except ValueError: pass data.close() except IOError: print('The datafile is missing!') print(man) print(other) Conclude by displaying the processed data on screen. 108 Chapter 4",trytry,108 Head First Python,"try: data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) line_spoken = line_spoken.strip() if role == 'Man': man.append(line_spoken) elif role == 'Other Man': other.append(line_spoken) except ValueError: pass data.close() except IOError: print('The datafile is missing!') Go on, try. print(man, ) print(other, ) Be sure to close your files. Open your two data files here. Specify the files to write to when you invoke “print()”. Handle any exceptions here. you are here 4 111",trytry,111 Head First Python,"try: At the bottom of your program, two calls to the print() BIF display your processed data on screen. You were to amend this code to save the data to two disk files instead. You were to call your disk files man_data.txt (for what the man said) and other_data.txt (for what the other man said). You were to make sure to both open and close your data files, as well as protect your code against an IOError using try/except. data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) line_spoken = line_spoken.strip() All of this code is unchanged. if role == 'Man': man.append(line_spoken) elif role == 'Other Man': other.append(line_spoken) except ValueError: pass data.close() except IOError: print('The datafile is missing!') try: man_file = open(‘man_data.txt’, ‘w’) other_file = open(‘other_data.txt’, ‘w’) print(man, ) print(other, ) file=man_file file=other_file Did you remember to open your files in WRITE mode? Open your two files, and assign each to file objects. Use the “print()” BIF to save the named lists to named disk files. man_file.close() other_file.close() except IOError: print('File error.’) Don’t forget to close BOTH files. Handle an I/O exception, should one occur. 112 Chapter 4",trytry,112 Head First Python,"try: with open(‘athletes.pickle', ‘wb') as athf: pickle.dump(all_athletes, athf) except IOError as ioerr: print(‘File error (put_and_store): ' + str(ioerr)) Each athlete’s name is used as the “key” in the dictionary. The “value” is the AthleteList object instance. And don’t forget a try/except to protect your file I/O code. return(all_athletes) def get_from_store(): all_athletes = {} Simply read the entire pickle into the dictionary. What could be easier? try: with open(‘athletes.pickle', ‘rb') as athf: all_athletes = pickle.load(athf) except IOError as ioerr: print(‘File error (get_from_store): ' + str(ioerr)) return(all_athletes) Again…don’t forget your try/except. 224 Chapter 7",trytry,224 Head First Python,"try: with open(filename) as f: data = f.readline() templ = data.strip().split(',') return(AthleteList(templ.pop(0), templ.pop(0), templ)) except IOError as ioerr: print('File error (get_coach_data): ' + str(ioerr)) return(None) def put_to_store(files_list): all_athletes = {} for each_file in files_list: ath = get_coach_data(each_file) all_athletes[ath.name] = ath try: with open('athletes.pickle', 'wb') as athf: pickle.dump(all_athletes, athf) except IOError as ioerr: print('File error (put_and_store): ' + str(ioerr)) return(all_athletes) 328 Chapter 9",trytry,328 Head First Python,"try: with open(filename) as f: data = f.readline() templ = data.strip().split(',') return(AthleteList(templ.pop(0), templ.pop(0), templ)) except IOError as ioerr: print('File error (get_coach_data): ' + str(ioerr)) return(None) def put_to_store(files_list): all_athletes = {} for each_file in files_list: ath = get_coach_data(each_file) all_athletes[ath.name] = ath try: with open('athletes.pickle', 'wb') as athf: pickle.dump(all_athletes, athf) except IOError as ioerr: print('File error (put_and_store): ' + str(ioerr)) return(all_athletes) 330 Chapter 9",trytry,330 Head First Python,"try: man_file = open('man_data.txt', 'w') other_file = open('other_data.txt', 'w') OK OK print(man, file=man_file) print(other, file=other_file) OK Not OK!! Crash! man_file.close() other_file.close() OK except IOError:",tryexcept,114 Head First Python,"try: with open('its.txt', ""w"") as data: print(""It's..."", file=data) except IOError as err:",tryexcept,120 Head First Python,"try: except IOError as err:",tryexcept,122 Head First Python,"try: Here’s a snippet of your code as it currently stands. Grab your pencil and strike out the code you no longer need, and then replace it with code that uses the facilities of pickle instead. Add any additional code that you think you might need, too. with open('man_data.txt', 'w') as man_file, open('other_data.txt', 'w') as other_file: nester.print_lol(man, fh=man_file) nester.print_lol(other, fh=other_file) except IOError as err:",tryexcept,133 Head First Python,"try: nester.print_lol(man, fh=man_file) nester.print_lol(other, fh=other_file) except IOError as err: print('File error: ' + str(err)) except pickle.PickleError as perr:",tryexcept,134 Head First Python,"try: except IOError as err: except pickle.PickleError as perr:",tryexcept,136 Head First Python,"try: except IOError as ioerr:",tryexcept,170 Head First Python,"try: with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr:",tryexcept,175 Head First Python,"try: with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr:",tryexcept,176 Head First Python,"try: with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr:",tryexcept,181 Head First Python,"try: with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr:",tryexcept,182 Head First Python,"try: with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr:",tryexcept,184 Head First Python,"try: with open(filename) as f: data = f.readline() templ = data.strip().split(‘,’) return({‘Name’ : templ.pop(0), ‘DOB’ : templ.pop(0), ‘Times’: str(sorted(set([sanitize(t) for t in templ]))[0:3])}) except IOError as ioerr:",tryexcept,186 Head First Python,"try: with open(filename) as f: data = f.readline() templ = data.strip().split(',') return({'Name' : templ.pop(0), 'DOB' : templ.pop(0), What needs to change here to ensure this function returns an Athlete object as opposed to a dictionary? 'Times': str(sorted(set([sanitize(t) for t in templ]))[0:3])}) except IOError as ioerr:",tryexcept,195 Head First Python,"try: with open(filename) as f: data = f.readline() templ = data.strip().split(',') Remove the dictionary creation code and replace it with Athlete object creation code instead. return({'Name' : templ.pop(0), 'DOB' : templ.pop(0), Athlete(templ.pop(0), templ.pop(0), templ) 'Times': str(sorted(set([sanitize(t) for t in templ]))[0:3])}) except IOError as ioerr:",tryexcept,196 Head First Python,"try: with open('athletes.pickle', 'rb') as athf: all_athletes = pickle.load(athf) except IOError as ioerr:",tryexcept,329 Head First Python,"try: with open('athletes.pickle', 'rb') as athf: all_athletes = pickle.load(athf) except IOError as ioerr:",tryexcept,331 Head First Python,class NamedList(list):,simpleclass,206 Head First Python,class AthleteList(list):,simpleclass,208 Head First Python,"def get(self): pass",pass,370 Head First Python,"for fab in ['John', 'Paul', 'George', 'Ringo']:",forwithlist,233 Head First Python,"names = ['John', 'Eric', ['Cleese', 'Idle'], 'Michael', ['Palin']]",nestedList,64 Head First Python,"names = ['John', 'Eric', ['Cleese', 'Idle'], 'Michael', ['Palin']]",nestedList,69 Head First Python,"names = ['John', 'Eric', ['Cleese', 'Idle'], 'Michael', ['Palin']]",nestedList,69 Head First Python,"names = ['John', 'Eric', ['Cleese', 'Idle'], 'Michael', ['Palin']]",nestedList,69 Head First Python,"clean = [float(sanitize(t)) for t in ['2-22', '3:33', '4.44']]",nestedList,156 Head First Python,"names = ['John', ['Johnny', 'Jack'], 'Michael', ['Mike', 'Mikey', 'Mick']]",nestedList,269 Head First Python,Python’s open(),openfunc,75 Head First Python,When you use the open(),openfunc,75 Head First Python,the_file = open('sketch.txt'),openfunc,75 Head First Python,data = open('sketch.txt'),openfunc,76 Head First Python,data = open('sketch.txt'),openfunc,78 Head First Python,data = open('sketch.txt'),openfunc,85 Head First Python,data = open('sketch.txt'),openfunc,86 Head First Python,data = open('sketch.txt'),openfunc,91 Head First Python,data = open('sketch.txt'),openfunc,92 Head First Python,data = open('sketch.txt'),openfunc,97 Head First Python,Use the open(),openfunc,103 Head First Python,Surely Python’s open(),openfunc,109 Head First Python,When you use the open(),openfunc,110 Head First Python,"access mode to use. By default, open()",openfunc,110 Head First Python,"out = open(""data.out"", ""w"")",openfunc,110 Head First Python,data = open('missing.txt'),openfunc,118 Head First Python,"data = open('its.txt', ""w"")",openfunc,120 Head First Python,Or combine the two “open(),openfunc,122 Head First Python,"page = urlopen(url, urlencode(post_data))",openfunc,275 Head First Python,page = urlopen(url),openfunc,275 Head First Python,"page = urlopen(url, urlencode(post_data))",openfunc,276 Head First Python,page = urlopen(url),openfunc,276 Head First Python,"page = urlopen(url, urlencode(post_data))",openfunc,282 Head First Python,page = urlopen(url),openfunc,282 Head First Python,urlencode() and urlopen(),openfunc,291 Head First Python,"page = urlopen(url, urlencode(post_data))",openfunc,305 Head First Python,page = urlopen(url),openfunc,305 Head First Python,"page = urlopen(url, urlencode(post_data))",openfunc,306 Head First Python,page = urlopen(url),openfunc,306 Head First Python,urlopen(),openfunc,457 Head First Python,self.response.out.write(html),write,371 Head First Python,self.response.out.write(html),write,372 Head First Python,invoking the out.write(),write,379 Head First Python,self.response.out.write(field),write,379 Head First Python,self.response.out.write(': '),write,379 Head First Python,self.response.out.write(self.request.get(field)),write,379 Head First Python,self.response.out.write('<br />'),write,379 Head First Python,self.response.out.write(html),write,380 Head First Python,self.response.out.write(html),write,381 Head First Python,self.response.out.write(html),write,382 Head First Python,head_text = headf.read(),read,227 Head First Python,foot_text = footf.read(),read,227 Head First Python,head_text = headf.read(),read,228 Head First Python,foot_text = footf.read(),read,228 Head First Python,head_text = headf.read(),read,230 Head First Python,foot_text = footf.read(),read,230 Head First Python,"return(page.read().decode(""utf8""))",read,275 Head First Python,"return(page.read().decode(""utf8""))",read,276 Head First Python,"return(page.read().decode(""utf8""))",read,282 Head First Python,form_text = formf.read(),read,298 Head First Python,"return(page.read().decode(""utf8""))",read,305 Head First Python,"return(page.read().decode(""utf8""))",read,306 Head First Python,"print(data.readline(), end='')",readline,76 Head First Python,"print(data.readline(), end='')",readline,76 Head First Python,Use the “readline(),readline,76 Head First Python,The readline(),readline,103 Head First Python,"print(data.readline(), end='')",readline,118 Head First Python,print(mdf.readline()),readline,124 Head First Python,data = jaf.readline(),readline,142 Head First Python,data = juf.readline(),readline,142 Head First Python,data = mif.readline(),readline,142 Head First Python,data = saf.readline(),readline,142 Head First Python,data = jaf.readline(),readline,151 Head First Python,data = juf.readline(),readline,151 Head First Python,data = mif.readline(),readline,151 Head First Python,data = saf.readline(),readline,151 Head First Python,data = jaf.readline(),readline,152 Head First Python,data = juf.readline(),readline,152 Head First Python,data = mif.readline(),readline,152 Head First Python,data = saf.readline(),readline,152 Head First Python,data = jaf.readline(),readline,168 Head First Python,data = juf.readline(),readline,168 Head First Python,data = mif.readline(),readline,168 Head First Python,data = saf.readline(),readline,168 Head First Python,data = jaf.readline(),readline,169 Head First Python,data = juf.readline(),readline,169 Head First Python,data = mif.readline(),readline,169 Head First Python,data = saf.readline(),readline,169 Head First Python,data = jaf.readline(),readline,170 Head First Python,data = juf.readline(),readline,170 Head First Python,data = mif.readline(),readline,170 Head First Python,data = saf.readline(),readline,170 Head First Python,data = f.readline(),readline,170 Head First Python,"paces.readline().strip().split(',')",readline,403 Head First Python,"paces.readline().strip().split(',')",readline,404 Head First Python,"column_headings = paces.readline().strip().split(',')",readline,407 Head First Python,import it,importfunc,43 Head First Python,import it,importfunc,43 Head First Python,import nester,importfunc,43 Head First Python,import statement,importfunc,43 Head First Python,import nester,importfunc,44 Head First Python,import your,importfunc,46 Head First Python,import nester,importfunc,46 Head First Python,import statement,importfunc,46 Head First Python,import your,importfunc,49 Head First Python,import them,importfunc,49 Head First Python,import the,importfunc,51 Head First Python,import the,importfunc,55 Head First Python,import the,importfunc,56 Head First Python,import nester,importfunc,58 Head First Python,import statement,importfunc,71 Head First Python,import a,importfunc,71 Head First Python,import the,importfunc,76 Head First Python,import os,importfunc,76 Head First Python,import it,importfunc,97 Head First Python,import os,importfunc,97 Head First Python,import into,importfunc,127 Head First Python,import into,importfunc,128 Head First Python,import the,importfunc,128 Head First Python,import the,importfunc,133 Head First Python,import pickle,importfunc,133 Head First Python,"import the",importfunc,133 Head First Python,import pickle,importfunc,134 Head First Python,import pickle,importfunc,136 Head First Python,import nester,importfunc,136 Head First Python,import the,importfunc,209 Head First Python,import pickle,importfunc,223 Head First Python,import pickle,importfunc,224 Head First Python,import your,importfunc,225 Head First Python,import has,importfunc,225 Head First Python,import athletemodel,importfunc,237 Head First Python,import yate,importfunc,237 Head First Python,import glob,importfunc,237 Head First Python,import athletemodel,importfunc,238 Head First Python,import yate,importfunc,238 Head First Python,import glob,importfunc,238 Head First Python,import cgi,importfunc,244 Head First Python,import cgi,importfunc,246 Head First Python,import athletemodel,importfunc,246 Head First Python,import yate,importfunc,246 Head First Python,import cgitb,importfunc,248 Head First Python,import android,importfunc,264 Head First Python,import json,importfunc,269 Head First Python,import json,importfunc,272 Head First Python,import athletemodel,importfunc,272 Head First Python,import yate,importfunc,272 Head First Python,import android,importfunc,274 Head First Python,import android,importfunc,274 Head First Python,import android,importfunc,275 Head First Python,import json,importfunc,275 Head First Python,import time,importfunc,275 Head First Python,import android,importfunc,276 Head First Python,import json,importfunc,276 Head First Python,import time,importfunc,276 Head First Python,import cgi,importfunc,281 Head First Python,import json,importfunc,281 Head First Python,import athletemodel,importfunc,281 Head First Python,import yate,importfunc,281 Head First Python,import android,importfunc,281 Head First Python,import json,importfunc,281 Head First Python,import time,importfunc,281 Head First Python,import sys,importfunc,284 Head First Python,import cgi,importfunc,296 Head First Python,import yate,importfunc,299 Head First Python,import cgi,importfunc,300 Head First Python,import os,importfunc,300 Head First Python,import time,importfunc,300 Head First Python,import sys,importfunc,300 Head First Python,import cgi,importfunc,301 Head First Python,import os,importfunc,301 Head First Python,import time,importfunc,301 Head First Python,import sys,importfunc,301 Head First Python,import yate,importfunc,301 Head First Python,import cgi,importfunc,302 Head First Python,import os,importfunc,302 Head First Python,import time,importfunc,302 Head First Python,import sys,importfunc,302 Head First Python,import yate,importfunc,302 Head First Python,import android,importfunc,305 Head First Python,import android,importfunc,306 Head First Python,import the,importfunc,313 Head First Python,"import the",importfunc,315 Head First Python,import sqlite3,importfunc,315 Head First Python,import sqlite3,importfunc,319 Head First Python,import sqlite3,importfunc,320 Head First Python,import sqlite3,importfunc,321 Head First Python,import glob,importfunc,321 Head First Python,import athletemodel,importfunc,321 Head First Python,import pickle,importfunc,328 Head First Python,import pickle,importfunc,330 Head First Python,import sqlite3,importfunc,332 Head First Python,import sqlite3,importfunc,335 Head First Python,import sqlite3,importfunc,336 Head First Python,import glob,importfunc,337 Head First Python,import athletemodel,importfunc,337 Head First Python,import yate,importfunc,337 Head First Python,import cgi,importfunc,337 Head First Python,import athletemodel,importfunc,337 Head First Python,import yate,importfunc,337 Head First Python,import json,importfunc,338 Head First Python,import athletemodel,importfunc,338 Head First Python,import yate,importfunc,338 Head First Python,import cgi,importfunc,338 Head First Python,import json,importfunc,338 Head First Python,import sys,importfunc,338 Head First Python,import athletemodel,importfunc,338 Head First Python,import yate,importfunc,338 Head First Python,import glob,importfunc,339 Head First Python,import athletemodel,importfunc,339 Head First Python,import yate,importfunc,339 Head First Python,import cgi,importfunc,339 Head First Python,import athletemodel,importfunc,339 Head First Python,import yate,importfunc,339 Head First Python,import json,importfunc,340 Head First Python,import athletemodel,importfunc,340 Head First Python,import yate,importfunc,340 Head First Python,import cgi,importfunc,340 Head First Python,import json,importfunc,340 Head First Python,import sys,importfunc,340 Head First Python,import athletemodel,importfunc,340 Head First Python,import yate,importfunc,340 Head First Python,import the,importfunc,364 Head First Python,import hfwwgDB,importfunc,371 Head First Python,import statement,importfunc,390 Head First Python,import the,importfunc,426 Head First Python,import time,importfunc,426 Head First Python,import android,importfunc,426 Head First Python,import doctest,importfunc,438 Head First Python,import your,importfunc,438 Head First Python,import statement,importfunc,452 Head First Python,from distutils.core import setup,importfromsimple,40 Head First Python,"from module import function",importfromsimple,49 Head First Python,from distutils.core import setup,importfromsimple,60 Head First Python,"from module import function",importfromsimple,71 Head First Python,from athletelist import AthleteList,importfromsimple,209 Head First Python,from athletelist import AthleteList,importfromsimple,223 Head First Python,from athletelist import AthleteList,importfromsimple,224 Head First Python,from string import Template,importfromsimple,227 Head First Python,from string import Template,importfromsimple,228 Head First Python,from string import Template,importfromsimple,230 Head First Python,from urllib import urlencode,importfromsimple,275 Head First Python,from urllib2 import urlopen,importfromsimple,275 Head First Python,from urllib import urlencode,importfromsimple,276 Head First Python,from urllib2 import urlopen,importfromsimple,276 Head First Python,from urllib import urlencode,importfromsimple,281 Head First Python,from urllib2 import urlopen,importfromsimple,281 Head First Python,from urllib import urlencode,importfromsimple,305 Head First Python,from urllib2 import urlopen,importfromsimple,305 Head First Python,from urllib import urlencode,importfromsimple,306 Head First Python,from urllib2 import urlopen,importfromsimple,306 Head First Python,from athletelist import AthleteList,importfromsimple,328 Head First Python,from athletelist import AthleteList,importfromsimple,330 Head First Python,from urllib import urlencode,importfromsimple,343 Head First Python,from urllib2 import urlopen,importfromsimple,343 Head First Python,from urllib import urlencode,importfromsimple,344 Head First Python,from urllib2 import urlopen,importfromsimple,344 Head First Python,from google.appengine.ext import db,importfromsimple,361 Head First Python,from google.appengine.ext import db,importfromsimple,362 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,364 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,365 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,366 Head First Python,from google.appengine.ext import db,importfromsimple,368 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,368 Head First Python,"from google.appengine.ext.db import djangoforms import birthDB",importfromsimple,368 Head First Python,from google.appengine.ext import webapp,importfromsimple,370 Head First Python,from google.appengine.ext.webapp.util import run_wsgi_app,importfromsimple,370 Head First Python,from google.appengine.ext import webapp,importfromsimple,371 Head First Python,from google.appengine.ext.webapp.util import run_wsgi_app,importfromsimple,371 Head First Python,from google.appengine.ext import db,importfromsimple,371 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,371 Head First Python,from google.appengine.ext.db import djangoforms,importfromsimple,371 Head First Python,from google.appengine.ext import webapp,importfromsimple,372 Head First Python,from google.appengine.ext.webapp.util import run_wsgi_app,importfromsimple,372 Head First Python,from google.appengine.ext import db,importfromsimple,372 Head First Python,from google.appengine.ext.webapp import template,importfromsimple,372 Head First Python,"from google.appengine.ext.db import djangoforms import hfwwgDB",importfromsimple,372 Head First Python,from google.appengine.ext import db,importfromsimple,380 Head First Python,from google.appengine.api import users,importfromsimple,390 Head First Python,from find_it import find_closest,importfromsimple,419 Head First Python,from find_it import find_closest,importfromsimple,420 Head First Python,self.thing = value,simpleattr,193 Head First Python,self.name = a_name,simpleattr,194 Head First Python,self.dob = a_dob,simpleattr,194 Head First Python,self.times = a_times,simpleattr,194 Head First Python,self.name = a_name,simpleattr,196 Head First Python,self.dob = a_dob,simpleattr,196 Head First Python,self.times = a_times,simpleattr,196 Head First Python,self.name = a_name,simpleattr,199 Head First Python,self.dob = a_dob,simpleattr,199 Head First Python,self.times = a_times,simpleattr,199 Head First Python,self.name = a_name,simpleattr,200 Head First Python,self.dob = a_dob,simpleattr,200 Head First Python,self.times = a_times,simpleattr,200 Head First Python,self.name = a_name,simpleattr,206 Head First Python,self.name = a_name,simpleattr,207 Head First Python,self.dob = a_dob,simpleattr,207 Head First Python,self.times = a_times,simpleattr,207 Head First Python,self.name = a_name,simpleattr,208 Head First Python,self.dob = a_dob,simpleattr,208 Head First Python,self.times = a_times,simpleattr,208 Head First Python,self.name = a_name,simpleattr,208 Head First Python,self.dob = a_dob,simpleattr,208 Head First Python,"def print_lol(the_list, level=0):",funcdefault,63 Head First Python,"def print_lol(the_list, , level=0):",funcdefault,67 Head First Python,"def print_lol(the_list, , level=0):",funcdefault,68 Head First Python,"def print_lol(the_list, indent=False, level=0, ):",funcdefault,127 Head First Python,"def print_lol(the_list, indent=False, level=0, ):",funcdefault,128 Head First Python,"def start_response(resp=""text/html""):",funcdefault,227 Head First Python,"def start_form(the_url, form_type=""POST""):",funcdefault,227 Head First Python,"def end_form(submit_msg=""Submit""):",funcdefault,227 Head First Python,"def header(header_text, header_level=2):",funcdefault,227 Head First Python,"def start_response(resp=""text/html""):",funcdefault,228 Head First Python,"def start_form(the_url, form_type=""POST""):",funcdefault,229 Head First Python,"def end_form(submit_msg=""Submit""):",funcdefault,229 Head First Python,"def header(header_text, header_level=2):",funcdefault,229 Head First Python,"def start_response(resp=""text/html""):",funcdefault,230 Head First Python,"def start_form(the_url, form_type=""POST""):",funcdefault,231 Head First Python,"def end_form(submit_msg=""Submit""):",funcdefault,231 Head First Python,"def header(header_text, header_level=2):",funcdefault,231 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,275 Head First Python,"def status_update(msg, how_long=2):",funcdefault,275 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,276 Head First Python,"def status_update(msg, how_long=2):",funcdefault,276 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,282 Head First Python,"def status_update(msg, how_long=2):",funcdefault,282 Head First Python,"def do_form(name, the_inputs, method=""POST"", text=""Submit""):",funcdefault,297 Head First Python,"def do_form(name, the_inputs, method=""POST"", text=""Submit""):",funcdefault,298 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,305 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,306 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,343 Head First Python,"def status_update(msg, how_long=2):",funcdefault,343 Head First Python,"def send_to_server(url, post_data=None):",funcdefault,344 Head First Python,"def status_update(msg, how_long=2):",funcdefault,344 Head First Python,"def do_dialog(title, data, func, ok='Select', notok='Quit'):",funcdefault,425 Head First Python,"def status_update(msg, how_long=2):",funcdefault,426 Head First Python,range(),rangefunc,53 Head First Python,range(),rangefunc,54 Head First Python,range(),rangefunc,54 Head First Python,range(),rangefunc,54 Head First Python,range(),rangefunc,54 Head First Python,range(),rangefunc,55 Head First Python,range(),rangefunc,55 Head First Python,range(),rangefunc,55 Head First Python,"range() BIF, amend your function to use range()",rangefunc,55 Head First Python,range(),rangefunc,56 Head First Python,range(),rangefunc,56 Head First Python,range(),rangefunc,71 Head First Python,range(),rangefunc,452 Head First Python,range(),rangefunc,455 Head First Python,def print_lol(the_list):,simplefunc,29 Head First Python,def print_lol(the_list):,simplefunc,30 Head First Python,def print_lol(the_list):,simplefunc,30 Head First Python,def print_lol(the_list):,simplefunc,35 Head First Python,def print_lol(the_list):,simplefunc,37 Head First Python,def print_lol(the_list):,simplefunc,38 Head First Python,def sanitize(time_string):,simplefunc,149 Head First Python,def sanitize(time_string):,simplefunc,150 Head First Python,def sanitize(time_string):,simplefunc,168 Head First Python,def sanitize(time_string):,simplefunc,175 Head First Python,def get_coach_data(filename):,simplefunc,175 Head First Python,def sanitize(time_string):,simplefunc,176 Head First Python,def get_coach_data(filename):,simplefunc,176 Head First Python,def sanitize(time_string):,simplefunc,181 Head First Python,def get_coach_data(filename):,simplefunc,181 Head First Python,def sanitize(time_string):,simplefunc,182 Head First Python,def get_coach_data(filename):,simplefunc,182 Head First Python,def sanitize(time_string):,simplefunc,184 Head First Python,def get_coach_data(filename):,simplefunc,184 Head First Python,def get_coach_data(filename):,simplefunc,186 Head First Python,def how_big(self):,simplefunc,193 Head First Python,def get_coach_data(filename):,simplefunc,195 Head First Python,def top3(self):,simplefunc,196 Head First Python,def get_coach_data(filename):,simplefunc,196 Head First Python,def top3(self):,simplefunc,199 Head First Python,def top3(self):,simplefunc,200 Head First Python,def top3(self):,simplefunc,207 Head First Python,def top3(self):,simplefunc,208 Head First Python,def top3(self):,simplefunc,208 Head First Python,def get_coach_data(filename):,simplefunc,223 Head First Python,def put_to_store(files_list):,simplefunc,223 Head First Python,def get_from_store():,simplefunc,223 Head First Python,def get_coach_data(filename):,simplefunc,224 Head First Python,def put_to_store(files_list):,simplefunc,224 Head First Python,def include_header(the_title):,simplefunc,227 Head First Python,def include_footer(the_links):,simplefunc,227 Head First Python,def u_list(items):,simplefunc,227 Head First Python,def para(para_text):,simplefunc,227 Head First Python,def include_header(the_title):,simplefunc,228 Head First Python,def include_footer(the_links):,simplefunc,228 Head First Python,def u_list(items):,simplefunc,229 Head First Python,def para(para_text):,simplefunc,229 Head First Python,def include_header(the_title):,simplefunc,230 Head First Python,def include_footer(the_links):,simplefunc,230 Head First Python,def u_list(items):,simplefunc,231 Head First Python,def para(para_text):,simplefunc,231 Head First Python,def get_names_from_store():,simplefunc,270 Head First Python,def create_inputs(inputs_list):,simplefunc,297 Head First Python,def create_inputs(inputs_list):,simplefunc,298 Head First Python,def get_coach_data(filename):,simplefunc,328 Head First Python,def get_from_store():,simplefunc,329 Head First Python,def get_names_from_store():,simplefunc,329 Head First Python,def get_coach_data(filename):,simplefunc,330 Head First Python,def get_from_store():,simplefunc,331 Head First Python,def get_names_from_store():,simplefunc,331 Head First Python,def get_names_from_store():,simplefunc,332 Head First Python,def get_athlete_from_id(athlete_id):,simplefunc,333 Head First Python,def get_names_from_store():,simplefunc,335 Head First Python,def get_names_from_store():,simplefunc,336 Head First Python,def get_namesID_from_store():,simplefunc,336 Head First Python,def main():,simplefunc,370 Head First Python,def main():,simplefunc,371 Head First Python,def get(self):,simplefunc,371 Head First Python,def get(self):,simplefunc,372 Head First Python,def main():,simplefunc,372 Head First Python,def post(self):,simplefunc,379 Head First Python,def post(self):,simplefunc,380 Head First Python,def post(self):,simplefunc,381 Head First Python,def post(self):,simplefunc,382 Head First Python,return to your OS,return,3 Head First Python,return to the start of the file.,return,76 Head First Python,return “None”,return,170 Head First Python,return a,return,184 Head First Python,return an,return,195 Head First Python,"return an Athlete object as opposed to a dictionary, and",return,196 Head First Python,"return a three-item list, as opposed to a string? Surely a string would",return,198 Head First Python,return an,return,209 Head First Python,"return a dictionary of",return,223 Head First Python,"return a HTML header tag (H1, H2, H2, and so on) with level 2",return,231 Head First Python,"return to the coach’s home page, or",return,241 Head First Python,"return to the coach’s home page, then select the hyperlink to display the list of athletes, select Sarah,",return,247 Head First Python,"return to the SL4A script listing.",return,283 Head First Python,return the object’s,return,285 Head First Python,return a,return,286 Head First Python,return a list,return,322 Head First Python,"return a dictionary, just as it’s always done.",return,327 Head First Python,"return that to the caller, right?",return,327 Head First Python,return the selected item.,return,425 Head First Python,"if you are using Mac OS X or Linux, type: python3 -V",simpleif,3 Head First Python,"if isinstance(each_item, list):",simpleif,22 Head First Python,if this code makes a difference to the output displayed on screen:,simpleif,22 Head First Python,"if isinstance(each_item, list): for nested_item in each_item:",simpleif,22 Head First Python,"if isinstance(each_item, list):",simpleif,23 Head First Python,"if isinstance(each_item, list):",simpleif,24 Head First Python,"if isinstance(each_item, list):",simpleif,24 Head First Python,"if isinstance(nested_item, list):",simpleif,24 Head First Python,"if isinstance(each_item, list): for nested_item in each_item:",simpleif,25 Head First Python,"if isinstance(nested_item, list): for deeper_item in nested_item:",simpleif,25 Head First Python,"if isinstance(each_item, list):",simpleif,28 Head First Python,"if isinstance(nested_item, list):",simpleif,28 Head First Python,"if isinstance(deeper_item, list):",simpleif,28 Head First Python,"if else:",simpleif,29 Head First Python,"if each_item in the_list:",simpleif,30 Head First Python,"if isinstance(each_item, list):",simpleif,30 Head First Python,"if isinstance(each_item, list):",simpleif,38 Head First Python,"if isinstance(each_item, list):",simpleif,55 Head First Python,"if isinstance(each_item, list):",simpleif,56 Head First Python,"if isinstance(each_item, list): print_lol(each_item)",simpleif,58 Head First Python,"if isinstance(each_item, list): print_lol(each_item)",simpleif,59 Head First Python,"if isinstance(each_item, list): print_lol(each_item, level)",simpleif,59 Head First Python,"if isinstance(each_item, list): print_lol(each_item, level+1)",simpleif,59 Head First Python,"if isinstance(each_item, list):",simpleif,67 Head First Python,"if isinstance(each_item, list):",simpleif,68 Head First Python,if indent :,simpleif,68 Head First Python,"if not each_line.find(':') == -1:",simpleif,86 Head First Python,if os.path.exists('sketch.txt'):,simpleif,97 Head First Python,"if not each_line.find(':') == -1: (role, line_spoken) = each_line.split(':', 1)",simpleif,97 Head First Python,"if isinstance(each_item, list):",simpleif,127 Head First Python,if indent:,simpleif,127 Head First Python,"if isinstance(each_item, list):",simpleif,128 Head First Python,if indent:,simpleif,128 Head First Python,if you enclose your code with try/except:,simpleif,136 Head First Python,if that’s what you need:,simpleif,156 Head First Python,if each_t not in unique_james:,simpleif,162 Head First Python,if post_data:,simpleif,275 Head First Python,if post_data:,simpleif,276 Head First Python,"if resp['which'] in ('positive'): selected_athlete = app.dialogGetSelectedItems().result[0]",simpleif,280 Head First Python,if post_data:,simpleif,282 Head First Python,if resp['which'] in ('positive'):,simpleif,282 Head First Python,if post_data:,simpleif,305 Head First Python,if post_data:,simpleif,306 Head First Python,"if resp is not None: web_server = resp",simpleif,306 Head First Python,"if resp is not None: tap on the Cancel button…",simpleif,306 Head First Python,if resp['which'] in ('positive'):,simpleif,343 Head First Python,if resp['which'] in ('positive'):,simpleif,344 Head First Python,if resp['which'] in ('positive'):,simpleif,345 Head First Python,if resp['which'] in ('negative'):,simpleif,345 Head First Python,if resp is not None:,simpleif,345 Head First Python,if resp['which'] in ('positive'):,simpleif,346 Head First Python,if resp['which'] in ('negative'):,simpleif,346 Head First Python,if resp is not None:,simpleif,346 Head First Python,"if diff == 0: File ""/Users/barryp/HeadFirstPython/chapter11/find_it.py"", line 11, in whats_the_difference",simpleif,417 Head First Python,if your time “problems” have been resolved:,simpleif,420 Head First Python,"if notok: app.dialogSetNegativeButtonText(notok)",simpleif,425 Head First Python,if resp['which'] in ('positive'):,simpleif,427 Head First Python,if resp['which'] in ('positive'):,simpleif,428 Head First Python,if resp['which'] in ('positive'):,simpleif,428 Head First Python,print(),printfunc,4 Head First Python,print(),printfunc,4 Head First Python,print(movies[1]),printfunc,9 Head First Python,print(),printfunc,9 Head First Python,"print() BIF. Then, use the len()",printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(len(cast)),printfunc,10 Head First Python,print(cast[1]),printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(cast),printfunc,10 Head First Python,print(fav_movies[0]),printfunc,15 Head First Python,print(fav_movies[1]),printfunc,15 Head First Python,print(),printfunc,15 Head First Python,print(),printfunc,15 Head First Python,print(),printfunc,15 Head First Python,print(each_flick),printfunc,15 Head First Python,print(movies[count]),printfunc,16 Head First Python,print(each_item),printfunc,16 Head First Python,print(movies[4][1][3]),printfunc,18 Head First Python,print(movies),printfunc,19 Head First Python,print(each_item),printfunc,19 Head First Python,print(each_item),printfunc,21 Head First Python,print(each_item),printfunc,22 Head First Python,print(each_item),printfunc,22 Head First Python,print(nested_item),printfunc,22 Head First Python,print(nested_item),printfunc,22 Head First Python,print(each_item),printfunc,22 Head First Python,print(nested_item),printfunc,23 Head First Python,print(each_item),printfunc,23 Head First Python,print(nested_item),printfunc,24 Head First Python,print(each_item),printfunc,24 Head First Python,print(),printfunc,24 Head First Python,print(each_item),printfunc,24 Head First Python,print(deeper_item),printfunc,24 Head First Python,print(nested_item),printfunc,24 Head First Python,print(each_item),printfunc,25 Head First Python,print(deeper_item),printfunc,25 Head First Python,print(nested_item),printfunc,25 Head First Python,print(deeper_item),printfunc,28 Head First Python,print(deepest_item),printfunc,28 Head First Python,print(nested_item),printfunc,28 Head First Python,print(each_item),printfunc,28 Head First Python,print(each_item),printfunc,30 Head First Python,print(each_item),printfunc,30 Head First Python,print(),printfunc,32 Head First Python,print(each_item),printfunc,35 Head First Python,print(each_item),printfunc,37 Head First Python,print(each_item),printfunc,38 Head First Python,print(num),printfunc,54 Head First Python,print(),printfunc,55 Head First Python,"print()’s default behavior), use this Python code: print(""\t"", end='')",printfunc,55 Head First Python,print(each_item),printfunc,55 Head First Python,print(),printfunc,56 Head First Python,"print()’s default behavior), use this Python code: print(""\t"", end='')",printfunc,56 Head First Python,"print(""\t"", end='')",printfunc,56 Head First Python,print(each_item),printfunc,56 Head First Python,"print(""\t"", end='')",printfunc,58 Head First Python,print(each_item),printfunc,58 Head First Python,"print(""\t"", end='')",printfunc,67 Head First Python,print(each_item),printfunc,67 Head First Python,"print(""\t"", end='')",printfunc,68 Head First Python,print(each_item),printfunc,68 Head First Python,"print(""\t"" * level, end='')",printfunc,68 Head First Python,print(),printfunc,71 Head First Python,print(),printfunc,76 Head First Python,"print(each_line, end='')",printfunc,76 Head First Python,"print(role, end='')",printfunc,78 Head First Python,"print(' said: ', end='')",printfunc,78 Head First Python,"print(line_spoken, end='')",printfunc,78 Head First Python,"print(role, end='')",printfunc,85 Head First Python,"print(' said: ', end='')",printfunc,85 Head First Python,"print(line_spoken, end='')",printfunc,85 Head First Python,"print(role, end='')",printfunc,86 Head First Python,"print(' said: ', end='')",printfunc,86 Head First Python,"print(line_spoken, end='')",printfunc,86 Head First Python,"print(role, end='')",printfunc,91 Head First Python,"print(' said: ', end='')",printfunc,91 Head First Python,"print(line_spoken, end='')",printfunc,91 Head First Python,"print(role, end='')",printfunc,92 Head First Python,"print(' said: ', end='')",printfunc,92 Head First Python,"print(line_spoken, end='')",printfunc,92 Head First Python,print(),printfunc,92 Head First Python,"print(role, end='')",printfunc,97 Head First Python,"print(' said: ', end='')",printfunc,97 Head First Python,"print(line_spoken, end='')",printfunc,97 Head First Python,print('The data file is missing!'),printfunc,97 Head First Python,print() BIF uses standard output (usually the screen),printfunc,110 Head First Python,"print(""Norwegian Blues stun easily."", file=out)",printfunc,110 Head First Python,print(),printfunc,111 Head First Python,print(),printfunc,113 Head First Python,print(),printfunc,113 Head First Python,print('File error.'),printfunc,114 Head First Python,print('Flying Circus'),printfunc,116 Head First Python,print() BIF),printfunc,118 Head First Python,print('File error: ' + err),printfunc,119 Head First Python,print('File error:' + err),printfunc,119 Head First Python,print('File error: ' + str(err)),printfunc,119 Head First Python,"print(""It's..."", file=data)",printfunc,120 Head First Python,print('File error: ' + str(err)),printfunc,120 Head First Python,print('File error: ' + str(err)),printfunc,120 Head First Python,print(‘File error: ' + str(err)),printfunc,122 Head First Python,"print(man, file=man_file)",printfunc,122 Head First Python,"print(other, file=other_file)",printfunc,122 Head First Python,"print(man, file=man_file)",printfunc,122 Head First Python,"print(other, file=other_file)",printfunc,122 Head First Python,print(),printfunc,124 Head First Python,print(),printfunc,124 Head First Python,print(),printfunc,125 Head First Python,print(),printfunc,125 Head First Python,print(),printfunc,126 Head First Python,"print(""\t"", end='', )",printfunc,127 Head First Python,"print(each_item, )",printfunc,127 Head First Python,"print(""\t"", end='', )",printfunc,128 Head First Python,"print(each_item, )",printfunc,128 Head First Python,print(),printfunc,128 Head First Python,"print()” BIF, the code needs to invoke “print_lol()",printfunc,128 Head First Python,print(),printfunc,129 Head First Python,print(a_list),printfunc,133 Head First Python,print('File error: ' + str(err)),printfunc,133 Head First Python,print(‘Pickling error: ‘ + str(perr)),printfunc,134 Head First Python,print('Pickling error: ' + str(perr)),printfunc,134 Head First Python,print(),printfunc,134 Head First Python,"print(""Dead Parrot Sketch"", file='myfavmonty.txt')",printfunc,134 Head First Python,print('File error: ' + str(err)),printfunc,136 Head First Python,print('Pickling error: ' + str(perr)),printfunc,136 Head First Python,print(new_man[0]),printfunc,136 Head First Python,print(new_man[-1]),printfunc,136 Head First Python,print(),printfunc,138 Head First Python,print(james),printfunc,142 Head First Python,print(julie),printfunc,142 Head First Python,print(mikey),printfunc,142 Head First Python,print(sarah),printfunc,142 Head First Python,print(),printfunc,145 Head First Python,print(),printfunc,146 Head First Python,print(sorted(james)),printfunc,146 Head First Python,print(sorted(julie)),printfunc,146 Head First Python,print(sorted(mikey)),printfunc,146 Head First Python,print(sorted(sarah)),printfunc,146 Head First Python,print(),printfunc,151 Head First Python,print( ),printfunc,151 Head First Python,print( ),printfunc,151 Head First Python,print( ),printfunc,151 Head First Python,print( ),printfunc,151 Head First Python,print( ),printfunc,152 Head First Python,print( ),printfunc,152 Head First Python,print( ),printfunc,152 Head First Python,print( ),printfunc,152 Head First Python,print(),printfunc,152 Head First Python,print(unique_james[0:3]),printfunc,162 Head First Python,print(sorted(set([sanitize(t) for t in james]))[0:3]),printfunc,168 Head First Python,print(sorted(set([sanitize(t) for t in julie]))[0:3]),printfunc,168 Head First Python,print(sorted(set([sanitize(t) for t in mikey]))[0:3]),printfunc,168 Head First Python,print(sorted(set([sanitize(t) for t in sarah]))[0:3]),printfunc,168 Head First Python,print(‘File error: ' + str(ioerr)),printfunc,170 Head First Python,print('File error: ' + str(ioerr)),printfunc,175 Head First Python,print('File error: ' + str(ioerr)),printfunc,176 Head First Python,print(),printfunc,176 Head First Python,print('File error: ' + str(ioerr)),printfunc,181 Head First Python,print('File error: ' + str(ioerr)),printfunc,182 Head First Python,print('File error: ' + str(ioerr)),printfunc,184 Head First Python,print(),printfunc,185 Head First Python,print(),printfunc,186 Head First Python,print(‘File error: ‘ + str(ioerr)),printfunc,186 Head First Python,print(),printfunc,186 Head First Python,print(james[‘Name’] + “’s fastest times are: “ + james[‘Times’]),printfunc,186 Head First Python,print(),printfunc,187 Head First Python,print(),printfunc,195 Head First Python,print('File error: ' + str(ioerr)),printfunc,195 Head First Python,"print(james['Name'] + ""'s fastest times are: "" + james['Times'])",printfunc,195 Head First Python,print(),printfunc,196 Head First Python,print('File error: ' + str(ioerr)),printfunc,196 Head First Python,"print(james['Name'] + ""'s fastest times are: "" + james['Times'])",printfunc,196 Head First Python,print(),printfunc,198 Head First Python,print(vera.top3()),printfunc,200 Head First Python,print(vera.top3()),printfunc,200 Head First Python,"print(johnny.name + "" is a "" + attr + ""."")",printfunc,206 Head First Python,print(vera.top3()),printfunc,208 Head First Python,print(vera.top3()),printfunc,208 Head First Python,print(data[each_athlete].name + ' ' + data[each_athlete].dob),printfunc,225 Head First Python,print(data_copy[each_athlete].name + ' ' + data_copy[each_athlete].dob),printfunc,225 Head First Python,print(),printfunc,232 Head First Python,print(),printfunc,232 Head First Python,"print(""Starting simple_httpd on port: "" + str(httpd.server_port))",printfunc,235 Head First Python,"print(yate.include_footer({""Home"": ""/index.html""}))",printfunc,237 Head First Python,"print(yate.start_form(""generate_timing_data.py""))",printfunc,237 Head First Python,"print(yate.para(""Select an athlete from the list to work with:""))",printfunc,237 Head First Python,"print(yate.include_header(""Coach Kelly's List of Athletes""))",printfunc,237 Head First Python,"print(yate.radio_button(""which_athlete"", athletes[each_athlete].name))",printfunc,237 Head First Python,print(yate.start_response()),printfunc,237 Head First Python,"print(yate.end_form(""Select""))",printfunc,237 Head First Python,print(yate.start_response()),printfunc,238 Head First Python,"print(yate.include_header(""Coach Kelly's List of Athletes""))",printfunc,238 Head First Python,"print(yate.start_form(""generate_timing_data.py""))",printfunc,238 Head First Python,"print(yate.para(""Select an athlete from the list to work with:""))",printfunc,238 Head First Python,"print(yate.radio_button(""which_athlete"", athletes[each_athlete].name))",printfunc,238 Head First Python,"print(yate.end_form(""Select""))",printfunc,238 Head First Python,"print(yate.include_footer({""Home"": ""/index.html""}))",printfunc,238 Head First Python,print(yate.start_response()),printfunc,246 Head First Python,"print(yate.include_header(""Coach Kelly's Timing Data""))",printfunc,246 Head First Python,"print(yate.para(""The top times for this athlete are:""))",printfunc,246 Head First Python,print(yate.u_list(athletes[athlete_name].top3())),printfunc,246 Head First Python,print(yate.u_list(athletes[athlete_name].top3())),printfunc,247 Head First Python,print(yate.u_list(athletes[athlete_name].top3())),printfunc,250 Head First Python,print(yate.u_list(athletes[athlete_name].top3)),printfunc,250 Head First Python,print(yate.start_response('application/json')),printfunc,272 Head First Python,print(json.dumps(sorted(names))),printfunc,272 Head First Python,print(yate.start_response('application/json')),printfunc,281 Head First Python,print(json.dumps(athletes[athlete_name])),printfunc,281 Head First Python,"print(json.dumps(athletes[athlete_name]), file=sys.stderr)",printfunc,284 Head First Python,print(),printfunc,284 Head First Python,print(yate.start_response('text/html')),printfunc,299 Head First Python,"print(yate.do_form('add_timing_data.py', ['TimeValue'], text='Send'))",printfunc,299 Head First Python,"print(host + "", "" + addr + "", "" + cur_time + "": "" + method, file=sys.stderr)",printfunc,300 Head First Python,print(yate.start_response('text/plain')),printfunc,301 Head First Python,print('OK.'),printfunc,301 Head First Python,print(file=sys.stderr),printfunc,301 Head First Python,print(yate.start_response('text/plain')),printfunc,302 Head First Python,print(),printfunc,302 Head First Python,print(file=sys.stderr),printfunc,302 Head First Python,print('OK.'),printfunc,302 Head First Python,print('File error (get_from_store): ' + str(ioerr)),printfunc,329 Head First Python,print('File error (get_from_store): ' + str(ioerr)),printfunc,331 Head First Python,print(yate.start_response()),printfunc,337 Head First Python,"print(yate.include_header(""NUAC's List of Athletes""))",printfunc,337 Head First Python,"print(yate.start_form(""generate_timing_data.py""))",printfunc,337 Head First Python,"print(yate.para(""Select an athlete from the list to work with:""))",printfunc,337 Head First Python,"print(yate.radio_button(""which_athlete"", athletes[each_athlete].name))",printfunc,337 Head First Python,"print(yate.end_form(""Select""))",printfunc,337 Head First Python,"print(yate.include_footer({""Home"": ""/index.html""}))",printfunc,337 Head First Python,print(yate.start_response()),printfunc,337 Head First Python,"print(yate.include_header(""NUAC's Timing Data""))",printfunc,337 Head First Python,"print(yate.header(""Athlete: "" + athlete_name + "", DOB: "" + athletes[athlete_name].dob + "".""))",printfunc,337 Head First Python,"print(yate.para(""The top times for this athlete are:""))",printfunc,337 Head First Python,print(yate.u_list(athletes[athlete_name].top3)),printfunc,337 Head First Python,"print(yate.para(""The entire set of timing data is: "" + str(athletes[athlete_name].clean_data)",printfunc,337 Head First Python,"print(yate.include_footer({""Home"": ""/index.html"", ""Select another athlete"": ""generate_list.py""}))",printfunc,337 Head First Python,print(yate.start_response('application/json')),printfunc,338 Head First Python,print(json.dumps(sorted(names))),printfunc,338 Head First Python,print(yate.start_response('application/json')),printfunc,338 Head First Python,print(json.dumps(athletes[athlete_name].as_dict)),printfunc,338 Head First Python,print(yate.start_response()),printfunc,339 Head First Python,"print(yate.include_header(""NUAC's List of Athletes""))",printfunc,339 Head First Python,"print(yate.start_form(""generate_timing_data.py""))",printfunc,339 Head First Python,"print(yate.para(""Select an athlete from the list to work with:""))",printfunc,339 Head First Python,"print(yate.radio_button(""which_athlete"", athletes[each_athlete].name))",printfunc,339 Head First Python,"print(yate.end_form(""Select""))",printfunc,339 Head First Python,"print(yate.include_footer({""Home"": ""/index.html""}))",printfunc,339 Head First Python,print(yate.start_response()),printfunc,339 Head First Python,"print(yate.include_header(""NUAC's Timing Data""))",printfunc,339 Head First Python,"print(yate.header(""Athlete: "" + athlete_name + "", DOB: "" + athletes[athlete_name].dob + "".""))",printfunc,339 Head First Python,"print(yate.para(""The top times for this athlete are:""))",printfunc,339 Head First Python,print(yate.u_list(athletes[athlete_name].top3)),printfunc,339 Head First Python,"print(yate.para(""The entire set of timing data is: "" + str(athletes[athlete_name].clean_data)",printfunc,339 Head First Python,"print(yate.include_footer({""Home"": ""/index.html"", ""Select another athlete"": ""generate_list.py""}))",printfunc,339 Head First Python,print(yate.start_response(‘application/json’)),printfunc,340 Head First Python,print(json.dumps(sorted(names))),printfunc,340 Head First Python,print(yate.start_response(‘application/json’)),printfunc,340 Head First Python,print(json.dumps(athletes[athlete_name].as_dict)),printfunc,340 Head First Python,print('Content-type: text/plain\n'),printfunc,356 Head First Python,print('Hello from Head First Python on GAE!'),printfunc,356 Head First Python,"print(num_cols, end=' -> ')",printfunc,403 Head First Python,print(column_headings),printfunc,403 Head First Python,"print(num_2mi, end=' -> ')",printfunc,403 Head First Python,print(row_data['2mi']),printfunc,403 Head First Python,"print(num_Marathon, end=' -> ')",printfunc,403 Head First Python,print(row_data['Marathon']),printfunc,403 Head First Python,"print(num_cols, end=' -> ')",printfunc,404 Head First Python,print(column_headings),printfunc,404 Head First Python,"print(num_2mi, end=' -> ')",printfunc,404 Head First Python,print(row_data['2mi']),printfunc,404 Head First Python,"print(num_Marathon, end=' -> ')",printfunc,404 Head First Python,print(row_data['Marathon']),printfunc,404 Head First Python,print(),printfunc,408 Head First Python,print(),printfunc,454 Head First Python,"movies = [""The Holy Grail"", ""The Life of Brian"", ""The Meaning of Life""]",simpleList,7 Head First Python,"movies = [""The Holy Grail"", ""The Life of Brian"", ""The Meaning of Life""]",simpleList,9 Head First Python,"cast = [""Cleese"", 'Palin', 'Jones', ""Idle""]",simpleList,10 Head First Python,"movies = [""The Holy Grail"", ""The Life of Brian"", ""The Meaning of Life""]",simpleList,13 Head First Python,"movies = [""The Holy Grail"", ""The Life of Brian"", ""The Meaning of Life""]",simpleList,14 Head First Python,"fav_movies = [""The Holy Grail"", ""The Life of Brian""]",simpleList,15 Head First Python,"fav_movies = [""The Holy Grail"", ""The Life of Brian""]",simpleList,15 Head First Python,"names = ['Michael', 'Terry']",simpleList,20 Head First Python,py_modules = ['nester'],simpleList,40 Head First Python,"cast = ['Palin’, 'Cleese’, 'Idle’, 'Jones’, 'Gilliam’, 'Chapman’]",simpleList,44 Head First Python,"cast = ['Palin', 'Cleese', 'Idle', 'Jones', 'Gilliam', 'Chapman']",simpleList,46 Head First Python,py_modules = ['nester'],simpleList,60 Head First Python,py_modules = ['nester'],simpleList,65 Head First Python,man = [],simpleList,108 Head First Python,other = [],simpleList,108 Head First Python,man = [],simpleList,111 Head First Python,other = [],simpleList,111 Head First Python,man = [],simpleList,112 Head First Python,other = [],simpleList,112 Head First Python,new_man = [],simpleList,136 Head First Python,"data = [6, 3, 1, 2, 4, 5]",simpleList,145 Head First Python,"data = [6, 3, 1, 2, 4, 5]",simpleList,145 Head First Python,clean_james = [],simpleList,152 Head First Python,clean_julie = [],simpleList,152 Head First Python,clean_mikey = [],simpleList,152 Head First Python,clean_sarah = [],simpleList,152 Head First Python,clean_mikey = [],simpleList,155 Head First Python,"mins = [1, 2, 3]",simpleList,156 Head First Python,"meters = [1, 10, 3]",simpleList,156 Head First Python,"lower = [""I"", ""don't"", ""like"", ""spam""]",simpleList,156 Head First Python,"dirty = ['2-22', '2:22', '2.22']",simpleList,156 Head First Python,unique_james = [],simpleList,162 Head First Python,new_l = [],simpleList,172 Head First Python,"cleese['Occupations'] = ['actor', 'comedian', 'writer', 'film producer']",simpleList,180 Head First Python,"the_files = ['sarah.txt', 'james.txt', 'mikey.txt', 'julie.txt']",simpleList,225 Head First Python,"_FINS = ['Falcate', 'Triangular', 'Rounded']",simpleList,376 Head First Python,"_WHALES = ['Humpback', 'Orca', 'Blue', 'Killer', 'Beluga', 'Fin', 'Gray', 'Sperm']",simpleList,376 Head First Python,"_BLOWS = ['Tall', 'Bushy', 'Dense']",simpleList,376 Head First Python,"_WAVES = ['Flat', 'Small', 'Moderate', 'Large', 'Breaking', 'High']",simpleList,376 Head First Python,exclude = ['which_user'],simpleList,390 Head First Python,times = [],simpleList,412 Head First Python,headings = [],simpleList,412 Head First Python,for each_flick in fav_movies:,forsimple,15 Head First Python,for each_item in movies:,forsimple,16 Head First Python,for each_item in movies:,forsimple,19 Head First Python,for each_item in movies:,forsimple,21 Head First Python,for each_item in movies:,forsimple,22 Head First Python,for each_item in movies:,forsimple,22 Head First Python,for nested_item in each_item:,forsimple,22 Head First Python,for each_item in movies:,forsimple,22 Head First Python,for each_item in movies:,forsimple,23 Head First Python,for nested_item in each_item:,forsimple,23 Head First Python,for each_item in movies:,forsimple,24 Head First Python,for nested_item in each_item:,forsimple,24 Head First Python,for each_item in movies:,forsimple,24 Head First Python,for nested_item in each_item:,forsimple,24 Head First Python,for deeper_item in nested_item:,forsimple,24 Head First Python,for each_item in movies:,forsimple,25 Head First Python,for each_item in movies:,forsimple,28 Head First Python,for nested_item in each_item:,forsimple,28 Head First Python,for deeper_item in nested_item:,forsimple,28 Head First Python,for deepest_item in deeper_item:,forsimple,28 Head First Python,for each_item in the_list:,forsimple,30 Head First Python,for each_item in the_list:,forsimple,35 Head First Python,for each_item in the_list:,forsimple,37 Head First Python,for each_item in the_list:,forsimple,38 Head First Python,for num in range(4):,forsimple,54 Head First Python,for each_item in the_list:,forsimple,55 Head First Python,for each_item in the_list:,forsimple,56 Head First Python,for tab_stop in range(level):,forsimple,56 Head First Python,for each_item in the_list:,forsimple,58 Head First Python,for tab_stop in range(level):,forsimple,58 Head First Python,for the second argument and note the change in the function’s behavior:,forsimple,64 Head First Python,for each_item in the_list:,forsimple,67 Head First Python,for tab_stop in range(level):,forsimple,67 Head First Python,for each_item in the_list:,forsimple,68 Head First Python,for tab_stop in range(level):,forsimple,68 Head First Python,for statement to process every line in the file:,forsimple,76 Head First Python,for each_line in data:,forsimple,76 Head First Python,for each_line in data:,forsimple,78 Head First Python,for each_line in data:,forsimple,85 Head First Python,for each_line in data:,forsimple,86 Head First Python,for each_line in data:,forsimple,91 Head First Python,for each_line in data:,forsimple,92 Head First Python,for each_line in data:,forsimple,97 Head First Python,for a single “:” character in the line. If the “:,forsimple,100 Head First Python,for each_item in the_list:,forsimple,127 Head First Python,for tab_stop in range(level):,forsimple,127 Head First Python,for each_item in the_list:,forsimple,128 Head First Python,for tab_stop in range(level):,forsimple,128 Head First Python,for each_t in james:,forsimple,152 Head First Python,for each_t in julie:,forsimple,152 Head First Python,for each_t in mikey:,forsimple,152 Head First Python,for each_t in sarah:,forsimple,152 Head First Python,for each_t in mikey:,forsimple,155 Head First Python,for each_t in james:,forsimple,162 Head First Python,for t in old_l:,forsimple,172 Head First Python,for t in sarah]))[0:,forsimple,175 Head First Python,for t in sarah]))[0:,forsimple,176 Head First Python,for t in sarah]))[0:,forsimple,181 Head First Python,for t in sarah]))[0:,forsimple,182 Head First Python,for t in sarah_data[‘Times’]]))[0:,forsimple,182 Head First Python,for t in sarah_data['Times']]))[0:,forsimple,184 Head First Python,for t in self.times]))[0:,forsimple,196 Head First Python,for t in self.times]))[0:,forsimple,199 Head First Python,for t in self.times]))[0:,forsimple,200 Head First Python,for attr in johnny:,forsimple,206 Head First Python,for t in self.times]))[0:,forsimple,207 Head First Python,for t in self.times]))[0:,forsimple,208 Head First Python,for t in self]))[0:,forsimple,208 Head First Python,for each_file in files_list:,forsimple,224 Head First Python,for each_athlete in data:,forsimple,225 Head First Python,for each_athlete in data_copy:,forsimple,225 Head First Python,for key in the_links:,forsimple,227 Head First Python,for item in items:,forsimple,227 Head First Python,for key in the_links:,forsimple,228 Head First Python,for item in items:,forsimple,229 Head First Python,for key in the_links:,forsimple,230 Head First Python,for item in items:,forsimple,231 Head First Python,for each_athlete in athletes:,forsimple,237 Head First Python,for each_athlete in athletes:,forsimple,238 Head First Python,for t in self]))[0:,forsimple,250 Head First Python,for each_input in inputs_list:,forsimple,298 Head First Python,for each_form_item in form.keys():,forsimple,301 Head First Python,for each_form_item in form.keys():,forsimple,302 Head First Python,for each_ath in athletes:,forsimple,321 Head First Python,for each_time in athletes[each_ath].clean_data:,forsimple,324 Head First Python,for each_athlete in sorted(athletes):,forsimple,337 Head First Python,for each_athlete in sorted(athletes):,forsimple,339 Head First Python,"for variable substitution in the template, Django uses the {{name}} syntax:",forsimple,363 Head First Python,for field in self.request.arguments():,forsimple,379 Head First Python,for each_line in paces:,forsimple,403 Head First Python,for each_line in paces:,forsimple,404 Head First Python,for each_line in paces:,forsimple,407 Head First Python,for i in range(len(column_headings)):,forsimple,407 Head First Python,for each_t in row_data[‘Marathon’].keys():,forsimple,412 Head First Python,"for each_h in sorted(row_data[‘10mi’].values(), reverse=True):",forsimple,412 Head First Python,for the following terms in your favorite search engine:,forsimple,441 Head First Python,count = count+1,assignwithSum,16 Head First Python,"return('<p></p><input type=submit value=""' + submit_msg + '"">')",assignwithSum,227 Head First Python,"return('<p></p><input type=submit value=""' + submit_msg + '""></form>')",assignwithSum,229 Head First Python,"return('<p></p><input type=submit value=""' + submit_msg + '""></form>')",assignwithSum,231 Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,275 Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,276 Head First Python,"athlete = json.loads(send_to_server(web_server + get_data_cgi,",assignwithSum,280 Head First Python,athlete_title = which_athlete + ' top 3 times:',assignwithSum,280 Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,282 Head First Python,"athlete = json.loads(send_to_server(web_server + get_data_cgi,",assignwithSum,282 Head First Python,"athlete_title = athlete['Name'] + ' (' + athlete['DOB'] + '), top 3 times:'",assignwithSum,282 Head First Python,"athlete = json.loads(send_to_server(web_server + get_data_cgi, {'which_athlete': which_athlete}))",assignwithSum,295 Head First Python,"html_inputs = html_inputs + ‘<input type= “Text"" name=""' + \",assignwithSum,298 Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,343 Head First Python,"athlete = json.loads(send_to_server(web_server + get_data_cgi,{'which_athlete': which_athlete}))",assignwithSum,343 Head First Python,"athlete_title = athlete['Name'] + ' (' + athlete['DOB'] + '), top 3 times:'",assignwithSum,343 Head First Python,athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi))),assignwithSum,344 Head First Python,"athlete = json.loads(send_to_server(web_server + get_data_cgi,{'which_athlete': which_athlete}))",assignwithSum,344 Head First Python,"athlete_title = athlete['Name'] + ' (' + athlete['DOB'] + '), top 3 times:'",assignwithSum,344 Head First Python,html = html +,assignwithSum,365 Head First Python,"html = html + template.render('templates/form_start.html’, {})",assignwithSum,366 Head First Python,"html = html + template.render(‘templates/form_end.html’, {‘sub_title’: ‘Submit Sighting’})",assignwithSum,366 Head First Python,"html = html + template.render(‘templates/footer.html’, {‘links’: ''})",assignwithSum,366 Head First Python,"html = html + template.render('templates/form_start.html', {})",assignwithSum,368 Head First Python,html = html + str(BirthDetailsForm(auto_id=False)),assignwithSum,368 Head First Python,"html = html + template.render('templates/form_end.html', {'sub_title': 'Submit Details'})",assignwithSum,368 Head First Python,"html = html + template.render('templates/footer.html', {'links': ''})",assignwithSum,368 Head First Python,"html = html + template.render('templates/form_start.html', {})",assignwithSum,371 Head First Python,"html = html + template.render('templates/form_end.html’, {'sub_title': 'Submit Sighting'})",assignwithSum,371 Head First Python,"html = html + template.render('templates/footer.html', {'links': ''})",assignwithSum,371 Head First Python,html = html + str(SightingForm()),assignwithSum,371 Head First Python,"html = html + template.render('templates/form_start.html', {})",assignwithSum,372 Head First Python,html = html + str(SightingForm()),assignwithSum,372 Head First Python,"html = html + template.render('templates/form_end.html’, {'sub_title': 'Submit Sighting'})",assignwithSum,372 Head First Python,"html = html + template.render('templates/footer.html', {'links': ''})",assignwithSum,372 Head First Python,"html = html + ""<p>Thank you for providing your birth details.</p>""",assignwithSum,380 Head First Python,"html = html + template.render('templates/footer.html',",assignwithSum,380 Head First Python,"html = html + ""<p>Thank you for providing your sighting data.</p>""",assignwithSum,381 Head First Python,"html = html + template.render('templates/footer.html',",assignwithSum,381 Head First Python,"html = html + ""<p>Thank you for providing your sighting data.</p>""",assignwithSum,382 Head First Python,"html = html + template.render('templates/footer.html',",assignwithSum,382 Head First Python,"displays the input dialog box. = app.dialogGetInput(""Enter a "" + distance_run + "" time:"",",assignwithSum,427 Head First Python,"recorded_time = app.dialogGetInput(""Enter a "" + distance_run + "" time:"",",assignwithSum,428 Head First Python,count = 0,simpleAssign,16 Head First Python,num_names = len(names),simpleAssign,20 Head First Python,indent=False,simpleAssign,68 Head First Python,"role, line_spoken) = each_line.split("":"")",simpleAssign,77 Head First Python,"role, line_spoken) = each_line.split(':')",simpleAssign,78 Head First Python,"role, line_spoken) = each_line.split(':')",simpleAssign,78 Head First Python,"role, line_spoken) = each_line.split(':', 1)",simpleAssign,81 Head First Python,"role, line_spoken) = each_line.split(':', 1)",simpleAssign,85 Head First Python,"role, line_spoken) = each_line.split(':', 1)",simpleAssign,86 Head First Python,"role, line_spoken) = each_line.split(':', 1)",simpleAssign,91 Head First Python,"role, line_spoken) = each_line.split(':', 1)",simpleAssign,92 Head First Python,fh=sys.stdout,simpleAssign,128 Head First Python,file=fh,simpleAssign,128 Head First Python,file=fh,simpleAssign,128 Head First Python,"print_lol(man, fh=man_file).",simpleAssign,129 Head First Python,a_list = pickle.load(myrestoredata),simpleAssign,133 Head First Python,"A: Consider print(), which has this signature: print(value, sep=' ', end='\n', file=sys.stdout). By",simpleAssign,134 Head First Python,new_man = pickle.load(man_file),simpleAssign,136 Head First Python,"james = data.strip().split(‘,’)",simpleAssign,142 Head First Python,"julie = data.strip().split(‘,’)",simpleAssign,142 Head First Python,"mikey = data.strip().split(‘,’)",simpleAssign,142 Head First Python,"sarah = data.strip().split(‘,’)",simpleAssign,142 Head First Python,data2 = sorted(data),simpleAssign,145 Head First Python,"mins, secs) = you are here 4",simpleAssign,149 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,150 Head First Python,"james = data.strip().split(',')",simpleAssign,151 Head First Python,"julie = data.strip().split(',')",simpleAssign,151 Head First Python,"mikey = data.strip().split(',')",simpleAssign,151 Head First Python,"sarah = data.strip().split(',')",simpleAssign,151 Head First Python,"james = data.strip().split(',')",simpleAssign,152 Head First Python,"julie = data.strip().split(',')",simpleAssign,152 Head First Python,"mikey = data.strip().split(',')",simpleAssign,152 Head First Python,"sarah = data.strip().split(',')",simpleAssign,152 Head First Python,"descending order, pass the reverse=True argument to",simpleAssign,153 Head First Python,james = sorted([sanitize(t) for t in james]),simpleAssign,161 Head First Python,james = sorted([sanitize(t) for t in james]),simpleAssign,162 Head First Python,distances = set(),simpleAssign,166 Head First Python,distances = set(james),simpleAssign,166 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,168 Head First Python,"james = data.strip().split(',')",simpleAssign,168 Head First Python,"julie = data.strip().split(',')",simpleAssign,168 Head First Python,"mikey = data.strip().split(',')",simpleAssign,168 Head First Python,"sarah = data.strip().split(',')",simpleAssign,168 Head First Python,"james = data.strip().split(',')",simpleAssign,169 Head First Python,"julie = data.strip().split(',')",simpleAssign,169 Head First Python,"mikey = data.strip().split(',')",simpleAssign,169 Head First Python,"sarah = data.strip().split(',')",simpleAssign,169 Head First Python,"james = data.strip().split(',')",simpleAssign,170 Head First Python,"julie = data.strip().split(',')",simpleAssign,170 Head First Python,"mikey = data.strip().split(',')",simpleAssign,170 Head First Python,"sarah = data.strip().split(',')",simpleAssign,170 Head First Python,sarah = get_coach_data(‘sarah.txt'),simpleAssign,170 Head First Python,Pass reverse=True to either,simpleAssign,172 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,175 Head First Python,"print(sarah_name + = get_coach_data('sarah2.txt')",simpleAssign,175 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,176 Head First Python,"sarah = get_coach_data('sarah2.txt')",simpleAssign,176 Head First Python,"sarah_name, sarah_dob) = sarah.pop(0), sarah.pop(0)",simpleAssign,176 Head First Python,palin = dict(),simpleAssign,180 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,181 Head First Python,sarah = get_coach_data('sarah2.txt'),simpleAssign,181 Head First Python,"sarah_name, sarah_dob) = sarah.pop(0), sarah.pop(0)",simpleAssign,181 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,182 Head First Python,sarah = get_coach_data('sarah2.txt'),simpleAssign,182 Head First Python,"sarah_name, sarah_dob) = sarah.pop(0), sarah.pop(0)",simpleAssign,182 Head First Python,sarah_data[‘Name’] = sarah.pop(0),simpleAssign,182 Head First Python,sarah_data[‘DOB’] = sarah.pop(0),simpleAssign,182 Head First Python,sarah_data[‘Times’] = sarah,simpleAssign,182 Head First Python,"mins, secs) = time_string.split(splitter)",simpleAssign,184 Head First Python,sarah = get_coach_data('sarah2.txt'),simpleAssign,184 Head First Python,sarah_data['Name'] = sarah.pop(0),simpleAssign,184 Head First Python,sarah_data['DOB'] = sarah.pop(0),simpleAssign,184 Head First Python,sarah_data['Times'] = sarah,simpleAssign,184 Head First Python,james = get_coach_data(‘james2.txt’),simpleAssign,186 Head First Python,a = Athlete(),simpleAssign,191 Head First Python,b = Athlete(),simpleAssign,191 Head First Python,c = Athlete(),simpleAssign,191 Head First Python,d = Athlete(),simpleAssign,191 Head First Python,a = Athlete(),simpleAssign,192 Head First Python,"d = Athlete(""Holy Grail"")",simpleAssign,193 Head First Python,"sarah = Athlete('Sarah Sweeney', '2002-6-17', ['2:58', '2.58', '1.56'])",simpleAssign,194 Head First Python,james = Athlete('James Jones'),simpleAssign,194 Head First Python,james = get_coach_data('james2.txt'),simpleAssign,195 Head First Python,james = get_coach_data('james2.txt'),simpleAssign,196 Head First Python,"Yes, that’s correct: more functionality = more methods.",simpleAssign,197 Head First Python,vera = Athlete(‘Vera Vi’),simpleAssign,200 Head First Python,"johnny = NamedList(""John Paul Jones"")",simpleAssign,206 Head First Python,vera = AthleteList(‘Vera Vi’),simpleAssign,208 Head First Python,new_d = {} or new_d = dict(),simpleAssign,212 Head First Python,ath = get_coach_data(each_file),simpleAssign,224 Head First Python,all_athletes[ath.name] = ath,simpleAssign,224 Head First Python,data = put_to_store(the_files),simpleAssign,225 Head First Python,data_copy = get_from_store(),simpleAssign,225 Head First Python,header = Template(head_text),simpleAssign,227 Head First Python,return(header.substitute(title=the_title)),simpleAssign,227 Head First Python,footer = Template(foot_text),simpleAssign,227 Head First Python,return(footer.substitute(links=link_string)),simpleAssign,227 Head First Python,header = Template(head_text),simpleAssign,228 Head First Python,return(header.substitute(title=the_title)),simpleAssign,228 Head First Python,footer = Template(foot_text),simpleAssign,228 Head First Python,return(footer.substitute(links=link_string)),simpleAssign,228 Head First Python,header = Template(head_text),simpleAssign,230 Head First Python,return(header.substitute(title=the_title)),simpleAssign,230 Head First Python,footer = Template(foot_text),simpleAssign,230 Head First Python,return(footer.substitute(links=link_string)),simpleAssign,230 Head First Python,"p></p><input type=submit value=""Submit""></form>'",simpleAssign,233 Head First Python,"p></p><input type=submit value=""Click to Confirm Your Order""></form>'",simpleAssign,233 Head First Python,port = 8080,simpleAssign,235 Head First Python,"httpd = HTTPServer(('', port), CGIHTTPRequestHandler)",simpleAssign,235 Head First Python,"data_files = glob.glob(""data/*.txt"")",simpleAssign,237 Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,237 Head First Python,"data_files = glob.glob(""data/*.txt"")",simpleAssign,238 Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,238 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,244 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,244 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,246 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,246 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,246 Head First Python,app = android.Android(),simpleAssign,264 Head First Python,to_transfer = json.dumps(names),simpleAssign,269 Head First Python,from_transfer = json.loads(to_transfer),simpleAssign,269 Head First Python,athletes = get_from_store(),simpleAssign,270 Head First Python,names = athletemodel.get_names_from_store(),simpleAssign,272 Head First Python,app = android.Android(),simpleAssign,274 Head First Python,app = android.Android(),simpleAssign,274 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,274 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,275 Head First Python,app = android.Android(),simpleAssign,275 Head First Python,app = android.Android(),simpleAssign,276 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,276 Head First Python,which_athlete = athlete_names[selected_athlete],simpleAssign,280 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,280 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,281 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,281 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,281 Head First Python,app = android.Android(),simpleAssign,282 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,282 Head First Python,selected_athlete = app.dialogGetSelectedItems().result[0],simpleAssign,282 Head First Python,which_athlete = athlete_names[selected_athlete],simpleAssign,282 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,282 Head First Python,"input type=""Text"" name=""TimeValue"" size=40>",simpleAssign,296 Head First Python,form = cgi.FieldStorage(),simpleAssign,296 Head First Python,"timing_value = form[""TimeValue""].value",simpleAssign,296 Head First Python,"return(form.substitute(cgi_name=name, http_method=method,",simpleAssign,297 Head First Python,"list_of_inputs=inputs, submit_text=text))",simpleAssign,297 Head First Python,"each_input + '"" size=40>'",simpleAssign,298 Head First Python,inputs = create_inputs(the_inputs),simpleAssign,298 Head First Python,form = Template(form_text),simpleAssign,298 Head First Python,"return(form.substitute(cgi_name=name, http_method=method,",simpleAssign,298 Head First Python,"list_of_inputs=inputs, submit_text=text))",simpleAssign,298 Head First Python,form = cgi.FieldStorage(),simpleAssign,300 Head First Python,addr = os.environ['REMOTE_ADDR'],simpleAssign,300 Head First Python,host = os.environ['REMOTE_HOST'],simpleAssign,300 Head First Python,method = os.environ['REQUEST_METHOD'],simpleAssign,300 Head First Python,cur_time = time.asctime(time.localtime()),simpleAssign,300 Head First Python,addr = os.environ['REMOTE_ADDR'],simpleAssign,301 Head First Python,host = os.environ['REMOTE_HOST'],simpleAssign,301 Head First Python,method = os.environ['REQUEST_METHOD'],simpleAssign,301 Head First Python,cur_time = time.asctime(time.localtime()),simpleAssign,301 Head First Python,"end='', file=sys.stderr)",simpleAssign,301 Head First Python,form = cgi.FieldStorage(),simpleAssign,301 Head First Python,file=sys.stderr),simpleAssign,301 Head First Python,addr = os.environ['REMOTE_ADDR'],simpleAssign,302 Head First Python,host = os.environ['REMOTE_HOST'],simpleAssign,302 Head First Python,method = os.environ['REQUEST_METHOD'],simpleAssign,302 Head First Python,cur_time = time.asctime(time.localtime()),simpleAssign,302 Head First Python,"end='', file=sys.stderr)",simpleAssign,302 Head First Python,form = cgi.FieldStorage(),simpleAssign,302 Head First Python,file=sys.stderr),simpleAssign,302 Head First Python,"resp = app.dialogGetInput(title, message, data).result",simpleAssign,304 Head First Python,app = android.Android(),simpleAssign,305 Head First Python,app = android.Android(),simpleAssign,306 Head First Python,"resp = app.dialogGetInput(server_title, server_msg, web_server).result",simpleAssign,306 Head First Python,"resp = app.dialogGetInput(timing_title, timing_msg).result",simpleAssign,306 Head First Python,new_time = resp,simpleAssign,306 Head First Python,connection = sqlite3.connect('test.sqlite'),simpleAssign,315 Head First Python,cursor = connection.cursor(),simpleAssign,315 Head First Python,connection = sqlite3.connect('coachdata.sqlite'),simpleAssign,319 Head First Python,cursor = connection.cursor(),simpleAssign,319 Head First Python,connection = sqlite3.connect('coachdata.sqlite'),simpleAssign,320 Head First Python,cursor = connection.cursor(),simpleAssign,320 Head First Python,connection = sqlite3.connect('coachdata.sqlite'),simpleAssign,321 Head First Python,cursor = connection.cursor(),simpleAssign,321 Head First Python,"data_files = glob.glob(""../data/*.txt"")",simpleAssign,321 Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,321 Head First Python,name = athletes[each_ath].name,simpleAssign,321 Head First Python,dob = athletes[each_ath].dob,simpleAssign,321 Head First Python,the_current_id = cursor.fetchone()[0],simpleAssign,324 Head First Python,athletes = get_from_store(),simpleAssign,329 Head First Python,athletes = get_from_store(),simpleAssign,331 Head First Python,connection = sqlite3.connect(db_name),simpleAssign,332 Head First Python,cursor = connection.cursor(),simpleAssign,332 Head First Python,"results = cursor.execute(""""""SELECT name FROM athletes"""""")",simpleAssign,332 Head First Python,connection = sqlite3.connect(db_name),simpleAssign,333 Head First Python,cursor = connection.cursor(),simpleAssign,333 Head First Python,"results = cursor.execute(""""""SELECT name, dob FROM athletes WHERE id=?"""""",",simpleAssign,333 Head First Python,"name, dob) = results.fetchone()",simpleAssign,333 Head First Python,"results = cursor.execute(""""""SELECT value FROM timing_data WHERE athlete_id=?"""""",",simpleAssign,333 Head First Python,connection = sqlite3.connect(db_name),simpleAssign,335 Head First Python,cursor = connection.cursor(),simpleAssign,335 Head First Python,"results = cursor.execute(""""""SELECT name FROM athletes"""""")",simpleAssign,335 Head First Python,connection = sqlite3.connect(db_name),simpleAssign,336 Head First Python,cursor = connection.cursor(),simpleAssign,336 Head First Python,"results = cursor.execute(""""""SELECT name FROM athletes"""""")",simpleAssign,336 Head First Python,connection = sqlite3.connect(db_name),simpleAssign,336 Head First Python,cursor = connection.cursor(),simpleAssign,336 Head First Python,"results = cursor.execute(“““SELECT name, id FROM athletes"""""")",simpleAssign,336 Head First Python,response = results.fetchall(),simpleAssign,336 Head First Python,"data_files = glob.glob(""data/*.txt"")",simpleAssign,337 Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,337 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,337 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,337 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,337 Head First Python,names = athletemodel.get_names_from_store(),simpleAssign,338 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,338 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,338 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,338 Head First Python,"data_files = glob.glob(""data/*.txt"")",simpleAssign,339 Head First Python,athletes = athletemodel.put_to_store(data_files),simpleAssign,339 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,339 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,339 Head First Python,athlete_name = form_data['which_athlete'].value,simpleAssign,339 Head First Python,athlete = athletemodel.get_athlete_from_id(athlete_id),simpleAssign,339 Head First Python,names = athletemodel.get_names_from_store(),simpleAssign,340 Head First Python,athletes = athletemodel.get_from_store(),simpleAssign,340 Head First Python,form_data = cgi.FieldStorage(),simpleAssign,340 Head First Python,athlete_name = form_data[‘which_athlete’].value,simpleAssign,340 Head First Python,athlete = athletemodel.get_athlete_from_id(athlete_id),simpleAssign,340 Head First Python,app = android.Android(),simpleAssign,343 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,343 Head First Python,selected_athlete = app.dialogGetSelectedItems().result[0],simpleAssign,343 Head First Python,which_athlete = athlete_names[selected_athlete],simpleAssign,343 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,343 Head First Python,app = android.Android(),simpleAssign,344 Head First Python,"athletes = Extract the athlete",simpleAssign,344 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,344 Head First Python,selected_athlete = app.dialogGetSelectedItems().result[0],simpleAssign,344 Head First Python,which_athlete = athlete_names[selected_athlete],simpleAssign,344 Head First Python,resp = app.dialogGetResponse().result,simpleAssign,344 Head First Python,new_time = resp,simpleAssign,345 Head First Python,"add_time_cgi = resp = app.dialogGetInput(timing_title, timing_msg).result",simpleAssign,345 Head First Python,"timing_msg = timing_title = 'Enter a new time'",simpleAssign,345 Head First Python,"resp = app.dialogGetInput(timing_title, timing_msg).result",simpleAssign,346 Head First Python,new_time = resp,simpleAssign,346 Head First Python,"name = email =",simpleAssign,361 Head First Python,"date = time =",simpleAssign,361 Head First Python,"location = fin_type =",simpleAssign,361 Head First Python,"whale_type = blow_type =",simpleAssign,361 Head First Python,"wave_type = Create a class called “Sighting” that inherits",simpleAssign,361 Head First Python,"name = db.StringProperty()",simpleAssign,362 Head First Python,"email = db.StringProperty()",simpleAssign,362 Head First Python,"date = db.DateProperty()",simpleAssign,362 Head First Python,"time = db.TimeProperty()",simpleAssign,362 Head First Python,"location = db.StringProperty()",simpleAssign,362 Head First Python,"fin_type = db.StringProperty()",simpleAssign,362 Head First Python,"whale_type = db.StringProperty()",simpleAssign,362 Head First Python,"blow_type = db.StringProperty()",simpleAssign,362 Head First Python,"wave_type = db.StringProperty()",simpleAssign,362 Head First Python,"html = template.render('templates/header.html', {'title': 'Report a Possible Sighting'})",simpleAssign,364 Head First Python,"html = template.render('templates/header.html', {'title': 'Report a Possible Sighting'})",simpleAssign,365 Head First Python,"html = template.render('templates/header.html', {'title': 'Report a Possible Sighting'})",simpleAssign,366 Head First Python,name = db.StringProperty(),simpleAssign,368 Head First Python,date_of_birth = db.DateProperty(),simpleAssign,368 Head First Python,time_of_birth = db.TimeProperty(),simpleAssign,368 Head First Python,model = birthDB.BirthDetails,simpleAssign,368 Head First Python,"html = template.render('templates/header.html', {'title': 'Provide your birth details'})",simpleAssign,368 Head First Python,"app = webapp.WSGIApplication([('/.*', IndexPage)], debug=True)",simpleAssign,370 Head First Python,"html = template.render('templates/header.html', {'title': 'Report a Possible Sighting'})",simpleAssign,371 Head First Python,"app = webapp.WSGIApplication([(‘/.*’, SightingInputPage)], debug=True)",simpleAssign,371 Head First Python,model = hfwwgDB.Sighting,simpleAssign,371 Head First Python,model = hfwwgDB.Sighting,simpleAssign,372 Head First Python,"html = template.render('templates/header.html', {'title': 'Report a Possible Sighting'})",simpleAssign,372 Head First Python,"app = webapp.WSGIApplication([('/.*', SightingInputPage)], debug=True)",simpleAssign,372 Head First Python,location = db.StringProperty(multiline=True),simpleAssign,376 Head First Python,fin_type = db.StringProperty(choices=_FINS),simpleAssign,376 Head First Python,whale_type = db.StringProperty(choices=_WHALES),simpleAssign,376 Head First Python,blow_type = db.StringProperty(choices=_BLOWS),simpleAssign,376 Head First Python,wave_type = db.StringProperty(choices=_WAVES),simpleAssign,376 Head First Python,name = db.StringProperty(),simpleAssign,380 Head First Python,date_of_birth = db.DateProperty(),simpleAssign,380 Head First Python,time_of_birth = db.TimeProperty(),simpleAssign,380 Head First Python,new_birth = birthDB.BirthDetails(),simpleAssign,380 Head First Python,new_birth.name = self.request.get('name'),simpleAssign,380 Head First Python,new_birth.date = self.request.get('date_of_birth'),simpleAssign,380 Head First Python,new_birth.time = self.request.get('time_of_birth')),simpleAssign,380 Head First Python,"html = template.render('templates/header.html', {'title': 'Thank you!'})",simpleAssign,380 Head First Python,"html = template.render('templates/header.html',",simpleAssign,381 Head First Python,new_sighting = hfwwgDB.Sighting(),simpleAssign,382 Head First Python,new_sighting.name = self.request.get(‘name’),simpleAssign,382 Head First Python,new_sighting.email = self.request.get(‘email’),simpleAssign,382 Head First Python,new_sighting.date = self.request.get(‘date’),simpleAssign,382 Head First Python,new_sighting.time = self.request.get(‘time’),simpleAssign,382 Head First Python,new_sighting.location = self.request.get(‘location’),simpleAssign,382 Head First Python,new_sighting.fin_type = self.request.get(‘fin_type’),simpleAssign,382 Head First Python,new_sighting.whale_type = self.request.get(‘whale_type’),simpleAssign,382 Head First Python,new_sighting.blow_type =self.request.get(‘blow_type’),simpleAssign,382 Head First Python,new_sighting.wave_type = self.request.get(‘wave_type’),simpleAssign,382 Head First Python,"html = template.render('templates/header.html',",simpleAssign,382 Head First Python,date = db.DateProperty(),simpleAssign,384 Head First Python,time = db.TimeProperty(),simpleAssign,384 Head First Python,date = db.StringProperty(),simpleAssign,385 Head First Python,time = db.StringProperty(),simpleAssign,385 Head First Python,which_user = db.UserProperty(),simpleAssign,390 Head First Python,model = hfwwgDB.Sighting,simpleAssign,390 Head First Python,new_sighting.which_user = users.get_current_user(),simpleAssign,390 Head First Python,num_cols = len(column_headings),simpleAssign,403 Head First Python,num_2mi = len(row_data['2mi']),simpleAssign,403 Head First Python,num_Marathon = len(row_data['Marathon']),simpleAssign,403 Head First Python,"column_headings = row_data[row_label] = row",simpleAssign,403 Head First Python,row_label = row.pop(0),simpleAssign,403 Head First Python,"row = each_line.strip().split(',')",simpleAssign,403 Head First Python,"column_headings = column_headings.pop(0)",simpleAssign,404 Head First Python,num_cols = len(column_headings),simpleAssign,404 Head First Python,num_2mi = len(row_data['2mi']),simpleAssign,404 Head First Python,num_Marathon = len(row_data['Marathon']),simpleAssign,404 Head First Python,"row = each_line.strip().split(',')",simpleAssign,404 Head First Python,row_label = row.pop(0),simpleAssign,404 Head First Python,row_data[row_label] = row,simpleAssign,404 Head First Python,"row = each_line.strip().split(',')",simpleAssign,407 Head First Python,row_label = row.pop(0),simpleAssign,407 Head First Python,inner_dict[row[i]] = column_headings[i],simpleAssign,407 Head First Python,row_data[row_label] = inner_dict,simpleAssign,407 Head First Python,column_heading = row_data['15k']['43:24'],simpleAssign,408 Head First Python,column_heading = row_data['15k']['43:24'],simpleAssign,409 Head First Python,res = input('What is your favorite programming language: '),simpleAssign,413 Head First Python,age = input('What is your age: '),simpleAssign,413 Head First Python,what = time2secs(look_for),simpleAssign,420 Head First Python,"res = find_closest(what, where)",simpleAssign,420 Head First Python,app = android.Android(),simpleAssign,426 Head First Python,"resp = do_dialog(""Pick a distance"", distances, )",simpleAssign,427 Head First Python,"distance_run = distance_run = distances[distance_run]",simpleAssign,427 Head First Python,"closest_time = find_nearest_time(format_time( ), row_data[distance_run])",simpleAssign,427 Head First Python,closest_column_heading = row_data[distance_run][closest_time],simpleAssign,427 Head First Python,"resp = do_dialog(""Pick a distance to predict"", distances, )",simpleAssign,427 Head First Python,"predicted_distance = predicted_distance = distances[predicted_distance]",simpleAssign,427 Head First Python,if row_data[predicted_distance][k] == closest_column_heading],simpleAssign,427 Head First Python,"resp = do_dialog(""Pick a distance"", distances, app.dialogSetSingleChoiceItems)",simpleAssign,428 Head First Python,distance_run = app.dialogGetSelectedItems().result[0],simpleAssign,428 Head First Python,distance_run = distances[distance_run],simpleAssign,428 Head First Python,"closest_time = find_nearest_time(format_time(recorded_time), row_data[distance_run])",simpleAssign,428 Head First Python,closest_column_heading = row_data[distance_run][closest_time],simpleAssign,428 Head First Python,"resp = do_dialog(""Pick a distance to predict"", distances, app.dialogSetSingleChoiceItems)",simpleAssign,428 Head First Python,predicted_distance = app.dialogGetSelectedItems().result[0],simpleAssign,428 Head First Python,predicted_distance = distances[predicted_distance],simpleAssign,428 Head First Python,if row_data[predicted_distance][k] == closest_column_heading],simpleAssign,428 "A python book Beginning python, advanced python, and python exercises","In [23]: c = [(x, y) for x in a for y in b]",listCompNested,38 "A python book Beginning python, advanced python, and python exercises","zip(('one', 'two'), (2, 3)))",zip,20 "A python book Beginning python, advanced python, and python exercises","def __init__(self, message="""", buttons=()",privatemethod,145 "A python book Beginning python, advanced python, and python exercises","@classmethod def",decaratorfunc,51 "A python book Beginning python, advanced python, and python exercises","@staticmethod def",decaratorfunc,51 "A python book Beginning python, advanced python, and python exercises","@wrapper def",decaratorfunc,51 "A python book Beginning python, advanced python, and python exercises","@afunc def",decaratorfunc,64 "A python book Beginning python, advanced python, and python exercises","@classmethod def",decaratorfunc,64 "A python book Beginning python, advanced python, and python exercises","@property def",decaratorfunc,65 "A python book Beginning python, advanced python, and python exercises","@description.setter def",decaratorfunc,66 "A python book Beginning python, advanced python, and python exercises","@functionwrapper def",decaratorfunc,224 "A python book Beginning python, advanced python, and python exercises","@classmethod def",decaratorfunc,224 "A python book Beginning python, advanced python, and python exercises","@dec def",decaratorfunc,225 "A python book Beginning python, advanced python, and python exercises","@trace def",decaratorfunc,226 "A python book Beginning python, advanced python, and python exercises","@trace def",decaratorfunc,226 "A python book Beginning python, advanced python, and python exercises","@dec(argA, argB) def",decaratorfunc,226 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func1') def",decaratorfunc,227 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func2') def",decaratorfunc,227 "A python book Beginning python, advanced python, and python exercises","@dec1 def",decaratorfunc,227 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func1') def",decaratorfunc,228 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func2') def",decaratorfunc,228 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func1') def",decaratorfunc,229 "A python book Beginning python, advanced python, and python exercises","@trace('tracing func2') def",decaratorfunc,229 "A python book Beginning python, advanced python, and python exercises","@classmethod. ● See the description of class",decaratorclass,64 "A python book Beginning python, advanced python, and python exercises","@classmethod and @staticmethod (instead of the classmethod() and staticmethod() built-in functions) to declare class",decaratorclass,64 "A python book Beginning python, advanced python, and python exercises",enumerate(),enumfunc,36 "A python book Beginning python, advanced python, and python exercises",enumerate(),enumfunc,36 "A python book Beginning python, advanced python, and python exercises",enumerate(iterable) -- Returns an iterable that produces pairs (tuples),enumfunc,37 "A python book Beginning python, advanced python, and python exercises",enumerate(),enumfunc,195 "A python book Beginning python, advanced python, and python exercises",enumerate(),enumfunc,196 "A python book Beginning python, advanced python, and python exercises",enumerate(),enumfunc,196 "A python book Beginning python, advanced python, and python exercises",In [6]: list2 = [f(x) for x in list1],simpleListComp,96 "A python book Beginning python, advanced python, and python exercises",b = [x * 2 for x in a],simpleListComp,171 "A python book Beginning python, advanced python, and python exercises",factorials = [t(n) for n in numbers],simpleListComp,172 "A python book Beginning python, advanced python, and python exercises",b = [x * 3 for x in a if x % 2 == 0],simpleListComp,172 "A python book Beginning python, advanced python, and python exercises","names3 = [name for name in names1 if name not in names2]",simpleListComp,173 "A python book Beginning python, advanced python, and python exercises",In [29]: gen1 = (item.upper() for item in items),generatorExpression,38 "A python book Beginning python, advanced python, and python exercises",gen = (item for item in collection if item not in excludes),generatorExpression,91 "A python book Beginning python, advanced python, and python exercises",genexpr = (f(x) for x in mylist),generatorExpression,97 "A python book Beginning python, advanced python, and python exercises",re.compile(),re,82 "A python book Beginning python, advanced python, and python exercises",re.subn(),re,85 "A python book Beginning python, advanced python, and python exercises",re.subn() function returns a tuple containing two values: (1),re,85 "A python book Beginning python, advanced python, and python exercises",import re,importre,82 "A python book Beginning python, advanced python, and python exercises",import re,importre,85 "A python book Beginning python, advanced python, and python exercises","def simplegenerator(): yield",generatorYield,54 "A python book Beginning python, advanced python, and python exercises","def walk_tree(self, level): yield",generatorYield,56 "A python book Beginning python, advanced python, and python exercises","def walk_tree(tree, level): yield",generatorYield,57 "A python book Beginning python, advanced python, and python exercises","def walk_tree_recur(tree, level): yield",generatorYield,57 "A python book Beginning python, advanced python, and python exercises",classmethod(),classmethod2,63 "A python book Beginning python, advanced python, and python exercises",classmethod() built-in),classmethod2,223 "A python book Beginning python, advanced python, and python exercises",staticmethod(),staticmethod2,64 "A python book Beginning python, advanced python, and python exercises",staticmethod(),staticmethod2,64 "A python book Beginning python, advanced python, and python exercises",staticmethod(),staticmethod2,223 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,30 "A python book Beginning python, advanced python, and python exercises","if __name__ == ""__main__"":",__name__,32 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,55 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,58 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,59 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,68 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,69 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,71 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,72 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,74 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,75 "A python book Beginning python, advanced python, and python exercises","if __name__ == ""__main__"":",__name__,77 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,77 "A python book Beginning python, advanced python, and python exercises","if __name__ == ""__main__"":",__name__,99 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,112 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,124 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,137 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,143 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,146 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,149 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,150 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,172 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,173 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,174 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,187 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,193 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,195 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,201 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,205 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,208 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,208 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,210 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,213 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,213 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,216 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,217 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,219 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,220 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,221 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,222 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,223 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,225 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,234 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,235 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,236 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,237 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,239 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,246 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,247 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,265 "A python book Beginning python, advanced python, and python exercises",if __name__ == '__main__':,__name__,266 "A python book Beginning python, advanced python, and python exercises",x.__class__,__class__,2 "A python book Beginning python, advanced python, and python exercises",The built-in types are introspect-able -- Use x.__class__,__class__,67 "A python book Beginning python, advanced python, and python exercises",dir(x.__class__,__class__,67 "A python book Beginning python, advanced python, and python exercises",type(x) is the same as x.__class__,__class__,67 "A python book Beginning python, advanced python, and python exercises",obj.__class__,__class__,69 "A python book Beginning python, advanced python, and python exercises",obj.__class__,__class__,69 "A python book Beginning python, advanced python, and python exercises",dir(anIter): ['__class__,__class__,90 "A python book Beginning python, advanced python, and python exercises","__add__', '__class__",__class__,176 "A python book Beginning python, advanced python, and python exercises",a.__dict__,__dict__,191 "A python book Beginning python, advanced python, and python exercises","with open('tmp01.txt', 'r') as infile:",withfunc,24 "A python book Beginning python, advanced python, and python exercises","with open('small_file.txt', 'r') as infile:",withfunc,24 "A python book Beginning python, advanced python, and python exercises","with open('tmp_outfile.txt', 'w') as outfile:",withfunc,24 "A python book Beginning python, advanced python, and python exercises","with open(infilename, 'r') as infile, open(outfilename, 'w') as outfile:",withfunc,44 "A python book Beginning python, advanced python, and python exercises","with open(infilename, 'r') as infile, open(outfilename, 'w') as outfile:",withfunc,70 "A python book Beginning python, advanced python, and python exercises","a = [11, None, 'abc', None, {}]",listwithdict,188 "A python book Beginning python, advanced python, and python exercises","if condition3: statements else:",ifelse,34 "A python book Beginning python, advanced python, and python exercises","while condition: block The while: statement is not often used in Python because the for: statement is usually more convenient, more idiomatic, and more Pythonic. Exercises: ● Write a while statement that prints integers from zero to 5. Solution: count = 0 while count < 5: count += 1 print count The break and continue statements are often useful in a while statement. See continue and break statements The while statement can also have an optional else: clause. The else: clause is executed if the while statement completes normally, that is if a break statement is not executed. 1.6.7 continue and break statements The break statement exits from a loop. The continue statement causes execution to immediately continue at the start of the loop. Can be used in for: and while:. When the for: statement or the while: statement has an else: clause, the block in the else:",whileelse,39 "A python book Beginning python, advanced python, and python exercises","while 1: line = raw_input('Enter a line (""q"" to quit):') if line == 'q': break if pat.search(line): print 'matched:', line else:",whileelse,82 "A python book Beginning python, advanced python, and python exercises","while 1: line = raw_input('Enter a line (""q"" to quit):') if line == 'q': break mo = pat.search(line) if mo: value1, value2 = mo.group(1, 2) print 'value1: %s value2: %s' % (value1, value2) else:",whileelse,84 "A python book Beginning python, advanced python, and python exercises","while 1: line = raw_input('Enter a line (""q"" to quit): ') if line == 'q': break mo = pat.search(line) if mo: value1, value2 = mo.group(1, 2) start1 = mo.start(1) end1 = mo.end(1) start2 = mo.start(2) end2 = mo.end(2) print 'value1: %s start1: %d end1: %d' % (value1, start1, end1) print 'value2: %s start2: %d end2: %d' % (value2, start2, end2) repl1 = raw_input('Enter replacement #1: ') repl2 = raw_input('Enter replacement #2: ') newline = (line[:start1] + repl1 + line[end1:start2] + repl2 + line[end2:]) print 'newline: %s' % newline else:",whileelse,86 "A python book Beginning python, advanced python, and python exercises","while 1: result = self.command_reco() if not result: break commandList.append(result) return ASTNode(ProgNodeType, commandList) def command_reco(self): if self.tokenType == EOFTokType: return None result = self.func_call_reco() return ASTNode(CommandNodeType, result) def func_call_reco(self): if self.tokenType == WordTokType: term = ASTNode(TermNodeType, self.token) self.tokenType, self.token, self.lineNo = self.tokens.next() if self.tokenType == LParTokType: self.tokenType, self.token, self.lineNo = self.tokens.next() result = self.func_call_list_reco() if result: if self.tokenType == RParTokType: self.tokenType, self.token, self.lineNo = \ self.tokens.next() return ASTNode(FuncCallNodeType, term, result) else: raise ParseError(self.lineNo, 'missing right paren') else: raise ParseError(self.lineNo, 'bad func call list') else: raise ParseError(self.lineNo, 'missing left paren') else:",whileelse,118 "A python book Beginning python, advanced python, and python exercises","while 1: tokenType, token = scanner.read() name, lineNo, columnNo = scanner.position() if tokenType == None: tokType = EOFTokType token = None elif tokenType == 'word': tokType = WordTokType elif tokenType == 'lpar': tokType = LParTokType elif tokenType == 'rpar': tokType = RParTokType elif tokenType == 'comma': tokType = CommaTokType else:",whileelse,129 "A python book Beginning python, advanced python, and python exercises","while True: count += 1 if count > 5: break",whilebreak,40 "A python book Beginning python, advanced python, and python exercises","while 1: target = raw_input('Enter a target line (""q"" to quit): ') if target == 'q': break repl = raw_input('Enter a replacement: ') result = pat.sub(repl, target) print 'result: %s' % result Here is another example of the use of a function to insert calculated replacements. import sys, re, string pat = re.compile('[a-m]+') def replacer(mo): return string.upper(mo.group(0)) print 'Upper-casing a-m.' while 1: target = raw_input('Enter a target line (""q"" to quit): ') if target == 'q': break result = pat.sub(replacer, target) print 'result: %s' % result Notes: ● If the replacement argument to sub is a function, that function must take one argument, a match object, and must return the modified (or replacement) value. The matched sub-string will be replaced by the value returned by this function. ● In our case, the function replacer converts the matched value to upper case. This is also a convenient use for a lambda instead of a named function, for example: import sys, re, string pat = re.compile('[a-m]+') print 'Upper-casing a-m.' while 1: target = raw_input('Enter a target line (""q"" to quit): ') if target == 'q': break",whilebreak,87 "A python book Beginning python, advanced python, and python exercises","while 1: result = self.func_call_reco() if not result: break",whilebreak,118 "A python book Beginning python, advanced python, and python exercises","while True: token = scanner.read() if token[0] is None: break",whilebreak,123 "A python book Beginning python, advanced python, and python exercises","while 1: result = self.func_call_reco() if not result: break terms.append(result) if self.tokenType != CommaTokType: break",whilebreak,128 "A python book Beginning python, advanced python, and python exercises","while idx < len(numbers): numbers[idx] *= 2 idx += 1 print 'after: %s' % (numbers, ) But, notice that this task is easier using the for: statement and the built-in enumerate() function: def test_for(): numbers = [11, 22, 33, 44, ] print 'before: %s' % (numbers, ) for idx, item in enumerate(numbers): numbers[idx] *= 2 print 'after: %s' % (numbers, ) 3.5.6 break and continue statements The continue statement skips the remainder of the statements in the body of a loop and starts immediately at the top of the loop again. A break statement in the body of a loop terminates the loop. It exits from the immediately containing loop. break and continue can be used in both for: and while: statements. Exercises: 1. Write a for: loop that takes a list of integers and triples each integer that is even. Use the continue statement. 2. Write a loop that takes a list of integers and computes the sum of all the integers up until a zero is found in the list. Use the break statement. Solutions: 1. The continue statement enables us to ""skip"" items that satisfy a condition or test: def test(): numbers = [11, 22, 33, 44, 55, 66, ] print 'before: %s' % (numbers, ) for idx, item in enumerate(numbers): if item % 2 != 0: continue numbers[idx] *= 3 print 'after: %s' % (numbers, ) test() 2. The break",whilebreak,197 "A python book Beginning python, advanced python, and python exercises","while count < 10: count += 1 if count % 2 == 0: continue",whilecontinue,40 "A python book Beginning python, advanced python, and python exercises",while k < kmax:,whilesimple,107 "A python book Beginning python, advanced python, and python exercises",while i < k and n % p[i] <> 0:,whilesimple,107 "A python book Beginning python, advanced python, and python exercises",while k < kmax:,whilesimple,109 "A python book Beginning python, advanced python, and python exercises",while i < k and n % p[i] <> 0:,whilesimple,109 "A python book Beginning python, advanced python, and python exercises",while 1:,whilesimple,119 "A python book Beginning python, advanced python, and python exercises",while condition:,whilesimple,196 "A python book Beginning python, advanced python, and python exercises",from module import *,fromstarstatements,7 "A python book Beginning python, advanced python, and python exercises",from A import *,fromstarstatements,31 "A python book Beginning python, advanced python, and python exercises",from my_package import *,fromstarstatements,59 "A python book Beginning python, advanced python, and python exercises",from my_package import *,fromstarstatements,60 "A python book Beginning python, advanced python, and python exercises",from A import B as C,asextension,31 "A python book Beginning python, advanced python, and python exercises",from simplepackage.simple import test1 as mytest,asextension,32 "A python book Beginning python, advanced python, and python exercises",from xml.etree import ElementTree as etree,asextension,235 "A python book Beginning python, advanced python, and python exercises",from xml.etree import ElementTree as etree,asextension,238 "A python book Beginning python, advanced python, and python exercises","in a file: import simplejson as json",asextension,249 "A python book Beginning python, advanced python, and python exercises","2. We can read the file into a string, then decode it from Json: import simplejson as json",asextension,250 "A python book Beginning python, advanced python, and python exercises","import sys import people_api as api",asextension,257 "A python book Beginning python, advanced python, and python exercises","Here are the relevant, modified subclasses (upcase_names_appl.py): import people_api as supermod",asextension,258 "A python book Beginning python, advanced python, and python exercises","import sys import upcase_names_appl as appl",asextension,259 "A python book Beginning python, advanced python, and python exercises","A Python Book import member_specs_api as supermod",asextension,262 "A python book Beginning python, advanced python, and python exercises","import sys import member_specs_api as supermod",asextension,266 "A python book Beginning python, advanced python, and python exercises","def __init__(self, file_name)",__init__,33 "A python book Beginning python, advanced python, and python exercises",def __init__(self),__init__,36 "A python book Beginning python, advanced python, and python exercises","def __init__(self, first='', last='')",__init__,52 "A python book Beginning python, advanced python, and python exercises","def __init__(self, data, children=None)",__init__,56 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name)",__init__,61 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name)",__init__,61 "A python book Beginning python, advanced python, and python exercises","def __init__(self, items=None)",__init__,62 "A python book Beginning python, advanced python, and python exercises","def __init__(self, items=[])",__init__,62 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name, size)",__init__,63 "A python book Beginning python, advanced python, and python exercises","def __init__(self, description)",__init__,65 "A python book Beginning python, advanced python, and python exercises","def __init__(self, description)",__init__,65 "A python book Beginning python, advanced python, and python exercises","def __init__(self, data=None, name='no_name')",__init__,67 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name)",__init__,68 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name, desc)",__init__,68 "A python book Beginning python, advanced python, and python exercises","def __init__(self, seq)",__init__,93 "A python book Beginning python, advanced python, and python exercises","def __init__(self, seq)",__init__,95 "A python book Beginning python, advanced python, and python exercises","def __init__(self, nodeType, *args)",__init__,116 "A python book Beginning python, advanced python, and python exercises","def __init__(self, lineNo, msg)",__init__,119 "A python book Beginning python, advanced python, and python exercises","def __init__(self, nodeType, *args)",__init__,126 "A python book Beginning python, advanced python, and python exercises",def __init__(self),__init__,127 "A python book Beginning python, advanced python, and python exercises","def __init__(self, lineNo, msg)",__init__,128 "A python book Beginning python, advanced python, and python exercises","def __init__(self, nodeType, *args)",__init__,134 "A python book Beginning python, advanced python, and python exercises","def __init__(self, msg, lineno, columnno)",__init__,134 "A python book Beginning python, advanced python, and python exercises","def __init__(self, msg, lineno, columnno)",__init__,134 "A python book Beginning python, advanced python, and python exercises","def __init__(self, message="""", default_text='', modal=True)",__init__,147 "A python book Beginning python, advanced python, and python exercises","def __init__(self, modal=True, multiple=True)",__init__,149 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name, size)",__init__,215 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name=None, children=None)",__init__,216 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name, height=-1, children=None)",__init__,217 "A python book Beginning python, advanced python, and python exercises","def __init__(self, data, children=None)",__init__,220 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name='-no name-')",__init__,222 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name='-no name-')",__init__,223 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name='-no name-')",__init__,224 "A python book Beginning python, advanced python, and python exercises","def __init__(self, urls)",__init__,230 "A python book Beginning python, advanced python, and python exercises",def __init__(self),__init__,233 "A python book Beginning python, advanced python, and python exercises","def __init__(self, locator=None, description=None, contact=None)",__init__,263 "A python book Beginning python, advanced python, and python exercises","try: except: statement Exceptions are a systematic and consistent way of processing errors and ""unusual"" events in Python. Caught and un-caught exceptions -- Uncaught exceptions terminate a program. The try: statement catches an exception. Almost all errors in Python are exceptions. Evaluation (execution model) of the try statement -- When an exception occurs in the try block, even if inside a nested function call, execution of the try block ends and the except clauses are searched for a matching exception. Tracebacks -- Also see the traceback module: http://docs.python.org/lib/module-traceback.html Exceptions are classes. Exception classes -- subclassing, args. An exception class in an except: clause catches instances of that exception class and all subclasses, but not superclasses. Built-in exception classes -- See: ● Module exceptions. Page 49",trytry,40 "A python book Beginning python, advanced python, and python exercises","try: raise RuntimeError('this silly error') except RuntimeError, exp: print ""[[[%s]]]"" % exp Reference: http://docs.python.org/lib/module-exceptions.html You can also get the arguments passed to the constructor of an exception object. In the above example, these would be: exp.args Why would you define your own exception class? One answer: You want a user of your code to catch your exception and no others. Catching an exception by exception class catches exceptions of that class and all its subclasses. So: except SomeExceptionClass, exp: matches and catches an exception if SomeExceptionClass is the exception class or a base class (superclass) of the exception class. The exception object (usually an instance of some exception class) is bound to exp. A more ""modern"" syntax is: except SomeExceptionClass as exp: So: class MyE(ValueError): pass try: raise MyE() except ValueError: print 'caught exception' will print ""caught exception"", because ValueError is a base class of MyE. Also see the entries for ""EAFP"" and ""LBYL"" in the Python glossary: http://docs.python.org/3/glossary.html. Exercises: ● Write a very simple, empty exception subclass. Solution: class MyE(Exception): Page 50",trytry,41 "A python book Beginning python, advanced python, and python exercises","try:except: statement that raises your exception and also catches it. Solution: try: raise MyE('hello there dave') except MyE, e: print e 1.6.9 raise statement Throw or raise an exception. Forms: ● raise instance ● raise MyExceptionClass(value) -- preferred. ● raise MyExceptionClass, value The raise statement takes: ● An (instance of) a built-in exception class. ● An instance of class Exception or ● An instance of a built-in subclass of class Exception or ● An instance of a user-defined subclass of class Exception or ● One of the above classes and (optionally) a value (for example, a string or a tuple). See http://docs.python.org/ref/raise.html. For a list of built-in exceptions, see http://docs.python.org/lib/module-exceptions.html. The following example defines an exception subclass and throws an instance of that subclass. It also shows how to pass and catch multiple arguments to the exception: class NotsobadError(Exception): pass def test(x): try: if x == 0: raise NotsobadError('a moderately bad error', 'not too bad') except NotsobadError, e: print 'Error args: %s' % (e.args, ) test(0) Which prints out the following: Error args: ('a moderately bad error', 'not too bad') Page 51",trytry,42 "A python book Beginning python, advanced python, and python exercises","try: self.tokenType, self.token, self.lineNo = self.tokens.next() except StopIteration: raise RuntimeError, 'Empty file' result = self.prog_reco() self.infile.close() self.infile = None return result def parseStream(self, instream): self.tokens = genTokens(instream, '<instream>') try: self.tokenType, self.token, self.lineNo = self.tokens.next() except StopIteration: Page 126",trytry,117 "A python book Beginning python, advanced python, and python exercises","try: result = parser.parseFile(infileName) except ParseError, exp: sys.stderr.write('ParseError: (%d) %s\n' % \ (exp.getLineNo(), exp.getMsg())) if result: result.show(0) def usage(): print __doc__ sys.exit(1) def main(): args = sys.argv[1:] try: opts, args = getopt.getopt(args, 'h', ['help']) except: usage() relink = 1 for opt, val in opts: if opt in ('-h', '--help'): usage() if len(args) != 1: usage() inputfile = args[0] test(inputfile) if __name__ == '__main__': #import pdb; pdb.set_trace() main() Comments and explanation: ● The tokenizer is a Python generator. It returns a Python generator that can produce ""(tokType, tok, lineNo)"" tuples. Our tokenizer is so simple-minded that we have to separate all of our tokens with whitespace. (A little later, we'll see how to use Plex to overcome this limitation.) ● The parser class (ProgParser) contains the recognizer methods that implement the production rules. Each of these methods recognizes a syntactic construct defined by a rule. In our example, these methods have names that end with ""_reco"". ● We could have, alternatively, implemented our recognizers as global functions, instead of as methods in a class. However, using a class gives us a place to ""hang"" the variables that are needed across methods and saves us from having to use (""evil"") global variables. ● A recognizer method recognizes terminals (syntactic elements on the right-hand side of the grammar rule for which there is no grammar rule) by (1) checking the token type and the token value, and then (2) calling the tokenizer to get the next token (because it has consumed a token). Page 129",trytry,120 "A python book Beginning python, advanced python, and python exercises","try: self.tokenType, self.token, self.lineNo = self.tokens.next() except StopIteration: raise RuntimeError, 'Empty file' result = self.prog_reco() self.infile.close() self.infile = None return result def parseStream(self, instream): self.tokens = None self.tokenType = NoneTokType self.token = '' self.lineNo = -1 self.tokens = genTokens(self.instream, '<stream>') try: self.tokenType, self.token, self.lineNo = self.tokens.next() except StopIteration: raise RuntimeError, 'Empty stream' result = self.prog_reco() self.infile.close() self.infile = None return result def prog_reco(self): commandList = [] while 1: result = self.command_reco() if not result: break Page 136",trytry,127 "A python book Beginning python, advanced python, and python exercises","try: result = parser.parseFile(infileName) except ParseError, exp: sys.stderr.write('ParseError: (%d) %s\n' % \ (exp.getLineNo(), exp.getMsg())) if result: result.show(0) def usage(): print __doc__ sys.exit(-1) def main(): args = sys.argv[1:] try: opts, args = getopt.getopt(args, 'h', ['help']) except: usage() for opt, val in opts: if opt in ('-h', '--help'): usage() if len(args) != 1: usage() infileName = args[0] test(infileName) if __name__ == '__main__': #import pdb; pdb.set_trace() main() And, here is a sample of the data we can apply this parser to: # Test for recursive descent parser and Plex. # Command #1 aaa() # Command #2 bbb (ccc()) # An end of line comment. # Command #3 ddd(eee(), fff(ggg(), hhh(), iii())) # End of test And, when we run our parser, it produces the following: $ python plex_recusive.py plex_recusive.data Node -- Type ProgNodeType Node -- Type CommandNodeType Node -- Type FuncCallNodeType Node -- Type TermNodeType Child: aaa Node -- Type FuncCallListNodeType Node -- Type CommandNodeType Page 139",trytry,130 "A python book Beginning python, advanced python, and python exercises","try:except: and raise statements The try:except: statement enables us to catch an exception that is thrown from within a block of code, or from code called from any depth withing that block. The raise statement enables us to throw an exception. An exception is a class or an instance of an exception class. If an exception is not caught, it results in a traceback and termination of the program. There is a set of standard exceptions. You can learn about them here: Built-in Exceptions -- http://docs.python.org/lib/module-exceptions.html. You can define your own exception classes. To do so, create an empty subclass of the class Exception. Defining your own exception will enable you (or others) to throw and then catch that specific exception type while ignore others exceptions. Exercises: 1. Write a try:except: statement that attempts to open a file for reading and catches the exception thrown when the file does not exist. Question: How do you find out the name of the exception that is thrown for an input/output error such as the failure to open a file? 2. Define an exception class. Then write a try:except: statement in which you throw and catch that specific exception. 3. Define an exception class and use it to implement a multi-level break from an inner loop, by-passing an outer loop. Solutions: 1. Use the Python interactive interpreter to learn the exception type thrown when a I/O error occurs. Example: >>> infile = open('xx_nothing__yy.txt', 'r') Traceback (most recent call last): File ""<stdin>"", line 1, in <module> IOError: [Errno 2] No such file or directory: 'xx_nothing__yy.txt' >>> Page 207",trytry,198 "A python book Beginning python, advanced python, and python exercises","try:except: block which catches that exception: def test(): infilename = 'nothing_noplace.txt' try: infile = open(infilename, 'r') for line in infile: print line except IOError, exp: print 'cannot open file ""%s""' % infilename test() 2. We define a exception class as a sub-class of class Exception, then throw it (with the raise statement) and catch it (with a try:except: statement): class SizeError(Exception): pass def test_exception(size): try: if size <= 0: raise SizeError, 'size must be greater than zero' # Produce a different error to show that it will not be caught. x = y except SizeError, exp: print '%s' % (exp, ) print 'goodbye' def test(): test_exception(-1) print '-' * 40 test_exception(1) test() When we run this script, it produces the following output: $ python workbook027.py size must be greater than zero goodbye ---------------------------------------- Traceback (most recent call last): File ""workbook027.py"", line 20, in <module> test() File ""workbook027.py"", line 18, in test test_exception(1) File ""workbook027.py"", line 10, in test_exception x = y NameError: global name 'y' is not defined Page 208",trytry,199 "A python book Beginning python, advanced python, and python exercises","try: # lxml from lxml import etree as etree_ XMLParser_import_library = XMLParser_import_lxml if Verbose_import_: print(""running with lxml.etree"") except ImportError: try: # cElementTree from Python 2.5+ import xml.etree.cElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print(""running with cElementTree on Python 2.5+"") except ImportError: try: # ElementTree from Python 2.5+ import xml.etree.ElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print(""running with ElementTree on Python 2.5+"") except ImportError: try: # normal cElementTree install import cElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print(""running with cElementTree"") except ImportError: try: # normal ElementTree install import elementtree.ElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print(""running with ElementTree"") except ImportError: raise ImportError(""Failed to import ElementTree from any known place"") def parsexml_(*args, **kwargs): if (XMLParser_import_library == XMLParser_import_lxml and 'parser' not in kwargs): # Use the lxml ElementTree compatible parser so that, e.g., Page 271",trytry,262 "A python book Beginning python, advanced python, and python exercises","try: rating = int(rating) except ValueError, exp: print 'Error: rating must be integer.' return connection, cursor = opendb() cursor.execute(""select * from plantsdb where p_name = '%s'"" % name) rows = cursor.fetchall() if len(rows) > 0: ql = ""update plantsdb set p_descrip='%s', p_rating='%s' where p_name='%s'"" % ( descrip, rating, name, ) print 'ql:', ql cursor.execute(ql) connection.commit() print 'Updated' else:",tryexceptelse,244 "A python book Beginning python, advanced python, and python exercises","try: if x == 0: raise NotsobadError('a moderately bad error', 'not too bad') except NotsobadError, e:",tryexcept,43 "A python book Beginning python, advanced python, and python exercises","try: print it.next() # Note 3 print it.next() print it.next() print it.next() except StopIteration, exp:",tryexcept,55 "A python book Beginning python, advanced python, and python exercises","try: print a.next() print a.next() print a.next() print a.next() print a.next() print a.next() except StopIteration, e:",tryexcept,94 "A python book Beginning python, advanced python, and python exercises","try: print a.next() print a.next() print a.next() print a.next() print a.next() print a.next() except StopIteration, e:",tryexcept,95 "A python book Beginning python, advanced python, and python exercises","try: # Do the parse result = yacc.parse(content) # Display the AST result.show(0) except LexerError, exp: exp.show() except ParserError, exp:",tryexcept,136 "A python book Beginning python, advanced python, and python exercises","try: for x in a: print 'outer -- x: %d' % x for y in b: if x > 22 and y > 444: raise BreakException1('leaving inner loop') print 'inner -- y: %d' % y print 'outer -- after' print '-' * 40 except BreakException1, exp:",tryexcept,200 "A python book Beginning python, advanced python, and python exercises","try: x = iter(x) except TypeError, exp:",tryexcept,212 "A python book Beginning python, advanced python, and python exercises","try: y = iter(x) except TypeError, exp:",tryexcept,230 "A python book Beginning python, advanced python, and python exercises","lambda Use a lambda, as a convenience, when you need a function that both:",lambda,52 "A python book Beginning python, advanced python, and python exercises","lambda first, last: '%s %s' % (first, last, ))",lambda,53 "A python book Beginning python, advanced python, and python exercises","lambda first, last: '%s, %s' % (last, first, ))",lambda,53 "A python book Beginning python, advanced python, and python exercises","lambda x: x,",lambda,53 "A python book Beginning python, advanced python, and python exercises","lambda x: x * 2,",lambda,53 "A python book Beginning python, advanced python, and python exercises","lambda mo: string.upper(mo.group(0)),",lambda,87 "A python book Beginning python, advanced python, and python exercises","def fn1(*args, **kwargs):",funcwith2star,47 "A python book Beginning python, advanced python, and python exercises","def test(size, *args, **kwargs):",funcwith2star,48 "A python book Beginning python, advanced python, and python exercises",def t(**kwargs):,funcwith2star,49 "A python book Beginning python, advanced python, and python exercises","def inner_fn(*args, **kwargs):",funcwith2star,51 "A python book Beginning python, advanced python, and python exercises","def show_args(x, y=-1, *args, **kwargs):",funcwith2star,205 "A python book Beginning python, advanced python, and python exercises","def func1(*args, **kwargs):",funcwith2star,206 "A python book Beginning python, advanced python, and python exercises","def func2(*args, **kwargs):",funcwith2star,206 "A python book Beginning python, advanced python, and python exercises","def inner(*args, **kwargs):",funcwith2star,226 "A python book Beginning python, advanced python, and python exercises","def inner2(*args, **kwargs):",funcwith2star,227 "A python book Beginning python, advanced python, and python exercises","def inner2(*args, **kwargs):",funcwith2star,228 "A python book Beginning python, advanced python, and python exercises","def inner(*args, **kwargs):",funcwith2star,228 "A python book Beginning python, advanced python, and python exercises","def inner2(*args, **kwargs):",funcwith2star,229 "A python book Beginning python, advanced python, and python exercises","def inner2(*args, **kwargs):",funcwith2star,229 "A python book Beginning python, advanced python, and python exercises",def t(*args):,funcwithstar,49 "A python book Beginning python, advanced python, and python exercises","def quit(self, *args):",funcwithstar,145 "A python book Beginning python, advanced python, and python exercises","def quit(self, *args):",funcwithstar,149 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,36 "A python book Beginning python, advanced python, and python exercises",class NotsobadError(Exception):,simpleclass,43 "A python book Beginning python, advanced python, and python exercises",class Context01(object):,simpleclass,43 "A python book Beginning python, advanced python, and python exercises",class Context01(object):,simpleclass,43 "A python book Beginning python, advanced python, and python exercises",class SomeClass(object):,simpleclass,51 "A python book Beginning python, advanced python, and python exercises",class B(object):,simpleclass,61 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,61 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,61 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,62 "A python book Beginning python, advanced python, and python exercises",class B(A):,simpleclass,62 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,63 "A python book Beginning python, advanced python, and python exercises",class B(object):,simpleclass,64 "A python book Beginning python, advanced python, and python exercises",class TestProperty(object):,simpleclass,65 "A python book Beginning python, advanced python, and python exercises",class TestProperty(object):,simpleclass,65 "A python book Beginning python, advanced python, and python exercises",class C(list):,simpleclass,66 "A python book Beginning python, advanced python, and python exercises",class D(dict):,simpleclass,67 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,68 "A python book Beginning python, advanced python, and python exercises",class B(A):,simpleclass,68 "A python book Beginning python, advanced python, and python exercises",class ParseError(Exception):,simpleclass,119 "A python book Beginning python, advanced python, and python exercises",class ParseError(Exception):,simpleclass,128 "A python book Beginning python, advanced python, and python exercises",class LexerError(Exception):,simpleclass,134 "A python book Beginning python, advanced python, and python exercises",class ParserError(Exception):,simpleclass,134 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,190 "A python book Beginning python, advanced python, and python exercises",class BreakException1(Exception):,simpleclass,200 "A python book Beginning python, advanced python, and python exercises",class Demo(object):,simpleclass,214 "A python book Beginning python, advanced python, and python exercises",class Plant(object):,simpleclass,215 "A python book Beginning python, advanced python, and python exercises",class Node(object):,simpleclass,216 "A python book Beginning python, advanced python, and python exercises",class Plant(Node):,simpleclass,217 "A python book Beginning python, advanced python, and python exercises",class Animal(Node):,simpleclass,217 "A python book Beginning python, advanced python, and python exercises",class A(object):,simpleclass,218 "A python book Beginning python, advanced python, and python exercises",class B(object):,simpleclass,218 "A python book Beginning python, advanced python, and python exercises",class C(object):,simpleclass,218 "A python book Beginning python, advanced python, and python exercises",class AnimalNode(object):,simpleclass,219 "A python book Beginning python, advanced python, and python exercises",class AnimalNode(object):,simpleclass,220 "A python book Beginning python, advanced python, and python exercises",class ASimpleClass(object):,simpleclass,221 "A python book Beginning python, advanced python, and python exercises",class ASimpleClass(object):,simpleclass,221 "A python book Beginning python, advanced python, and python exercises",class CountInstances(object):,simpleclass,222 "A python book Beginning python, advanced python, and python exercises",class CountInstances(object):,simpleclass,223 "A python book Beginning python, advanced python, and python exercises",class CountInstances(object):,simpleclass,224 "A python book Beginning python, advanced python, and python exercises",class WebPages(object):,simpleclass,230 "A python book Beginning python, advanced python, and python exercises","raise ParseError(self.lineNo, 'missing left paren')",raise,128 "A python book Beginning python, advanced python, and python exercises","raise LexerError(msg, t.lineno, columnno)",raise,135 "A python book Beginning python, advanced python, and python exercises","raise ParserError(msg, t.lineno, columnno)",raise,136 "A python book Beginning python, advanced python, and python exercises",">>> class MyClass: ... pass",pass,29 "A python book Beginning python, advanced python, and python exercises","def __enter__(self): pass",pass,43 "A python book Beginning python, advanced python, and python exercises","def __exit__(self, exc_type, exc_value, traceback): pass",pass,43 "A python book Beginning python, advanced python, and python exercises","with MyContextManager() as obj: pass",pass,44 "A python book Beginning python, advanced python, and python exercises","In [17]:class A: ....: pass",pass,45 "A python book Beginning python, advanced python, and python exercises","HelloClass(cls, arg): pass",pass,51 "A python book Beginning python, advanced python, and python exercises","HelloStatic(arg): pass",pass,51 "A python book Beginning python, advanced python, and python exercises","fn1(msg): pass",pass,51 "A python book Beginning python, advanced python, and python exercises","In [104]: class A: .....: pass",pass,60 "A python book Beginning python, advanced python, and python exercises","In [21]: class A(object): ....: pass",pass,60 "A python book Beginning python, advanced python, and python exercises","def __init__(self): pass",pass,117 "A python book Beginning python, advanced python, and python exercises",">>> class A(object): ... pass",pass,191 "A python book Beginning python, advanced python, and python exercises","func(arg1, arg2): pass",pass,225 "A python book Beginning python, advanced python, and python exercises","def func(arg1, arg2): pass",pass,225 "A python book Beginning python, advanced python, and python exercises","func(arg1, arg2): pass",pass,226 "A python book Beginning python, advanced python, and python exercises","def func(arg1, arg2): pass",pass,226 "A python book Beginning python, advanced python, and python exercises","func(arg1, arg2, ...): pass",pass,227 "A python book Beginning python, advanced python, and python exercises","def func(arg1, arg2, ...): pass",pass,227 "A python book Beginning python, advanced python, and python exercises",for x in [y for y in range(10) if y % 2 == 0]:,forwithlist,38 "A python book Beginning python, advanced python, and python exercises","posstr = ('(%d, %d)' % (position[1]",nestedTuple,123 "A python book Beginning python, advanced python, and python exercises","for child in self.get_children(): for level1, tree1 in child.walk_tree(level+1):",fornested,56 "A python book Beginning python, advanced python, and python exercises","for tree in trees: for tree in walk_tree(tree, level):",fornested,57 "A python book Beginning python, advanced python, and python exercises","for child in tree.get_children(): for level1, tree1 in walk_tree_recur(child, level+1):",fornested,57 "A python book Beginning python, advanced python, and python exercises","for row in rows: for idx, field in enumerate(row):",fornested,242 "A python book Beginning python, advanced python, and python exercises","In [115]: values = {'vegetable': 'chard', 'fruit': 'nectarine'}",simpleDict,16 "A python book Beginning python, advanced python, and python exercises","In [7]: values = {'name': 'dave', 'hobby': 'birding'}",simpleDict,18 "A python book Beginning python, advanced python, and python exercises","d2 = {key1: value1, key2: value2, }",simpleDict,20 "A python book Beginning python, advanced python, and python exercises","In [43]: d = {'aa': 111, 'bb': 222}",simpleDict,21 "A python book Beginning python, advanced python, and python exercises","In [47]: d = {'aa': 111, 'bb': 222}",simpleDict,21 "A python book Beginning python, advanced python, and python exercises","d = {'tomato': 101, 'cucumber': 102}",simpleDict,21 "A python book Beginning python, advanced python, and python exercises","d = {'tomato': 101, 'cucumber': 102}",simpleDict,21 "A python book Beginning python, advanced python, and python exercises","name_dict = {first: last, 'Elvis': 'Presley'}",simpleDict,22 "A python book Beginning python, advanced python, and python exercises","d = {'aa': 111, 'bb': 222, 'cc': 333}",simpleDict,22 "A python book Beginning python, advanced python, and python exercises","In [52]: mydict = {'peach': 'sweet', 'lemon': 'tangy'}",simpleDict,23 "A python book Beginning python, advanced python, and python exercises","In [14]: b = {'aa': 11, 'bb': 22}",simpleDict,28 "A python book Beginning python, advanced python, and python exercises","d = {'aa': 111, 'bb': 222}",simpleDict,34 "A python book Beginning python, advanced python, and python exercises","In [9]:d = {'aa': 111, 'bb': 222, 'cc': 333}",simpleDict,45 "A python book Beginning python, advanced python, and python exercises","In [5]: d2 = {'width': 8.5, 'height': 11}",simpleDict,181 "A python book Beginning python, advanced python, and python exercises","In [6]: d3 = {1: 'RED', 2: 'GREEN', 3: 'BLUE', }",simpleDict,181 "A python book Beginning python, advanced python, and python exercises","In [6]: trees = {'poplar': 'deciduous', 'cedar': 'evergreen'}",simpleDict,182 "A python book Beginning python, advanced python, and python exercises","dic1 = {'albert': 'cute', }",simpleDict,203 "A python book Beginning python, advanced python, and python exercises","a = {'aa': 11, 'bb': 22, }",simpleDict,208 "A python book Beginning python, advanced python, and python exercises","a = {'aa': 11, 'bb': 22, }",simpleDict,208 "A python book Beginning python, advanced python, and python exercises",codecs.open(),openfunc,20 "A python book Beginning python, advanced python, and python exercises","infile = open('infile1.txt', 'r', encoding='utf-8')",openfunc,20 "A python book Beginning python, advanced python, and python exercises","outfile = open('outfile1.txt', 'w', encoding='utf-8')",openfunc,20 "A python book Beginning python, advanced python, and python exercises","In [28]: f = open('mylog.txt', 'w')",openfunc,23 "A python book Beginning python, advanced python, and python exercises","Use the (built-in) open(path, mode)",openfunc,23 "A python book Beginning python, advanced python, and python exercises","object. You could also use file(), but open()",openfunc,23 "A python book Beginning python, advanced python, and python exercises","infile = open('myfile.txt', 'r')",openfunc,24 "A python book Beginning python, advanced python, and python exercises","outfile = open('myfile.txt', 'w') # open for (over-)",openfunc,24 "A python book Beginning python, advanced python, and python exercises","log = open('myfile.txt', 'a')",openfunc,24 "A python book Beginning python, advanced python, and python exercises","with open('small_file.txt', 'r')",openfunc,24 "A python book Beginning python, advanced python, and python exercises","about modes, see the description of the open()",openfunc,25 "A python book Beginning python, advanced python, and python exercises","In [39]: f = open('mylog.txt', 'a')",openfunc,25 "A python book Beginning python, advanced python, and python exercises","In [63]: outfile = open('tmp1.zip', 'wb')",openfunc,25 "A python book Beginning python, advanced python, and python exercises","In [55]: f = open('tmp1.txt', 'r')",openfunc,26 "A python book Beginning python, advanced python, and python exercises","In [1]: outfile = open('tmp.log', 'w')",openfunc,33 "A python book Beginning python, advanced python, and python exercises","In [6]: infile = open('tmp.log', 'r')",openfunc,33 "A python book Beginning python, advanced python, and python exercises",Create a file object. Use open(),openfunc,69 "A python book Beginning python, advanced python, and python exercises","infile = open(infileName, ""r"")",openfunc,123 "A python book Beginning python, advanced python, and python exercises",The open(),openfunc,186 "A python book Beginning python, advanced python, and python exercises","outfile = open(infilename, 'w')",openfunc,186 "A python book Beginning python, advanced python, and python exercises","infile = open(infilename, 'r')",openfunc,186 "A python book Beginning python, advanced python, and python exercises","outfile = open(infilename, 'a')",openfunc,186 "A python book Beginning python, advanced python, and python exercises","infile = open(infilename, 'r')",openfunc,186 "A python book Beginning python, advanced python, and python exercises",1. Use the open(),openfunc,187 "A python book Beginning python, advanced python, and python exercises","infile = open('tmp.txt', 'r')",openfunc,187 "A python book Beginning python, advanced python, and python exercises","infile = open('tmp.txt', 'r')",openfunc,187 "A python book Beginning python, advanced python, and python exercises","infile = open(infilename, 'r')",openfunc,187 "A python book Beginning python, advanced python, and python exercises",f = urllib.urlopen(url),openfunc,194 "A python book Beginning python, advanced python, and python exercises",f = urllib.urlopen(url),openfunc,195 "A python book Beginning python, advanced python, and python exercises",f = urllib.urlopen(url),openfunc,213 "A python book Beginning python, advanced python, and python exercises",f = urllib.urlopen(url),openfunc,231 "A python book Beginning python, advanced python, and python exercises",infile = open(infilename),openfunc,246 "A python book Beginning python, advanced python, and python exercises",infile = open('test1.yaml'),openfunc,248 "A python book Beginning python, advanced python, and python exercises",infile = open('test1.yaml'),openfunc,248 "A python book Beginning python, advanced python, and python exercises","infile = open('test1.yaml', 'r')",openfunc,248 "A python book Beginning python, advanced python, and python exercises","outfile = open('test1_new.yaml', 'w')",openfunc,248 "A python book Beginning python, advanced python, and python exercises","fout = open('tmpdata.json', 'w')",openfunc,249 "A python book Beginning python, advanced python, and python exercises","fin = open('tmpdata.json', 'r')",openfunc,250 "A python book Beginning python, advanced python, and python exercises",outfile.write(line),write,20 "A python book Beginning python, advanced python, and python exercises",In [29]: f.write('message #1\n'),write,23 "A python book Beginning python, advanced python, and python exercises",In [30]: f.write('message #2\n'),write,23 "A python book Beginning python, advanced python, and python exercises",In [31]: f.write('message #3\n'),write,23 "A python book Beginning python, advanced python, and python exercises",outfile.write('line: %s' % line.upper()),write,24 "A python book Beginning python, advanced python, and python exercises",In [40]: f.write('message #4\n'),write,25 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('hello\n'),write,33 "A python book Beginning python, advanced python, and python exercises","def write(self, msg)",write,33 "A python book Beginning python, advanced python, and python exercises",self.out_file.write('[[%s]]' % msg),write,33 "A python book Beginning python, advanced python, and python exercises",outfile.write('%s\n' % line.upper()),write,44 "A python book Beginning python, advanced python, and python exercises",f.write(ch * 10),write,70 "A python book Beginning python, advanced python, and python exercises",f.write('\n'),write,70 "A python book Beginning python, advanced python, and python exercises",outfile.write('%s\n' % line.translate(tran_table)),write,70 "A python book Beginning python, advanced python, and python exercises","outFile.write('<?xml version=""1.0"" ?>\n')",write,98 "A python book Beginning python, advanced python, and python exercises","sys.stderr.write('Lexer error (%d, %d)",write,134 "A python book Beginning python, advanced python, and python exercises","sys.stderr.write('Parser error (%d, %d)",write,134 "A python book Beginning python, advanced python, and python exercises",outfile.write('line 1\n'),write,186 "A python book Beginning python, advanced python, and python exercises",outfile.write('line 2\n'),write,186 "A python book Beginning python, advanced python, and python exercises",outfile.write('line 3\n'),write,186 "A python book Beginning python, advanced python, and python exercises",outfile.write('line 4\n'),write,186 "A python book Beginning python, advanced python, and python exercises",convenient way of producing output than using sys.stdout.write(),write,191 "A python book Beginning python, advanced python, and python exercises",outfile.write(msg),write,203 "A python book Beginning python, advanced python, and python exercises",outfile.write(line),write,204 "A python book Beginning python, advanced python, and python exercises",fout.write(content),write,249 "A python book Beginning python, advanced python, and python exercises",fout.write('\n'),write,250 "A python book Beginning python, advanced python, and python exercises",outfile.write('Starting fancy export'),write,256 "A python book Beginning python, advanced python, and python exercises","sys.stdout.write('<?xml version=""1.0"" ?>\n')",write,264 "A python book Beginning python, advanced python, and python exercises","sys.stdout.write('<?xml version=""1.0"" ?>\n')",write,264 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('#from member_specs_api import *\n\n'),write,265 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('import member_specs_api as model_\n\n'),write,265 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('rootObj = model_.contact_list(\n'),write,265 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write(')\n'),write,265 "A python book Beginning python, advanced python, and python exercises","sys.stdout.write('<?xml version=""1.0"" ?>\n')",write,266 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('-' * 60),write,266 "A python book Beginning python, advanced python, and python exercises",sys.stdout.write('\n'),write,266 "A python book Beginning python, advanced python, and python exercises",content = tmp_file.read(),read,33 "A python book Beginning python, advanced python, and python exercises",Other ways of reading from a file/stream object: my_file.read(),read,70 "A python book Beginning python, advanced python, and python exercises",result = outfile.read(),read,72 "A python book Beginning python, advanced python, and python exercises",result = outfile.read(),read,72 "A python book Beginning python, advanced python, and python exercises",result = outfile.read(),read,73 "A python book Beginning python, advanced python, and python exercises",inContent = inFile.read(),read,98 "A python book Beginning python, advanced python, and python exercises","The call ""scanner.read()"" gets the next token. It returns a tuple containing (1)",read,124 "A python book Beginning python, advanced python, and python exercises",content = infile.read(),read,136 "A python book Beginning python, advanced python, and python exercises",content = infile.read(),read,187 "A python book Beginning python, advanced python, and python exercises",stuff = f.read(),read,194 "A python book Beginning python, advanced python, and python exercises",stuff = f.read(),read,195 "A python book Beginning python, advanced python, and python exercises",stuff = f.read(),read,213 "A python book Beginning python, advanced python, and python exercises",content = f.read(),read,231 "A python book Beginning python, advanced python, and python exercises",data_str = infile.read(),read,248 "A python book Beginning python, advanced python, and python exercises",content = fin.read(),read,250 "A python book Beginning python, advanced python, and python exercises","my_file.readline(), my_file.readlines()",readline,70 "A python book Beginning python, advanced python, and python exercises",import it,importfunc,2 "A python book Beginning python, advanced python, and python exercises",import urllib,importfunc,2 "A python book Beginning python, advanced python, and python exercises",import this,importfunc,6 "A python book Beginning python, advanced python, and python exercises","import Page",importfunc,8 "A python book Beginning python, advanced python, and python exercises",import string,importfunc,17 "A python book Beginning python, advanced python, and python exercises",import types,importfunc,18 "A python book Beginning python, advanced python, and python exercises",import zipfile,importfunc,25 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,30 "A python book Beginning python, advanced python, and python exercises",import looks,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import looks,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import imp,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import A,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import A,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import module,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,31 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,32 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,32 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,32 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,33 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,33 "A python book Beginning python, advanced python, and python exercises",import func1,importfunc,60 "A python book Beginning python, advanced python, and python exercises",import mypackage,importfunc,60 "A python book Beginning python, advanced python, and python exercises",import pdb,importfunc,68 "A python book Beginning python, advanced python, and python exercises",import pdb,importfunc,69 "A python book Beginning python, advanced python, and python exercises",import inspect,importfunc,69 "A python book Beginning python, advanced python, and python exercises",import string,importfunc,70 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,71 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,71 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,72 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,72 "A python book Beginning python, advanced python, and python exercises",import pdb,importfunc,74 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,75 "A python book Beginning python, advanced python, and python exercises",import doctest,importfunc,77 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,78 "A python book Beginning python, advanced python, and python exercises",import sqlite3,importfunc,78 "A python book Beginning python, advanced python, and python exercises",import module,importfunc,82 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,98 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,98 "A python book Beginning python, advanced python, and python exercises",import unittest,importfunc,98 "A python book Beginning python, advanced python, and python exercises",import webserv_example_heavy_sub,importfunc,98 "A python book Beginning python, advanced python, and python exercises",import from,importfunc,104 "A python book Beginning python, advanced python, and python exercises",import MyLibrary,importfunc,105 "A python book Beginning python, advanced python, and python exercises",import string,importfunc,106 "A python book Beginning python, advanced python, and python exercises",import python_201_pyrex_primes,importfunc,108 "A python book Beginning python, advanced python, and python exercises",import python_201_pyrex_clsprimes,importfunc,110 "A python book Beginning python, advanced python, and python exercises",import python_201_pyrex_clsprimes,importfunc,111 "A python book Beginning python, advanced python, and python exercises",import test_c,importfunc,112 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,115 "A python book Beginning python, advanced python, and python exercises",import string,importfunc,115 "A python book Beginning python, advanced python, and python exercises",import types,importfunc,115 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,115 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,122 "A python book Beginning python, advanced python, and python exercises",import Plex,importfunc,122 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,125 "A python book Beginning python, advanced python, and python exercises",import Plex,importfunc,125 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,133 "A python book Beginning python, advanced python, and python exercises",import types,importfunc,133 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,133 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,139 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,141 "A python book Beginning python, advanced python, and python exercises",import pprint,importfunc,143 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,145 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,145 "A python book Beginning python, advanced python, and python exercises",import gtk,importfunc,145 "A python book Beginning python, advanced python, and python exercises",import gtk,importfunc,146 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,147 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,147 "A python book Beginning python, advanced python, and python exercises",import gtk,importfunc,147 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,149 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,149 "A python book Beginning python, advanced python, and python exercises",import gtk,importfunc,149 "A python book Beginning python, advanced python, and python exercises",import pdb,importfunc,150 "A python book Beginning python, advanced python, and python exercises",import easygui,importfunc,152 "A python book Beginning python, advanced python, and python exercises",import easygui,importfunc,152 "A python book Beginning python, advanced python, and python exercises",import individual,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import and,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import individual,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import the,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import testpackages,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import testpackages,importfunc,153 "A python book Beginning python, advanced python, and python exercises",import the,importfunc,154 "A python book Beginning python, advanced python, and python exercises",import print,importfunc,157 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,161 "A python book Beginning python, advanced python, and python exercises",import os,importfunc,176 "A python book Beginning python, advanced python, and python exercises",import os,importfunc,176 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,179 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,179 "A python book Beginning python, advanced python, and python exercises",import types,importfunc,180 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,187 "A python book Beginning python, advanced python, and python exercises",import urllib,importfunc,194 "A python book Beginning python, advanced python, and python exercises",import urllib,importfunc,195 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,203 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,204 "A python book Beginning python, advanced python, and python exercises",import urllib,importfunc,213 "A python book Beginning python, advanced python, and python exercises",import our,importfunc,216 "A python book Beginning python, advanced python, and python exercises",import urllib,importfunc,230 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,233 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,234 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,235 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,236 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,237 "A python book Beginning python, advanced python, and python exercises",import os,importfunc,237 "A python book Beginning python, advanced python, and python exercises",import getopt,importfunc,237 "A python book Beginning python, advanced python, and python exercises",import time,importfunc,238 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,239 "A python book Beginning python, advanced python, and python exercises",import gadfly,importfunc,241 "A python book Beginning python, advanced python, and python exercises",import gadfly,importfunc,241 "A python book Beginning python, advanced python, and python exercises",import gadfly,importfunc,242 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,243 "A python book Beginning python, advanced python, and python exercises",import sqlite3,importfunc,243 "A python book Beginning python, advanced python, and python exercises",import csv,importfunc,246 "A python book Beginning python, advanced python, and python exercises",import yaml,importfunc,248 "A python book Beginning python, advanced python, and python exercises",import pprint,importfunc,248 "A python book Beginning python, advanced python, and python exercises",import pprint,importfunc,248 "A python book Beginning python, advanced python, and python exercises",import yaml,importfunc,248 "A python book Beginning python, advanced python, and python exercises",import pprint,importfunc,248 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,253 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,255 "A python book Beginning python, advanced python, and python exercises",import the,importfunc,255 "A python book Beginning python, advanced python, and python exercises",import statement,importfunc,255 "A python book Beginning python, advanced python, and python exercises",import your,importfunc,257 "A python book Beginning python, advanced python, and python exercises",import your,importfunc,257 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,261 "A python book Beginning python, advanced python, and python exercises",import member_specs_upper,importfunc,266 "A python book Beginning python, advanced python, and python exercises",import garden_api,importfunc,269 "A python book Beginning python, advanced python, and python exercises",import sys,importfunc,269 "A python book Beginning python, advanced python, and python exercises",from A import B,importfromsimple,31 "A python book Beginning python, advanced python, and python exercises",from A.B import C -- (1) Possibly import object,importfromsimple,31 "A python book Beginning python, advanced python, and python exercises","from a module from the standard library, for example import compile",importfromsimple,32 "A python book Beginning python, advanced python, and python exercises",from simplepackage import simple,importfromsimple,32 "A python book Beginning python, advanced python, and python exercises",from simplepackage.simple import test1,importfromsimple,32 "A python book Beginning python, advanced python, and python exercises",from IPython.Shell import IPShellEmbed,importfromsimple,116 "A python book Beginning python, advanced python, and python exercises",from IPython.Shell import IPShellEmbed,importfromsimple,125 "A python book Beginning python, advanced python, and python exercises",from distutils.core import setup,importfromsimple,154 "A python book Beginning python, advanced python, and python exercises",from xml.dom import minidom,importfromsimple,234 "A python book Beginning python, advanced python, and python exercises",from lxml import etree,importfromsimple,236 "A python book Beginning python, advanced python, and python exercises",from lxml import etree,importfromsimple,238 "A python book Beginning python, advanced python, and python exercises",from lxml import etree,importfromsimple,239 "A python book Beginning python, advanced python, and python exercises","from a string: import yaml",importfromsimple,248 "A python book Beginning python, advanced python, and python exercises",from StringIO import StringIO,importfromsimple,264 "A python book Beginning python, advanced python, and python exercises","self.out_file = file(file_name, 'a')",simpleattr,33 "A python book Beginning python, advanced python, and python exercises","self.data = [11,22,33]",simpleattr,36 "A python book Beginning python, advanced python, and python exercises",self.idx = 0,simpleattr,36 "A python book Beginning python, advanced python, and python exercises",self.idx +=1,simpleattr,36 "A python book Beginning python, advanced python, and python exercises",self.first = first,simpleattr,52 "A python book Beginning python, advanced python, and python exercises",self.last = last,simpleattr,52 "A python book Beginning python, advanced python, and python exercises",self.initlevel = 0,simpleattr,56 "A python book Beginning python, advanced python, and python exercises",self.data = data,simpleattr,56 "A python book Beginning python, advanced python, and python exercises",self.children = children,simpleattr,56 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,61 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,62 "A python book Beginning python, advanced python, and python exercises",self.items = items,simpleattr,62 "A python book Beginning python, advanced python, and python exercises",self.items = items,simpleattr,62 "A python book Beginning python, advanced python, and python exercises",self.size = size,simpleattr,63 "A python book Beginning python, advanced python, and python exercises",self._description = description,simpleattr,65 "A python book Beginning python, advanced python, and python exercises",self._description = description,simpleattr,65 "A python book Beginning python, advanced python, and python exercises",self._description = description,simpleattr,65 "A python book Beginning python, advanced python, and python exercises",self._description = description,simpleattr,66 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,67 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,68 "A python book Beginning python, advanced python, and python exercises",self.desc = desc,simpleattr,68 "A python book Beginning python, advanced python, and python exercises",self.failUnless(len(result) == 0),simpleattr,72 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,91 "A python book Beginning python, advanced python, and python exercises",self.value = value,simpleattr,91 "A python book Beginning python, advanced python, and python exercises",self.children = children,simpleattr,91 "A python book Beginning python, advanced python, and python exercises",self.children = children,simpleattr,92 "A python book Beginning python, advanced python, and python exercises",self.seq = seq,simpleattr,93 "A python book Beginning python, advanced python, and python exercises",self.idx = 0,simpleattr,93 "A python book Beginning python, advanced python, and python exercises",self.idx += 1,simpleattr,93 "A python book Beginning python, advanced python, and python exercises",self.idx += 1,simpleattr,94 "A python book Beginning python, advanced python, and python exercises",self.idx = 0,simpleattr,94 "A python book Beginning python, advanced python, and python exercises",self.seq = seq,simpleattr,95 "A python book Beginning python, advanced python, and python exercises",self.iterator = self._next(),simpleattr,95 "A python book Beginning python, advanced python, and python exercises",self.next = self.iterator.next,simpleattr,95 "A python book Beginning python, advanced python, and python exercises",self.iterator = self._next(),simpleattr,95 "A python book Beginning python, advanced python, and python exercises",self.next = self.iterator.next,simpleattr,95 "A python book Beginning python, advanced python, and python exercises",self.iterator = self._next(),simpleattr,96 "A python book Beginning python, advanced python, and python exercises",self.next = self.iterator.next,simpleattr,96 "A python book Beginning python, advanced python, and python exercises",self.failUnless(inContent == outContent),simpleattr,98 "A python book Beginning python, advanced python, and python exercises",self.nodeType = nodeType,simpleattr,116 "A python book Beginning python, advanced python, and python exercises",self.children = [],simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.infileName = infileName,simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.tokens = None,simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.tokenType = NoneTokType,simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.token = '',simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.lineNo = -1,simpleattr,117 "A python book Beginning python, advanced python, and python exercises","self.infile = file(self.infileName, 'r')",simpleattr,117 "A python book Beginning python, advanced python, and python exercises",self.tokens = genTokens(self.infile),simpleattr,117 "A python book Beginning python, advanced python, and python exercises","self.tokenType, self.token, self.lineNo = self.tokens.next()",simpleattr,119 "A python book Beginning python, advanced python, and python exercises",self.lineNo = lineNo,simpleattr,119 "A python book Beginning python, advanced python, and python exercises",self.msg = msg,simpleattr,119 "A python book Beginning python, advanced python, and python exercises",self.nodeType = nodeType,simpleattr,126 "A python book Beginning python, advanced python, and python exercises",self.children = [],simpleattr,126 "A python book Beginning python, advanced python, and python exercises",self.tokens = None,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.tokenType = NoneTokType,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.token = '',simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.lineNo = -1,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.infile = None,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.tokens = None,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.tokens = None,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.tokenType = NoneTokType,simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.token = '',simpleattr,127 "A python book Beginning python, advanced python, and python exercises",self.lineNo = -1,simpleattr,127 "A python book Beginning python, advanced python, and python exercises","self.infile = file(infileName, 'r')",simpleattr,127 "A python book Beginning python, advanced python, and python exercises","self.tokens = genTokens(self.infile, infileName)",simpleattr,127 "A python book Beginning python, advanced python, and python exercises","self.tokenType, self.token, self.lineNo = self.tokens.next()",simpleattr,128 "A python book Beginning python, advanced python, and python exercises","self.tokenType, self.token, self.lineNo = \",simpleattr,128 "A python book Beginning python, advanced python, and python exercises","self.tokenType, self.token, self.lineNo = self.tokens.next()",simpleattr,128 "A python book Beginning python, advanced python, and python exercises",self.lineNo = lineNo,simpleattr,129 "A python book Beginning python, advanced python, and python exercises",self.msg = msg,simpleattr,129 "A python book Beginning python, advanced python, and python exercises",self.nodeType = nodeType,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.children = [],simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.msg = msg,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.lineno = lineno,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.columnno = columnno,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.msg = msg,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.lineno = lineno,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.columnno = columnno,simpleattr,134 "A python book Beginning python, advanced python, and python exercises",self.ret = None,simpleattr,145 "A python book Beginning python, advanced python, and python exercises","self.ret = button.get_data(""user_data"")",simpleattr,145 "A python book Beginning python, advanced python, and python exercises",self.entry = gtk.Entry(),simpleattr,147 "A python book Beginning python, advanced python, and python exercises",self.ret = None,simpleattr,148 "A python book Beginning python, advanced python, and python exercises",self.ret = self.entry.get_text(),simpleattr,148 "A python book Beginning python, advanced python, and python exercises",self.multiple = multiple,simpleattr,149 "A python book Beginning python, advanced python, and python exercises",self.ret = None,simpleattr,149 "A python book Beginning python, advanced python, and python exercises",self.ret = self.get_filename(),simpleattr,150 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,215 "A python book Beginning python, advanced python, and python exercises",self.size = size,simpleattr,215 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,216 "A python book Beginning python, advanced python, and python exercises",self.children = children,simpleattr,216 "A python book Beginning python, advanced python, and python exercises",self.height = height,simpleattr,217 "A python book Beginning python, advanced python, and python exercises",self.color = color,simpleattr,217 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,219 "A python book Beginning python, advanced python, and python exercises",self.left_branch = left_branch,simpleattr,219 "A python book Beginning python, advanced python, and python exercises",self.right_branch = right_branch,simpleattr,219 "A python book Beginning python, advanced python, and python exercises",self.data = data,simpleattr,220 "A python book Beginning python, advanced python, and python exercises",self.children = children,simpleattr,220 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,222 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,223 "A python book Beginning python, advanced python, and python exercises",self.name = name,simpleattr,224 "A python book Beginning python, advanced python, and python exercises",self.urls = urls,simpleattr,230 "A python book Beginning python, advanced python, and python exercises",self.current_index = 0,simpleattr,230 "A python book Beginning python, advanced python, and python exercises",self.current_index = 0,simpleattr,230 "A python book Beginning python, advanced python, and python exercises",self.current_index += 1,simpleattr,231 "A python book Beginning python, advanced python, and python exercises",self.level = 0,simpleattr,233 "A python book Beginning python, advanced python, and python exercises",self.level += 1,simpleattr,233 "A python book Beginning python, advanced python, and python exercises",self.level -= 1,simpleattr,233 "A python book Beginning python, advanced python, and python exercises",self.level += 1,simpleattr,233 "A python book Beginning python, advanced python, and python exercises",self.level -= 1,simpleattr,233 "A python book Beginning python, advanced python, and python exercises","Try: list1 + list2, list1 * n, list1 += list2, etc.",assignIncrement,13 "A python book Beginning python, advanced python, and python exercises","Incrementally building up large strings from lots of small strings -- the new way -- The += operation on strings has been optimized. So, when you do this str1 += str2,",assignIncrement,17 "A python book Beginning python, advanced python, and python exercises",index += 1,assignIncrement,29 "A python book Beginning python, advanced python, and python exercises",index += 5,assignIncrement,29 "A python book Beginning python, advanced python, and python exercises",index += f(x),assignIncrement,29 "A python book Beginning python, advanced python, and python exercises",A.count += 1,assignIncrement,64 "A python book Beginning python, advanced python, and python exercises",level += 1,assignIncrement,117 "A python book Beginning python, advanced python, and python exercises",lineNo += 1,assignIncrement,119 "A python book Beginning python, advanced python, and python exercises",scanner.line_count += 1,assignIncrement,123 "A python book Beginning python, advanced python, and python exercises",level += 1,assignIncrement,126 "A python book Beginning python, advanced python, and python exercises",level += 1,assignIncrement,134 "A python book Beginning python, advanced python, and python exercises","t.lineno += t.value.count(""\n"")",assignIncrement,135 "A python book Beginning python, advanced python, and python exercises","And, augmented assignment (+= and *=) also work.",assignIncrement,175 "A python book Beginning python, advanced python, and python exercises",1. The += operator increments the value of an integer:,assignIncrement,189 "A python book Beginning python, advanced python, and python exercises",count += 1,assignIncrement,189 "A python book Beginning python, advanced python, and python exercises",count += 1,assignIncrement,189 "A python book Beginning python, advanced python, and python exercises",2. The += operator appends characters to the end of a string:,assignIncrement,189 "A python book Beginning python, advanced python, and python exercises",3. The += operator appends items in one list to another:,assignIncrement,190 "A python book Beginning python, advanced python, and python exercises",In [22]: a += b,assignIncrement,190 "A python book Beginning python, advanced python, and python exercises",count += n,assignIncrement,195 "A python book Beginning python, advanced python, and python exercises",b[idx] += value,assignIncrement,196 "A python book Beginning python, advanced python, and python exercises",sum += item,assignIncrement,198 "A python book Beginning python, advanced python, and python exercises",sum += value,assignIncrement,201 "A python book Beginning python, advanced python, and python exercises",level += 1,assignIncrement,210 "A python book Beginning python, advanced python, and python exercises",indent += 1,assignIncrement,216 "A python book Beginning python, advanced python, and python exercises",indent += 1,assignIncrement,217 "A python book Beginning python, advanced python, and python exercises",indent += 1,assignIncrement,217 "A python book Beginning python, advanced python, and python exercises",level += 1,assignIncrement,220 "A python book Beginning python, advanced python, and python exercises",CountInstances.instance_count += 1,assignIncrement,222 "A python book Beginning python, advanced python, and python exercises",CountInstances.instance_count += 1,assignIncrement,223 "A python book Beginning python, advanced python, and python exercises",CountInstances.instance_count += 1,assignIncrement,224 "A python book Beginning python, advanced python, and python exercises",count += 1,assignIncrement,235 "A python book Beginning python, advanced python, and python exercises",def test(size=0):,funcdefault,48 "A python book Beginning python, advanced python, and python exercises","def walk(self, level=0):",funcdefault,92 "A python book Beginning python, advanced python, and python exercises","def walk(node, level=0):",funcdefault,92 "A python book Beginning python, advanced python, and python exercises","def quit(self, w=None, event=None):",funcdefault,148 "A python book Beginning python, advanced python, and python exercises","def file_sel_box(title=""Browse"", modal=False, multiple=True):",funcdefault,150 "A python book Beginning python, advanced python, and python exercises",def file_open_box(modal=True):,funcdefault,150 "A python book Beginning python, advanced python, and python exercises",def file_save_box(modal=True):,funcdefault,150 "A python book Beginning python, advanced python, and python exercises","def sample_func(arg1, arg2, arg3='empty', arg4=0):",funcdefault,202 "A python book Beginning python, advanced python, and python exercises","def sample_func(arg1, arg2=[]):",funcdefault,202 "A python book Beginning python, advanced python, and python exercises","def sample_func(arg1, arg2=None):",funcdefault,202 "A python book Beginning python, advanced python, and python exercises","def adder(a, b=[]):",funcdefault,202 "A python book Beginning python, advanced python, and python exercises","def writer(outfile, msg='\n'):",funcdefault,203 "A python book Beginning python, advanced python, and python exercises","def add_to_dict(name, value, dic=None):",funcdefault,203 "A python book Beginning python, advanced python, and python exercises","def walk_and_show(node, level=0):",funcdefault,210 "A python book Beginning python, advanced python, and python exercises","def show(self, indent=0):",funcdefault,216 "A python book Beginning python, advanced python, and python exercises","def show(self, indent=0):",funcdefault,217 "A python book Beginning python, advanced python, and python exercises","def show(self, indent=0):",funcdefault,217 "A python book Beginning python, advanced python, and python exercises","def show(self, level=0):",funcdefault,219 "A python book Beginning python, advanced python, and python exercises","def show(self, level=''):",funcdefault,220 "A python book Beginning python, advanced python, and python exercises",range() and xrange(),rangefunc,12 "A python book Beginning python, advanced python, and python exercises",range(n),rangefunc,13 "A python book Beginning python, advanced python, and python exercises","range([start,] stop[, step])",rangefunc,37 "A python book Beginning python, advanced python, and python exercises",range() or xrange(),rangefunc,40 "A python book Beginning python, advanced python, and python exercises",range(),rangefunc,194 "A python book Beginning python, advanced python, and python exercises",range(),rangefunc,194 "A python book Beginning python, advanced python, and python exercises",range() instead of range(),rangefunc,194 "A python book Beginning python, advanced python, and python exercises",range(),rangefunc,194 "A python book Beginning python, advanced python, and python exercises",range() instead of range(),rangefunc,195 "A python book Beginning python, advanced python, and python exercises",range(3),rangefunc,262 "A python book Beginning python, advanced python, and python exercises",def show_tree(t):,simplefunc,15 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,17 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,20 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,24 "A python book Beginning python, advanced python, and python exercises",def close(self):,simplefunc,33 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,33 "A python book Beginning python, advanced python, and python exercises",def __iter__(self):,simplefunc,36 "A python book Beginning python, advanced python, and python exercises",def next(self):,simplefunc,36 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,36 "A python book Beginning python, advanced python, and python exercises",def get_args(self):,simplefunc,43 "A python book Beginning python, advanced python, and python exercises",def test(x):,simplefunc,43 "A python book Beginning python, advanced python, and python exercises",def __enter__(self):,simplefunc,43 "A python book Beginning python, advanced python, and python exercises",def fn():,simplefunc,48 "A python book Beginning python, advanced python, and python exercises",def t(x):,simplefunc,49 "A python book Beginning python, advanced python, and python exercises",def t():,simplefunc,50 "A python book Beginning python, advanced python, and python exercises",def s():,simplefunc,50 "A python book Beginning python, advanced python, and python exercises",def u():,simplefunc,50 "A python book Beginning python, advanced python, and python exercises",def v():,simplefunc,50 "A python book Beginning python, advanced python, and python exercises",def w():,simplefunc,50 "A python book Beginning python, advanced python, and python exercises",def wrapper(fn):,simplefunc,51 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,52 "A python book Beginning python, advanced python, and python exercises",def list_tripler(somelist):,simplefunc,54 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,54 "A python book Beginning python, advanced python, and python exercises",def get_data(self):,simplefunc,56 "A python book Beginning python, advanced python, and python exercises",def get_children(self):,simplefunc,56 "A python book Beginning python, advanced python, and python exercises",def __iter__(self):,simplefunc,56 "A python book Beginning python, advanced python, and python exercises",def show_level(level):,simplefunc,57 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,57 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,59 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,61 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,61 "A python book Beginning python, advanced python, and python exercises",def get_size(self):,simplefunc,63 "A python book Beginning python, advanced python, and python exercises",def dup_string(x):,simplefunc,64 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,64 "A python book Beginning python, advanced python, and python exercises",def inc_count():,simplefunc,64 "A python book Beginning python, advanced python, and python exercises",def dec_count():,simplefunc,65 "A python book Beginning python, advanced python, and python exercises",def get_count(self):,simplefunc,65 "A python book Beginning python, advanced python, and python exercises",def _get_description(self):,simplefunc,65 "A python book Beginning python, advanced python, and python exercises",def get_len(self):,simplefunc,66 "A python book Beginning python, advanced python, and python exercises",def get_len(self):,simplefunc,67 "A python book Beginning python, advanced python, and python exercises",def get_keys(self):,simplefunc,67 "A python book Beginning python, advanced python, and python exercises",def get_name(self):,simplefunc,67 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,67 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,68 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,68 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,70 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,70 "A python book Beginning python, advanced python, and python exercises",def testFoo(self):,simplefunc,71 "A python book Beginning python, advanced python, and python exercises",def testBar01(self):,simplefunc,71 "A python book Beginning python, advanced python, and python exercises",def testBar02(self):,simplefunc,71 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,71 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,72 "A python book Beginning python, advanced python, and python exercises",def test_1_generate(self):,simplefunc,72 "A python book Beginning python, advanced python, and python exercises",def test_2_compare_superclasses(self):,simplefunc,72 "A python book Beginning python, advanced python, and python exercises",def test_3_compare_subclasses(self):,simplefunc,73 "A python book Beginning python, advanced python, and python exercises",def check_result(result):,simplefunc,73 "A python book Beginning python, advanced python, and python exercises",def suite():,simplefunc,73 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,73 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,74 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,74 "A python book Beginning python, advanced python, and python exercises",def testFoo(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def checkBar01(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def setUp(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def tearDown(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def testBar01(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def testBar02(self):,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def function_test_1():,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def make_suite():,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,75 "A python book Beginning python, advanced python, and python exercises",def _test():,simplefunc,77 "A python book Beginning python, advanced python, and python exercises",def f(n):,simplefunc,77 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,77 "A python book Beginning python, advanced python, and python exercises",def create_table(db_name):,simplefunc,78 "A python book Beginning python, advanced python, and python exercises",def retrieve(db_name):,simplefunc,79 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,79 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,83 "A python book Beginning python, advanced python, and python exercises",def repl_func(mo):,simplefunc,85 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,85 "A python book Beginning python, advanced python, and python exercises",def generateItems(seq):,simplefunc,89 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,91 "A python book Beginning python, advanced python, and python exercises",def iterchildren(self):,simplefunc,92 "A python book Beginning python, advanced python, and python exercises",def get_filler(level):,simplefunc,92 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,92 "A python book Beginning python, advanced python, and python exercises",def next(self):,simplefunc,93 "A python book Beginning python, advanced python, and python exercises",def __iter__(self):,simplefunc,94 "A python book Beginning python, advanced python, and python exercises",def refresh(self):,simplefunc,94 "A python book Beginning python, advanced python, and python exercises",def test_iteratorexample():,simplefunc,94 "A python book Beginning python, advanced python, and python exercises",def _next(self):,simplefunc,95 "A python book Beginning python, advanced python, and python exercises",def __iter__(self):,simplefunc,95 "A python book Beginning python, advanced python, and python exercises",def refresh(self):,simplefunc,95 "A python book Beginning python, advanced python, and python exercises",def test_yielditeratorexample():,simplefunc,95 "A python book Beginning python, advanced python, and python exercises",def f(x):,simplefunc,96 "A python book Beginning python, advanced python, and python exercises",def f(x):,simplefunc,97 "A python book Beginning python, advanced python, and python exercises",def test_one(self):,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def test_two(self):,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def suite():,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def test_import_export1(self):,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def suite():,simplefunc,98 "A python book Beginning python, advanced python, and python exercises",def test_main():,simplefunc,99 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,112 "A python book Beginning python, advanced python, and python exercises",def prog_reco(self):,simplefunc,118 "A python book Beginning python, advanced python, and python exercises",def func_call_list_reco(self):,simplefunc,118 "A python book Beginning python, advanced python, and python exercises",def getLineNo(self):,simplefunc,119 "A python book Beginning python, advanced python, and python exercises",def getMsg(self):,simplefunc,119 "A python book Beginning python, advanced python, and python exercises",def is_word(token):,simplefunc,119 "A python book Beginning python, advanced python, and python exercises",def genTokens(infile):,simplefunc,119 "A python book Beginning python, advanced python, and python exercises",def test(infileName):,simplefunc,119 "A python book Beginning python, advanced python, and python exercises",def test(infileName):,simplefunc,123 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,123 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,123 "A python book Beginning python, advanced python, and python exercises",def command_reco(self):,simplefunc,128 "A python book Beginning python, advanced python, and python exercises",def func_call_reco(self):,simplefunc,128 "A python book Beginning python, advanced python, and python exercises",def func_call_list_reco(self):,simplefunc,128 "A python book Beginning python, advanced python, and python exercises",def getLineNo(self):,simplefunc,129 "A python book Beginning python, advanced python, and python exercises",def getMsg(self):,simplefunc,129 "A python book Beginning python, advanced python, and python exercises",def test(infileName):,simplefunc,129 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,134 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,134 "A python book Beginning python, advanced python, and python exercises",def t_COMMENT(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def t_newline(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def t_error(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_prog(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_command_list_1(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_command_list_2(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_command(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_func_call_1(t):,simplefunc,135 "A python book Beginning python, advanced python, and python exercises",def p_func_call_2(t):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def p_func_call_list_1(t):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def p_func_call_list_2(t):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def p_term(t):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def p_error(t):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def parse(infileName):,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,136 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,137 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,139 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,141 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,142 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,143 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,146 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,146 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,146 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,148 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,148 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,148 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,150 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,150 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,150 "A python book Beginning python, advanced python, and python exercises",def testeasygui():,simplefunc,152 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,152 "A python book Beginning python, advanced python, and python exercises",def show_version():,simplefunc,160 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,160 "A python book Beginning python, advanced python, and python exercises",def show_version():,simplefunc,160 "A python book Beginning python, advanced python, and python exercises",def t(n):,simplefunc,171 "A python book Beginning python, advanced python, and python exercises",def t(n):,simplefunc,172 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,172 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,173 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,174 "A python book Beginning python, advanced python, and python exercises",def exercise1():,simplefunc,179 "A python book Beginning python, advanced python, and python exercises",def exercise2():,simplefunc,179 "A python book Beginning python, advanced python, and python exercises",def exercise3():,simplefunc,180 "A python book Beginning python, advanced python, and python exercises",def exercise4():,simplefunc,180 "A python book Beginning python, advanced python, and python exercises",def exercise5():,simplefunc,180 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,183 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,185 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,185 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,185 "A python book Beginning python, advanced python, and python exercises",def test(infilename):,simplefunc,186 "A python book Beginning python, advanced python, and python exercises",def test(infilename):,simplefunc,187 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,187 "A python book Beginning python, advanced python, and python exercises",def test(color):,simplefunc,192 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,193 "A python book Beginning python, advanced python, and python exercises",def walk(url_list):,simplefunc,194 "A python book Beginning python, advanced python, and python exercises",def walk(url_list):,simplefunc,195 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,195 "A python book Beginning python, advanced python, and python exercises",def test_while():,simplefunc,196 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,197 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,200 "A python book Beginning python, advanced python, and python exercises",def list_sum(values):,simplefunc,201 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,201 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,202 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,203 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,203 "A python book Beginning python, advanced python, and python exercises",def add_comment(line):,simplefunc,204 "A python book Beginning python, advanced python, and python exercises",def remove_comment(line):,simplefunc,204 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,204 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,205 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,206 "A python book Beginning python, advanced python, and python exercises",def fancy(obj):,simplefunc,207 "A python book Beginning python, advanced python, and python exercises",def plain(obj):,simplefunc,207 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,208 "A python book Beginning python, advanced python, and python exercises",def fancy(obj):,simplefunc,208 "A python book Beginning python, advanced python, and python exercises",def plain(obj):,simplefunc,208 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,208 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,210 "A python book Beginning python, advanced python, and python exercises",def isiterable(x):,simplefunc,212 "A python book Beginning python, advanced python, and python exercises",def iseven(n):,simplefunc,212 "A python book Beginning python, advanced python, and python exercises",def f(n):,simplefunc,212 "A python book Beginning python, advanced python, and python exercises",def g(n):,simplefunc,212 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,212 "A python book Beginning python, advanced python, and python exercises",def walk(url_list):,simplefunc,213 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,213 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,214 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,214 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,215 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,215 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,216 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,217 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,218 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,220 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,221 "A python book Beginning python, advanced python, and python exercises",def show_class(msg):,simplefunc,221 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,222 "A python book Beginning python, advanced python, and python exercises",def show_instance_count(cls):,simplefunc,222 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,222 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,223 "A python book Beginning python, advanced python, and python exercises",def show_instance_count():,simplefunc,223 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,223 "A python book Beginning python, advanced python, and python exercises",def method1(self):,simplefunc,224 "A python book Beginning python, advanced python, and python exercises",def method1(self):,simplefunc,224 "A python book Beginning python, advanced python, and python exercises",def show(self):,simplefunc,224 "A python book Beginning python, advanced python, and python exercises",def show_instance_count(cls):,simplefunc,225 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,225 "A python book Beginning python, advanced python, and python exercises",def trace(func):,simplefunc,226 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,226 "A python book Beginning python, advanced python, and python exercises",def trace(msg):,simplefunc,227 "A python book Beginning python, advanced python, and python exercises",def inner1(func):,simplefunc,227 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,227 "A python book Beginning python, advanced python, and python exercises",def trace(msg):,simplefunc,228 "A python book Beginning python, advanced python, and python exercises",def inner1(func):,simplefunc,228 "A python book Beginning python, advanced python, and python exercises",def horizontal_line(func):,simplefunc,228 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,228 "A python book Beginning python, advanced python, and python exercises",def trace(msg):,simplefunc,228 "A python book Beginning python, advanced python, and python exercises",def inner1(func):,simplefunc,229 "A python book Beginning python, advanced python, and python exercises",def horizontal_line(line_chr):,simplefunc,229 "A python book Beginning python, advanced python, and python exercises",def inner1(func):,simplefunc,229 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,229 "A python book Beginning python, advanced python, and python exercises",def isiterable(x):,simplefunc,230 "A python book Beginning python, advanced python, and python exercises",def __iter__(self):,simplefunc,230 "A python book Beginning python, advanced python, and python exercises",def next(self):,simplefunc,231 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,231 "A python book Beginning python, advanced python, and python exercises",def startDocument(self):,simplefunc,233 "A python book Beginning python, advanced python, and python exercises",def endDocument(self):,simplefunc,233 "A python book Beginning python, advanced python, and python exercises",def test(infilename):,simplefunc,234 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,234 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,234 "A python book Beginning python, advanced python, and python exercises",def show_tree(doc):,simplefunc,234 "A python book Beginning python, advanced python, and python exercises",def show_level(level):,simplefunc,235 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,235 "A python book Beginning python, advanced python, and python exercises",def show_tree(doc):,simplefunc,235 "A python book Beginning python, advanced python, and python exercises",def show_level(level):,simplefunc,236 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,236 "A python book Beginning python, advanced python, and python exercises",def show_tree(doc):,simplefunc,236 "A python book Beginning python, advanced python, and python exercises",def show_level(level):,simplefunc,237 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,237 "A python book Beginning python, advanced python, and python exercises",def show_tree(doc):,simplefunc,238 "A python book Beginning python, advanced python, and python exercises",def show_level(level):,simplefunc,238 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,239 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,239 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,239 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,241 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,241 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,242 "A python book Beginning python, advanced python, and python exercises",def createdb():,simplefunc,243 "A python book Beginning python, advanced python, and python exercises",def showdb():,simplefunc,243 "A python book Beginning python, advanced python, and python exercises",def showdb1(cursor):,simplefunc,243 "A python book Beginning python, advanced python, and python exercises",def deletefromdb(name):,simplefunc,244 "A python book Beginning python, advanced python, and python exercises",def opendb():,simplefunc,245 "A python book Beginning python, advanced python, and python exercises",def hr():,simplefunc,245 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,245 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,245 "A python book Beginning python, advanced python, and python exercises",def test(infilename):,simplefunc,246 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,246 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,248 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,248 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,248 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,249 "A python book Beginning python, advanced python, and python exercises",def test():,simplefunc,250 "A python book Beginning python, advanced python, and python exercises",def test(names):,simplefunc,257 "A python book Beginning python, advanced python, and python exercises",def upcase_names(self):,simplefunc,258 "A python book Beginning python, advanced python, and python exercises",def upcase_names(self):,simplefunc,258 "A python book Beginning python, advanced python, and python exercises",def create_people(names):,simplefunc,259 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,259 "A python book Beginning python, advanced python, and python exercises",def upper_elements(obj):,simplefunc,263 "A python book Beginning python, advanced python, and python exercises",def remap(name):,simplefunc,263 "A python book Beginning python, advanced python, and python exercises",def upper(self):,simplefunc,263 "A python book Beginning python, advanced python, and python exercises",def upper(self):,simplefunc,263 "A python book Beginning python, advanced python, and python exercises",def get_root_tag(node):,simplefunc,264 "A python book Beginning python, advanced python, and python exercises",def parse(inFilename):,simplefunc,264 "A python book Beginning python, advanced python, and python exercises",def parseString(inString):,simplefunc,264 "A python book Beginning python, advanced python, and python exercises",def parseLiteral(inFilename):,simplefunc,264 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,265 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,265 "A python book Beginning python, advanced python, and python exercises",def process(inFilename):,simplefunc,266 "A python book Beginning python, advanced python, and python exercises",def usage():,simplefunc,266 "A python book Beginning python, advanced python, and python exercises",def main():,simplefunc,266 "A python book Beginning python, advanced python, and python exercises",return from function; (3) stuff into a,return,5 "A python book Beginning python, advanced python, and python exercises",return it from a function.,return,10 "A python book Beginning python, advanced python, and python exercises",return is not automatically added.,return,33 "A python book Beginning python, advanced python, and python exercises",return self,return,36 "A python book Beginning python, advanced python, and python exercises",return x,return,36 "A python book Beginning python, advanced python, and python exercises",return '::::'.join(self.args),return,43 "A python book Beginning python, advanced python, and python exercises",return 'some value or other' # usually we want to return,return,43 "A python book Beginning python, advanced python, and python exercises","return self,",return,44 "A python book Beginning python, advanced python, and python exercises","return a true value. Otherwise, the",return,44 "A python book Beginning python, advanced python, and python exercises",return statement is used to return values from a function.,return,46 "A python book Beginning python, advanced python, and python exercises","return statement takes zero or more values, separated by commas. Using commas",return,46 "A python book Beginning python, advanced python, and python exercises","return multiple values, use a tuple or list. Don't forget that (assignment) unpacking",return,46 "A python book Beginning python, advanced python, and python exercises","return x * 3, y * 4",return,46 "A python book Beginning python, advanced python, and python exercises",return them from a function.,return,48 "A python book Beginning python, advanced python, and python exercises","return a value, returns None.",return,48 "A python book Beginning python, advanced python, and python exercises",return '[[%s]]' % x,return,49 "A python book Beginning python, advanced python, and python exercises",return x,return,50 "A python book Beginning python, advanced python, and python exercises",return x,return,50 "A python book Beginning python, advanced python, and python exercises",return result,return,51 "A python book Beginning python, advanced python, and python exercises",return inner_fn,return,51 "A python book Beginning python, advanced python, and python exercises",return (like a function) multiple values.,return,52 "A python book Beginning python, advanced python, and python exercises",return the formatted name.,return,52 "A python book Beginning python, advanced python, and python exercises","return statement with no value.",return,55 "A python book Beginning python, advanced python, and python exercises",return self.initlevel,return,56 "A python book Beginning python, advanced python, and python exercises",return self.data,return,56 "A python book Beginning python, advanced python, and python exercises",return self.children,return,56 "A python book Beginning python, advanced python, and python exercises",return self.walk_tree(self.initlevel),return,56 "A python book Beginning python, advanced python, and python exercises",return a1,return,58 "A python book Beginning python, advanced python, and python exercises",return an iterator. They,return,58 "A python book Beginning python, advanced python, and python exercises",return A.size,return,63 "A python book Beginning python, advanced python, and python exercises",return s1,return,64 "A python book Beginning python, advanced python, and python exercises",return A.count,return,65 "A python book Beginning python, advanced python, and python exercises",return self._description,return,65 "A python book Beginning python, advanced python, and python exercises",return self._description,return,65 "A python book Beginning python, advanced python, and python exercises",return len(self),return,66 "A python book Beginning python, advanced python, and python exercises",return len(self),return,67 "A python book Beginning python, advanced python, and python exercises",return contentstr,return,67 "A python book Beginning python, advanced python, and python exercises",return self.name,return,67 "A python book Beginning python, advanced python, and python exercises",return flag1 and flag2,return,73 "A python book Beginning python, advanced python, and python exercises",return unittest.makeSuite(GenTest),return,73 "A python book Beginning python, advanced python, and python exercises",return testsuite,return,73 "A python book Beginning python, advanced python, and python exercises",return 0,return,75 "A python book Beginning python, advanced python, and python exercises",return suite,return,75 "A python book Beginning python, advanced python, and python exercises",return -10,return,77 "A python book Beginning python, advanced python, and python exercises",return 0,return,77 "A python book Beginning python, advanced python, and python exercises",return s2,return,85 "A python book Beginning python, advanced python, and python exercises",return the iterator; (2) the next() method should,return,88 "A python book Beginning python, advanced python, and python exercises",return the next item to be iterated over and when finished (there are no more,return,88 "A python book Beginning python, advanced python, and python exercises",return gen,return,91 "A python book Beginning python, advanced python, and python exercises",return self.name,return,92 "A python book Beginning python, advanced python, and python exercises",return self.value,return,92 "A python book Beginning python, advanced python, and python exercises",return ' ' * level,return,92 "A python book Beginning python, advanced python, and python exercises",return value,return,94 "A python book Beginning python, advanced python, and python exercises",return self,return,94 "A python book Beginning python, advanced python, and python exercises",return self.iterator,return,95 "A python book Beginning python, advanced python, and python exercises",return x * 3,return,96 "A python book Beginning python, advanced python, and python exercises",return x*3,return,97 "A python book Beginning python, advanced python, and python exercises",return testsuite,return,98 "A python book Beginning python, advanced python, and python exercises","return cmp(string.lower(arg1), string.lower(arg2))",return,98 "A python book Beginning python, advanced python, and python exercises",return testsuite,return,99 "A python book Beginning python, advanced python, and python exercises",return NULL;,return,101 "A python book Beginning python, advanced python, and python exercises",return NULL;,return,102 "A python book Beginning python, advanced python, and python exercises",return NULL;,return,102 "A python book Beginning python, advanced python, and python exercises",return a value:,return,103 "A python book Beginning python, advanced python, and python exercises",return (width * height);,return,106 "A python book Beginning python, advanced python, and python exercises",return (3.14 * radius * radius);,return,106 "A python book Beginning python, advanced python, and python exercises",return 123;,return,106 "A python book Beginning python, advanced python, and python exercises",return 1;,return,106 "A python book Beginning python, advanced python, and python exercises",return s4,return,107 "A python book Beginning python, advanced python, and python exercises",return result,return,108 "A python book Beginning python, advanced python, and python exercises",return result,return,109 "A python book Beginning python, advanced python, and python exercises",return result;,return,112 "A python book Beginning python, advanced python, and python exercises",return result,return,118 "A python book Beginning python, advanced python, and python exercises",return None,return,118 "A python book Beginning python, advanced python, and python exercises","return ASTNode(FuncCallListNodeType, terms)",return,119 "A python book Beginning python, advanced python, and python exercises",return self.lineNo,return,119 "A python book Beginning python, advanced python, and python exercises",return self.msg,return,119 "A python book Beginning python, advanced python, and python exercises",return 1,return,119 "A python book Beginning python, advanced python, and python exercises","return ASTNode(ProgNodeType, commandList)",return,128 "A python book Beginning python, advanced python, and python exercises","return ASTNode(CommandNodeType, result)",return,128 "A python book Beginning python, advanced python, and python exercises","return ASTNode(FuncCallNodeType, term,",return,128 "A python book Beginning python, advanced python, and python exercises",return None,return,128 "A python book Beginning python, advanced python, and python exercises","return ASTNode(FuncCallListNodeType, terms)",return,128 "A python book Beginning python, advanced python, and python exercises",return self.lineNo,return,129 "A python book Beginning python, advanced python, and python exercises",return self.msg,return,129 "A python book Beginning python, advanced python, and python exercises",return which button was pressed,return,145 "A python book Beginning python, advanced python, and python exercises",return win.ret,return,146 "A python book Beginning python, advanced python, and python exercises",return win.ret,return,148 "A python book Beginning python, advanced python, and python exercises",return win.ret,return,150 "A python book Beginning python, advanced python, and python exercises","return file_sel_box(""Open"", modal=modal, multiple=True)",return,150 "A python book Beginning python, advanced python, and python exercises","return file_sel_box(""Save As"", modal=modal, multiple=False)",return,150 "A python book Beginning python, advanced python, and python exercises","return def for lambda try",return,157 "A python book Beginning python, advanced python, and python exercises",return n * t(n - 1),return,171 "A python book Beginning python, advanced python, and python exercises",return n * t(n - 1),return,172 "A python book Beginning python, advanced python, and python exercises","return an arbitrary (key, value) pair",return,184 "A python book Beginning python, advanced python, and python exercises","return an iterator over (key, value) pairs",return,184 "A python book Beginning python, advanced python, and python exercises",return an iterator over the mapping's keys,return,184 "A python book Beginning python, advanced python, and python exercises",return an iterator over the mapping's values,return,184 "A python book Beginning python, advanced python, and python exercises","return True and False.",return,188 "A python book Beginning python, advanced python, and python exercises",return local_var1 + local_var2,return,201 "A python book Beginning python, advanced python, and python exercises",return statement enables us to return a value from a function:,return,201 "A python book Beginning python, advanced python, and python exercises",return sum,return,201 "A python book Beginning python, advanced python, and python exercises",return b,return,202 "A python book Beginning python, advanced python, and python exercises",return dic,return,203 "A python book Beginning python, advanced python, and python exercises",return line,return,204 "A python book Beginning python, advanced python, and python exercises",return line,return,204 "A python book Beginning python, advanced python, and python exercises","return value of a function satisfy some description, then we can say",return,207 "A python book Beginning python, advanced python, and python exercises",return each value. The function takes these arguments:,return,211 "A python book Beginning python, advanced python, and python exercises",return flag,return,212 "A python book Beginning python, advanced python, and python exercises",return n % 2 == 0,return,212 "A python book Beginning python, advanced python, and python exercises",return n * 2,return,212 "A python book Beginning python, advanced python, and python exercises",return n ** 2,return,212 "A python book Beginning python, advanced python, and python exercises",return inner,return,226 "A python book Beginning python, advanced python, and python exercises",return retval,return,227 "A python book Beginning python, advanced python, and python exercises",return inner2,return,227 "A python book Beginning python, advanced python, and python exercises",return inner1,return,227 "A python book Beginning python, advanced python, and python exercises",return result,return,227 "A python book Beginning python, advanced python, and python exercises",return content * 3,return,227 "A python book Beginning python, advanced python, and python exercises",return retval,return,228 "A python book Beginning python, advanced python, and python exercises",return inner2,return,228 "A python book Beginning python, advanced python, and python exercises",return inner1,return,228 "A python book Beginning python, advanced python, and python exercises",return retval,return,228 "A python book Beginning python, advanced python, and python exercises",return inner,return,228 "A python book Beginning python, advanced python, and python exercises",return result,return,228 "A python book Beginning python, advanced python, and python exercises",return content * 3,return,228 "A python book Beginning python, advanced python, and python exercises",return retval,return,229 "A python book Beginning python, advanced python, and python exercises",return inner2,return,229 "A python book Beginning python, advanced python, and python exercises",return inner1,return,229 "A python book Beginning python, advanced python, and python exercises",return retval,return,229 "A python book Beginning python, advanced python, and python exercises",return inner2,return,229 "A python book Beginning python, advanced python, and python exercises",return inner1,return,229 "A python book Beginning python, advanced python, and python exercises",return result,return,229 "A python book Beginning python, advanced python, and python exercises",return content * 3,return,229 "A python book Beginning python, advanced python, and python exercises",return False,return,230 "A python book Beginning python, advanced python, and python exercises",return True,return,230 "A python book Beginning python, advanced python, and python exercises",return self,return,230 "A python book Beginning python, advanced python, and python exercises",return content,return,231 "A python book Beginning python, advanced python, and python exercises",return count,return,235 "A python book Beginning python, advanced python, and python exercises","return connection, cursor",return,245 "A python book Beginning python, advanced python, and python exercises",return people,return,259 "A python book Beginning python, advanced python, and python exercises",return doc,return,263 "A python book Beginning python, advanced python, and python exercises",return newname,return,263 "A python book Beginning python, advanced python, and python exercises","return tag, rootClass",return,264 "A python book Beginning python, advanced python, and python exercises",return rootObj,return,264 "A python book Beginning python, advanced python, and python exercises",return rootObj,return,264 "A python book Beginning python, advanced python, and python exercises",return rootObj,return,265 "A python book Beginning python, advanced python, and python exercises",return rootObj,return,266 "A python book Beginning python, advanced python, and python exercises","if x: if y:",simpleif,4 "A python book Beginning python, advanced python, and python exercises","if not t: ....: return",simpleif,15 "A python book Beginning python, advanced python, and python exercises","if d.get('eggplant') is None: ... print 'missing'",simpleif,21 "A python book Beginning python, advanced python, and python exercises",if the key is missing. Example:,simpleif,22 "A python book Beginning python, advanced python, and python exercises","if key in mydict: ....: print mydict[key]",simpleif,23 "A python book Beginning python, advanced python, and python exercises","if flag is None: ... print 'clear'",simpleif,26 "A python book Beginning python, advanced python, and python exercises","if flag is not None: ... print 'hello'",simpleif,27 "A python book Beginning python, advanced python, and python exercises","if condition1: statements",simpleif,34 "A python book Beginning python, advanced python, and python exercises","if condition2: statements",simpleif,34 "A python book Beginning python, advanced python, and python exercises","if x is None: ...",simpleif,34 "A python book Beginning python, advanced python, and python exercises","if x is not None: ...",simpleif,34 "A python book Beginning python, advanced python, and python exercises",if expression. Example:,simpleif,35 "A python book Beginning python, advanced python, and python exercises","if self.idx < len(self.data): x = self.data[self.idx]",simpleif,36 "A python book Beginning python, advanced python, and python exercises","if item > 100: value1 = item",simpleif,39 "A python book Beginning python, advanced python, and python exercises",if it does the following:,simpleif,53 "A python book Beginning python, advanced python, and python exercises","if item > max: return # Note 2",simpleif,54 "A python book Beginning python, advanced python, and python exercises","if children is None: self.children = []",simpleif,56 "A python book Beginning python, advanced python, and python exercises","if items is None: ....: self.items = []",simpleif,62 "A python book Beginning python, advanced python, and python exercises","if data is None: data = {}",simpleif,67 "A python book Beginning python, advanced python, and python exercises","if len1 <= 5: flag1 = 1",simpleif,73 "A python book Beginning python, advanced python, and python exercises","if s1.find('Generated') > -1: flag2 = 1",simpleif,73 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,74 "A python book Beginning python, advanced python, and python exercises","if len(args) != 0: usage()",simpleif,74 "A python book Beginning python, advanced python, and python exercises","if name1 < name2: return 1",simpleif,75 "A python book Beginning python, advanced python, and python exercises","if name1 > name2: return -1",simpleif,75 "A python book Beginning python, advanced python, and python exercises","if n == 1: return 10",simpleif,77 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: sys.stderr.write('\nusage: test_db.py <db_name>\n\n')",simpleif,79 "A python book Beginning python, advanced python, and python exercises","if mo: value = mo.group(1)",simpleif,83 "A python book Beginning python, advanced python, and python exercises","if children is None: self.children = []",simpleif,91 "A python book Beginning python, advanced python, and python exercises",if self.idx >= len(self.seq):,simpleif,93 "A python book Beginning python, advanced python, and python exercises","if flag: flag = 0",simpleif,95 "A python book Beginning python, advanced python, and python exercises","if kmax > 1000: kmax = 1000",simpleif,107 "A python book Beginning python, advanced python, and python exercises","if i == k: p[k] = n",simpleif,107 "A python book Beginning python, advanced python, and python exercises","if kmax > 1000: kmax = 1000",simpleif,109 "A python book Beginning python, advanced python, and python exercises","if i == k: p[k] = n",simpleif,109 "A python book Beginning python, advanced python, and python exercises","if isinstance(child, ASTNode): child.show(level)",simpleif,117 "A python book Beginning python, advanced python, and python exercises",if self.tokenType != CommaTokType:,simpleif,118 "A python book Beginning python, advanced python, and python exercises","if letter not in string.ascii_letters: return None",simpleif,119 "A python book Beginning python, advanced python, and python exercises","if is_word(tok): tokType = WordTokType",simpleif,119 "A python book Beginning python, advanced python, and python exercises","if tok == '(': tokType = LParTokType",simpleif,119 "A python book Beginning python, advanced python, and python exercises","if tok == ')': tokType = RParTokType",simpleif,119 "A python book Beginning python, advanced python, and python exercises","if tok == ',': tokType = CommaTokType",simpleif,119 "A python book Beginning python, advanced python, and python exercises","if we run the parser on the this input data, we see:",simpleif,121 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: usage()",simpleif,124 "A python book Beginning python, advanced python, and python exercises","if isinstance(child, ASTNode): child.show(level)",simpleif,126 "A python book Beginning python, advanced python, and python exercises","if self.tokenType == EOFTokType: return None",simpleif,128 "A python book Beginning python, advanced python, and python exercises","if self.tokenType == WordTokType: term = ASTNode(TermNodeType, self.token)",simpleif,128 "A python book Beginning python, advanced python, and python exercises","if self.tokenType == LParTokType: self.tokenType, self.token, self.lineNo =",simpleif,128 "A python book Beginning python, advanced python, and python exercises","if result: if self.tokenType == RParTokType:",simpleif,128 "A python book Beginning python, advanced python, and python exercises","if isinstance(child, ASTNode): child.show(level)",simpleif,134 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,137 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: usage()",simpleif,137 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print 'usage: python pyparsing_test1.py <datafile.txt>'",simpleif,139 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print 'usage: python pyparsing_test3.py <datafile.txt>'",simpleif,142 "A python book Beginning python, advanced python, and python exercises","if line and line[0] != ""#"": fields = record.parseString(line)",simpleif,142 "A python book Beginning python, advanced python, and python exercises","if modal: self.set_modal(True)",simpleif,145 "A python book Beginning python, advanced python, and python exercises","if pixmap: self.realize()",simpleif,145 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,146 "A python book Beginning python, advanced python, and python exercises","if len(args) != 0: usage()",simpleif,146 "A python book Beginning python, advanced python, and python exercises","if modal: self.set_modal(True)",simpleif,147 "A python book Beginning python, advanced python, and python exercises","if message: label = gtk.Label(message)",simpleif,147 "A python book Beginning python, advanced python, and python exercises","if result is None: print 'Canceled'",simpleif,148 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,148 "A python book Beginning python, advanced python, and python exercises","if len(args) != 0: usage()",simpleif,149 "A python book Beginning python, advanced python, and python exercises","if modal: self.set_modal(True)",simpleif,149 "A python book Beginning python, advanced python, and python exercises","if multiple: self.set_select_multiple(True)",simpleif,149 "A python book Beginning python, advanced python, and python exercises","if self.multiple: self.ret = self.get_selections()",simpleif,149 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,150 "A python book Beginning python, advanced python, and python exercises","if len(args) != 0: usage()",simpleif,150 "A python book Beginning python, advanced python, and python exercises",if the following is evaluated in the user's code:,simpleif,153 "A python book Beginning python, advanced python, and python exercises",if statement:,simpleif,159 "A python book Beginning python, advanced python, and python exercises",if x > 0:,simpleif,159 "A python book Beginning python, advanced python, and python exercises","if x > 0: print x",simpleif,160 "A python book Beginning python, advanced python, and python exercises","if x > 5: show_config()",simpleif,161 "A python book Beginning python, advanced python, and python exercises","if n <= 1: return n",simpleif,171 "A python book Beginning python, advanced python, and python exercises","if n <= 1: return n",simpleif,172 "A python book Beginning python, advanced python, and python exercises",if clause. Here is a template:,simpleif,172 "A python book Beginning python, advanced python, and python exercises",if clause of our list comprehension checks for containment in the list names2:,simpleif,172 "A python book Beginning python, advanced python, and python exercises","if Vegetables.has_key('Parsley'): print 'we have leafy, %s parsley' %",simpleif,185 "A python book Beginning python, advanced python, and python exercises","if line: print line",simpleif,187 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print __doc__",simpleif,187 "A python book Beginning python, advanced python, and python exercises","if item is None: ... count += 1",simpleif,188 "A python book Beginning python, advanced python, and python exercises","if not bananas: ... print 'yes, we have no bananas'",simpleif,192 "A python book Beginning python, advanced python, and python exercises","if color == RED: print ""It's red.""",simpleif,193 "A python book Beginning python, advanced python, and python exercises","if item == 0: break",simpleif,198 "A python book Beginning python, advanced python, and python exercises","if arg2 is None: arg2 = []",simpleif,202 "A python book Beginning python, advanced python, and python exercises","if dic is None: dic = {}",simpleif,203 "A python book Beginning python, advanced python, and python exercises","if line.startswith('## '): line = line[3:]",simpleif,204 "A python book Beginning python, advanced python, and python exercises","if node is None: return",simpleif,210 "A python book Beginning python, advanced python, and python exercises","if test_func(x): if transforms is None:",simpleif,212 "A python book Beginning python, advanced python, and python exercises","if isiterable(transforms): for func in transforms:",simpleif,212 "A python book Beginning python, advanced python, and python exercises","if children is None: self.children = []",simpleif,216 "A python book Beginning python, advanced python, and python exercises","if self.left_branch is not None: self.left_branch.show(level)",simpleif,220 "A python book Beginning python, advanced python, and python exercises","if self.right_branch is not None: self.right_branch.show(level)",simpleif,220 "A python book Beginning python, advanced python, and python exercises","if children is None: self.children = []",simpleif,220 "A python book Beginning python, advanced python, and python exercises","if self.current_index >= len(self.urls): raise StopIteration",simpleif,231 "A python book Beginning python, advanced python, and python exercises","if content: self.show_with_level('characters: ""%s""' %",simpleif,233 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: usage()",simpleif,234 "A python book Beginning python, advanced python, and python exercises","if node.nodeType == minidom.Node.ELEMENT_NODE: show_level(level)",simpleif,234 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print __doc__",simpleif,235 "A python book Beginning python, advanced python, and python exercises","if node.text: text = node.text.strip()",simpleif,235 "A python book Beginning python, advanced python, and python exercises","if node.tail: tail = node.tail.strip()",simpleif,236 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print __doc__",simpleif,236 "A python book Beginning python, advanced python, and python exercises","if node.text: text = node.text.strip()",simpleif,237 "A python book Beginning python, advanced python, and python exercises","if node.tail: tail = node.tail.strip()",simpleif,237 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: print __doc__",simpleif,237 "A python book Beginning python, advanced python, and python exercises","if node.text: text = node.text.strip()",simpleif,238 "A python book Beginning python, advanced python, and python exercises","if node.tail: tail = node.tail.strip()",simpleif,238 "A python book Beginning python, advanced python, and python exercises","if node.tag == tag: node.attrib[attrname] = attrvalue",simpleif,238 "A python book Beginning python, advanced python, and python exercises","if os.path.exists(outdocname): response = raw_input('Output file (%s) exists.",simpleif,238 "A python book Beginning python, advanced python, and python exercises","if response == 'y': write_output = True",simpleif,239 "A python book Beginning python, advanced python, and python exercises","if write_output: doc.write(outdocname)",simpleif,239 "A python book Beginning python, advanced python, and python exercises","if opt in ('-h', '--help'): usage()",simpleif,239 "A python book Beginning python, advanced python, and python exercises","if len(args) != 2: usage()",simpleif,239 "A python book Beginning python, advanced python, and python exercises","if len(rows) > 0: cursor.execute(""delete from plantsdb where",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if len(args) < 1: usage()",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if cmd == 'create': if len(args) != 1:",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if cmd == 'show': if len(args) != 1:",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if cmd == 'add': if len(args) < 4:",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if cmd == 'delete': if len(args) < 2:",simpleif,245 "A python book Beginning python, advanced python, and python exercises","if len(fields) == 3: line = '%s %s %s' % (fields[0].ljust(20),",simpleif,246 "A python book Beginning python, advanced python, and python exercises","if item.get_data_type() == 'xs:string': name = remap(item.get_name())",simpleif,263 "A python book Beginning python, advanced python, and python exercises","if isinstance(val1, list): for idx, val2 in enumerate(val1):",simpleif,263 "A python book Beginning python, advanced python, and python exercises","if hasattr(supermod, tag): rootClass = getattr(supermod, tag)",simpleif,264 "A python book Beginning python, advanced python, and python exercises","if rootClass is None: rootTag = 'contact-list'",simpleif,264 "A python book Beginning python, advanced python, and python exercises","if rootClass is None: rootTag = 'contact-list'",simpleif,264 "A python book Beginning python, advanced python, and python exercises","if rootClass is None: rootTag = 'contact-list'",simpleif,265 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: usage()",simpleif,265 "A python book Beginning python, advanced python, and python exercises","if len(args) != 1: usage()",simpleif,266 "A python book Beginning python, advanced python, and python exercises",print(data.asList()),printfunc,143 "A python book Beginning python, advanced python, and python exercises",print(),printfunc,191 "A python book Beginning python, advanced python, and python exercises",print(data),printfunc,248 "A python book Beginning python, advanced python, and python exercises",print(data),printfunc,248 "A python book Beginning python, advanced python, and python exercises","lowerLeft = (x1, y1)",simpleTuple,101 "A python book Beginning python, advanced python, and python exercises","extent = (width1, height1)",simpleTuple,101 "A python book Beginning python, advanced python, and python exercises","buttons=('Ok', 'Cancel'))",simpleTuple,146 "A python book Beginning python, advanced python, and python exercises","In [1]: a1 = (11, 22, 33, )",simpleTuple,168 "A python book Beginning python, advanced python, and python exercises","In [3]: a2 = ('aaa', 'bbb', 'ccc')",simpleTuple,168 "A python book Beginning python, advanced python, and python exercises","In [13]: a7 = (6,)",simpleTuple,168 "A python book Beginning python, advanced python, and python exercises","stuff = ['aa', 'bb', 'cc']",simpleList,11 "A python book Beginning python, advanced python, and python exercises","In [77]: a = [11, 22, 33]",simpleList,13 "A python book Beginning python, advanced python, and python exercises",In [25]: a = [],simpleList,14 "A python book Beginning python, advanced python, and python exercises","In [37]: b = ['bb', None, None]",simpleList,14 "A python book Beginning python, advanced python, and python exercises","In [38]: c = ['cc', None, None]",simpleList,14 "A python book Beginning python, advanced python, and python exercises","In [39]: root = ['aa', b, c]",simpleList,14 "A python book Beginning python, advanced python, and python exercises",content = [],simpleList,16 "A python book Beginning python, advanced python, and python exercises",In [25]: strlist = [],simpleList,17 "A python book Beginning python, advanced python, and python exercises","In [3]: a[2:5] = [11, 22, 33, 44, 55, 66]",simpleList,29 "A python book Beginning python, advanced python, and python exercises","In [35]: a = b = [11, 22]",simpleList,30 "A python book Beginning python, advanced python, and python exercises","In [25]: items = ['apple', 'banana', 'cherry', 'date']",simpleList,37 "A python book Beginning python, advanced python, and python exercises","In [28]: items = ['apple', 'banana', 'cherry', 'date']",simpleList,38 "A python book Beginning python, advanced python, and python exercises","In [20]: b = [11,22,33]",simpleList,38 "A python book Beginning python, advanced python, and python exercises","In [13]:a = [111, 222, 333, 444]",simpleList,45 "A python book Beginning python, advanced python, and python exercises","__all__ = ['func1', 'func2',]",simpleList,60 "A python book Beginning python, advanced python, and python exercises",content = [],simpleList,67 "A python book Beginning python, advanced python, and python exercises","In [5]: list1 = [11, 22, 33]",simpleList,96 "A python book Beginning python, advanced python, and python exercises",result = [],simpleList,107 "A python book Beginning python, advanced python, and python exercises",result = [],simpleList,109 "A python book Beginning python, advanced python, and python exercises",commandList = [],simpleList,118 "A python book Beginning python, advanced python, and python exercises",terms = [],simpleList,118 "A python book Beginning python, advanced python, and python exercises",terms = [],simpleList,128 "A python book Beginning python, advanced python, and python exercises",packages = ['testpackages'] # [3],simpleList,154 "A python book Beginning python, advanced python, and python exercises","In [26]: a3 = [100, 200, 300, ]",simpleList,168 "A python book Beginning python, advanced python, and python exercises","In [5]: a3 = ['basil', 'parsley', 'coriander']",simpleList,168 "A python book Beginning python, advanced python, and python exercises","In [8]: a5 = [(11, 22), (33, 44), (55,)]",simpleList,168 "A python book Beginning python, advanced python, and python exercises","11, 22] == [11, 22]",simpleList,169 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44, ]",simpleList,170 "A python book Beginning python, advanced python, and python exercises","b = [55, 66]",simpleList,170 "A python book Beginning python, advanced python, and python exercises","a = ['aa', 11]",simpleList,170 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44, ]",simpleList,170 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44, ]",simpleList,170 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44]",simpleList,171 "A python book Beginning python, advanced python, and python exercises","names = ['alice', 'bertrand', 'charlene']",simpleList,171 "A python book Beginning python, advanced python, and python exercises","numbers = [2, 3, 4, 5]",simpleList,171 "A python book Beginning python, advanced python, and python exercises","names = ['alice', 'bertrand', 'charlene']",simpleList,172 "A python book Beginning python, advanced python, and python exercises","numbers = [2, 3, 4, 5]",simpleList,172 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44]",simpleList,172 "A python book Beginning python, advanced python, and python exercises","names1 = ['alice', 'bertrand', 'charlene', 'daniel']",simpleList,172 "A python book Beginning python, advanced python, and python exercises","names2 = ['bertrand', 'charlene']",simpleList,172 "A python book Beginning python, advanced python, and python exercises","names2 = ['bertrand', 'charlene']",simpleList,173 "A python book Beginning python, advanced python, and python exercises","a = [""home"", ""myusername"", ""Workdir"", ""notes.txt""]",simpleList,176 "A python book Beginning python, advanced python, and python exercises","a = [""home"", ""myusername"", ""Workdir"", ""notes.txt""]",simpleList,176 "A python book Beginning python, advanced python, and python exercises",lines = [],simpleList,178 "A python book Beginning python, advanced python, and python exercises","In [20]: a = [11, 22, 33]",simpleList,190 "A python book Beginning python, advanced python, and python exercises","In [21]: b = [44, 55]",simpleList,190 "A python book Beginning python, advanced python, and python exercises","trees = ['pine', 'oak', 'elm']",simpleList,190 "A python book Beginning python, advanced python, and python exercises","bananas = ['banana1', 'banana2', 'banana3',]",simpleList,192 "A python book Beginning python, advanced python, and python exercises","bananas = ['banana1', 'banana2', 'banana3',]",simpleList,192 "A python book Beginning python, advanced python, and python exercises","In [13]: a = [11, 22, 33, ]",simpleList,193 "A python book Beginning python, advanced python, and python exercises","a = [1, 2, 3, 4, 5]",simpleList,196 "A python book Beginning python, advanced python, and python exercises","b = [100, 200, 300, 400, 500]",simpleList,196 "A python book Beginning python, advanced python, and python exercises","In [13]: a = [1, 2, 3, 4, 5]",simpleList,196 "A python book Beginning python, advanced python, and python exercises","In [14]: b = [100, 200, 300, 400, 500]",simpleList,196 "A python book Beginning python, advanced python, and python exercises","numbers = [11, 22, 33, 44, ]",simpleList,196 "A python book Beginning python, advanced python, and python exercises","numbers = [11, 22, 33, 0, 44, 55, 66, ]",simpleList,197 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44, 55, 66, ]",simpleList,200 "A python book Beginning python, advanced python, and python exercises","b = [111, 222, 333, 444, 555, 666, ]",simpleList,200 "A python book Beginning python, advanced python, and python exercises","a = [11, 22, 33, 44, ]",simpleList,201 "A python book Beginning python, advanced python, and python exercises","Func_list = [fancy, plain, ]",simpleList,208 "A python book Beginning python, advanced python, and python exercises",Indents = [' ' * idx for idx in range(10)],simpleList,210 "A python book Beginning python, advanced python, and python exercises","data1 = [11, 22, 33, 44, 55, 66, 77, ]",simpleList,212 "A python book Beginning python, advanced python, and python exercises","plants = [p1, p2, ]",simpleList,215 "A python book Beginning python, advanced python, and python exercises",Indents = [' ' * n for n in range(10)],simpleList,215 "A python book Beginning python, advanced python, and python exercises","n6 = Animal('raptor', children=[n3, n4,]",simpleList,217 "A python book Beginning python, advanced python, and python exercises","n7a = Animal('bird', children=[n5, n6,]",simpleList,217 "A python book Beginning python, advanced python, and python exercises","n5 = Plant('oak', children=[n1, n2,]",simpleList,217 "A python book Beginning python, advanced python, and python exercises","n6 = Plant('conifer', children=[n3, n4,]",simpleList,217 "A python book Beginning python, advanced python, and python exercises","n7b = Plant('tree', children=[n5, n6,]",simpleList,217 "A python book Beginning python, advanced python, and python exercises","objs = [A(), B(), C(), A(), ]",simpleList,218 "A python book Beginning python, advanced python, and python exercises",Indents = [' ' * idx for idx in range(10)],simpleList,219 "A python book Beginning python, advanced python, and python exercises",instances = [],simpleList,222 "A python book Beginning python, advanced python, and python exercises",instances = [],simpleList,223 "A python book Beginning python, advanced python, and python exercises",instances = [],simpleList,225 "A python book Beginning python, advanced python, and python exercises","names = ['albert', 'betsy', 'charlie']",simpleList,259 "A python book Beginning python, advanced python, and python exercises",for item in stuff:,forsimple,11 "A python book Beginning python, advanced python, and python exercises",for membership with the in operator. Example:,forsimple,13 "A python book Beginning python, advanced python, and python exercises",for statement to print the items in the list. Solution:,forsimple,14 "A python book Beginning python, advanced python, and python exercises",for item in a:,forsimple,14 "A python book Beginning python, advanced python, and python exercises",for new code in Python 2) is to use the string.format method. See here:,forsimple,17 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,20 "A python book Beginning python, advanced python, and python exercises",for key in d.iterkeys():,forsimple,21 "A python book Beginning python, advanced python, and python exercises",for key in d.keys():,forsimple,22 "A python book Beginning python, advanced python, and python exercises",for value in d.values():,forsimple,22 "A python book Beginning python, advanced python, and python exercises",for item in d.items():,forsimple,22 "A python book Beginning python, advanced python, and python exercises","for key, value in d.items():",forsimple,23 "A python book Beginning python, advanced python, and python exercises",for k in myDict:,forsimple,23 "A python book Beginning python, advanced python, and python exercises",for k in myDict.iterkeys():,forsimple,23 "A python book Beginning python, advanced python, and python exercises",for a key in a dictionary. Example:,forsimple,23 "A python book Beginning python, advanced python, and python exercises",for line in f:,forsimple,23 "A python book Beginning python, advanced python, and python exercises",for x in infile:,forsimple,24 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,24 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,24 "A python book Beginning python, advanced python, and python exercises",for line in f:,forsimple,25 "A python book Beginning python, advanced python, and python exercises","for example, in an if: statement:",forsimple,27 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,33 "A python book Beginning python, advanced python, and python exercises",for x in y:,forsimple,35 "A python book Beginning python, advanced python, and python exercises",for x in a:,forsimple,36 "A python book Beginning python, advanced python, and python exercises","for idx, item in enumerate(items):",forsimple,37 "A python book Beginning python, advanced python, and python exercises","for idx, value in enumerate([11,22,33]):",forsimple,37 "A python book Beginning python, advanced python, and python exercises",for x in gen1:,forsimple,38 "A python book Beginning python, advanced python, and python exercises",for item in data1:,forsimple,39 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,44 "A python book Beginning python, advanced python, and python exercises",for val in range(max):,forsimple,47 "A python book Beginning python, advanced python, and python exercises",for arg in args:,forsimple,49 "A python book Beginning python, advanced python, and python exercises",for key in kwargs.keys():,forsimple,49 "A python book Beginning python, advanced python, and python exercises",for item in somelist:,forsimple,54 "A python book Beginning python, advanced python, and python exercises",for item in somelist:,forsimple,54 "A python book Beginning python, advanced python, and python exercises",for item in it:,forsimple,54 "A python book Beginning python, advanced python, and python exercises",for item in it:,forsimple,54 "A python book Beginning python, advanced python, and python exercises",for item in it:,forsimple,55 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,56 "A python book Beginning python, advanced python, and python exercises","for child in walk_list(tree.get_children(), level+1):",forsimple,57 "A python book Beginning python, advanced python, and python exercises","for level, item in walk_tree(a1, initLevel):",forsimple,57 "A python book Beginning python, advanced python, and python exercises","for level, item in walk_tree_recur(a1, initLevel):",forsimple,57 "A python book Beginning python, advanced python, and python exercises","for level, item in a1:",forsimple,58 "A python book Beginning python, advanced python, and python exercises",for key in self:,forsimple,67 "A python book Beginning python, advanced python, and python exercises",for line in f:,forsimple,70 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,70 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,70 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,74 "A python book Beginning python, advanced python, and python exercises",for row in cursor:,forsimple,79 "A python book Beginning python, advanced python, and python exercises",for line in Targets:,forsimple,83 "A python book Beginning python, advanced python, and python exercises",for item in seq:,forsimple,89 "A python book Beginning python, advanced python, and python exercises",for x in anIter:,forsimple,89 "A python book Beginning python, advanced python, and python exercises",for fruit in iter1:,forsimple,91 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,92 "A python book Beginning python, advanced python, and python exercises",for child in self.iterchildren():,forsimple,92 "A python book Beginning python, advanced python, and python exercises",for child in node.iterchildren():,forsimple,92 "A python book Beginning python, advanced python, and python exercises",for x in a:,forsimple,94 "A python book Beginning python, advanced python, and python exercises",for x in a:,forsimple,94 "A python book Beginning python, advanced python, and python exercises",for x in self.seq:,forsimple,95 "A python book Beginning python, advanced python, and python exercises",for x in a:,forsimple,95 "A python book Beginning python, advanced python, and python exercises",for x in a:,forsimple,95 "A python book Beginning python, advanced python, and python exercises",for x in genexpr:,forsimple,97 "A python book Beginning python, advanced python, and python exercises",for p in plist:,forsimple,107 "A python book Beginning python, advanced python, and python exercises",for p in plist:,forsimple,109 "A python book Beginning python, advanced python, and python exercises","for parsing and processing XML in Python. Here are a few places to look for support:",forsimple,114 "A python book Beginning python, advanced python, and python exercises",for item in args:,forsimple,117 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,117 "A python book Beginning python, advanced python, and python exercises",for item in child:,forsimple,117 "A python book Beginning python, advanced python, and python exercises",for idx in range(level):,forsimple,117 "A python book Beginning python, advanced python, and python exercises",for letter in token:,forsimple,119 "A python book Beginning python, advanced python, and python exercises",for tok in toks:,forsimple,119 "A python book Beginning python, advanced python, and python exercises",for item in args:,forsimple,126 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,126 "A python book Beginning python, advanced python, and python exercises",for item in child:,forsimple,126 "A python book Beginning python, advanced python, and python exercises",for idx in range(level):,forsimple,126 "A python book Beginning python, advanced python, and python exercises",for item in args:,forsimple,134 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,134 "A python book Beginning python, advanced python, and python exercises",for item in child:,forsimple,134 "A python book Beginning python, advanced python, and python exercises",for idx in range(level):,forsimple,134 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,137 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,139 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,142 "A python book Beginning python, advanced python, and python exercises",for text in buttons:,forsimple,145 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,146 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,148 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,150 "A python book Beginning python, advanced python, and python exercises","for key, value in Vegetables.items():",forsimple,185 "A python book Beginning python, advanced python, and python exercises",for key in keys:,forsimple,185 "A python book Beginning python, advanced python, and python exercises","for the existence of a key in a dictionary, we can use either the in operator (preferred) or the d.has_key() method (old style):",forsimple,185 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,186 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,186 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,187 "A python book Beginning python, advanced python, and python exercises",for item in a:,forsimple,188 "A python book Beginning python, advanced python, and python exercises",for X in Y:,forsimple,193 "A python book Beginning python, advanced python, and python exercises",for value in a:,forsimple,193 "A python book Beginning python, advanced python, and python exercises",for chr1 in b:,forsimple,194 "A python book Beginning python, advanced python, and python exercises",for url in url_list:,forsimple,194 "A python book Beginning python, advanced python, and python exercises",for idx in range(6):,forsimple,195 "A python book Beginning python, advanced python, and python exercises",for n in xrange(100000):,forsimple,195 "A python book Beginning python, advanced python, and python exercises",for url in url_list:,forsimple,195 "A python book Beginning python, advanced python, and python exercises",for url in walk(Urls):,forsimple,195 "A python book Beginning python, advanced python, and python exercises","for idx, value in enumerate(a):",forsimple,196 "A python book Beginning python, advanced python, and python exercises",for item in numbers:,forsimple,198 "A python book Beginning python, advanced python, and python exercises",for value in values:,forsimple,201 "A python book Beginning python, advanced python, and python exercises",for line in infile:,forsimple,204 "A python book Beginning python, advanced python, and python exercises",for func in funcs:,forsimple,208 "A python book Beginning python, advanced python, and python exercises",for x in content:,forsimple,212 "A python book Beginning python, advanced python, and python exercises","for val in filter_and_transform(data1, iseven, f):",forsimple,212 "A python book Beginning python, advanced python, and python exercises","for val in filter_and_transform(data1, iseven):",forsimple,213 "A python book Beginning python, advanced python, and python exercises",for url in url_list:,forsimple,213 "A python book Beginning python, advanced python, and python exercises",for x in walk(Urls):,forsimple,213 "A python book Beginning python, advanced python, and python exercises",for plant in plants:,forsimple,215 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,216 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,217 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,217 "A python book Beginning python, advanced python, and python exercises","for idx, obj in enumerate(objs):",forsimple,218 "A python book Beginning python, advanced python, and python exercises",for child in self.children:,forsimple,220 "A python book Beginning python, advanced python, and python exercises",for instance in instances:,forsimple,222 "A python book Beginning python, advanced python, and python exercises",for instance in instances:,forsimple,223 "A python book Beginning python, advanced python, and python exercises",for instance in instances:,forsimple,225 "A python book Beginning python, advanced python, and python exercises",for item in X:,forsimple,230 "A python book Beginning python, advanced python, and python exercises",for page in pages:,forsimple,231 "A python book Beginning python, advanced python, and python exercises",for key in node.attributes.keys():,forsimple,234 "A python book Beginning python, advanced python, and python exercises",for child in node.childNodes:,forsimple,235 "A python book Beginning python, advanced python, and python exercises",for x in range(level):,forsimple,235 "A python book Beginning python, advanced python, and python exercises","for key, value in node.attrib.iteritems():",forsimple,235 "A python book Beginning python, advanced python, and python exercises",for child in node.getchildren():,forsimple,236 "A python book Beginning python, advanced python, and python exercises",for x in range(level):,forsimple,236 "A python book Beginning python, advanced python, and python exercises","for key, value in node.attrib.iteritems():",forsimple,236 "A python book Beginning python, advanced python, and python exercises",for child in node.getchildren():,forsimple,237 "A python book Beginning python, advanced python, and python exercises",for x in range(level):,forsimple,237 "A python book Beginning python, advanced python, and python exercises","for key, value in node.attrib.iteritems():",forsimple,238 "A python book Beginning python, advanced python, and python exercises",for child in node.getchildren():,forsimple,238 "A python book Beginning python, advanced python, and python exercises",for x in range(level):,forsimple,238 "A python book Beginning python, advanced python, and python exercises",for child in node.getchildren():,forsimple,238 "A python book Beginning python, advanced python, and python exercises","for opt, val in opts:",forsimple,239 "A python book Beginning python, advanced python, and python exercises",for row in rows:,forsimple,241 "A python book Beginning python, advanced python, and python exercises",for row in cur:,forsimple,241 "A python book Beginning python, advanced python, and python exercises",for field in cur.description:,forsimple,242 "A python book Beginning python, advanced python, and python exercises",for spec in Values:,forsimple,243 "A python book Beginning python, advanced python, and python exercises",for rowdescription in description:,forsimple,244 "A python book Beginning python, advanced python, and python exercises",for row in rows:,forsimple,244 "A python book Beginning python, advanced python, and python exercises",for row in rows:,forsimple,244 "A python book Beginning python, advanced python, and python exercises",for parsing and generating CSV files in the Python standard library. See:,forsimple,246 "A python book Beginning python, advanced python, and python exercises",for fields in reader:,forsimple,246 "A python book Beginning python, advanced python, and python exercises",for the definitions in that schema:,forsimple,252 "A python book Beginning python, advanced python, and python exercises",for person in self.get_person():,forsimple,256 "A python book Beginning python, advanced python, and python exercises","for count, name in enumerate(names):",forsimple,257 "A python book Beginning python, advanced python, and python exercises",for person in self.get_person():,forsimple,258 "A python book Beginning python, advanced python, and python exercises","for count, name in enumerate(names):",forsimple,259 "A python book Beginning python, advanced python, and python exercises",for item in obj.member_data_items_:,forsimple,263 "A python book Beginning python, advanced python, and python exercises",for child in self.get_contact():,forsimple,263 "A python book Beginning python, advanced python, and python exercises","In [1]: fn = lambda x, y, z: (x ** 2) + (y * 2) + z",assignwithSum,52 "A python book Beginning python, advanced python, and python exercises",pat = r'(\d+)',assignwithSum,85 "A python book Beginning python, advanced python, and python exercises",newline = line[:start1] + repl1 + line[end1:start2] +,assignwithSum,86 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('[0-9]+'),assignwithSum,86 "A python book Beginning python, advanced python, and python exercises",i = i + 1,assignwithSum,107 "A python book Beginning python, advanced python, and python exercises",k = k + 1,assignwithSum,107 "A python book Beginning python, advanced python, and python exercises",n = n + 1,assignwithSum,107 "A python book Beginning python, advanced python, and python exercises",i = i + 1,assignwithSum,109 "A python book Beginning python, advanced python, and python exercises",k = k + 1,assignwithSum,109 "A python book Beginning python, advanced python, and python exercises",n = n + 1,assignwithSum,109 "A python book Beginning python, advanced python, and python exercises",name = letter + Plex.Rep(letter | digit),assignwithSum,123 "A python book Beginning python, advanced python, and python exercises","comment = Plex.Str('""') + Plex.Rep( Plex.AnyBut('""')) +",assignwithSum,123 "A python book Beginning python, advanced python, and python exercises",totalmass = totalmass + mass,assignwithSum,124 "A python book Beginning python, advanced python, and python exercises",name = letter + Plex.Rep(letter | digit),assignwithSum,129 "A python book Beginning python, advanced python, and python exercises","comment = Plex.Str(""#"") + Plex.Rep(Plex.AnyBut(""\n""))",assignwithSum,129 "A python book Beginning python, advanced python, and python exercises","lineDef = fieldDef + ZeroOrMore("","" + fieldDef)",assignwithSum,139 "A python book Beginning python, advanced python, and python exercises","lineDef = fieldDef + ZeroOrMore("","" + fieldDef)",assignwithSum,140 "A python book Beginning python, advanced python, and python exercises","identifier = Word(alphas, alphanums + ""_"")",assignwithSum,140 "A python book Beginning python, advanced python, and python exercises","args = arg + ZeroOrMore("","" + arg)",assignwithSum,141 "A python book Beginning python, advanced python, and python exercises",expression = functor + lparen + args + rparen,assignwithSum,141 "A python book Beginning python, advanced python, and python exercises",city = Group(Word(alphas) + ZeroOrMore(Word(alphas))),assignwithSum,141 "A python book Beginning python, advanced python, and python exercises","name = Group(lastname + Suppress("","") + firstname)",assignwithSum,141 "A python book Beginning python, advanced python, and python exercises","phone = Combine(Word(nums, exact=3) + ""-"" + Word(nums, exact=3) + ""-""",assignwithSum,141 "A python book Beginning python, advanced python, and python exercises","location = Group(city + Suppress("","") + state + zip)",assignwithSum,141 "A python book Beginning python, advanced python, and python exercises",record = name + phone + location,assignwithSum,141 "A python book Beginning python, advanced python, and python exercises",rowData = Group( vert + Word(alphas) + vert +,assignwithSum,143 "A python book Beginning python, advanced python, and python exercises",datatable = heading + Dict( ZeroOrMore(rowData) ) + trailing,assignwithSum,143 "A python book Beginning python, advanced python, and python exercises",total_count = tree_count + vegetable_count +,assignwithSum,158 "A python book Beginning python, advanced python, and python exercises",total_count = tree_count + vegetable_count +,assignwithSum,159 "A python book Beginning python, advanced python, and python exercises",total_count = tree_count + \,assignwithSum,159 "A python book Beginning python, advanced python, and python exercises",z = x + y,assignwithSum,160 "A python book Beginning python, advanced python, and python exercises",z = x + y,assignwithSum,160 "A python book Beginning python, advanced python, and python exercises",value1 = 4 * (3 + 5),assignwithSum,163 "A python book Beginning python, advanced python, and python exercises",value4 = value1 + value2 + value3 - value4,assignwithSum,163 "A python book Beginning python, advanced python, and python exercises",s3 = s1 + s2,assignwithSum,175 "A python book Beginning python, advanced python, and python exercises",path = a[0] + os.sep + a[1] + os.sep + a[2] +,assignwithSum,176 "A python book Beginning python, advanced python, and python exercises",local_var1 = arg1 + 1,assignwithSum,201 "A python book Beginning python, advanced python, and python exercises","Zope, Twisted, etc). Try: http://dir.gmane.org/search.php?match=python.",simpleAssign,2 "A python book Beginning python, advanced python, and python exercises",The comparison operators <> and != are alternate spellings of the same operator.,simpleAssign,9 "A python book Beginning python, advanced python, and python exercises",In [8]: a = 4,simpleAssign,12 "A python book Beginning python, advanced python, and python exercises",In [9]: b = 5,simpleAssign,12 "A python book Beginning python, advanced python, and python exercises",In [19]: size = 25,simpleAssign,16 "A python book Beginning python, advanced python, and python exercises",In [20]: factor = 3.45,simpleAssign,16 "A python book Beginning python, advanced python, and python exercises","t = string.maketrans('abc', '123')",simpleAssign,17 "A python book Beginning python, advanced python, and python exercises","In [4]: 'n1: {num1} n2: {num2}'.format(num2=25, num1=100)",simpleAssign,18 "A python book Beginning python, advanced python, and python exercises","In [5]: 'n1: {num1} n2: {num2} again: {num1}'.format(num2=25,",simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",num1=100),simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [96]: a = u'abcd',simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [98]: b = unicode('efgh'),simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [107]: a = u'abcd',simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [110]: b = u'Sel\xe7uk',simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [123]: a = u'abcd',simpleAssign,18 "A python book Beginning python, advanced python, and python exercises",In [6]: b = a.encode('utf-8'),simpleAssign,19 "A python book Beginning python, advanced python, and python exercises",line = line.upper(),simpleAssign,20 "A python book Beginning python, advanced python, and python exercises","dict(one=2, two=3)",simpleAssign,20 "A python book Beginning python, advanced python, and python exercises",In [104]: dict1['category'] = 38,simpleAssign,21 "A python book Beginning python, advanced python, and python exercises","In [33]: f = file('mylog.txt', 'r')",simpleAssign,23 "A python book Beginning python, advanced python, and python exercises","In [42]: f = file('mylog.txt', 'r')",simpleAssign,25 "A python book Beginning python, advanced python, and python exercises","In [64]: zfile = zipfile.ZipFile(outfile, 'w', zipfile.ZIP_DEFLATED)",simpleAssign,25 "A python book Beginning python, advanced python, and python exercises",In [56]: lines = f.readlines(),simpleAssign,26 "A python book Beginning python, advanced python, and python exercises",flag = None,simpleAssign,26 "A python book Beginning python, advanced python, and python exercises",a = set(),simpleAssign,27 "A python book Beginning python, advanced python, and python exercises","b = set([11, 22])",simpleAssign,27 "A python book Beginning python, advanced python, and python exercises","c = set([22, 33])",simpleAssign,27 "A python book Beginning python, advanced python, and python exercises",Form -- target = expression.,simpleAssign,28 "A python book Beginning python, advanced python, and python exercises","x, y, z = 11, 22, 33",simpleAssign,28 "A python book Beginning python, advanced python, and python exercises","x, y, z] = 111, 222, 333",simpleAssign,28 "A python book Beginning python, advanced python, and python exercises","a, (b, c) = 11, (22, 33)",simpleAssign,28 "A python book Beginning python, advanced python, and python exercises","a, B = 11, (22, 33)",simpleAssign,28 "A python book Beginning python, advanced python, and python exercises","In [22]: LITTLE, MEDIUM, LARGE = range(1, 4)",simpleAssign,28 "A python book Beginning python, advanced python, and python exercises",In [10]: a = range(10),simpleAssign,28 "A python book Beginning python, advanced python, and python exercises",In [16]: b['bb'] = 1000,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",In [17]: b['cc'] = 2000,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",In [1]: a = range(10),simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",anObj = MyClass(),simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",index = 0,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",index -= 1,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",index *= 3,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",obj1 = A(),simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",obj2 = obj1,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",In [23]: a = range(10),simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",In [25]: b = a,simpleAssign,29 "A python book Beginning python, advanced python, and python exercises",In [27]: b[3] = 333,simpleAssign,30 "A python book Beginning python, advanced python, and python exercises",In [32]: a = b = 123,simpleAssign,30 "A python book Beginning python, advanced python, and python exercises",a = 111,simpleAssign,30 "A python book Beginning python, advanced python, and python exercises",b = 222,simpleAssign,30 "A python book Beginning python, advanced python, and python exercises","a, b = b, a",simpleAssign,30 "A python book Beginning python, advanced python, and python exercises",writer = Writer('outputfile.txt'),simpleAssign,33 "A python book Beginning python, advanced python, and python exercises",save_stdout = sys.stdout,simpleAssign,33 "A python book Beginning python, advanced python, and python exercises",sys.stdout = writer,simpleAssign,33 "A python book Beginning python, advanced python, and python exercises",tmp_file = file('outputfile.txt'),simpleAssign,33 "A python book Beginning python, advanced python, and python exercises",sys.stdout = save_stdout,simpleAssign,33 "A python book Beginning python, advanced python, and python exercises",is and is not -- The identical object. Cf. a is b and id(a) == id(b).,simpleAssign,34 "A python book Beginning python, advanced python, and python exercises",x = 'yes' if a == b else 'no',simpleAssign,35 "A python book Beginning python, advanced python, and python exercises",a = A(),simpleAssign,36 "A python book Beginning python, advanced python, and python exercises",In [19]: a = range(4),simpleAssign,38 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,40 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,40 "A python book Beginning python, advanced python, and python exercises",line = line.rstrip(),simpleAssign,44 "A python book Beginning python, advanced python, and python exercises",In [18]:a = A(),simpleAssign,45 "A python book Beginning python, advanced python, and python exercises",In [19]:a.x = 123,simpleAssign,45 "A python book Beginning python, advanced python, and python exercises","In [9]: a, b = test(3, 4)",simpleAssign,46 "A python book Beginning python, advanced python, and python exercises",In [53]: def t(max=5):,simpleAssign,47 "A python book Beginning python, advanced python, and python exercises",test(size=25),simpleAssign,48 "A python book Beginning python, advanced python, and python exercises","t(arg1=11, arg2=22)",simpleAssign,49 "A python book Beginning python, advanced python, and python exercises",In [1]: X = 3,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",X = 4,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",X = 5,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",x = X,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",X = 6,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",x = X,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",X = 7,simpleAssign,50 "A python book Beginning python, advanced python, and python exercises",HelloClass = classmethod(HelloClass),simpleAssign,51 "A python book Beginning python, advanced python, and python exercises",HelloStatic = staticmethod(HelloStatic),simpleAssign,51 "A python book Beginning python, advanced python, and python exercises","result = fn(*args, **kwargs)",simpleAssign,51 "A python book Beginning python, advanced python, and python exercises",fn1 = wrapper(fn1),simpleAssign,51 "A python book Beginning python, advanced python, and python exercises","In [3]: format = lambda obj, category: 'The ""%s"" is a ""%s"".' % (obj,",simpleAssign,52 "A python book Beginning python, advanced python, and python exercises","In [79]: a = lambda x, y: (x * 3, y * 4, (x, y))",simpleAssign,52 "A python book Beginning python, advanced python, and python exercises","t = Test('Dave', 'Kuhlman')",simpleAssign,52 "A python book Beginning python, advanced python, and python exercises",item *= 3,simpleAssign,54 "A python book Beginning python, advanced python, and python exercises",it = simplegenerator(),simpleAssign,54 "A python book Beginning python, advanced python, and python exercises",alist = range(5),simpleAssign,54 "A python book Beginning python, advanced python, and python exercises",it = list_tripler(alist),simpleAssign,54 "A python book Beginning python, advanced python, and python exercises",alist = range(8),simpleAssign,54 "A python book Beginning python, advanced python, and python exercises","it = limit_iterator(alist, 4)",simpleAssign,55 "A python book Beginning python, advanced python, and python exercises",it = simplegenerator(),simpleAssign,55 "A python book Beginning python, advanced python, and python exercises","def set_initlevel(self, initlevel): self.initlevel = initlevel",simpleAssign,56 "A python book Beginning python, advanced python, and python exercises",a7 = Node('777'),simpleAssign,57 "A python book Beginning python, advanced python, and python exercises",a6 = Node('666'),simpleAssign,57 "A python book Beginning python, advanced python, and python exercises",a5 = Node('555'),simpleAssign,57 "A python book Beginning python, advanced python, and python exercises",a4 = Node('444'),simpleAssign,57 "A python book Beginning python, advanced python, and python exercises","a3 = Node('333', [a4, a5])",simpleAssign,57 "A python book Beginning python, advanced python, and python exercises","a2 = Node('222', [a6, a7])",simpleAssign,57 "A python book Beginning python, advanced python, and python exercises","a1 = Node('111', [a2, a3])",simpleAssign,57 "A python book Beginning python, advanced python, and python exercises",initLevel = 2,simpleAssign,57 "A python book Beginning python, advanced python, and python exercises",iter1 = iter(a1),simpleAssign,58 "A python book Beginning python, advanced python, and python exercises",In [105]: a = A(),simpleAssign,60 "A python book Beginning python, advanced python, and python exercises",In [22]: a = A(),simpleAssign,61 "A python book Beginning python, advanced python, and python exercises",In [107]: b = B(),simpleAssign,61 "A python book Beginning python, advanced python, and python exercises",In [111]: a = A('dave'),simpleAssign,61 "A python book Beginning python, advanced python, and python exercises",size = 5,simpleAssign,63 "A python book Beginning python, advanced python, and python exercises",Caution: self.variable = x creates a new member variable.,simpleAssign,63 "A python book Beginning python, advanced python, and python exercises","A decorator of the form @afunc is the same as m = afunc(m). So, this:",simpleAssign,64 "A python book Beginning python, advanced python, and python exercises",m = afunc(m),simpleAssign,64 "A python book Beginning python, advanced python, and python exercises",Count = 0,simpleAssign,64 "A python book Beginning python, advanced python, and python exercises",dup_string = staticmethod(dup_string),simpleAssign,64 "A python book Beginning python, advanced python, and python exercises",A.count -= 1,simpleAssign,65 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,65 "A python book Beginning python, advanced python, and python exercises",In [4]: a = A(),simpleAssign,65 "A python book Beginning python, advanced python, and python exercises",In [9]: b = A(),simpleAssign,65 "A python book Beginning python, advanced python, and python exercises","description = property(_get_description, _set_description)",simpleAssign,65 "A python book Beginning python, advanced python, and python exercises","c = C((11,22,33))",simpleAssign,66 "A python book Beginning python, advanced python, and python exercises","c = C((11,22,33,44,55,66,77,88))",simpleAssign,66 "A python book Beginning python, advanced python, and python exercises","d = D({'aa': 111, 'bb':222, 'cc':333})",simpleAssign,67 "A python book Beginning python, advanced python, and python exercises","f = file('tmp.py', 'r')",simpleAssign,70 "A python book Beginning python, advanced python, and python exercises","infile = file(filename, 'r')",simpleAssign,70 "A python book Beginning python, advanced python, and python exercises","f = file('tmp.txt', 'w')",simpleAssign,70 "A python book Beginning python, advanced python, and python exercises","tran_table = string.maketrans('aeiou', 'AEIOU')",simpleAssign,70 "A python book Beginning python, advanced python, and python exercises",line = line.rstrip(),simpleAssign,70 "A python book Beginning python, advanced python, and python exercises",my_test_loader = unittest.TestLoader(),simpleAssign,72 "A python book Beginning python, advanced python, and python exercises",my_test_loader.sortTestMethodsUsing = my_cmp_func,simpleAssign,72 "A python book Beginning python, advanced python, and python exercises",unittest.main(testLoader=my_test_loader),simpleAssign,72 "A python book Beginning python, advanced python, and python exercises","outfile, infile = popen2.popen2(cmd)",simpleAssign,72 "A python book Beginning python, advanced python, and python exercises","outfile, infile = popen2.popen2(cmd)",simpleAssign,72 "A python book Beginning python, advanced python, and python exercises","outfile, infile = popen2.popen2(cmd)",simpleAssign,72 "A python book Beginning python, advanced python, and python exercises","outfile, infile = popen2.popen2(cmd)",simpleAssign,73 "A python book Beginning python, advanced python, and python exercises","outfile, infile = popen2.popen2(cmd)",simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",flag1 = 0,simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",flag2 = 0,simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",lines = result.split('\n'),simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",len1 = len(lines),simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",loader = unittest.TestLoader(),simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",loader = unittest.defaultTestLoader,simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",testsuite = loader.loadTestsFromTestCase(GenTest),simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",testsuite = suite(),simpleAssign,73 "A python book Beginning python, advanced python, and python exercises","runner = unittest.TextTestRunner(sys.stdout, verbosity=2)",simpleAssign,73 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,74 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,74 "A python book Beginning python, advanced python, and python exercises",relink = 1,simpleAssign,74 "A python book Beginning python, advanced python, and python exercises",suite = unittest.TestSuite(),simpleAssign,75 "A python book Beginning python, advanced python, and python exercises",sortUsing=compare_names)),simpleAssign,75 "A python book Beginning python, advanced python, and python exercises",suite = make_suite(),simpleAssign,75 "A python book Beginning python, advanced python, and python exercises",runner = unittest.TextTestRunner(),simpleAssign,75 "A python book Beginning python, advanced python, and python exercises",elif n == 2:,simpleAssign,77 "A python book Beginning python, advanced python, and python exercises",con = sqlite3.connect(db_name),simpleAssign,78 "A python book Beginning python, advanced python, and python exercises",cursor = con.cursor(),simpleAssign,78 "A python book Beginning python, advanced python, and python exercises",con = sqlite3.connect(db_name),simpleAssign,79 "A python book Beginning python, advanced python, and python exercises",cursor = con.cursor(),simpleAssign,79 "A python book Beginning python, advanced python, and python exercises",rows = cursor.fetchall(),simpleAssign,79 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,79 "A python book Beginning python, advanced python, and python exercises",db_name = args[0],simpleAssign,79 "A python book Beginning python, advanced python, and python exercises",http://www.artima.com/weblogs/viewpost.jsp?thread=4829,simpleAssign,80 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('aa[bc]*dd'),simpleAssign,82 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('aa[0-9]*bb'),simpleAssign,82 "A python book Beginning python, advanced python, and python exercises",x = pat.match('aa1234bbccddee'),simpleAssign,82 "A python book Beginning python, advanced python, and python exercises",x = pat.match('xxxxaa1234bbccddee'),simpleAssign,82 "A python book Beginning python, advanced python, and python exercises",x = pat.search('xxxxaa1234bbccddee'),simpleAssign,82 "A python book Beginning python, advanced python, and python exercises","x = re.search(pat, 'xxxxaa1234bbccddee')",simpleAssign,83 "A python book Beginning python, advanced python, and python exercises","In [69]: mo = re.search(r'height: (\d*) width: (\d*)', 'height: 123",simpleAssign,83 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('<<([0-9]*)>>'),simpleAssign,83 "A python book Beginning python, advanced python, and python exercises",mo = pat.search(line),simpleAssign,83 "A python book Beginning python, advanced python, and python exercises","of parentheses), then you can use ""value = mo.group(N)"" to extract the value",simpleAssign,84 "A python book Beginning python, advanced python, and python exercises","matched by the Nth group from the matching object. ""value = mo.group(1)""",simpleAssign,84 "A python book Beginning python, advanced python, and python exercises","returns the first extracted value; ""value = mo.group(2)"" returns the second; etc. An",simpleAssign,84 "A python book Beginning python, advanced python, and python exercises","Use ""values = mo.groups()"" to get a tuple containing the strings matched by all",simpleAssign,84 "A python book Beginning python, advanced python, and python exercises","In [76]: mo = re.search(r'h: (\d*) w: (\d*)', 'h: 123",simpleAssign,84 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('aa([0-9]*)bb([0-9]*)cc'),simpleAssign,84 "A python book Beginning python, advanced python, and python exercises",s1 = mo.group(1),simpleAssign,85 "A python book Beginning python, advanced python, and python exercises","out_str, count = re.subn(pat, repl_func, in_str)",simpleAssign,85 "A python book Beginning python, advanced python, and python exercises",pat = re.compile('aa([0-9]*)bb([0-9]*)cc'),simpleAssign,86 "A python book Beginning python, advanced python, and python exercises",result = pat.sub(,simpleAssign,87 "A python book Beginning python, advanced python, and python exercises",anIter = generateItems([]),simpleAssign,89 "A python book Beginning python, advanced python, and python exercises","anIter = generateItems([111,222,333])",simpleAssign,89 "A python book Beginning python, advanced python, and python exercises","anIter = generateItems(['aaa', 'bbb', 'ccc'])",simpleAssign,89 "A python book Beginning python, advanced python, and python exercises","iter1 = make_producer(DATA, ('apple', 'orange', 'honeydew', ))",simpleAssign,91 "A python book Beginning python, advanced python, and python exercises",children=None):,simpleAssign,91 "A python book Beginning python, advanced python, and python exercises","def set_name(self, name): self.name = name",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","def set_value(self, value): self.value = value",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a7 = Node('gilbert', '777')",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a6 = Node('fred', '666')",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a5 = Node('ellie', '555')",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a4 = Node('daniel', '444')",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a3 = Node('carl', '333', [a4, a5])",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a2 = Node('bill', '222', [a6, a7])",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises","a1 = Node('alice', '111', [a2, a3])",simpleAssign,92 "A python book Beginning python, advanced python, and python exercises",value = self.seq[self.idx],simpleAssign,94 "A python book Beginning python, advanced python, and python exercises",a = IteratorExample('edcba'),simpleAssign,94 "A python book Beginning python, advanced python, and python exercises",a = IteratorExample('abcde'),simpleAssign,94 "A python book Beginning python, advanced python, and python exercises",flag = 0,simpleAssign,95 "A python book Beginning python, advanced python, and python exercises",flag = 1,simpleAssign,95 "A python book Beginning python, advanced python, and python exercises",a = YieldIteratorExample('edcba'),simpleAssign,95 "A python book Beginning python, advanced python, and python exercises",a = YieldIteratorExample('abcde'),simpleAssign,95 "A python book Beginning python, advanced python, and python exercises",mylist = range(10),simpleAssign,97 "A python book Beginning python, advanced python, and python exercises",loader = unittest.TestLoader(),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",testsuite = loader.loadTestsFromTestCase(MyTest),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",testsuite = suite(),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises","runner = unittest.TextTestRunner(sys.stdout, verbosity=2)",simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",result = runner.run(testsuite),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises","inFile = file('test1_in.xml', 'r')",simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",doc = webserv_example_heavy_sub.parseString(inContent),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",outFile = StringIO.StringIO(),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",outContent = outFile.getvalue(),simpleAssign,98 "A python book Beginning python, advanced python, and python exercises",loader = unittest.TestLoader(),simpleAssign,99 "A python book Beginning python, advanced python, and python exercises",loader.sortTestMethodsUsing = mycmpfunc,simpleAssign,99 "A python book Beginning python, advanced python, and python exercises",testsuite = loader.loadTestsFromTestCase(XmlTest),simpleAssign,99 "A python book Beginning python, advanced python, and python exercises",testsuite = suite(),simpleAssign,99 "A python book Beginning python, advanced python, and python exercises","runner = unittest.TextTestRunner(sys.stdout, verbosity=2)",simpleAssign,99 "A python book Beginning python, advanced python, and python exercises",result = runner.run(testsuite),simpleAssign,99 "A python book Beginning python, advanced python, and python exercises","success and failure. In our example, we used ""self.failUnless(inContent == outContent)"" to ensure that the content we parsed and the content that we",simpleAssign,99 "A python book Beginning python, advanced python, and python exercises",loader.sortTestMethodsUsing = mycmpfunc,simpleAssign,100 "A python book Beginning python, advanced python, and python exercises",message = NULL;,simpleAssign,102 "A python book Beginning python, advanced python, and python exercises",if (n == 0),simpleAssign,102 "A python book Beginning python, advanced python, and python exercises",s1 = string.strip(s1),simpleAssign,106 "A python book Beginning python, advanced python, and python exercises",s2 = string.strip(s2),simpleAssign,106 "A python book Beginning python, advanced python, and python exercises",s4 = s3 * 4,simpleAssign,107 "A python book Beginning python, advanced python, and python exercises",plist = primes(kmax),simpleAssign,107 "A python book Beginning python, advanced python, and python exercises",k = 0,simpleAssign,107 "A python book Beginning python, advanced python, and python exercises",n = 2,simpleAssign,107 "A python book Beginning python, advanced python, and python exercises",i = 0,simpleAssign,107 "A python book Beginning python, advanced python, and python exercises",plist = self.primes(kmax),simpleAssign,109 "A python book Beginning python, advanced python, and python exercises",k = 0,simpleAssign,109 "A python book Beginning python, advanced python, and python exercises",n = 2,simpleAssign,109 "A python book Beginning python, advanced python, and python exercises",i = 0,simpleAssign,109 "A python book Beginning python, advanced python, and python exercises",primes = python_201_pyrex_clsprimes.Primes(),simpleAssign,110 "A python book Beginning python, advanced python, and python exercises",result = width * height * 3;,simpleAssign,112 "A python book Beginning python, advanced python, and python exercises","result = calculate(w, h)",simpleAssign,112 "A python book Beginning python, advanced python, and python exercises",Prog ::= Command | Command Prog,simpleAssign,115 "A python book Beginning python, advanced python, and python exercises",Command ::= Func_call,simpleAssign,115 "A python book Beginning python, advanced python, and python exercises",Func_call ::= Term '(' Func_call_list ')',simpleAssign,115 "A python book Beginning python, advanced python, and python exercises","Func_call_list ::= Func_call | Func_call ',' Func_call_list",simpleAssign,115 "A python book Beginning python, advanced python, and python exercises",Prog ::= Command | Command Prog,simpleAssign,115 "A python book Beginning python, advanced python, and python exercises",Command ::= Func_call,simpleAssign,115 "A python book Beginning python, advanced python, and python exercises",Func_call ::= Term '(' Func_call_list ')',simpleAssign,115 "A python book Beginning python, advanced python, and python exercises","Func_call_list ::= Func_call | Func_call ',' Func_call_list",simpleAssign,115 "A python book Beginning python, advanced python, and python exercises","ipshell = IPShellEmbed((),",simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",NoneNodeType = 0,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",ProgNodeType = 1,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",CommandNodeType = 2,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",FuncCallNodeType = 3,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",FuncCallListNodeType = 4,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",TermNodeType = 5,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",NoneTokType = 0,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",LParTokType = 1,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",RParTokType = 2,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",WordTokType = 3,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",CommaTokType = 4,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",EOFTokType = 5,simpleAssign,116 "A python book Beginning python, advanced python, and python exercises",elif type(child) == types.ListType:,simpleAssign,117 "A python book Beginning python, advanced python, and python exercises",result = self.prog_reco(),simpleAssign,118 "A python book Beginning python, advanced python, and python exercises",gen = genTokens(infile),simpleAssign,119 "A python book Beginning python, advanced python, and python exercises","tokType, tok, lineNo = gen.next()",simpleAssign,119 "A python book Beginning python, advanced python, and python exercises",lineNo = 0,simpleAssign,119 "A python book Beginning python, advanced python, and python exercises",line = infile.next(),simpleAssign,119 "A python book Beginning python, advanced python, and python exercises",toks = line.split(),simpleAssign,119 "A python book Beginning python, advanced python, and python exercises",parser = ProgParser(),simpleAssign,119 "A python book Beginning python, advanced python, and python exercises",result = None,simpleAssign,120 "A python book Beginning python, advanced python, and python exercises","letter = Plex.Range(""AZaz"")",simpleAssign,123 "A python book Beginning python, advanced python, and python exercises","digit = Plex.Range(""09"")",simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",number = Plex.Rep1(digit),simpleAssign,123 "A python book Beginning python, advanced python, and python exercises","space = Plex.Any("" \t"")",simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",endline = Plex.Str('\n'),simpleAssign,123 "A python book Beginning python, advanced python, and python exercises","resword = Plex.Str(""if"", ""then"", ""else"", ""end"")",simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",lexicon = Plex.Lexicon([,simpleAssign,123 "A python book Beginning python, advanced python, and python exercises","scanner = Plex.Scanner(lexicon, infile, infileName)",simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",scanner.line_count = 0,simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",position = scanner.position(),simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",tokstr = tokstr.ljust(20),simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,123 "A python book Beginning python, advanced python, and python exercises",infileName = args[0],simpleAssign,124 "A python book Beginning python, advanced python, and python exercises",Prog ::= Command | Command Prog,simpleAssign,125 "A python book Beginning python, advanced python, and python exercises",Command ::= Func_call,simpleAssign,125 "A python book Beginning python, advanced python, and python exercises",Func_call ::= Term '(' Func_call_list ')',simpleAssign,125 "A python book Beginning python, advanced python, and python exercises","Func_call_list ::= Func_call | Func_call ',' Func_call_list",simpleAssign,125 "A python book Beginning python, advanced python, and python exercises","ipshell = IPShellEmbed((),",simpleAssign,125 "A python book Beginning python, advanced python, and python exercises",NoneNodeType = 0,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",ProgNodeType = 1,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",CommandNodeType = 2,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",FuncCallNodeType = 3,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",FuncCallListNodeType = 4,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",TermNodeType = 5,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",NoneTokType = 0,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",LParTokType = 1,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",RParTokType = 2,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",WordTokType = 3,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",CommaTokType = 4,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",EOFTokType = 5,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",elif type(child) == types.ListType:,simpleAssign,126 "A python book Beginning python, advanced python, and python exercises",result = self.func_call_reco(),simpleAssign,128 "A python book Beginning python, advanced python, and python exercises",result = self.func_call_list_reco(),simpleAssign,128 "A python book Beginning python, advanced python, and python exercises",gen = genTokens(infile),simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","tokType, tok, lineNo = gen.next()",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","letter = Plex.Range(""AZaz"")",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","digit = Plex.Range(""09"")",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",lpar = Plex.Str('('),simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",rpar = Plex.Str(')'),simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","comma = Plex.Str(',')",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","space = Plex.Any("" \t\n"")",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",lexicon = Plex.Lexicon([,simpleAssign,129 "A python book Beginning python, advanced python, and python exercises","scanner = Plex.Scanner(lexicon, infile, infileName)",simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",tokType = NoneTokType,simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",tok = token,simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",parser = ProgParser(),simpleAssign,129 "A python book Beginning python, advanced python, and python exercises",result = None,simpleAssign,130 "A python book Beginning python, advanced python, and python exercises",Prog ::= Command*,simpleAssign,132 "A python book Beginning python, advanced python, and python exercises",Command ::= Func_call,simpleAssign,132 "A python book Beginning python, advanced python, and python exercises",Func_call ::= Term '(' Func_call_list ')',simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",Func_call_list ::= Func_call*,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",startlinepos = 0,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",NoneNodeType = 0,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",ProgNodeType = 1,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",CommandNodeType = 2,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",CommandListNodeType = 3,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",FuncCallNodeType = 4,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",FuncCallListNodeType = 5,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",TermNodeType = 6,simpleAssign,133 "A python book Beginning python, advanced python, and python exercises",elif type(child) == types.ListType:,simpleAssign,134 "A python book Beginning python, advanced python, and python exercises",t_LPAR = r'\(',simpleAssign,135 "A python book Beginning python, advanced python, and python exercises",t_RPAR = r'\)',simpleAssign,135 "A python book Beginning python, advanced python, and python exercises","t_COMMA = r'\,'",simpleAssign,135 "A python book Beginning python, advanced python, and python exercises",t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*',simpleAssign,135 "A python book Beginning python, advanced python, and python exercises",startlinepos = t.lexer.lexpos - 1,simpleAssign,135 "A python book Beginning python, advanced python, and python exercises",columnno = t.lexer.lexpos - startlinepos,simpleAssign,135 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(ProgNodeType, t[1])",simpleAssign,135 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(CommandListNodeType, t[1])",simpleAssign,135 "A python book Beginning python, advanced python, and python exercises",t[0] = t[1],simpleAssign,135 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(CommandNodeType, t[1])",simpleAssign,135 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(FuncCallNodeType, t[1])",simpleAssign,136 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(FuncCallNodeType, t[1], t[3])",simpleAssign,136 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(FuncCallListNodeType, t[1])",simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",t[0] = t[1],simpleAssign,136 "A python book Beginning python, advanced python, and python exercises","t[0] = ASTNode(TermNodeType, t[1])",simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",columnno = t.lexer.lexpos - startlinepos,simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",startlinepos = 0,simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",lex.lex(debug=1),simpleAssign,136 "A python book Beginning python, advanced python, and python exercises","infile = file(infileName, 'r')",simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",USAGE_TEXT = __doc__,simpleAssign,136 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,137 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,137 "A python book Beginning python, advanced python, and python exercises",relink = 1,simpleAssign,137 "A python book Beginning python, advanced python, and python exercises",infileName = args[0],simpleAssign,137 "A python book Beginning python, advanced python, and python exercises",fieldDef = Word(alphanums),simpleAssign,139 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,139 "A python book Beginning python, advanced python, and python exercises",infilename = sys.argv[1],simpleAssign,139 "A python book Beginning python, advanced python, and python exercises","infile = file(infilename, 'r')",simpleAssign,139 "A python book Beginning python, advanced python, and python exercises",fields = lineDef.parseString(line),simpleAssign,139 "A python book Beginning python, advanced python, and python exercises",lineDef = delimitedList(fieldDef),simpleAssign,140 "A python book Beginning python, advanced python, and python exercises","lparen = Literal(""("")",simpleAssign,140 "A python book Beginning python, advanced python, and python exercises","rparen = Literal("")"")",simpleAssign,140 "A python book Beginning python, advanced python, and python exercises",integer = Word( nums ),simpleAssign,140 "A python book Beginning python, advanced python, and python exercises",functor = identifier,simpleAssign,140 "A python book Beginning python, advanced python, and python exercises",arg = identifier | integer,simpleAssign,140 "A python book Beginning python, advanced python, and python exercises","content = raw_input(""Enter an expression: "")",simpleAssign,141 "A python book Beginning python, advanced python, and python exercises",parsedContent = expression.parseString(content),simpleAssign,141 "A python book Beginning python, advanced python, and python exercises",lastname = Word(alphas),simpleAssign,141 "A python book Beginning python, advanced python, and python exercises",firstname = Word(alphas),simpleAssign,141 "A python book Beginning python, advanced python, and python exercises","state = Word(alphas, exact=2)",simpleAssign,141 "A python book Beginning python, advanced python, and python exercises","zip = Word(nums, exact=5)",simpleAssign,141 "A python book Beginning python, advanced python, and python exercises","Word(nums, exact=4))",simpleAssign,141 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,142 "A python book Beginning python, advanced python, and python exercises",infilename = sys.argv[1],simpleAssign,142 "A python book Beginning python, advanced python, and python exercises","infile = file(infilename, 'r')",simpleAssign,142 "A python book Beginning python, advanced python, and python exercises",line = line.strip(),simpleAssign,142 "A python book Beginning python, advanced python, and python exercises",We use the len=n argument to the Word constructor to restict the parser to,simpleAssign,142 "A python book Beginning python, advanced python, and python exercises",number. Word also accepts min=n'' and ``max=n to enable you to restrict,simpleAssign,142 "A python book Beginning python, advanced python, and python exercises","vert = Literal(""|"").suppress()",simpleAssign,143 "A python book Beginning python, advanced python, and python exercises",number = Word(nums),simpleAssign,143 "A python book Beginning python, advanced python, and python exercises",trailing = Literal(,simpleAssign,143 "A python book Beginning python, advanced python, and python exercises",data = datatable.parseString(testData),simpleAssign,143 "A python book Beginning python, advanced python, and python exercises","pixmap=None,",simpleAssign,145 "A python book Beginning python, advanced python, and python exercises",modal= True):,simpleAssign,145 "A python book Beginning python, advanced python, and python exercises",hbox = gtk.HBox(spacing=5),simpleAssign,145 "A python book Beginning python, advanced python, and python exercises","pixmap = Pixmap(self, pixmap)",simpleAssign,145 "A python book Beginning python, advanced python, and python exercises","hbox.pack_start(pixmap, expand=False)",simpleAssign,145 "A python book Beginning python, advanced python, and python exercises",label = gtk.Label(message),simpleAssign,145 "A python book Beginning python, advanced python, and python exercises",b = gtk.Button(text),simpleAssign,145 "A python book Beginning python, advanced python, and python exercises","pixmap=None,",simpleAssign,145 "A python book Beginning python, advanced python, and python exercises",modal= True):,simpleAssign,145 "A python book Beginning python, advanced python, and python exercises","win = MessageBox(message, buttons, pixmap=pixmap, modal=modal)",simpleAssign,145 "A python book Beginning python, advanced python, and python exercises","result = message_box(title='Test #1',",simpleAssign,146 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,146 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,146 "A python book Beginning python, advanced python, and python exercises",relink = 1,simpleAssign,146 "A python book Beginning python, advanced python, and python exercises",box = gtk.VBox(spacing=10),simpleAssign,147 "A python book Beginning python, advanced python, and python exercises","button = gtk.Button(""OK"")",simpleAssign,147 "A python book Beginning python, advanced python, and python exercises","button = gtk.Button(""Cancel"")",simpleAssign,147 "A python book Beginning python, advanced python, and python exercises",modal=True):,simpleAssign,148 "A python book Beginning python, advanced python, and python exercises","win = EntryDialog(message, default_text, modal=modal)",simpleAssign,148 "A python book Beginning python, advanced python, and python exercises","result = input_box(title='Test #2',",simpleAssign,148 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,148 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,148 "A python book Beginning python, advanced python, and python exercises",relink = 1,simpleAssign,148 "A python book Beginning python, advanced python, and python exercises","win = FileChooser(modal=modal, multiple=multiple)",simpleAssign,150 "A python book Beginning python, advanced python, and python exercises",result = file_open_box(),simpleAssign,150 "A python book Beginning python, advanced python, and python exercises",result = file_save_box(),simpleAssign,150 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,150 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help'])",simpleAssign,150 "A python book Beginning python, advanced python, and python exercises",relink = 1,simpleAssign,150 "A python book Beginning python, advanced python, and python exercises","response = easygui.enterbox(msg='Enter your name:', title='Name",simpleAssign,152 "A python book Beginning python, advanced python, and python exercises","easygui.msgbox(msg=response, title='Your Response')",simpleAssign,152 "A python book Beginning python, advanced python, and python exercises",response = easygui.fileopenbox(msg='Select a file'),simpleAssign,152 "A python book Beginning python, advanced python, and python exercises","long_description = long_description,",simpleAssign,154 "A python book Beginning python, advanced python, and python exercises",python setup.py sdist --formats=gztar,simpleAssign,155 "A python book Beginning python, advanced python, and python exercises",x = 3,simpleAssign,160 "A python book Beginning python, advanced python, and python exercises",x = 25,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",y = float(x),simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x1 = 1234,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x2 = int('1234'),simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x1 = 2.0e3,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x1 = 1.234,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x3 = float('1.234'),simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x4 = 2.0e3,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",x5 = 2.0e-3,simpleAssign,162 "A python book Beginning python, advanced python, and python exercises",In [7]: value1 = 23,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",In [9]: value3 = 0,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",value1 = 0.01,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",value3 = 3e-4,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",value4 = value1 * (value2 - value3),simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",x = 5,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",y = 8,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",z = float(x) / y,simpleAssign,163 "A python book Beginning python, advanced python, and python exercises",x = 20,simpleAssign,165 "A python book Beginning python, advanced python, and python exercises",y = 50,simpleAssign,165 "A python book Beginning python, advanced python, and python exercises",z = float(x) / y,simpleAssign,166 "A python book Beginning python, advanced python, and python exercises",In [21]: a = tuple(),simpleAssign,169 "A python book Beginning python, advanced python, and python exercises",b = a.pop(),simpleAssign,170 "A python book Beginning python, advanced python, and python exercises",b = a.pop(),simpleAssign,170 "A python book Beginning python, advanced python, and python exercises",s2 = s1.rstrip(),simpleAssign,177 "A python book Beginning python, advanced python, and python exercises",s2 = s1.center(20),simpleAssign,177 "A python book Beginning python, advanced python, and python exercises",s2 = s1.upper(),simpleAssign,177 "A python book Beginning python, advanced python, and python exercises",words = s1.split(),simpleAssign,178 "A python book Beginning python, advanced python, and python exercises",a = u'abcd',simpleAssign,179 "A python book Beginning python, advanced python, and python exercises",b = unicode('efgh'),simpleAssign,179 "A python book Beginning python, advanced python, and python exercises",a = u'abcd',simpleAssign,180 "A python book Beginning python, advanced python, and python exercises",a = u'abcd',simpleAssign,180 "A python book Beginning python, advanced python, and python exercises",unicode_string = utf8_string.decode('utf-8'),simpleAssign,180 "A python book Beginning python, advanced python, and python exercises",unicode_string = u'aa\u0107bb',simpleAssign,180 "A python book Beginning python, advanced python, and python exercises",a[k] = v,simpleAssign,183 "A python book Beginning python, advanced python, and python exercises",keys = Vegetables.keys(),simpleAssign,185 "A python book Beginning python, advanced python, and python exercises",lines = content.splitlines(),simpleAssign,187 "A python book Beginning python, advanced python, and python exercises",lines = infile.readlines(),simpleAssign,187 "A python book Beginning python, advanced python, and python exercises",line = line.rstrip(),simpleAssign,187 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,187 "A python book Beginning python, advanced python, and python exercises",infilename = args[0],simpleAssign,187 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,188 "A python book Beginning python, advanced python, and python exercises",x = 3,simpleAssign,189 "A python book Beginning python, advanced python, and python exercises",y = 4,simpleAssign,189 "A python book Beginning python, advanced python, and python exercises",z = 5,simpleAssign,189 "A python book Beginning python, advanced python, and python exercises",1. The = operator is an assignment statement that binds a value to a variable:,simpleAssign,189 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,189 "A python book Beginning python, advanced python, and python exercises",1. The -= operator decrements the value of an integer:,simpleAssign,190 "A python book Beginning python, advanced python, and python exercises",count = 5,simpleAssign,190 "A python book Beginning python, advanced python, and python exercises",count -= 1,simpleAssign,190 "A python book Beginning python, advanced python, and python exercises",a = A(),simpleAssign,190 "A python book Beginning python, advanced python, and python exercises",a = A(),simpleAssign,191 "A python book Beginning python, advanced python, and python exercises",a.category = 25,simpleAssign,191 "A python book Beginning python, advanced python, and python exercises","NO_COLOR, RED, GREEN, BLUE = range(4)",simpleAssign,192 "A python book Beginning python, advanced python, and python exercises","NO_COLOR, RED, GREEN, BLUE = range(4)",simpleAssign,192 "A python book Beginning python, advanced python, and python exercises",elif color == GREEN:,simpleAssign,193 "A python book Beginning python, advanced python, and python exercises",elif color == BLUE:,simpleAssign,193 "A python book Beginning python, advanced python, and python exercises",color = BLUE,simpleAssign,193 "A python book Beginning python, advanced python, and python exercises",In [8]: count = 0,simpleAssign,195 "A python book Beginning python, advanced python, and python exercises",idx = 0,simpleAssign,197 "A python book Beginning python, advanced python, and python exercises",sum = 0,simpleAssign,198 "A python book Beginning python, advanced python, and python exercises",local_var2 = arg2 * 2,simpleAssign,201 "A python book Beginning python, advanced python, and python exercises","result = function_name(1, 2)",simpleAssign,201 "A python book Beginning python, advanced python, and python exercises",sum = 0,simpleAssign,201 "A python book Beginning python, advanced python, and python exercises",dic[name] = value,simpleAssign,203 "A python book Beginning python, advanced python, and python exercises",line = filterfunc(line),simpleAssign,204 "A python book Beginning python, advanced python, and python exercises","show_args(x=2, y=3)",simpleAssign,205 "A python book Beginning python, advanced python, and python exercises","show_args(y=5, x=4)",simpleAssign,205 "A python book Beginning python, advanced python, and python exercises","show_args(11, y=44, a=55, b=66)",simpleAssign,205 "A python book Beginning python, advanced python, and python exercises","result = transforms([11, 22], p, [f, g])",simpleAssign,211 "A python book Beginning python, advanced python, and python exercises",transforms=None),simpleAssign,211 "A python book Beginning python, advanced python, and python exercises","result = filter_and_transforms([11, 22], p, [f,",simpleAssign,212 "A python book Beginning python, advanced python, and python exercises",transforms=None):,simpleAssign,212 "A python book Beginning python, advanced python, and python exercises",x = func(x),simpleAssign,212 "A python book Beginning python, advanced python, and python exercises",flag = True,simpleAssign,212 "A python book Beginning python, advanced python, and python exercises",flag = False,simpleAssign,212 "A python book Beginning python, advanced python, and python exercises",a = Demo(),simpleAssign,214 "A python book Beginning python, advanced python, and python exercises","p1 = Plant('Eggplant', 25)",simpleAssign,215 "A python book Beginning python, advanced python, and python exercises","p2 = Plant('Tomato', 36)",simpleAssign,215 "A python book Beginning python, advanced python, and python exercises",n1 = Node('N1'),simpleAssign,216 "A python book Beginning python, advanced python, and python exercises",n2 = Node('N2'),simpleAssign,216 "A python book Beginning python, advanced python, and python exercises",n3 = Node('N3'),simpleAssign,216 "A python book Beginning python, advanced python, and python exercises",n4 = Node('N4'),simpleAssign,216 "A python book Beginning python, advanced python, and python exercises","n5 = Node('N5', [n1, n2,])",simpleAssign,216 "A python book Beginning python, advanced python, and python exercises","n6 = Node('N6', [n3, n4,])",simpleAssign,216 "A python book Beginning python, advanced python, and python exercises","n7 = Node('N7', [n5, n6,])",simpleAssign,216 "A python book Beginning python, advanced python, and python exercises",children=None):,simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n1 = Animal('scrubjay', 'gray blue')",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n2 = Animal('raven', 'black')",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n3 = Animal('american kestrel', 'brown')",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n4 = Animal('red-shouldered hawk', 'brown and",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n5 = Animal('corvid', 'none', [n1, n2,])",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n1 = Plant('valley oak', 50)",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n2 = Plant('canyon live oak', 40)",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n3 = Plant('jeffery pine', 120)",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n4 = Plant('ponderosa pine', 140)",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","n8 = Node('birds and trees', [n7a, n7b,])",simpleAssign,217 "A python book Beginning python, advanced python, and python exercises","def __init__(self, name, left_branch=None,",simpleAssign,219 "A python book Beginning python, advanced python, and python exercises",right_branch=None):,simpleAssign,219 "A python book Beginning python, advanced python, and python exercises","Tree = AnimalNode('animals',",simpleAssign,220 "A python book Beginning python, advanced python, and python exercises","Tree = AnimalNode('animals', [",simpleAssign,220 "A python book Beginning python, advanced python, and python exercises",show_class = classmethod(show_class),simpleAssign,221 "A python book Beginning python, advanced python, and python exercises",show_class = staticmethod(show_class),simpleAssign,222 "A python book Beginning python, advanced python, and python exercises",instance_count = 0,simpleAssign,222 "A python book Beginning python, advanced python, and python exercises","show_instance_count = classmethod(show_instance_count)",simpleAssign,222 "A python book Beginning python, advanced python, and python exercises",instance_count = 0,simpleAssign,223 "A python book Beginning python, advanced python, and python exercises","show_instance_count = staticmethod(show_instance_count)",simpleAssign,223 "A python book Beginning python, advanced python, and python exercises",method1 = functionwrapper(method1),simpleAssign,224 "A python book Beginning python, advanced python, and python exercises",method1 = classmethod(method1),simpleAssign,224 "A python book Beginning python, advanced python, and python exercises",instance_count = 0,simpleAssign,224 "A python book Beginning python, advanced python, and python exercises","show_instance_count = classmethod(show_instance_count)",simpleAssign,225 "A python book Beginning python, advanced python, and python exercises",func = dec(func),simpleAssign,225 "A python book Beginning python, advanced python, and python exercises","func = dec(argA, argB)(func)",simpleAssign,226 "A python book Beginning python, advanced python, and python exercises","retval = func(*args, **kwargs)",simpleAssign,227 "A python book Beginning python, advanced python, and python exercises","result = func2((x, y))",simpleAssign,227 "A python book Beginning python, advanced python, and python exercises","result = func1('aa', 'bb')",simpleAssign,227 "A python book Beginning python, advanced python, and python exercises",func = dec2(dec1(func)),simpleAssign,227 "A python book Beginning python, advanced python, and python exercises","retval = func(*args, **kwargs)",simpleAssign,228 "A python book Beginning python, advanced python, and python exercises","retval = func(*args, **kwargs)",simpleAssign,228 "A python book Beginning python, advanced python, and python exercises","result = func2((x, y))",simpleAssign,228 "A python book Beginning python, advanced python, and python exercises","result = func1('aa', 'bb')",simpleAssign,228 "A python book Beginning python, advanced python, and python exercises","retval = func(*args, **kwargs)",simpleAssign,229 "A python book Beginning python, advanced python, and python exercises","retval = func(*args, **kwargs)",simpleAssign,229 "A python book Beginning python, advanced python, and python exercises","result = func2((x, y))",simpleAssign,229 "A python book Beginning python, advanced python, and python exercises","result = func1('aa', 'bb')",simpleAssign,229 "A python book Beginning python, advanced python, and python exercises",url = self.urls[self.current_index],simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",pages = WebPages(urls),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",pages = WebPages(urls),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",page = pages.next(),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",page = pages.next(),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",page = pages.next(),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",page = pages.next(),simpleAssign,231 "A python book Beginning python, advanced python, and python exercises",content = content.strip(),simpleAssign,233 "A python book Beginning python, advanced python, and python exercises",parser = make_parser(),simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",handler = TestHandler(),simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",infilename = args[0],simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",root = doc.documentElement,simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",count = 0,simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",attr = node.attributes.get(key),simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",if (len(node.childNodes) == 1 and,simpleAssign,234 "A python book Beginning python, advanced python, and python exercises","node.childNodes[0].nodeType == Page 243",simpleAssign,234 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,235 "A python book Beginning python, advanced python, and python exercises",docname = args[0],simpleAssign,235 "A python book Beginning python, advanced python, and python exercises",doc = minidom.parse(docname),simpleAssign,235 "A python book Beginning python, advanced python, and python exercises",root = doc.getroot(),simpleAssign,235 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,236 "A python book Beginning python, advanced python, and python exercises",docname = args[0],simpleAssign,236 "A python book Beginning python, advanced python, and python exercises",doc = etree.parse(docname),simpleAssign,236 "A python book Beginning python, advanced python, and python exercises",root = doc.getroot(),simpleAssign,236 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,237 "A python book Beginning python, advanced python, and python exercises",docname = args[0],simpleAssign,237 "A python book Beginning python, advanced python, and python exercises",doc = etree.parse(docname),simpleAssign,237 "A python book Beginning python, advanced python, and python exercises",root = doc.getroot(),simpleAssign,238 "A python book Beginning python, advanced python, and python exercises",root = doc.getroot(),simpleAssign,238 "A python book Beginning python, advanced python, and python exercises",doc = etree.parse(indocname),simpleAssign,238 "A python book Beginning python, advanced python, and python exercises",date = time.ctime(),simpleAssign,238 "A python book Beginning python, advanced python, and python exercises",write_output = False,simpleAssign,238 "A python book Beginning python, advanced python, and python exercises",write_output = True,simpleAssign,239 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,239 "A python book Beginning python, advanced python, and python exercises","opts, args = getopt.getopt(args, 'h', ['help',",simpleAssign,239 "A python book Beginning python, advanced python, and python exercises",indocname = args[0],simpleAssign,239 "A python book Beginning python, advanced python, and python exercises",outdocname = args[1],simpleAssign,239 "A python book Beginning python, advanced python, and python exercises",doc = etree.parse('people.xml'),simpleAssign,239 "A python book Beginning python, advanced python, and python exercises",root = doc.getroot(),simpleAssign,239 "A python book Beginning python, advanced python, and python exercises","connection = gadfly.connect(""dbtest1"",",simpleAssign,241 "A python book Beginning python, advanced python, and python exercises",cur = connection.cursor(),simpleAssign,241 "A python book Beginning python, advanced python, and python exercises",rows = cur.fetchall(),simpleAssign,241 "A python book Beginning python, advanced python, and python exercises","connection = gadfly.connect(""dbtest1"",",simpleAssign,241 "A python book Beginning python, advanced python, and python exercises",cur = connection.cursor(),simpleAssign,241 "A python book Beginning python, advanced python, and python exercises",rows = cur.fetchall(),simpleAssign,242 "A python book Beginning python, advanced python, and python exercises",connection = sqlite3.connect('sqlite3plantsdb'),simpleAssign,243 "A python book Beginning python, advanced python, and python exercises",cursor = connection.cursor(),simpleAssign,243 "A python book Beginning python, advanced python, and python exercises",q2 = q1 % spec,simpleAssign,243 "A python book Beginning python, advanced python, and python exercises","connection, cursor = opendb()",simpleAssign,243 "A python book Beginning python, advanced python, and python exercises",description = cursor.description,simpleAssign,243 "A python book Beginning python, advanced python, and python exercises",rows = cursor.fetchall(),simpleAssign,244 "A python book Beginning python, advanced python, and python exercises",descrip = row[1],simpleAssign,244 "A python book Beginning python, advanced python, and python exercises",name = row[0],simpleAssign,244 "A python book Beginning python, advanced python, and python exercises","connection, cursor = opendb()",simpleAssign,244 "A python book Beginning python, advanced python, and python exercises",rows = cursor.fetchall(),simpleAssign,245 "A python book Beginning python, advanced python, and python exercises","connection = sqlite3.connect(""sqlite3plantsdb"")",simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",cursor = connection.cursor(),simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",cmd = args[0],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",name = args[1],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",descrip = args[2],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",rating = args[3],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",name = args[1],simpleAssign,245 "A python book Beginning python, advanced python, and python exercises",reader = csv.reader(infile),simpleAssign,246 "A python book Beginning python, advanced python, and python exercises",data = yaml.load(infile),simpleAssign,248 "A python book Beginning python, advanced python, and python exercises",data = yaml.load(data_str),simpleAssign,248 "A python book Beginning python, advanced python, and python exercises",data = yaml.load(infile),simpleAssign,248 "A python book Beginning python, advanced python, and python exercises","yaml.dump(data, outfile, default_flow_style=False)",simpleAssign,248 "A python book Beginning python, advanced python, and python exercises",content = json.dumps(Data),simpleAssign,249 "A python book Beginning python, advanced python, and python exercises",data = json.loads(content),simpleAssign,250 "A python book Beginning python, advanced python, and python exercises",generateDS.py -s people_appl1.py --super=people_api people.xsd,simpleAssign,253 "A python book Beginning python, advanced python, and python exercises",super=people_api people.xsd,simpleAssign,253 "A python book Beginning python, advanced python, and python exercises",generateDS.py -s people_appl2.py --super=people_api people.xsd,simpleAssign,253 "A python book Beginning python, advanced python, and python exercises",generateDS.py --session=test01.session,simpleAssign,253 "A python book Beginning python, advanced python, and python exercises",member-specs=list|dict,simpleAssign,255 "A python book Beginning python, advanced python, and python exercises","def __init__(self, comments=None, person=None, programmer=None,",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises","python_programmer=None, java_programmer=None):",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises",supermod.people.subclass = peopleTypeSub,simpleAssign,256 "A python book Beginning python, advanced python, and python exercises","def __init__(self, vegetable=None, fruit=None, ratio=None,",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises","id=None, value=None,",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises","name=None, interest=None, category=None, agent=None,",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises","promoter=None,",simpleAssign,256 "A python book Beginning python, advanced python, and python exercises",description=None):,simpleAssign,256 "A python book Beginning python, advanced python, and python exercises",supermod.person.subclass = personTypeSub,simpleAssign,257 "A python book Beginning python, advanced python, and python exercises",people = api.peopleType(),simpleAssign,257 "A python book Beginning python, advanced python, and python exercises","person = api.personType(name=name, id=id)",simpleAssign,257 "A python book Beginning python, advanced python, and python exercises","def __init__(self, comments=None, person=None,",simpleAssign,258 "A python book Beginning python, advanced python, and python exercises","specialperson=None, programmer=None, python_programmer=None,",simpleAssign,258 "A python book Beginning python, advanced python, and python exercises",java_programmer=None):,simpleAssign,258 "A python book Beginning python, advanced python, and python exercises",supermod.peopleType.subclass = peopleTypeSub,simpleAssign,258 "A python book Beginning python, advanced python, and python exercises","def __init__(self, vegetable=None, fruit=None, ratio=None,",simpleAssign,258 "A python book Beginning python, advanced python, and python exercises","id=None, value=None, name=None, interest=None, category=None,",simpleAssign,258 "A python book Beginning python, advanced python, and python exercises","agent=None, promoter=None, description=None, range_=None,",simpleAssign,258 "A python book Beginning python, advanced python, and python exercises",extensiontype_=None):,simpleAssign,258 "A python book Beginning python, advanced python, and python exercises",supermod.personType.subclass = personTypeSub,simpleAssign,258 "A python book Beginning python, advanced python, and python exercises",people = appl.peopleTypeSub(),simpleAssign,259 "A python book Beginning python, advanced python, and python exercises","person = appl.personTypeSub(name=name, id=id)",simpleAssign,259 "A python book Beginning python, advanced python, and python exercises",people = create_people(names),simpleAssign,259 "A python book Beginning python, advanced python, and python exercises","containing an item for each member. If you want a list, then use ""--member-specs=list"",",simpleAssign,260 "A python book Beginning python, advanced python, and python exercises","member-specs=dict"".",simpleAssign,260 "A python book Beginning python, advanced python, and python exercises",super=member_specs_api \,simpleAssign,261 "A python book Beginning python, advanced python, and python exercises",member-specs=list \,simpleAssign,261 "A python book Beginning python, advanced python, and python exercises",member-specs=list.,simpleAssign,261 "A python book Beginning python, advanced python, and python exercises",etree_ = None,simpleAssign,262 "A python book Beginning python, advanced python, and python exercises",Verbose_import_ = False,simpleAssign,262 "A python book Beginning python, advanced python, and python exercises",XMLParser_import_library = None,simpleAssign,262 "A python book Beginning python, advanced python, and python exercises",kwargs['parser'] = etree_.ETCompatXMLParser(),simpleAssign,263 "A python book Beginning python, advanced python, and python exercises","doc = etree_.parse(*args, **kwargs)",simpleAssign,263 "A python book Beginning python, advanced python, and python exercises","val1 = getattr(obj, name)",simpleAssign,263 "A python book Beginning python, advanced python, and python exercises",val1[idx] = val2.upper(),simpleAssign,263 "A python book Beginning python, advanced python, and python exercises","newname = name.replace('-', '_')",simpleAssign,263 "A python book Beginning python, advanced python, and python exercises",supermod.contactlistType.subclass = contactlistTypeSub,simpleAssign,263 "A python book Beginning python, advanced python, and python exercises","def __init__(self, priority=None, color_code=None, id=None,",simpleAssign,263 "A python book Beginning python, advanced python, and python exercises","first_name=None, last_name=None, interest=None, category=None):",simpleAssign,263 "A python book Beginning python, advanced python, and python exercises",supermod.contactType.subclass = contactTypeSub,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",tag = supermod.Tag_pattern_.match(node.tag).groups()[-1],simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootClass = None,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = parsexml_(inFilename),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootNode = doc.getroot(),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises","rootTag, rootClass = get_root_tag(rootNode)",simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootClass = supermod.contactlistType,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootObj = rootClass.factory(),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = None,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises","rootObj.export(sys.stdout, 0, name_=rootTag,",simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = None,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = parsexml_(StringIO(inString)),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootNode = doc.getroot(),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises","rootTag, rootClass = get_root_tag(rootNode)",simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootClass = supermod.contactlistType,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootObj = rootClass.factory(),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = None,simpleAssign,264 "A python book Beginning python, advanced python, and python exercises","rootObj.export(sys.stdout, 0, name_=rootTag,",simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",doc = parsexml_(inFilename),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootNode = doc.getroot(),simpleAssign,264 "A python book Beginning python, advanced python, and python exercises","rootTag, rootClass = get_root_tag(rootNode)",simpleAssign,264 "A python book Beginning python, advanced python, and python exercises",rootClass = supermod.contactlistType,simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",rootObj = rootClass.factory(),simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",doc = None,simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",infilename = args[0],simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",root = parse(infilename),simpleAssign,265 "A python book Beginning python, advanced python, and python exercises",doc = supermod.parsexml_(inFilename),simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",rootNode = doc.getroot(),simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",rootClass = member_specs_upper.contactlistTypeSub,simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",rootObj = rootClass.factory(),simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",doc = None,simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",args = sys.argv[1:],simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",infilename = args[0],simpleAssign,266 "A python book Beginning python, advanced python, and python exercises",plant = garden_api.PlantType(),simpleAssign,269 2019 Book A Beginner's Guide To Python 3 Program,map(),map,129 2019 Book A Beginner's Guide To Python 3 Program,map() and reduce(),map,397 2019 Book A Beginner's Guide To Python 3 Program,map() and reduce()),map,398 2019 Book A Beginner's Guide To Python 3 Program,"map(function, iterable, ...)",map,399 2019 Book A Beginner's Guide To Python 3 Program,map(),map,402 2019 Book A Beginner's Guide To Python 3 Program,map(),map,403 2019 Book A Beginner's Guide To Python 3 Program,class Shape(metaclass=ABCMeta):,metaclassheader,289 2019 Book A Beginner's Guide To Python 3 Program,class Shape(metaclass=ABCMeta):,metaclassheader,289 2019 Book A Beginner's Guide To Python 3 Program,class Person(metaclass=ABCMeta):,metaclassheader,291 2019 Book A Beginner's Guide To Python 3 Program,class PrinterMixin(metaclass=ABCMeta):,metaclassheader,293 2019 Book A Beginner's Guide To Python 3 Program,class IDPrinterMixin(metaclass=ABCMeta):,metaclassheader,293 2019 Book A Beginner's Guide To Python 3 Program,class Player(metaclass=ABCMeta):,metaclassheader,408 2019 Book A Beginner's Guide To Python 3 Program,"super().__init__(name, age)",superfunc,203 2019 Book A Beginner's Guide To Python 3 Program,super().__init__() reference. This allows whatever initialisation is,superfunc,203 2019 Book A Beginner's Guide To Python 3 Program,super().__init__() ini-,superfunc,203 2019 Book A Beginner's Guide To Python 3 Program,"super().__init__(name, age, id)",superfunc,203 2019 Book A Beginner's Guide To Python 3 Program,"super().__init__(name, age)",superfunc,210 2019 Book A Beginner's Guide To Python 3 Program,"super().__init__(name, age)",superfunc,211 2019 Book A Beginner's Guide To Python 3 Program,super().__init__(id),superfunc,290 2019 Book A Beginner's Guide To Python 3 Program,super().__init__(name),superfunc,293 2019 Book A Beginner's Guide To Python 3 Program,super().__init__(name),superfunc,294 2019 Book A Beginner's Guide To Python 3 Program,super().__init__(board),superfunc,409 2019 Book A Beginner's Guide To Python 3 Program,super().__init__(board),superfunc,410 2019 Book A Beginner's Guide To Python 3 Program,"@classmethod def",decaratorfunc,197 2019 Book A Beginner's Guide To Python 3 Program,"@staticmethod def",decaratorfunc,199 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,247 2019 Book A Beginner's Guide To Python 3 Program,"@age.setter def",decaratorfunc,247 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,247 2019 Book A Beginner's Guide To Python 3 Program,"@name.deleter def",decaratorfunc,247 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"@age.setter def",decaratorfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"@name.deleter def",decaratorfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"@age.setter def",decaratorfunc,264 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,270 2019 Book A Beginner's Guide To Python 3 Program,"@id.setter def",decaratorfunc,270 2019 Book A Beginner's Guide To Python 3 Program,"@abstractmethod def",decaratorfunc,289 2019 Book A Beginner's Guide To Python 3 Program,"@abstractmethod def",decaratorfunc,289 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,290 2019 Book A Beginner's Guide To Python 3 Program,"@logger def",decaratorfunc,323 2019 Book A Beginner's Guide To Python 3 Program,"@logger def",decaratorfunc,324 2019 Book A Beginner's Guide To Python 3 Program,"@make_italic def",decaratorfunc,325 2019 Book A Beginner's Guide To Python 3 Program,"@register() def",decaratorfunc,326 2019 Book A Beginner's Guide To Python 3 Program,"@register(active=False) def",decaratorfunc,326 2019 Book A Beginner's Guide To Python 3 Program,"@pretty_print def",decaratorfunc,327 2019 Book A Beginner's Guide To Python 3 Program,"@trace def",decaratorfunc,328 2019 Book A Beginner's Guide To Python 3 Program,"@logger def",decaratorfunc,331 2019 Book A Beginner's Guide To Python 3 Program,"@logger def",decaratorfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"@wraps(func) def",decaratorfunc,333 2019 Book A Beginner's Guide To Python 3 Program,"@timer def",decaratorfunc,334 2019 Book A Beginner's Guide To Python 3 Program,"@timer def",decaratorfunc,334 2019 Book A Beginner's Guide To Python 3 Program,"@timer def",decaratorfunc,380 2019 Book A Beginner's Guide To Python 3 Program,"@property def",decaratorfunc,408 2019 Book A Beginner's Guide To Python 3 Program,"@counter.setter def",decaratorfunc,408 2019 Book A Beginner's Guide To Python 3 Program,"@abstractmethod def",decaratorfunc,408 2019 Book A Beginner's Guide To Python 3 Program,"@classmethod and take a rst parameter which represents the class",decaratorclass,197 2019 Book A Beginner's Guide To Python 3 Program,"@singleton class",decaratorclass,330 2019 Book A Beginner's Guide To Python 3 Program,"@singleton class",decaratorclass,330 2019 Book A Beginner's Guide To Python 3 Program,list2 = [item + 1 for item in list1],simpleListComp,383 2019 Book A Beginner's Guide To Python 3 Program,list3 = [item + 1 for item in list1 if item % 2 == 0],simpleListComp,384 2019 Book A Beginner's Guide To Python 3 Program,"def gen_numbers(): yield",generatorYield,339 2019 Book A Beginner's Guide To Python 3 Program,"def gen_numbers2(): print('Start') yield",generatorYield,340 2019 Book A Beginner's Guide To Python 3 Program,"def __get__(self, inst, owner):",descriptorGet,305 2019 Book A Beginner's Guide To Python 3 Program,"def __set__(self, inst, value):",descriptorSet,305 2019 Book A Beginner's Guide To Python 3 Program,"def __delete__(self, instance):",descriptorDelete,305 2019 Book A Beginner's Guide To Python 3 Program,if __name__ == '__main__':,__name__,280 2019 Book A Beginner's Guide To Python 3 Program,if __name__ == '__main__':,__name__,281 2019 Book A Beginner's Guide To Python 3 Program,if __name__ == '__main__':,__name__,414 2019 Book A Beginner's Guide To Python 3 Program,print(p1.__class__,__class__,193 2019 Book A Beginner's Guide To Python 3 Program,denes attributes such as __class__,__class__,208 2019 Book A Beginner's Guide To Python 3 Program,return self.__class__,__class__,408 2019 Book A Beginner's Guide To Python 3 Program,print(Person.__dict__,__dict__,193 2019 Book A Beginner's Guide To Python 3 Program,print(p1.__dict__,__dict__,193 2019 Book A Beginner's Guide To Python 3 Program,"0x10595d488>, '__dict__': <attribute '__dict__",__dict__,194 2019 Book A Beginner's Guide To Python 3 Program,str(inst.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,return inst.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,inst.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,Note use of __dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,self.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,self.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,return 'Point[' + str(self.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,str(self.__dict__,__dict__,305 2019 Book A Beginner's Guide To Python 3 Program,The Cursor __init__() method uses the __dict__,__dict__,306 2019 Book A Beginner's Guide To Python 3 Program,The __str__() method also uses the __dict__,__dict__,306 2019 Book A Beginner's Guide To Python 3 Program,attributes and one for object attributes. These dictionaries are called __dict__,__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,be accessed either from the class <class>.__dict__,__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,instance of the class <instance.>__dict__,__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,"print('Student.__dict__:', Student.__dict__",__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,"print('student.__dict__:', student.__dict__",__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,Student.__dict__,__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,"0x10d515158>, '__dict__",__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,student.__dict__,__dict__,313 2019 Book A Beginner's Guide To Python 3 Program,appropriate __dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,"print(""Student.__dict__['count']:"", Student.__dict__",__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,"print(""student.__dict__['name']:"", student.__dict__",__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,Student.__dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,student.__dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,"However, accessing attributes via the __dict__",__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,you try to access a class variable via the objects __dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,"print(""student.__dict__['count']:"", student.__dict__",__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,This will generate a KeyError indicating that the object __dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,"print(""student.__dict__",__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,student.__dict__,__dict__,314 2019 Book A Beginner's Guide To Python 3 Program,objects (and classes) __dict__,__dict__,315 2019 Book A Beginner's Guide To Python 3 Program,Python rst looks in __dict__,__dict__,316 2019 Book A Beginner's Guide To Python 3 Program,Also note that if an attribute is accessed directly from the __dict__,__dict__,316 2019 Book A Beginner's Guide To Python 3 Program,example student.__dict__,__dict__,316 2019 Book A Beginner's Guide To Python 3 Program,tion of the method should either access the __dict__,__dict__,317 2019 Book A Beginner's Guide To Python 3 Program,objects dictionary (e.g. student.__dict__,__dict__,318 2019 Book A Beginner's Guide To Python 3 Program,"try: except ZeroDivisionError as e: else: finally: my_function(6, 2) print(e) print('Everything worked OK') print('Always runs') The try block will run, if no error is raised then the else clause will be executed and last of all the nally code will run, we will therefore have as output: my_function in my_function out Everything worked OK Always runs If however we pass in 6 and 0 to my_function(): try: except ZeroDivisionError as e: else: finally:",tryexceptelsefinally,260 2019 Book A Beginner's Guide To Python 3 Program,"s3 = { [1, 2, 3] }",dictwithList,366 2019 Book A Beginner's Guide To Python 3 Program,"s3 = { frozenset([1, 2, 3]) }",dictwithList,367 2019 Book A Beginner's Guide To Python 3 Program,"if num < 0: print('Its negative') else:",ifelse,65 2019 Book A Beginner's Guide To Python 3 Program,"if savings < 10000: print('Welcome Sir!') else:",ifelse,66 2019 Book A Beginner's Guide To Python 3 Program,"while number_to_guess != guess: print('Sorry wrong number') if count_number_of_tries == 4: break # TBD ... guess = int(input('Please guess again: ')) count_number_of_tries += 1 8.4.5 Notify the Player Whether Higher or Lower We also said at the beginning that to make it easier for the player to guess the number; we should indicate whether their guess was higher or lower than the actual number. To do this we can again use the if statement; if the guess is lower we print one message but if it was higher we print another. At this point we have a choice regarding whether to have a separate if state- ment to that used to decide if the maximum goes has been reached or to extend that one with an elif. Each approach can work but the latter indicates that these conditions are all related so that is the one we will use. The while loop now looks like: count_number_of_tries = 1 guess = int(input('Please guess a number between 1 and 10: ')) while number_to_guess != guess: print('Sorry wrong number') if count_number_of_tries == 4: elif guess < number_to_guess: else:",whileelse,88 2019 Book A Beginner's Guide To Python 3 Program,"while not user_input_accepted: user_input = input('Do you want to finish (y/n): ') if user_input == 'y': user_input_accepted = True elif user_input == 'n': ok_to_finish = False user_input_accepted = True else:",whileelse,136 2019 Book A Beginner's Guide To Python 3 Program,"while not input_ok: print('Menu Options are:') print('\t1. Add') print('\t2. Subtract') print('\t3. Multiply') print('\t4. Divide') print('-----------------') user_selection = input('Please make a selection: ') if user_selection in ('1', '2', '3', '4'): input_ok = True else:",whileelse,138 2019 Book A Beginner's Guide To Python 3 Program,"while invalid_input: print(prompt) user_input = input() if not user_input.isdigit(): print('Input must be a number') else: user_input_int = int(user_input) if user_input_int < 1 or user_input_int > 3: print('input must be a number in the range 1 to 3') else: invalid_input = False return user_input_int - 1 def get_move(self): """""" Allow the human player to enter their move """""" while True: row = self._get_user_input('Please input the row: ') column = self._get_user_input('Please input the column: ') if self.board.is_empty_cell(row, column): return Move(self.counter, row, column) else:",whileelse,409 2019 Book A Beginner's Guide To Python 3 Program,"while True: # Randomly select the cell row = random.randint(0, 2) column = random.randint(0, 2) # Check to see if the cell is empty if self.board.is_empty_cell(row, column): return Move(self.counter, row, column) def get_move(self): """""" Provide a very simple algorithm for selecting a move"""""" if self.board.is_empty_cell(1, 1): # Choose the center return Move(self.counter, 1, 1) elif self.board.is_empty_cell(0, 0): # Choose the top left return Move(self.counter, 0, 0) elif self.board.is_empty_cell(2, 2): # Choose the bottom right return Move(self.counter, 2, 2) elif self.board.is_empty_cell(0, 2): # Choose the top right return Move(self.counter, 0, 2) elif self.board.is_empty_cell(0, 2): # Choose the top right return Move(self.counter, 2, 0) else:",whileelse,410 2019 Book A Beginner's Guide To Python 3 Program,"while self.winner is None: # Human players move if self.next_player == self.human: print(self.board) print('Your move') move = self.human.get_move() self.board.add_move(move) if self.board.check_for_winner(self.human): self.winner = self.human else: self.next_player = self.computer # Computers move else: print('Computers move') move = self.computer.get_move() self.board.add_move(move) if self.board.check_for_winner(self.computer): self.winner = self.computer else:",whileelse,413 2019 Book A Beginner's Guide To Python 3 Program,"while number_to_guess != guess: print('Sorry wrong number') # TBD ... guess = int(input('Please guess again: ')) 8.4.4 Check They Haven’t Exceeded Their Maximum Number of Guess We also said above that the player can’t play forever; they have to guess the correct number within 4 goes. We therefore need to add some logic which will stop the game once they exceed this number. We will therefore need a variable to keep track of the number of attempts they have made. We should call this variable something meaningful so that we know what it represents, for example we could call it count_number_of_tries and ini- tialise it with the value 1: count_number_of_tries = 1 This needs to happen before we enter the while loop. Inside the while loop we need to do two things • check to see if the number of tries has been exceeded, • increment the number of tries if they are still allowed to play the game. We will use an if statement to check to see if the number of tries has been met; if it has we want to terminate the loop; the easiest way to this is via a break statement. if count_number_of_tries == 4: break If we don’t break",whilebreak,87 2019 Book A Beginner's Guide To Python 3 Program,"while not finished: result = 0 menu_choice = get_operation_choice() n1, n2 = get_numbers_from_user() if menu_choice == '1': result = add(n1, n2) elif menu_choice == '2': result = subtract(n1, n2) elif menu_choice == '3': result - multiply(n1, n2) elif menu_choice == '4': result = divide(n1, n2) print('Result:', result) print('=================') finished = check_if_user_has_finished(() print('Bye') 13.10 Running the Calculator If you now run the calculator you will be prompted as appropriate for input. You can try and break",whilebreak,140 2019 Book A Beginner's Guide To Python 3 Program,while loop has the basic form:,whilesimple,72 2019 Book A Beginner's Guide To Python 3 Program,while <test-condition-is-true>:,whilesimple,72 2019 Book A Beginner's Guide To Python 3 Program,while loop in Python:,whilesimple,72 2019 Book A Beginner's Guide To Python 3 Program,while count < 10:,whilesimple,72 2019 Book A Beginner's Guide To Python 3 Program,while loop will terminate:,whilesimple,79 2019 Book A Beginner's Guide To Python 3 Program,while roll_again == 'y':,whilesimple,79 2019 Book A Beginner's Guide To Python 3 Program,while number_to_guess != guess:,whilesimple,86 2019 Book A Beginner's Guide To Python 3 Program,while number_to_guess != guess:,whilesimple,86 2019 Book A Beginner's Guide To Python 3 Program,while number_to_guess != guess:,whilesimple,89 2019 Book A Beginner's Guide To Python 3 Program,while not value_as_string.isnumeric():,whilesimple,117 2019 Book A Beginner's Guide To Python 3 Program,while not finished:,whilesimple,134 2019 Book A Beginner's Guide To Python 3 Program,while not finished:,whilesimple,137 2019 Book A Beginner's Guide To Python 3 Program,while not finished:,whilesimple,138 2019 Book A Beginner's Guide To Python 3 Program,while not value_as_string.isnumeric():,whilesimple,139 2019 Book A Beginner's Guide To Python 3 Program,while not finished:,whilesimple,139 2019 Book A Beginner's Guide To Python 3 Program,while value <= limit:,whilesimple,341 2019 Book A Beginner's Guide To Python 3 Program,while not (counter == 'X' or counter == 'O'):,whilesimple,412 2019 Book A Beginner's Guide To Python 3 Program,from utils import *,fromstarstatements,273 2019 Book A Beginner's Guide To Python 3 Program,from utils import *,fromstarstatements,274 2019 Book A Beginner's Guide To Python 3 Program,from utils.functions import *,fromstarstatements,282 2019 Book A Beginner's Guide To Python 3 Program,from utils.classes import *,fromstarstatements,282 2019 Book A Beginner's Guide To Python 3 Program,from accounts import *,fromstarstatements,284 2019 Book A Beginner's Guide To Python 3 Program,"for example: import utils as utilities",asextension,273 2019 Book A Beginner's Guide To Python 3 Program,from utils import printer as myfunc,asextension,274 2019 Book A Beginner's Guide To Python 3 Program,from util.functions import f1 as myfunc,asextension,282 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,181 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,187 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,188 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,188 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,190 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,196 2019 Book A Beginner's Guide To Python 3 Program,thus __init__(),__init__,197 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,197 2019 Book A Beginner's Guide To Python 3 Program,the __init__(),__init__,198 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,202 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,203 2019 Book A Beginner's Guide To Python 3 Program,the __init__(),__init__,203 2019 Book A Beginner's Guide To Python 3 Program,s __init__(),__init__,203 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id, region, sales)",__init__,203 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,207 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,207 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,210 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,210 2019 Book A Beginner's Guide To Python 3 Program,the __init__() initialiser),__init__,211 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,211 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,211 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, day, month, year)",__init__,226 2019 Book A Beginner's Guide To Python 3 Program,as __init__() and __str__()),__init__,231 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, value=0)",__init__,232 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, value=0)",__init__,234 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, value=0)",__init__,237 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,242 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,242 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,243 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,245 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,247 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,263 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, value)",__init__,264 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, id)",__init__,270 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, id)",__init__,289 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, id)",__init__,289 2019 Book A Beginner's Guide To Python 3 Program,"a __init__()",__init__,289 2019 Book A Beginner's Guide To Python 3 Program,"the __init__()",__init__,289 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, id)",__init__,290 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,291 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,291 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,293 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,293 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age, id)",__init__,294 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, d)",__init__,298 2019 Book A Beginner's Guide To Python 3 Program,def __init__(self),__init__,302 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,305 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, x0, y0)",__init__,305 2019 Book A Beginner's Guide To Python 3 Program,the __init__() method),__init__,306 2019 Book A Beginner's Guide To Python 3 Program,method __init__(),__init__,310 2019 Book A Beginner's Guide To Python 3 Program,def __init__(self),__init__,310 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,312 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,315 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,316 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,317 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name)",__init__,318 2019 Book A Beginner's Guide To Python 3 Program,the __init__(),__init__,319 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, surname, age)",__init__,327 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, x, y)",__init__,328 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, limit)",__init__,338 2019 Book A Beginner's Guide To Python 3 Program,def __init__(self),__init__,392 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, name, age)",__init__,398 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, string)",__init__,407 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, counter, x, y)",__init__,408 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, board)",__init__,408 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, board)",__init__,409 2019 Book A Beginner's Guide To Python 3 Program,"def __init__(self, board)",__init__,410 2019 Book A Beginner's Guide To Python 3 Program,def __init__(self),__init__,411 2019 Book A Beginner's Guide To Python 3 Program,def __init__(self),__init__,412 2019 Book A Beginner's Guide To Python 3 Program,"try: except <type of exception to monitor for>: <code to monitor> <code to call if exception is found> A concrete example of this is given below for a try statement that will be used to monitor a call to runcalc: try: except ZeroDivisionError: runcalc(6) print('oops') which now results in the string 'oops' being printed out. This is because when runcalc is called the '/' operator throws the ZeroDivisionError which is passed back to the calling code which has an except clause specifying this type of exception. This catches the exception and runs the associated code block which in this case prints out the string 'oops'. In fact, we don’t have to be as precise as this; the except clause can be given a class of exception to look for and it will match any exception that is of that type or is an instance of a subclass of the exception. We therefore can also write: try: runcalc(6) except Exception: print('oops') The Exception class is a grandparent of the ZeroDivisionError thus any ZeroDivisionError object is also a type of Exception and thus the except block matches the exception passed. This means that you can write one except clause and that clause can handle a whole range of exceptions.",trytry,255 2019 Book A Beginner's Guide To Python 3 Program,"try: runcalc(6) except ZeroDivisionError: print('oops') except IndexError: print('arrgh') except FileNotFoundError: print('huh!') except Exception: print('Duh!') In this case the rst except monitors for a ZeroDivisionError but the other excepts monitor for other types of exception. Note that the except Exception is the last except clause in the list as ZeroDivisionError, IndexError and FileNotFoundError are all eventual subclasses of Exception and thus this clause would catch any of these types of exception. As only one except clause is allowed to run; if this except handler came st the other except handers would never ever be run. 24.5.1 Accessing the Exception Object It is possible to gain access to the exception object being caught by the except clause using the as keyword. This follows the exception type being monitored and can be used to bind the exception object to a variable, for example: try: except ZeroDivisionError as exp: runcalc(6) print(exp) print('oops') Which produces: division by zero oops If there are multiple except clauses, each except clause can decide whether to bind the exception object to a variable or not (and each variable can have a different name):",trytry,256 2019 Book A Beginner's Guide To Python 3 Program,"try: except ZeroDivisionError as exp: except FileNotFoundError: except Exception as exception: except IndexError as e: runcalc(6) print(exp) print('oops') print(e) print('arrgh') print('huh!') print(exception) print('Duh!') In the above example three of the four except clauses bind the exception to a variable (each with a different name—although they could all have the same name) but one, the FileNotFoundError except clause does not bind the exception to a variable. 24.5.2 Jumping to Exception Handlers One of the interesting features of Exception handling in Python is that when an Error or an Exception is raised it is immediately thrown to the exception handlers (the except clauses). Any statements that follow the point at which the exception is raised are not run. This means that a function may be terminated early and further statements in the calling code may not be run. As an example, consider the following code. This code denes a function my_function() that prints out a string, performs a division operation which will cause a ZeroDivisionError to be raised if the y value is Zero and then it has a further print statement. This function is called from within a try statement. Notice that there is a print statement each side of the call to my_function(). There is also a handler for the ZeroDivisionError. def my_function(x, y): print('my_function in') result = x / y print('my_function out') return result print('Starting') try: print('Before my_function') my_function(6, 2) print('After my_function') print('oops') except ZeroDivisionError as exp: print('Done')",trytry,257 2019 Book A Beginner's Guide To Python 3 Program,"try: my_function(6, 0) except IndexError as e: print(e) except: print('Something went wrong') This must be the last except clause as it omits the exception type and thus acts as a wildcard. It can be used to ensure that you get notied that an error did occur— although you do not know what type of error it actually was; therefore, use this feature with caution. 24.5.4 The Else Clause The try statement also has an optional else clause. If this is present, then it must come after all except clauses. The else clause is executed if and only if no exceptions were raised. If any exception was raised the else clause will not be run. An example of the else clause is shown below: try: except ZeroDivisionError as e: else: my_function(6, 2) print(e) print('Everything worked OK') In this case the output is: my_function in my_function out Everything worked OK",trytry,259 2019 Book A Beginner's Guide To Python 3 Program,"try: function_bang() except ValueError: print('oops') raise This will re raise the ValueError caught by the except clause. Note here we did not even bind it to a variable; however, we could have done this if required. try: except ValueError as ve: function_bang() print(ve) raise 24.7 Dening an Custom Exception You can dene your own Errors and Exceptions, which can give you more control over what happens in particular circumstances. To dene an exception, you create a subclass of the Exception class or one of its subclasses. For example, to dene a InvalidAgeException, we can extend the Exception class and generate an appropriate message: class InvalidAgeException(Exception): """""" Valid Ages must be between 0 and 120 """""" This class can be used to explicitly represent an issue when an age is set on a Person which is not within the acceptable age range.",trytry,262 2019 Book A Beginner's Guide To Python 3 Program,"try: print('Before my_function') my_function(6, 0) print('After my_function') print('oops') except ZeroDivisionError as exp:",tryexcept,258 2019 Book A Beginner's Guide To Python 3 Program,"try: except ValueError as ve:",tryexcept,261 2019 Book A Beginner's Guide To Python 3 Program,"try: p = Person('Adam', 21) p.age = -1 print(e) except InvalidAgeException as e:",tryexcept,264 2019 Book A Beginner's Guide To Python 3 Program,"try: except Exception as e:",tryexcept,265 2019 Book A Beginner's Guide To Python 3 Program,"try: except AmountError as e:",tryexcept,266 2019 Book A Beginner's Guide To Python 3 Program,"try: print('balance:', acc1.balance) acc1.withdraw(300.00) print('balance:', acc1.balance) except BalanceError as e:",tryexcept,267 2019 Book A Beginner's Guide To Python 3 Program,"try: print('balance:', acc1.balance) acc1.withdraw(300.00) print('balance:', acc1.balance) except accounts.BalanceError as e:",tryexcept,284 2019 Book A Beginner's Guide To Python 3 Program,"try: while True: line = (yield) if pattern in line: print(line) except GeneratorExit:",tryexcept,343 2019 Book A Beginner's Guide To Python 3 Program,"s2 = { {1, 2, 3} }",nestedDict,366 2019 Book A Beginner's Guide To Python 3 Program,"s2 = { frozenset({1, 2, 3}) }",nestedDict,367 2019 Book A Beginner's Guide To Python 3 Program,lambda arguments: expression,lambda,124 2019 Book A Beginner's Guide To Python 3 Program,"def my_function(*args, **kwargs):",funcwith2star,122 2019 Book A Beginner's Guide To Python 3 Program,def named(**kwargs):,funcwith2star,123 2019 Book A Beginner's Guide To Python 3 Program,def greeter(*args):,funcwithstar,121 2019 Book A Beginner's Guide To Python 3 Program,"def __exit__(self, *args):",funcwithstar,302 2019 Book A Beginner's Guide To Python 3 Program,class nameOfClass(SuperClass):,simpleclass,181 2019 Book A Beginner's Guide To Python 3 Program,class SubClassName(BaseClassName):,simpleclass,202 2019 Book A Beginner's Guide To Python 3 Program,class Employee(Person):,simpleclass,203 2019 Book A Beginner's Guide To Python 3 Program,class SalesPerson(Employee):,simpleclass,203 2019 Book A Beginner's Guide To Python 3 Program,class Person(object):,simpleclass,207 2019 Book A Beginner's Guide To Python 3 Program,class Employee(Person):,simpleclass,210 2019 Book A Beginner's Guide To Python 3 Program,class Employee(Person):,simpleclass,211 2019 Book A Beginner's Guide To Python 3 Program,class J(H):,simpleclass,220 2019 Book A Beginner's Guide To Python 3 Program,class Birthday(Date):,simpleclass,227 2019 Book A Beginner's Guide To Python 3 Program,class InvalidAgeException(Exception):,simpleclass,264 2019 Book A Beginner's Guide To Python 3 Program,class DivideByYWhenZeroException(Exception):,simpleclass,265 2019 Book A Beginner's Guide To Python 3 Program,class Bag(MutableSequence):,simpleclass,287 2019 Book A Beginner's Guide To Python 3 Program,class Bag(MutableSequence):,simpleclass,288 2019 Book A Beginner's Guide To Python 3 Program,class Circle(Shape):,simpleclass,290 2019 Book A Beginner's Guide To Python 3 Program,class Employee(object):,simpleclass,291 2019 Book A Beginner's Guide To Python 3 Program,class Person(object):,simpleclass,293 2019 Book A Beginner's Guide To Python 3 Program,class ContextManagedClass(object):,simpleclass,302 2019 Book A Beginner's Guide To Python 3 Program,class Employee(Person):,simpleclass,303 2019 Book A Beginner's Guide To Python 3 Program,class SalesPerson(Employee):,simpleclass,303 2019 Book A Beginner's Guide To Python 3 Program,class Logger(object):,simpleclass,305 2019 Book A Beginner's Guide To Python 3 Program,class Cursor(object):,simpleclass,305 2019 Book A Beginner's Guide To Python 3 Program,class Bag():,simpleclass,310 2019 Book A Beginner's Guide To Python 3 Program,class with the signature __len__(self):,simpleclass,311 2019 Book A Beginner's Guide To Python 3 Program,class Evens(object):,simpleclass,338 2019 Book A Beginner's Guide To Python 3 Program,class NotHashableThing(object):,simpleclass,378 2019 Book A Beginner's Guide To Python 3 Program,class HumanPlayer(Player):,simpleclass,409 2019 Book A Beginner's Guide To Python 3 Program,class ComputerPlayer(Player):,simpleclass,410 2019 Book A Beginner's Guide To Python 3 Program,raise ValueError('Unknown request'),raise,156 2019 Book A Beginner's Guide To Python 3 Program,raise an exception in my_function(),raise,261 2019 Book A Beginner's Guide To Python 3 Program,raise <Exception/Error type to raise>(),raise,261 2019 Book A Beginner's Guide To Python 3 Program,raise ValueError('Bang!'),raise,261 2019 Book A Beginner's Guide To Python 3 Program,raise ValueError # short hand for raise ValueError(),raise,262 2019 Book A Beginner's Guide To Python 3 Program,raise InvalidAgeException(value),raise,263 2019 Book A Beginner's Guide To Python 3 Program,raise InvalidAgeException(value),raise,264 2019 Book A Beginner's Guide To Python 3 Program,"self.cells = [[' ', ' ', ' '], [' ', ' ', ' ']",nestedList,411 2019 Book A Beginner's Guide To Python 3 Program,"for arg in args: for key in kwargs.keys():",fornested,122 2019 Book A Beginner's Guide To Python 3 Program,import string,importfunc,44 2019 Book A Beginner's Guide To Python 3 Program,import statement,importfunc,44 2019 Book A Beginner's Guide To Python 3 Program,import string,importfunc,44 2019 Book A Beginner's Guide To Python 3 Program,import random,importfunc,79 2019 Book A Beginner's Guide To Python 3 Program,import random,importfunc,86 2019 Book A Beginner's Guide To Python 3 Program,import random,importfunc,89 2019 Book A Beginner's Guide To Python 3 Program,import math,importfunc,155 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,225 2019 Book A Beginner's Guide To Python 3 Program,import Dates,importfunc,228 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,271 2019 Book A Beginner's Guide To Python 3 Program,import all,importfunc,271 2019 Book A Beginner's Guide To Python 3 Program,import utils,importfunc,271 2019 Book A Beginner's Guide To Python 3 Program,import utils,importfunc,271 2019 Book A Beginner's Guide To Python 3 Program,import statement,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import statements,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import utils,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import support,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import statements,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import statements,importfunc,272 2019 Book A Beginner's Guide To Python 3 Program,import statement,importfunc,273 2019 Book A Beginner's Guide To Python 3 Program,import everything,importfunc,273 2019 Book A Beginner's Guide To Python 3 Program,import everything,importfunc,273 2019 Book A Beginner's Guide To Python 3 Program,import is,importfunc,273 2019 Book A Beginner's Guide To Python 3 Program,import of,importfunc,274 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,274 2019 Book A Beginner's Guide To Python 3 Program,import and,importfunc,274 2019 Book A Beginner's Guide To Python 3 Program,import to,importfunc,275 2019 Book A Beginner's Guide To Python 3 Program,import into,importfunc,275 2019 Book A Beginner's Guide To Python 3 Program,import utils,importfunc,276 2019 Book A Beginner's Guide To Python 3 Program,"import statement",importfunc,276 2019 Book A Beginner's Guide To Python 3 Program,import sys,importfunc,276 2019 Book A Beginner's Guide To Python 3 Program,import module1,importfunc,279 2019 Book A Beginner's Guide To Python 3 Program,import a,importfunc,282 2019 Book A Beginner's Guide To Python 3 Program,import all,importfunc,282 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,283 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,289 2019 Book A Beginner's Guide To Python 3 Program,import time,importfunc,331 2019 Book A Beginner's Guide To Python 3 Program,import time,importfunc,331 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,334 2019 Book A Beginner's Guide To Python 3 Program,import is,importfunc,336 2019 Book A Beginner's Guide To Python 3 Program,import the,importfunc,385 2019 Book A Beginner's Guide To Python 3 Program,import collections,importfunc,385 2019 Book A Beginner's Guide To Python 3 Program,import itertools,importfunc,387 2019 Book A Beginner's Guide To Python 3 Program,import it,importfunc,401 2019 Book A Beginner's Guide To Python 3 Program,from utils import Shape,importfromsimple,273 2019 Book A Beginner's Guide To Python 3 Program,from utils import _special_function,importfromsimple,275 2019 Book A Beginner's Guide To Python 3 Program,from util import Shape,importfromsimple,275 2019 Book A Beginner's Guide To Python 3 Program,from and import styles,importfromsimple,282 2019 Book A Beginner's Guide To Python 3 Program,from utils.file_utils.file_support import file_logger,importfromsimple,283 2019 Book A Beginner's Guide To Python 3 Program,from this module so that you can import the,importfromsimple,284 2019 Book A Beginner's Guide To Python 3 Program,from collections import MutableSequence,importfromsimple,287 2019 Book A Beginner's Guide To Python 3 Program,from collections import MutableSequence,importfromsimple,288 2019 Book A Beginner's Guide To Python 3 Program,from abc import ABCMeta,importfromsimple,289 2019 Book A Beginner's Guide To Python 3 Program,from abc import ABCMeta,importfromsimple,291 2019 Book A Beginner's Guide To Python 3 Program,from abc import ABCMeta,importfromsimple,293 2019 Book A Beginner's Guide To Python 3 Program,from functools import wraps,importfromsimple,333 2019 Book A Beginner's Guide To Python 3 Program,from timeit import default_timer,importfromsimple,334 2019 Book A Beginner's Guide To Python 3 Program,from timeit import default_timer,importfromsimple,380 2019 Book A Beginner's Guide To Python 3 Program,from functools import reduce,importfromsimple,401 2019 Book A Beginner's Guide To Python 3 Program,"self.state == ""off"" then",simpleattr,173 2019 Book A Beginner's Guide To Python 3 Program,"self.tate = ""wash""",simpleattr,173 2019 Book A Beginner's Guide To Python 3 Program,"self.state == ""wash"" then",simpleattr,173 2019 Book A Beginner's Guide To Python 3 Program,"self.state = ""wipe""",simpleattr,173 2019 Book A Beginner's Guide To Python 3 Program,"self.state == ""working"" then",simpleattr,175 2019 Book A Beginner's Guide To Python 3 Program,"self.tate = ""notWorking""",simpleattr,175 2019 Book A Beginner's Guide To Python 3 Program,"self.state = ""working""",simpleattr,175 2019 Book A Beginner's Guide To Python 3 Program,self.status = relay.working().,simpleattr,176 2019 Book A Beginner's Guide To Python 3 Program,"self.status == ""working"" then",simpleattr,176 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,181 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,181 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,187 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,187 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,188 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,188 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,188 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,188 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,190 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,190 2019 Book A Beginner's Guide To Python 3 Program,self.age += 1,simpleattr,190 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,196 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,196 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,197 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,197 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,202 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,202 2019 Book A Beginner's Guide To Python 3 Program,self.age += 1,simpleattr,202 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,203 2019 Book A Beginner's Guide To Python 3 Program,self.region = region,simpleattr,203 2019 Book A Beginner's Guide To Python 3 Program,self.sales = sales,simpleattr,203 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,207 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,207 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,207 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,207 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,210 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,210 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,210 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,211 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,211 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,211 2019 Book A Beginner's Guide To Python 3 Program,self.day = day,simpleattr,226 2019 Book A Beginner's Guide To Python 3 Program,self.month = month,simpleattr,226 2019 Book A Beginner's Guide To Python 3 Program,self.year = year,simpleattr,226 2019 Book A Beginner's Guide To Python 3 Program,self.value = value,simpleattr,232 2019 Book A Beginner's Guide To Python 3 Program,self.value = value,simpleattr,234 2019 Book A Beginner's Guide To Python 3 Program,self.value = value,simpleattr,237 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,242 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,242 2019 Book A Beginner's Guide To Python 3 Program,self._name = name,simpleattr,242 2019 Book A Beginner's Guide To Python 3 Program,self._age = age,simpleattr,242 2019 Book A Beginner's Guide To Python 3 Program,self._name = name,simpleattr,243 2019 Book A Beginner's Guide To Python 3 Program,self._age = age,simpleattr,243 2019 Book A Beginner's Guide To Python 3 Program,self._age = new_age,simpleattr,243 2019 Book A Beginner's Guide To Python 3 Program,self._name = name,simpleattr,245 2019 Book A Beginner's Guide To Python 3 Program,self._age = age,simpleattr,245 2019 Book A Beginner's Guide To Python 3 Program,self._age = new_age,simpleattr,245 2019 Book A Beginner's Guide To Python 3 Program,self._name = name,simpleattr,247 2019 Book A Beginner's Guide To Python 3 Program,self._age = age,simpleattr,247 2019 Book A Beginner's Guide To Python 3 Program,self._age = value,simpleattr,247 2019 Book A Beginner's Guide To Python 3 Program,self._name = name,simpleattr,263 2019 Book A Beginner's Guide To Python 3 Program,self._age = age,simpleattr,263 2019 Book A Beginner's Guide To Python 3 Program,self._age = value,simpleattr,263 2019 Book A Beginner's Guide To Python 3 Program,self.value = value,simpleattr,264 2019 Book A Beginner's Guide To Python 3 Program,self._age = value,simpleattr,264 2019 Book A Beginner's Guide To Python 3 Program,self._id = id,simpleattr,270 2019 Book A Beginner's Guide To Python 3 Program,self._id = id,simpleattr,270 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,289 2019 Book A Beginner's Guide To Python 3 Program,self._id = id,simpleattr,289 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,291 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,291 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,291 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,291 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,291 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,293 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,293 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,293 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,294 2019 Book A Beginner's Guide To Python 3 Program,self.id = id,simpleattr,294 2019 Book A Beginner's Guide To Python 3 Program,self.value = d,simpleattr,298 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,305 2019 Book A Beginner's Guide To Python 3 Program,"self.name, '=',",simpleattr,305 2019 Book A Beginner's Guide To Python 3 Program,self.name] = value,simpleattr,305 2019 Book A Beginner's Guide To Python 3 Program,self.x = self.x + dx,simpleattr,305 2019 Book A Beginner's Guide To Python 3 Program,self.y = self.y + dy,simpleattr,305 2019 Book A Beginner's Guide To Python 3 Program,"self.data = ['a', 'b', 'c']",simpleattr,310 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,312 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,315 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,316 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,317 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,318 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,327 2019 Book A Beginner's Guide To Python 3 Program,self.surname = surname,simpleattr,327 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,327 2019 Book A Beginner's Guide To Python 3 Program,self.x = x,simpleattr,328 2019 Book A Beginner's Guide To Python 3 Program,self.y = y,simpleattr,328 2019 Book A Beginner's Guide To Python 3 Program,self.x = x,simpleattr,328 2019 Book A Beginner's Guide To Python 3 Program,self.y = y,simpleattr,328 2019 Book A Beginner's Guide To Python 3 Program,self._balance += amount,simpleattr,334 2019 Book A Beginner's Guide To Python 3 Program,self._balance -= amount,simpleattr,334 2019 Book A Beginner's Guide To Python 3 Program,self.limit = limit,simpleattr,338 2019 Book A Beginner's Guide To Python 3 Program,self.val = 0,simpleattr,338 2019 Book A Beginner's Guide To Python 3 Program,self.val += 2,simpleattr,338 2019 Book A Beginner's Guide To Python 3 Program,self._list = [] # initial internal data,simpleattr,392 2019 Book A Beginner's Guide To Python 3 Program,self.name = name,simpleattr,398 2019 Book A Beginner's Guide To Python 3 Program,self.age = age,simpleattr,398 2019 Book A Beginner's Guide To Python 3 Program,self.label = string,simpleattr,407 2019 Book A Beginner's Guide To Python 3 Program,self.x = x,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self.y = y,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self.counter = counter,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self.board = board,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self._counter = None,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self._counter = value,simpleattr,408 2019 Book A Beginner's Guide To Python 3 Program,self.separator = '\n' + ('-' * 11) + '\n',simpleattr,411 2019 Book A Beginner's Guide To Python 3 Program,self.board = Board(),simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.human = HumanPlayer(self.board),simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.computer = ComputerPlayer(self.board),simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.next_player = None,simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.winner = None,simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.human.counter = X,simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.computer.counter = O,simpleattr,412 2019 Book A Beginner's Guide To Python 3 Program,self.human.counter = O,simpleattr,413 2019 Book A Beginner's Guide To Python 3 Program,self.computer.counter = X,simpleattr,413 2019 Book A Beginner's Guide To Python 3 Program,self.next_player = self.human,simpleattr,413 2019 Book A Beginner's Guide To Python 3 Program,self.next_player = self.computer,simpleattr,413 2019 Book A Beginner's Guide To Python 3 Program,self.next_player = self.human,simpleattr,413 2019 Book A Beginner's Guide To Python 3 Program,"operator. For example, the += compound operator is a combination of the add",assignIncrement,58 2019 Book A Beginner's Guide To Python 3 Program,x += 1 # has the same behaviour as x = x + 1,assignIncrement,58 2019 Book A Beginner's Guide To Python 3 Program,x += 2,assignIncrement,59 2019 Book A Beginner's Guide To Python 3 Program,count += 1 # also part of the while loop,assignIncrement,72 2019 Book A Beginner's Guide To Python 3 Program,count (remember count +=1 is equivalent to count = count + 1).,assignIncrement,72 2019 Book A Beginner's Guide To Python 3 Program,count_number_of_tries += 1,assignIncrement,88 2019 Book A Beginner's Guide To Python 3 Program,count_number_of_tries += 1,assignIncrement,90 2019 Book A Beginner's Guide To Python 3 Program,count += 1,assignIncrement,91 2019 Book A Beginner's Guide To Python 3 Program,"print('You are now', self.age) += 1",assignIncrement,188 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay += 2.50,assignIncrement,189 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay += 2.50,assignIncrement,190 2019 Book A Beginner's Guide To Python 3 Program,Person.instance_count += 1,assignIncrement,196 2019 Book A Beginner's Guide To Python 3 Program,cls.instance_count += 1,assignIncrement,197 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay += 2.50,assignIncrement,203 2019 Book A Beginner's Guide To Python 3 Program,Student.count += 1,assignIncrement,312 2019 Book A Beginner's Guide To Python 3 Program,Student.count += 1,assignIncrement,315 2019 Book A Beginner's Guide To Python 3 Program,Student.count += 1,assignIncrement,316 2019 Book A Beginner's Guide To Python 3 Program,Student.count += 1,assignIncrement,317 2019 Book A Beginner's Guide To Python 3 Program,Student.count += 1,assignIncrement,318 2019 Book A Beginner's Guide To Python 3 Program,value += 2,assignIncrement,341 2019 Book A Beginner's Guide To Python 3 Program,end of the list or we can use the += operator which does the same thing:,assignIncrement,356 2019 Book A Beginner's Guide To Python 3 Program,Note that strictly speaking both extend() and += take an iterable.,assignIncrement,356 2019 Book A Beginner's Guide To Python 3 Program,"def factorial(n, depth = 1):",funcdefault,97 2019 Book A Beginner's Guide To Python 3 Program,"def tail_factorial(n, accumulator=1):",funcdefault,98 2019 Book A Beginner's Guide To Python 3 Program,"def greeter(name, message = 'Live Long and Prosper'):",funcdefault,119 2019 Book A Beginner's Guide To Python 3 Program,"def greeter(message = 'Live Long and Prosper', name):",funcdefault,120 2019 Book A Beginner's Guide To Python 3 Program,def register(active=True):,funcdefault,326 2019 Book A Beginner's Guide To Python 3 Program,range(...),rangefunc,74 2019 Book A Beginner's Guide To Python 3 Program,def print_msg():,simplefunc,114 2019 Book A Beginner's Guide To Python 3 Program,def print_my_msg(msg):,simplefunc,114 2019 Book A Beginner's Guide To Python 3 Program,def square(n):,simplefunc,115 2019 Book A Beginner's Guide To Python 3 Program,def get_integer_input(message):,simplefunc,117 2019 Book A Beginner's Guide To Python 3 Program,def my_function():,simplefunc,127 2019 Book A Beginner's Guide To Python 3 Program,def print_max():,simplefunc,128 2019 Book A Beginner's Guide To Python 3 Program,def print_max():,simplefunc,128 2019 Book A Beginner's Guide To Python 3 Program,def print_max():,simplefunc,129 2019 Book A Beginner's Guide To Python 3 Program,def get_msg():,simplefunc,149 2019 Book A Beginner's Guide To Python 3 Program,def get_some_other_msg():,simplefunc,152 2019 Book A Beginner's Guide To Python 3 Program,def mult_by_two(num):,simplefunc,154 2019 Book A Beginner's Guide To Python 3 Program,def mult_by_five(num):,simplefunc,154 2019 Book A Beginner's Guide To Python 3 Program,def square(num):,simplefunc,154 2019 Book A Beginner's Guide To Python 3 Program,def add_one(num):,simplefunc,154 2019 Book A Beginner's Guide To Python 3 Program,def simple_tax_calculator(amount):,simplefunc,155 2019 Book A Beginner's Guide To Python 3 Program,def make_checker(s):,simplefunc,156 2019 Book A Beginner's Guide To Python 3 Program,def make_function():,simplefunc,157 2019 Book A Beginner's Guide To Python 3 Program,def increase(num):,simplefunc,163 2019 Book A Beginner's Guide To Python 3 Program,def increment(num):,simplefunc,163 2019 Book A Beginner's Guide To Python 3 Program,def reset_function():,simplefunc,163 2019 Book A Beginner's Guide To Python 3 Program,def move_up(self):,simplefunc,173 2019 Book A Beginner's Guide To Python 3 Program,def birthday(self):,simplefunc,202 2019 Book A Beginner's Guide To Python 3 Program,def bonus(self):,simplefunc,203 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,210 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,210 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,210 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,210 2019 Book A Beginner's Guide To Python 3 Program,def move(self):,simplefunc,215 2019 Book A Beginner's Guide To Python 3 Program,def move(self):,simplefunc,215 2019 Book A Beginner's Guide To Python 3 Program,def get_data(self):,simplefunc,216 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,218 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,218 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def print_info(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def get_data(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def print_info(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def print_info(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def get_data(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def print_info(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def get_data(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def print_info(self):,simplefunc,219 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,220 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,220 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,220 2019 Book A Beginner's Guide To Python 3 Program,def is_day_of_week(self):,simplefunc,226 2019 Book A Beginner's Guide To Python 3 Program,def is_birthday():,simplefunc,227 2019 Book A Beginner's Guide To Python 3 Program,def test(date):,simplefunc,228 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,232 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,234 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,237 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,242 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,242 2019 Book A Beginner's Guide To Python 3 Program,def get_age(self):,simplefunc,243 2019 Book A Beginner's Guide To Python 3 Program,def get_name(self):,simplefunc,243 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,243 2019 Book A Beginner's Guide To Python 3 Program,def get_age(self):,simplefunc,245 2019 Book A Beginner's Guide To Python 3 Program,def get_name(self):,simplefunc,245 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,245 2019 Book A Beginner's Guide To Python 3 Program,def del_name(self):,simplefunc,246 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,247 2019 Book A Beginner's Guide To Python 3 Program,def runcalc(x):,simplefunc,254 2019 Book A Beginner's Guide To Python 3 Program,def function_bang():,simplefunc,261 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,263 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,264 2019 Book A Beginner's Guide To Python 3 Program,def main():,simplefunc,265 2019 Book A Beginner's Guide To Python 3 Program,def printer(some_object):,simplefunc,270 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,270 2019 Book A Beginner's Guide To Python 3 Program,def _special_function():,simplefunc,274 2019 Book A Beginner's Guide To Python 3 Program,def my_func():,simplefunc,275 2019 Book A Beginner's Guide To Python 3 Program,def f1():,simplefunc,279 2019 Book A Beginner's Guide To Python 3 Program,def f2():,simplefunc,279 2019 Book A Beginner's Guide To Python 3 Program,def f1():,simplefunc,280 2019 Book A Beginner's Guide To Python 3 Program,def f2():,simplefunc,280 2019 Book A Beginner's Guide To Python 3 Program,def f1():,simplefunc,281 2019 Book A Beginner's Guide To Python 3 Program,def f2():,simplefunc,281 2019 Book A Beginner's Guide To Python 3 Program,def main():,simplefunc,281 2019 Book A Beginner's Guide To Python 3 Program,def __len__(self):,simplefunc,288 2019 Book A Beginner's Guide To Python 3 Program,def display(self):,simplefunc,290 2019 Book A Beginner's Guide To Python 3 Program,def birthday(self):,simplefunc,291 2019 Book A Beginner's Guide To Python 3 Program,def birthday(self):,simplefunc,291 2019 Book A Beginner's Guide To Python 3 Program,def print_me(self):,simplefunc,293 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,293 2019 Book A Beginner's Guide To Python 3 Program,def print_id(self):,simplefunc,293 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,294 2019 Book A Beginner's Guide To Python 3 Program,def night_out(p):,simplefunc,303 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,310 2019 Book A Beginner's Guide To Python 3 Program,def get_length(self):,simplefunc,311 2019 Book A Beginner's Guide To Python 3 Program,def my_default(self):,simplefunc,316 2019 Book A Beginner's Guide To Python 3 Program,def my_default(self):,simplefunc,317 2019 Book A Beginner's Guide To Python 3 Program,def logger(func):,simplefunc,322 2019 Book A Beginner's Guide To Python 3 Program,def inner():,simplefunc,322 2019 Book A Beginner's Guide To Python 3 Program,def target():,simplefunc,323 2019 Book A Beginner's Guide To Python 3 Program,def logger(func):,simplefunc,324 2019 Book A Beginner's Guide To Python 3 Program,def make_bold(fn):,simplefunc,325 2019 Book A Beginner's Guide To Python 3 Program,def makebold_wrapped():,simplefunc,325 2019 Book A Beginner's Guide To Python 3 Program,def make_italic(fn):,simplefunc,325 2019 Book A Beginner's Guide To Python 3 Program,def makeitalic_wrapped():,simplefunc,325 2019 Book A Beginner's Guide To Python 3 Program,def wrap(func):,simplefunc,326 2019 Book A Beginner's Guide To Python 3 Program,def wrapper():,simplefunc,326 2019 Book A Beginner's Guide To Python 3 Program,def pretty_print(method):,simplefunc,327 2019 Book A Beginner's Guide To Python 3 Program,def method_wrapper(self):,simplefunc,327 2019 Book A Beginner's Guide To Python 3 Program,def print_self(self):,simplefunc,327 2019 Book A Beginner's Guide To Python 3 Program,def trace(method):,simplefunc,328 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,328 2019 Book A Beginner's Guide To Python 3 Program,def singleton(cls):,simplefunc,329 2019 Book A Beginner's Guide To Python 3 Program,def get_instance():,simplefunc,329 2019 Book A Beginner's Guide To Python 3 Program,def print_it(self):,simplefunc,330 2019 Book A Beginner's Guide To Python 3 Program,def logger(func):,simplefunc,331 2019 Book A Beginner's Guide To Python 3 Program,def inner():,simplefunc,331 2019 Book A Beginner's Guide To Python 3 Program,def logger(func):,simplefunc,332 2019 Book A Beginner's Guide To Python 3 Program,def inner():,simplefunc,332 2019 Book A Beginner's Guide To Python 3 Program,def logger(func):,simplefunc,333 2019 Book A Beginner's Guide To Python 3 Program,def __iter__(self):,simplefunc,338 2019 Book A Beginner's Guide To Python 3 Program,def __next__(self):,simplefunc,338 2019 Book A Beginner's Guide To Python 3 Program,def evens_up_to(limit):,simplefunc,341 2019 Book A Beginner's Guide To Python 3 Program,def grep(pattern):,simplefunc,343 2019 Book A Beginner's Guide To Python 3 Program,def is_even(i):,simplefunc,398 2019 Book A Beginner's Guide To Python 3 Program,def __str__(self):,simplefunc,398 2019 Book A Beginner's Guide To Python 3 Program,def add_one(i):,simplefunc,400 2019 Book A Beginner's Guide To Python 3 Program,def __iter__(self):,simplefunc,403 2019 Book A Beginner's Guide To Python 3 Program,def select_player_to_go_first(self):,simplefunc,413 2019 Book A Beginner's Guide To Python 3 Program,def play(self):,simplefunc,413 2019 Book A Beginner's Guide To Python 3 Program,return to the Hello World program and look at what it is,return,22 2019 Book A Beginner's Guide To Python 3 Program,return to it here and take a closer look at what is going on.,return,22 2019 Book A Beginner's Guide To Python 3 Program,return key.,return,24 2019 Book A Beginner's Guide To Python 3 Program,return to the data held at that location. This address is often referred to as the,return,25 2019 Book A Beginner's Guide To Python 3 Program,return the type of,return,33 2019 Book A Beginner's Guide To Python 3 Program,return to this concept more when we explore classes and objects. For the moment,return,36 2019 Book A Beginner's Guide To Python 3 Program,return either True or False,return,38 2019 Book A Beginner's Guide To Python 3 Program,return to the import statement later in the book; for now just except,return,44 2019 Book A Beginner's Guide To Python 3 Program,return a,return,44 2019 Book A Beginner's Guide To Python 3 Program,"return self.pattern.sub(convert, self.template)",return,46 2019 Book A Beginner's Guide To Python 3 Program,return str(mapping[named]),return,46 2019 Book A Beginner's Guide To Python 3 Program,return any remainder,return,54 2019 Book A Beginner's Guide To Python 3 Program,return Boolean values. They are key to the conditional elements,return,62 2019 Book A Beginner's Guide To Python 3 Program,return a value; statements do,return,67 2019 Book A Beginner's Guide To Python 3 Program,return it as the result of the if expression. For example:,return,68 2019 Book A Beginner's Guide To Python 3 Program,return True if the number is even (note the brackets are optional but,return,70 2019 Book A Beginner's Guide To Python 3 Program,return to the kilometres to miles converter you wrote in,return,70 2019 Book A Beginner's Guide To Python 3 Program,return when it,return,72 2019 Book A Beginner's Guide To Python 3 Program,return to this feature of the for loop when we look at collections/containers of data,return,74 2019 Book A Beginner's Guide To Python 3 Program,return with an error message.,return,81 2019 Book A Beginner's Guide To Python 3 Program,return a result.,return,93 2019 Book A Beginner's Guide To Python 3 Program,return (often with some result). The termination condition may be because:,return,94 2019 Book A Beginner's Guide To Python 3 Program,return to this in a later chapter on Functional,return,94 2019 Book A Beginner's Guide To Python 3 Program,return without a result.,return,95 2019 Book A Beginner's Guide To Python 3 Program,return the value 1 if the number passed in is 1—this is the base case.,return,96 2019 Book A Beginner's Guide To Python 3 Program,return 1 # The base case,return,97 2019 Book A Beginner's Guide To Python 3 Program,return res,return,97 2019 Book A Beginner's Guide To Python 3 Program,return 1,return,97 2019 Book A Beginner's Guide To Python 3 Program,return result,return,97 2019 Book A Beginner's Guide To Python 3 Program,return the value 2 and so on.,return,98 2019 Book A Beginner's Guide To Python 3 Program,return accumulator,return,98 2019 Book A Beginner's Guide To Python 3 Program,"return tail_factorial(n - 1, accumulator * n)",return,98 2019 Book A Beginner's Guide To Python 3 Program,return a value.,return,111 2019 Book A Beginner's Guide To Python 3 Program,return a value from a function. In Python this can be,return,115 2019 Book A Beginner's Guide To Python 3 Program,return statement. Whenever a return statement is encountered,return,115 2019 Book A Beginner's Guide To Python 3 Program,return any values following,return,115 2019 Book A Beginner's Guide To Python 3 Program,return keyword.,return,115 2019 Book A Beginner's Guide To Python 3 Program,return n * n,return,115 2019 Book A Beginner's Guide To Python 3 Program,return that value. The returned value can then be used at the point that the function,return,115 2019 Book A Beginner's Guide To Python 3 Program,"return multiple values from a function, for example in this",return,116 2019 Book A Beginner's Guide To Python 3 Program,"return b, a",return,116 2019 Book A Beginner's Guide To Python 3 Program,return int(value_as_string),return,117 2019 Book A Beginner's Guide To Python 3 Program,return another number. We have,return,133 2019 Book A Beginner's Guide To Python 3 Program,return x + y,return,133 2019 Book A Beginner's Guide To Python 3 Program,return x - y,return,133 2019 Book A Beginner's Guide To Python 3 Program,return x * y,return,133 2019 Book A Beginner's Guide To Python 3 Program,return x / y,return,133 2019 Book A Beginner's Guide To Python 3 Program,return ok_to_finish,return,136 2019 Book A Beginner's Guide To Python 3 Program,return True if (and only if) user_selection contains one of the,return,138 2019 Book A Beginner's Guide To Python 3 Program,return user_selection,return,138 2019 Book A Beginner's Guide To Python 3 Program,return both numbers. Both functions are shown here:,return,139 2019 Book A Beginner's Guide To Python 3 Program,"return num1, num2",return,139 2019 Book A Beginner's Guide To Python 3 Program,return int(value_as_string),return,139 2019 Book A Beginner's Guide To Python 3 Program,return value.,return,143 2019 Book A Beginner's Guide To Python 3 Program,return num + 1,return,147 2019 Book A Beginner's Guide To Python 3 Program,return different values for the previously entered parameters. For,return,147 2019 Book A Beginner's Guide To Python 3 Program,return num + amount,return,147 2019 Book A Beginner's Guide To Python 3 Program,"return (or both), a function. To do this we will",return,149 2019 Book A Beginner's Guide To Python 3 Program,return 'Hello Python World!',return,149 2019 Book A Beginner's Guide To Python 3 Program,return 'Some other message!!!',return,152 2019 Book A Beginner's Guide To Python 3 Program,return result,return,153 2019 Book A Beginner's Guide To Python 3 Program,return y * 10.0,return,153 2019 Book A Beginner's Guide To Python 3 Program,return the value,return,153 2019 Book A Beginner's Guide To Python 3 Program,return num * 2,return,154 2019 Book A Beginner's Guide To Python 3 Program,return num * 5,return,154 2019 Book A Beginner's Guide To Python 3 Program,return num * num,return,154 2019 Book A Beginner's Guide To Python 3 Program,return num + 1,return,154 2019 Book A Beginner's Guide To Python 3 Program,return func(num),return,154 2019 Book A Beginner's Guide To Python 3 Program,return math.ceil(amount * 0.3),return,155 2019 Book A Beginner's Guide To Python 3 Program,return func(salary),return,155 2019 Book A Beginner's Guide To Python 3 Program,return lambda n: n%2 == 0,return,156 2019 Book A Beginner's Guide To Python 3 Program,return lambda n: n >= 0,return,156 2019 Book A Beginner's Guide To Python 3 Program,return lambda n: n < 0,return,156 2019 Book A Beginner's Guide To Python 3 Program,return a named function. This is done by returning,return,157 2019 Book A Beginner's Guide To Python 3 Program,return x + y,return,157 2019 Book A Beginner's Guide To Python 3 Program,return adder,return,157 2019 Book A Beginner's Guide To Python 3 Program,return x * y,return,159 2019 Book A Beginner's Guide To Python 3 Program,return a *,return,160 2019 Book A Beginner's Guide To Python 3 Program,"return lambda y: func(num, y)",return,161 2019 Book A Beginner's Guide To Python 3 Program,return num + more,return,163 2019 Book A Beginner's Guide To Python 3 Program,return num + 1,return,163 2019 Book A Beginner's Guide To Python 3 Program,"return something. However, it is up to the object to determine how",return,169 2019 Book A Beginner's Guide To Python 3 Program,return a string,return,186 2019 Book A Beginner's Guide To Python 3 Program,return a string from the __str__ method that provides and the name,return,187 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,187 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,188 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,188 2019 Book A Beginner's Guide To Python 3 Program,"return any parameters; however, instance",return,189 2019 Book A Beginner's Guide To Python 3 Program,return the amount someone should be paid:,return,189 2019 Book A Beginner's Guide To Python 3 Program,return hours_worked * rate_of_pay,return,189 2019 Book A Beginner's Guide To Python 3 Program,return a Boolean value depending upon the age attribute:,return,190 2019 Book A Beginner's Guide To Python 3 Program,return self.age < 20,return,190 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,190 2019 Book A Beginner's Guide To Python 3 Program,return hours_worked * rate_of_pay,return,190 2019 Book A Beginner's Guide To Python 3 Program,return self.age < 20,return,190 2019 Book A Beginner's Guide To Python 3 Program,return anything (i.e. it does not return a value),return,191 2019 Book A Beginner's Guide To Python 3 Program,"return the number of instances of this class that have been created.",return,198 2019 Book A Beginner's Guide To Python 3 Program,return hours_worked * rate_of_pay,return,203 2019 Book A Beginner's Guide To Python 3 Program,return self.sales *,return,203 2019 Book A Beginner's Guide To Python 3 Program,return 'Person ' + self.name + ' is ' + str(self.age),return,210 2019 Book A Beginner's Guide To Python 3 Program,return 'Employee(' + str(self.id) + ')',return,210 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,210 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age) + ' - i,return,210 2019 Book A Beginner's Guide To Python 3 Program,return self.name + ' is ' + str(self.age),return,211 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + '-id(' + str(self.id) + ')',return,211 2019 Book A Beginner's Guide To Python 3 Program,return super().get_data() + 'FData',return,216 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'X',return,218 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'X',return,218 2019 Book A Beginner's Guide To Python 3 Program,return 'A',return,219 2019 Book A Beginner's Guide To Python 3 Program,return 'B',return,219 2019 Book A Beginner's Guide To Python 3 Program,return 'C',return,219 2019 Book A Beginner's Guide To Python 3 Program,return 'CData',return,219 2019 Book A Beginner's Guide To Python 3 Program,return 'D',return,219 2019 Book A Beginner's Guide To Python 3 Program,return 'E',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'F',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().get_data() + 'FData',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'G',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().get_data() + 'GData',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'H',return,219 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'J',return,220 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'I',return,220 2019 Book A Beginner's Guide To Python 3 Program,return super().__str__() + 'X',return,220 2019 Book A Beginner's Guide To Python 3 Program,return Boolean;,return,225 2019 Book A Beginner's Guide To Python 3 Program,"return Boolean;",return,225 2019 Book A Beginner's Guide To Python 3 Program,return self.month == month_index,return,226 2019 Book A Beginner's Guide To Python 3 Program,return true if it does and,return,228 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,232 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,232 2019 Book A Beginner's Guide To Python 3 Program,return 'Quantity[' + str(self.value) + ']',return,232 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,234 2019 Book A Beginner's Guide To Python 3 Program,return 'Quantity[' + str(self.value) + ']',return,234 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,236 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,236 2019 Book A Beginner's Guide To Python 3 Program,return Quantity(new_value),return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value == other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value != other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value >= other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value > other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value < other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return self.value <= other.value,return,237 2019 Book A Beginner's Guide To Python 3 Program,return 'Quantity[' + str(self.value) + ']',return,237 2019 Book A Beginner's Guide To Python 3 Program,return the,return,238 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self.name) + '] is ' +,return,242 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self._name) +'] is ' + s,return,242 2019 Book A Beginner's Guide To Python 3 Program,return self._age,return,243 2019 Book A Beginner's Guide To Python 3 Program,return self._name,return,243 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self._name) +'] is ' +,return,243 2019 Book A Beginner's Guide To Python 3 Program,return the attribute being used (as is the case here).,return,243 2019 Book A Beginner's Guide To Python 3 Program,return self._age,return,245 2019 Book A Beginner's Guide To Python 3 Program,return self._name,return,245 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self._name) +'] is ' +,return,245 2019 Book A Beginner's Guide To Python 3 Program,return self._age,return,247 2019 Book A Beginner's Guide To Python 3 Program,return self._name,return,247 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self._name) +'] is ' +,return,247 2019 Book A Beginner's Guide To Python 3 Program,return self._age,return,263 2019 Book A Beginner's Guide To Python 3 Program,return self._name,return,263 2019 Book A Beginner's Guide To Python 3 Program,return 'Person[' + str(self._name) + '] is ' +,return,263 2019 Book A Beginner's Guide To Python 3 Program,return 'InvalidAgeException(' + str(self.value) + ')',return,264 2019 Book A Beginner's Guide To Python 3 Program,return 'Shape - ' + self._id,return,270 2019 Book A Beginner's Guide To Python 3 Program,return self._id,return,270 2019 Book A Beginner's Guide To Python 3 Program,return self._id,return,290 2019 Book A Beginner's Guide To Python 3 Program,return True for that class with respect to the virtual,return,291 2019 Book A Beginner's Guide To Python 3 Program,return True:,return,292 2019 Book A Beginner's Guide To Python 3 Program,return 'Employee(' + self.id + ')' + self.name + '[',return,293 2019 Book A Beginner's Guide To Python 3 Program,return 'Employee(' + self.id + ')' + self.name + '[',return,294 2019 Book A Beginner's Guide To Python 3 Program,return values from these methods. In these languages it helps to,return,296 2019 Book A Beginner's Guide To Python 3 Program,return x + y,return,296 2019 Book A Beginner's Guide To Python 3 Program,return x + y,return,298 2019 Book A Beginner's Guide To Python 3 Program,return x - y,return,298 2019 Book A Beginner's Guide To Python 3 Program,return x * y,return,298 2019 Book A Beginner's Guide To Python 3 Program,return x / y,return,298 2019 Book A Beginner's Guide To Python 3 Program,return Distance(self.value + other.value),return,298 2019 Book A Beginner's Guide To Python 3 Program,return Distance(self.value - other.value),return,298 2019 Book A Beginner's Guide To Python 3 Program,return 'Distance[' + str(self.value) +,return,298 2019 Book A Beginner's Guide To Python 3 Program,return x / y,return,299 2019 Book A Beginner's Guide To Python 3 Program,return an object that will be used,return,301 2019 Book A Beginner's Guide To Python 3 Program,return self although it is not a requirement to do so (this flexibility,return,301 2019 Book A Beginner's Guide To Python 3 Program,return self,return,302 2019 Book A Beginner's Guide To Python 3 Program,return True,return,302 2019 Book A Beginner's Guide To Python 3 Program,return 'ContextManagedClass object',return,302 2019 Book A Beginner's Guide To Python 3 Program,"return such a string, you use the same method (__str__(), in Python).",return,303 2019 Book A Beginner's Guide To Python 3 Program,return the,return,304 2019 Book A Beginner's Guide To Python 3 Program,return self.data[pos],return,310 2019 Book A Beginner's Guide To Python 3 Program,return 'Bag(' + str(self.data) + ')',return,310 2019 Book A Beginner's Guide To Python 3 Program,return len(self.data),return,311 2019 Book A Beginner's Guide To Python 3 Program,return the length of the associated data items.,return,311 2019 Book A Beginner's Guide To Python 3 Program,return 'default',return,315 2019 Book A Beginner's Guide To Python 3 Program,return a reference to a method to use as,return,316 2019 Book A Beginner's Guide To Python 3 Program,return a,return,316 2019 Book A Beginner's Guide To Python 3 Program,return self.my_default,return,316 2019 Book A Beginner's Guide To Python 3 Program,return 'default',return,316 2019 Book A Beginner's Guide To Python 3 Program,return a reference to the,return,316 2019 Book A Beginner's Guide To Python 3 Program,return an attribute value,return,317 2019 Book A Beginner's Guide To Python 3 Program,return 'default',return,317 2019 Book A Beginner's Guide To Python 3 Program,"return object.__getattribute__(self, name)",return,317 2019 Book A Beginner's Guide To Python 3 Program,return a default value of −1.,return,319 2019 Book A Beginner's Guide To Python 3 Program,return the value −1 which will,return,320 2019 Book A Beginner's Guide To Python 3 Program,return a third function representing the decorated,return,321 2019 Book A Beginner's Guide To Python 3 Program,return a,return,321 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,322 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,324 2019 Book A Beginner's Guide To Python 3 Program,return makebold_wrapped,return,325 2019 Book A Beginner's Guide To Python 3 Program,"return ""<b>"" + fn() + ""</b>""",return,325 2019 Book A Beginner's Guide To Python 3 Program,return makeitalic_wrapped,return,325 2019 Book A Beginner's Guide To Python 3 Program,"return ""<i>"" + fn() + ""</i>""",return,325 2019 Book A Beginner's Guide To Python 3 Program,return 'hello world',return,325 2019 Book A Beginner's Guide To Python 3 Program,return wrapper,return,326 2019 Book A Beginner's Guide To Python 3 Program,return wrap,return,326 2019 Book A Beginner's Guide To Python 3 Program,"return ""<p>{0}</p>"".format(method(self))",return,327 2019 Book A Beginner's Guide To Python 3 Program,return method_wrapper,return,327 2019 Book A Beginner's Guide To Python 3 Program,"return self.name + "" "" + self.surname",return,327 2019 Book A Beginner's Guide To Python 3 Program,return method_wrapper,return,328 2019 Book A Beginner's Guide To Python 3 Program,"return 'Point - ' + str(self.x) + ',' +",return,328 2019 Book A Beginner's Guide To Python 3 Program,return instance,return,329 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,331 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,332 2019 Book A Beginner's Guide To Python 3 Program,"return ""Hello ""+name",return,332 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,333 2019 Book A Beginner's Guide To Python 3 Program,return a sequence of values. Iterators may be nite,return,337 2019 Book A Beginner's Guide To Python 3 Program,return the next,return,337 2019 Book A Beginner's Guide To Python 3 Program,return or to raise the,return,337 2019 Book A Beginner's Guide To Python 3 Program,return the iterator,return,337 2019 Book A Beginner's Guide To Python 3 Program,return a different object that will be used to implement the iterator or,return,337 2019 Book A Beginner's Guide To Python 3 Program,return itself as the iterator—it’s the designers choice.,return,337 2019 Book A Beginner's Guide To Python 3 Program,return self,return,338 2019 Book A Beginner's Guide To Python 3 Program,return return_val,return,338 2019 Book A Beginner's Guide To Python 3 Program,return iter-,return,339 2019 Book A Beginner's Guide To Python 3 Program,return one of the values associated with a yield statement; in this case the,return,340 2019 Book A Beginner's Guide To Python 3 Program,return no value; if required the generator,return,342 2019 Book A Beginner's Guide To Python 3 Program,return what is known as a slice from a Tuple. This is a new,return,348 2019 Book A Beginner's Guide To Python 3 Program,return a subset,return,352 2019 Book A Beginner's Guide To Python 3 Program,return a new instance of the class Tuple and have no,return,352 2019 Book A Beginner's Guide To Python 3 Program,return to your Account related classes.,return,361 2019 Book A Beginner's Guide To Python 3 Program,"return that item as a result of running the method); however it removes the last item in the",return,365 2019 Book A Beginner's Guide To Python 3 Program,return the associated value. It is,return,374 2019 Book A Beginner's Guide To Python 3 Program,return inner,return,380 2019 Book A Beginner's Guide To Python 3 Program,return 1,return,380 2019 Book A Beginner's Guide To Python 3 Program,return factorial_value,return,380 2019 Book A Beginner's Guide To Python 3 Program,return the stored value if one is present.,return,381 2019 Book A Beginner's Guide To Python 3 Program,return the value,return,382 2019 Book A Beginner's Guide To Python 3 Program,return almost immediately.,return,382 2019 Book A Beginner's Guide To Python 3 Program,return in,return,382 2019 Book A Beginner's Guide To Python 3 Program,return iterators constructed,return,387 2019 Book A Beginner's Guide To Python 3 Program,return self._list.pop(0),return,392 2019 Book A Beginner's Guide To Python 3 Program,return len(self._list),return,392 2019 Book A Beginner's Guide To Python 3 Program,return self.__len__() == 0,return,392 2019 Book A Beginner's Guide To Python 3 Program,return self._list[0],return,392 2019 Book A Beginner's Guide To Python 3 Program,return 'Queue: ' + str(self._list),return,392 2019 Book A Beginner's Guide To Python 3 Program,return the size of the stack. This method also meets,return,395 2019 Book A Beginner's Guide To Python 3 Program,return i % 2 == 0,return,398 2019 Book A Beginner's Guide To Python 3 Program,return 'Person(' + self.name +,return,398 2019 Book A Beginner's Guide To Python 3 Program,return i + 1,return,400 2019 Book A Beginner's Guide To Python 3 Program,return a whole integer (rather than a,return,402 2019 Book A Beginner's Guide To Python 3 Program,return iter(self._list),return,403 2019 Book A Beginner's Guide To Python 3 Program,return True if not return False. Call this function is_job().,return,403 2019 Book A Beginner's Guide To Python 3 Program,return this as the result of the function. Call this function add_item().,return,403 2019 Book A Beginner's Guide To Python 3 Program,return self.label,return,407 2019 Book A Beginner's Guide To Python 3 Program,return self._counter,return,408 2019 Book A Beginner's Guide To Python 3 Program,return row1 + self.separator + row2 + self.separator +,return,411 2019 Book A Beginner's Guide To Python 3 Program,return self.cells[row][column] == ' ',return,411 2019 Book A Beginner's Guide To Python 3 Program,return self.cells[row][column] == counter,return,411 2019 Book A Beginner's Guide To Python 3 Program,return True,return,411 2019 Book A Beginner's Guide To Python 3 Program,return False,return,411 2019 Book A Beginner's Guide To Python 3 Program,return (# across the top,return,411 2019 Book A Beginner's Guide To Python 3 Program,"if you type in python on a Mac you will get something like this:",simpleif,13 2019 Book A Beginner's Guide To Python 3 Program,if you try the following:,simpleif,38 2019 Book A Beginner's Guide To Python 3 Program,if we divide 3 by 2:,simpleif,55 2019 Book A Beginner's Guide To Python 3 Program,if we multiple them together then we get a floating point number:,simpleif,57 2019 Book A Beginner's Guide To Python 3 Program,"if num < 0: print(num, 'is negative')",simpleif,64 2019 Book A Beginner's Guide To Python 3 Program,"if num > 0: print(num, 'is positive')",simpleif,64 2019 Book A Beginner's Guide To Python 3 Program,if the conditional part of the if statement returns False. For example:,simpleif,65 2019 Book A Beginner's Guide To Python 3 Program,if we enter the value 1:,simpleif,65 2019 Book A Beginner's Guide To Python 3 Program,if we enter the value −1:,simpleif,65 2019 Book A Beginner's Guide To Python 3 Program,"if savings == 0: print(""Sorry no savings"")",simpleif,66 2019 Book A Beginner's Guide To Python 3 Program,"if savings < 500: print('Well done')",simpleif,66 2019 Book A Beginner's Guide To Python 3 Program,"if savings < 1000: print('Thats a tidy sum')",simpleif,66 2019 Book A Beginner's Guide To Python 3 Program,"if temp < 0: print('It is freezing')",simpleif,67 2019 Book A Beginner's Guide To Python 3 Program,"if snowing: print('Put on boots')",simpleif,67 2019 Book A Beginner's Guide To Python 3 Program,"if block, for example:",simpleif,67 2019 Book A Beginner's Guide To Python 3 Program,"if temp < 0: print('It is freezing')",simpleif,67 2019 Book A Beginner's Guide To Python 3 Program,"if snowing: print('Put on boots')",simpleif,67 2019 Book A Beginner's Guide To Python 3 Program,if they are over 12 and under 20. We could write this as:,simpleif,68 2019 Book A Beginner's Guide To Python 3 Program,if the value of i is even:,simpleif,77 2019 Book A Beginner's Guide To Python 3 Program,if square(3) < 15:,simpleif,115 2019 Book A Beginner's Guide To Python 3 Program,if we have the following:,simpleif,127 2019 Book A Beginner's Guide To Python 3 Program,if we write:,simpleif,128 2019 Book A Beginner's Guide To Python 3 Program,if we write:,simpleif,151 2019 Book A Beginner's Guide To Python 3 Program,"if s == 'even': elif s == 'positive':",simpleif,156 2019 Book A Beginner's Guide To Python 3 Program,"if s == 'negative': else:",simpleif,156 2019 Book A Beginner's Guide To Python 3 Program,if we write:,simpleif,197 2019 Book A Beginner's Guide To Python 3 Program,if we change the order of the parent classes such that we swap I and J:,simpleif,218 2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(other, int): else:",simpleif,236 2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(other, int): else:",simpleif,236 2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(value,int) & value > 0 & value < 120:",simpleif,247 2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(value, int) & (value > 0 & value < 120):",simpleif,263 2019 Book A Beginner's Guide To Python 3 Program,"if we write: try:",simpleif,263 2019 Book A Beginner's Guide To Python 3 Program,"if isinstance(value,int) & (value > 0 & value < 120): else:",simpleif,264 2019 Book A Beginner's Guide To Python 3 Program,if our utils module now included a function:,simpleif,274 2019 Book A Beginner's Guide To Python 3 Program,if we explicitly import the function then we can still reference it:,simpleif,275 2019 Book A Beginner's Guide To Python 3 Program,if we now write:,simpleif,279 2019 Book A Beginner's Guide To Python 3 Program,"if we extend the above example: Bag.name = 'My Bag'",simpleif,312 2019 Book A Beginner's Guide To Python 3 Program,"if active: func()",simpleif,326 2019 Book A Beginner's Guide To Python 3 Program,if self.val > self.limit:,simpleif,338 2019 Book A Beginner's Guide To Python 3 Program,"if number.isnumeric(): num = int(number)",simpleif,345 2019 Book A Beginner's Guide To Python 3 Program,"if num <= 2: else:",simpleif,345 2019 Book A Beginner's Guide To Python 3 Program,if two objects are equal. For example:,simpleif,378 2019 Book A Beginner's Guide To Python 3 Program,if statement to lter out all odd numbers:,simpleif,384 2019 Book A Beginner's Guide To Python 3 Program,"if random.randint(0, 1) == 0:",simpleif,413 2019 Book A Beginner's Guide To Python 3 Program,if self.winner is not None:,simpleif,413 2019 Book A Beginner's Guide To Python 3 Program,"if self.board.is_full(): print('Game is a Tie')",simpleif,413 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello, world')",printfunc,9 2019 Book A Beginner's Guide To Python 3 Program,print(5 + 4),printfunc,9 2019 Book A Beginner's Guide To Python 3 Program,print(name),printfunc,9 2019 Book A Beginner's Guide To Python 3 Program,print('Hello World') and Print('Hello World'),printfunc,18 2019 Book A Beginner's Guide To Python 3 Program,print('Hello World') and Print('Hello World'),printfunc,20 2019 Book A Beginner's Guide To Python 3 Program,print('Hello World'),printfunc,22 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,23 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello, world')",printfunc,24 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello ', user_name)",printfunc,24 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello', user_name)",printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello, world')",printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello', name)",printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello Best Friend', name)",printfunc,25 2019 Book A Beginner's Guide To Python 3 Program,print(my_variable),printfunc,26 2019 Book A Beginner's Guide To Python 3 Program,print(my_variable),printfunc,26 2019 Book A Beginner's Guide To Python 3 Program,print(my_variable),printfunc,26 2019 Book A Beginner's Guide To Python 3 Program,"print('Hello', user_name)",printfunc,28 2019 Book A Beginner's Guide To Python 3 Program,print(name),printfunc,29 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,29 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,30 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,31 2019 Book A Beginner's Guide To Python 3 Program,"print(""It's the day"")",printfunc,32 2019 Book A Beginner's Guide To Python 3 Program,"print('She said ""hello"" to everyone')",printfunc,32 2019 Book A Beginner's Guide To Python 3 Program,print(z),printfunc,33 2019 Book A Beginner's Guide To Python 3 Program,print(type(my_variable)),printfunc,33 2019 Book A Beginner's Guide To Python 3 Program,print(string_3),printfunc,34 2019 Book A Beginner's Guide To Python 3 Program,print('Hello ' + 'World'),printfunc,34 2019 Book A Beginner's Guide To Python 3 Program,print(len(string_3)),printfunc,34 2019 Book A Beginner's Guide To Python 3 Program,print(my_string[4]),printfunc,34 2019 Book A Beginner's Guide To Python 3 Program,print(my_string[4]),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,print(my_string[1:5]),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,print(my_string[:5]),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,print(my_string[2:]),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,print('*' * 10),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,print('Hi' * 10),printfunc,35 2019 Book A Beginner's Guide To Python 3 Program,"print('Source string:', title)",printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,print('Split using a space'),printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,print(title.split(' ')),printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,print('Split using a comma'),printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,"print(title.split(','))",printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,print(title.split(' ')),printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,"print(""my_string.count(' '):"", my_string.count(' '))",printfunc,36 2019 Book A Beginner's Guide To Python 3 Program,"print(welcome_message.replace(""Hello"", ""Goodbye""))",printfunc,37 2019 Book A Beginner's Guide To Python 3 Program,print('Edward Alun Rawlings'.find('Alun')),printfunc,37 2019 Book A Beginner's Guide To Python 3 Program,print('Edward John Rawlings'.find('Alun')),printfunc,37 2019 Book A Beginner's Guide To Python 3 Program,print(msg),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print(msg),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print('James' == 'James'),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print('James' == 'John'),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print('James' != 'John'),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print('James' == 'james'),printfunc,38 2019 Book A Beginner's Guide To Python 3 Program,print('Testing a String'),printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 20),printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string', some_string)",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print(""some_string.startswith('H')",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print(""some_string.startswith('h')",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print(""some_string.endswith('d')"", some_string.endswith('d'))",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.istitle()', some_string.istitle())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.isupper()', some_string.isupper())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.islower()', some_string.islower())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.isalpha()', some_string.isalpha())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,print('String conversions'),printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 20),printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.upper()', some_string.upper())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.lower()', some_string.lower())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.title()', some_string.title())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('some_string.swapcase()', some_string.swapcase())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,"print('String leading, trailing spaces', "" xyz "".strip())",printfunc,39 2019 Book A Beginner's Guide To Python 3 Program,print(some_string.isupper),printfunc,40 2019 Book A Beginner's Guide To Python 3 Program,print(some_string.isupper()),printfunc,40 2019 Book A Beginner's Guide To Python 3 Program,print(format_string.format('Phoebe')),printfunc,41 2019 Book A Beginner's Guide To Python 3 Program,"print(""{} is {} years old"".format(name, age))",printfunc,41 2019 Book A Beginner's Guide To Python 3 Program,"print(format_string.format('Smith', 'Carol', 75))",printfunc,42 2019 Book A Beginner's Guide To Python 3 Program,print('|{:25}|'.format('25 characters width')),printfunc,42 2019 Book A Beginner's Guide To Python 3 Program,print('|{:<25}|'.format('left aligned')),printfunc,43 2019 Book A Beginner's Guide To Python 3 Program,print('|{:>25}|'.format('right aligned')),printfunc,43 2019 Book A Beginner's Guide To Python 3 Program,print('|{:^25}|'.format('centered')),printfunc,43 2019 Book A Beginner's Guide To Python 3 Program,"print('{:,}'.format(1234567890))",printfunc,43 2019 Book A Beginner's Guide To Python 3 Program,"print('{:,}'.format(1234567890.0))",printfunc,43 2019 Book A Beginner's Guide To Python 3 Program,print(template.substitute(d)),printfunc,45 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,49 2019 Book A Beginner's Guide To Python 3 Program,print(type(x)),printfunc,49 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,49 2019 Book A Beginner's Guide To Python 3 Program,print(type(x)),printfunc,49 2019 Book A Beginner's Guide To Python 3 Program,print(type(age)),printfunc,50 2019 Book A Beginner's Guide To Python 3 Program,print(age),printfunc,50 2019 Book A Beginner's Guide To Python 3 Program,print(exchange_rate),printfunc,50 2019 Book A Beginner's Guide To Python 3 Program,print(type(exchange_rate)),printfunc,50 2019 Book A Beginner's Guide To Python 3 Program,"print('int value as a float:', float_value)",printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,print(type(float_value)),printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,"print('string value as a float:', float_value)",printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,print(type(float_value)),printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,print(exchange_rate),printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,print(type(exchange_rate)),printfunc,51 2019 Book A Beginner's Guide To Python 3 Program,"print('c1:', c1, ', c2:', c2)",printfunc,52 2019 Book A Beginner's Guide To Python 3 Program,print(type(c1)),printfunc,52 2019 Book A Beginner's Guide To Python 3 Program,print(c1.real),printfunc,52 2019 Book A Beginner's Guide To Python 3 Program,print(c1.imag),printfunc,52 2019 Book A Beginner's Guide To Python 3 Program,print(all_ok),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(all_ok),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(type(all_ok)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(int(True)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(int(False)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(bool(1)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(bool(0)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(status),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(type(status)),printfunc,53 2019 Book A Beginner's Guide To Python 3 Program,print(home + away),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(type(home + away)),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(10 * 4),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(type(10*4)),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(goals_for - goals_against),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(type(goals_for - goals_against)),printfunc,54 2019 Book A Beginner's Guide To Python 3 Program,print(100 / 20),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,print(type(100 / 20)),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,print(res1),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,print(type(res1)),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,print(res1),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,print(type(res1)),printfunc,55 2019 Book A Beginner's Guide To Python 3 Program,"print('Modulus division 4 % 2:', 4 % 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,"print('Modulus division 3 % 2:', 3 % 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,print(a ** b),printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,"print('True division 3/2:', 3 / 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,"print('True division 3//2:', -3 / 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,"print('Integer division 3//2:', 3 // 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,"print('Integer division 3//2:', -3 // 2)",printfunc,56 2019 Book A Beginner's Guide To Python 3 Program,print(2.3 + 1.5),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(1.5 / 2.3),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(1.5 * 2.3),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(2.3 - 1.5),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(1.5 - 2.3),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(i),printfunc,57 2019 Book A Beginner's Guide To Python 3 Program,print(c3),printfunc,58 2019 Book A Beginner's Guide To Python 3 Program,print(winner is None),printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,print(winner is not None),printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner:', winner)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner is None:', winner is None)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner is not None:', winner is not None)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,print(type(winner)),printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,print('Set winner to True'),printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner:', winner)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner is None:', winner is None)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print('winner is not None:', winner is not None)",printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,print(type(winner)),printfunc,59 2019 Book A Beginner's Guide To Python 3 Program,"print(num, 'squared is ', num * num)",printfunc,64 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,64 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,65 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,65 2019 Book A Beginner's Guide To Python 3 Program,print('Its not negative'),printfunc,65 2019 Book A Beginner's Guide To Python 3 Program,print() statement will be run otherwise (else) the second print(),printfunc,65 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,65 2019 Book A Beginner's Guide To Python 3 Program,print('Thank you'),printfunc,66 2019 Book A Beginner's Guide To Python 3 Program,print('Thats a tidy sum'),printfunc,66 2019 Book A Beginner's Guide To Python 3 Program,print('Time for Hot Chocolate'),printfunc,67 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,67 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,67 2019 Book A Beginner's Guide To Python 3 Program,print('Time for Hot Chocolate'),printfunc,67 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,67 2019 Book A Beginner's Guide To Python 3 Program,print(status),printfunc,68 2019 Book A Beginner's Guide To Python 3 Program,print(status),printfunc,68 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,"print(count, ' ', end='')",printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,72 2019 Book A Beginner's Guide To Python 3 Program,print('Print out values in a range'),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,"print(i, ' ', end='')",printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,print('Print out values in a range with an increment of 2'),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,"print(i, ' ', end='')",printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,74 2019 Book A Beginner's Guide To Python 3 Program,"print('.', end='')",printfunc,75 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,75 2019 Book A Beginner's Guide To Python 3 Program,print('Only print code if all iterations completed'),printfunc,76 2019 Book A Beginner's Guide To Python 3 Program,"print(i, ' ', end='')",printfunc,76 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,76 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,77 2019 Book A Beginner's Guide To Python 3 Program,"print(i, ' ', end='')",printfunc,77 2019 Book A Beginner's Guide To Python 3 Program,print('hey its an even number'),printfunc,77 2019 Book A Beginner's Guide To Python 3 Program,print('we love even numbers'),printfunc,77 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,77 2019 Book A Beginner's Guide To Python 3 Program,print('Only print code if all iterations completed'),printfunc,78 2019 Book A Beginner's Guide To Python 3 Program,"print(i, ' ', end='')",printfunc,78 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,78 2019 Book A Beginner's Guide To Python 3 Program,print('All iterations successful'),printfunc,78 2019 Book A Beginner's Guide To Python 3 Program,print('Rolling the dices...'),printfunc,79 2019 Book A Beginner's Guide To Python 3 Program,print('The values are....'),printfunc,79 2019 Book A Beginner's Guide To Python 3 Program,print(dice1),printfunc,79 2019 Book A Beginner's Guide To Python 3 Program,print(dice2),printfunc,79 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,82 2019 Book A Beginner's Guide To Python 3 Program,print('Sorry wrong number'),printfunc,86 2019 Book A Beginner's Guide To Python 3 Program,print('Your guess was lower than the number'),printfunc,88 2019 Book A Beginner's Guide To Python 3 Program,print('Your guess was higher than the number'),printfunc,88 2019 Book A Beginner's Guide To Python 3 Program,print('Welcome to the number guess game'),printfunc,89 2019 Book A Beginner's Guide To Python 3 Program,print('Sorry wrong number'),printfunc,89 2019 Book A Beginner's Guide To Python 3 Program,print('Your guess was lower than the number'),printfunc,90 2019 Book A Beginner's Guide To Python 3 Program,print('Your guess was higher than the number'),printfunc,90 2019 Book A Beginner's Guide To Python 3 Program,print('Well done you won!'),printfunc,90 2019 Book A Beginner's Guide To Python 3 Program,"print(""Sorry - you loose"")",printfunc,90 2019 Book A Beginner's Guide To Python 3 Program,print('Game Over'),printfunc,90 2019 Book A Beginner's Guide To Python 3 Program,"print(‘value found:’, current_node.value)",printfunc,95 2019 Book A Beginner's Guide To Python 3 Program,print('calling recursive_function'),printfunc,96 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(5)),printfunc,97 2019 Book A Beginner's Guide To Python 3 Program,"print('\t' * depth, 'Returning 1')",printfunc,97 2019 Book A Beginner's Guide To Python 3 Program,"print('\t' * depth, 'Returning:', result)",printfunc,97 2019 Book A Beginner's Guide To Python 3 Program,print('Calling factorial( 5 )'),printfunc,97 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(5)),printfunc,97 2019 Book A Beginner's Guide To Python 3 Program,print(tail_factorial(5)),printfunc,98 2019 Book A Beginner's Guide To Python 3 Program,"print('is_prime(3):', is_prime(3))",printfunc,99 2019 Book A Beginner's Guide To Python 3 Program,"print('is_prime(7):', is_prime(7))",printfunc,99 2019 Book A Beginner's Guide To Python 3 Program,"print('is_prime(9):', is_prime(9))",printfunc,99 2019 Book A Beginner's Guide To Python 3 Program,"print('is_prime(31):', is_prime(31))",printfunc,99 2019 Book A Beginner's Guide To Python 3 Program,print(row),printfunc,100 2019 Book A Beginner's Guide To Python 3 Program,print() and input(),printfunc,112 2019 Book A Beginner's Guide To Python 3 Program,print('Hello World!'),printfunc,114 2019 Book A Beginner's Guide To Python 3 Program,print(msg),printfunc,114 2019 Book A Beginner's Guide To Python 3 Program,print(result),printfunc,115 2019 Book A Beginner's Guide To Python 3 Program,print(square( 5)),printfunc,115 2019 Book A Beginner's Guide To Python 3 Program,"print(x, ',', y)",printfunc,116 2019 Book A Beginner's Guide To Python 3 Program,print(z),printfunc,116 2019 Book A Beginner's Guide To Python 3 Program,print('The input must be an integer'),printfunc,117 2019 Book A Beginner's Guide To Python 3 Program,"print('age is', age)",printfunc,117 2019 Book A Beginner's Guide To Python 3 Program,print(get_integer_input.__doc__),printfunc,118 2019 Book A Beginner's Guide To Python 3 Program,"print('Welcome', name, '-', message)",printfunc,119 2019 Book A Beginner's Guide To Python 3 Program,"print('Welcome', name, '-', message)",printfunc,119 2019 Book A Beginner's Guide To Python 3 Program,"print('Welcome', name, '-', message)",printfunc,120 2019 Book A Beginner's Guide To Python 3 Program,"print(prompt, title, name, '-', message)",printfunc,120 2019 Book A Beginner's Guide To Python 3 Program,"print('Welcome', name)",printfunc,121 2019 Book A Beginner's Guide To Python 3 Program,"print('arg:', arg)",printfunc,122 2019 Book A Beginner's Guide To Python 3 Program,"print('key:', key, 'has value: ', kwargs[key])",printfunc,122 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 50),printfunc,122 2019 Book A Beginner's Guide To Python 3 Program,"print('arg:', key, 'has value:', kwargs[key])",printfunc,123 2019 Book A Beginner's Guide To Python 3 Program,print(double(10)),printfunc,124 2019 Book A Beginner's Guide To Python 3 Program,print(func1(4)),printfunc,125 2019 Book A Beginner's Guide To Python 3 Program,"print(func2(3, 4))",printfunc,125 2019 Book A Beginner's Guide To Python 3 Program,"print(func3(2, 3, 4))",printfunc,125 2019 Book A Beginner's Guide To Python 3 Program,print(a_variable),printfunc,127 2019 Book A Beginner's Guide To Python 3 Program,print(a_variable),printfunc,127 2019 Book A Beginner's Guide To Python 3 Program,print(a_variable),printfunc,127 2019 Book A Beginner's Guide To Python 3 Program,print(a_variable),printfunc,127 2019 Book A Beginner's Guide To Python 3 Program,print(max),printfunc,128 2019 Book A Beginner's Guide To Python 3 Program,print(max),printfunc,128 2019 Book A Beginner's Guide To Python 3 Program,print(max),printfunc,129 2019 Book A Beginner's Guide To Python 3 Program,print(max),printfunc,129 2019 Book A Beginner's Guide To Python 3 Program,"print('inner:', title)",printfunc,129 2019 Book A Beginner's Guide To Python 3 Program,"print('outer:', title)",printfunc,129 2019 Book A Beginner's Guide To Python 3 Program,"print('inner:', title)",printfunc,130 2019 Book A Beginner's Guide To Python 3 Program,"print('outer:', title)",printfunc,130 2019 Book A Beginner's Guide To Python 3 Program,print('Simple Calculator App'),printfunc,133 2019 Book A Beginner's Guide To Python 3 Program,"print('Result:', result)",printfunc,134 2019 Book A Beginner's Guide To Python 3 Program,print('================='),printfunc,134 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,134 2019 Book A Beginner's Guide To Python 3 Program,"print('Response must be (y/n), please try again')",printfunc,136 2019 Book A Beginner's Guide To Python 3 Program,"print('Result:', result)",printfunc,137 2019 Book A Beginner's Guide To Python 3 Program,print('================='),printfunc,137 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,137 2019 Book A Beginner's Guide To Python 3 Program,print('Invalid Input (must be 1 - 4)'),printfunc,138 2019 Book A Beginner's Guide To Python 3 Program,print('-----------------'),printfunc,138 2019 Book A Beginner's Guide To Python 3 Program,"print('Result:', result)",printfunc,138 2019 Book A Beginner's Guide To Python 3 Program,print('================='),printfunc,138 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,138 2019 Book A Beginner's Guide To Python 3 Program,print('The input must be an integer'),printfunc,139 2019 Book A Beginner's Guide To Python 3 Program,"print('Result:', result)",printfunc,139 2019 Book A Beginner's Guide To Python 3 Program,print('================='),printfunc,139 2019 Book A Beginner's Guide To Python 3 Program,print('Bye'),printfunc,139 2019 Book A Beginner's Guide To Python 3 Program,print(element),printfunc,144 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,147 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,147 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,147 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,147 2019 Book A Beginner's Guide To Python 3 Program,print(message),printfunc,150 2019 Book A Beginner's Guide To Python 3 Program,print(message),printfunc,150 2019 Book A Beginner's Guide To Python 3 Program,print(type(get_msg)),printfunc,150 2019 Book A Beginner's Guide To Python 3 Program,print(another_reference()),printfunc,151 2019 Book A Beginner's Guide To Python 3 Program,print(get_msg()),printfunc,152 2019 Book A Beginner's Guide To Python 3 Program,print(get_msg()),printfunc,152 2019 Book A Beginner's Guide To Python 3 Program,print(get_msg()),printfunc,152 2019 Book A Beginner's Guide To Python 3 Program,print(another_reference()),printfunc,152 2019 Book A Beginner's Guide To Python 3 Program,print(result),printfunc,154 2019 Book A Beginner's Guide To Python 3 Program,"print(apply(10, mult_by_five))",printfunc,154 2019 Book A Beginner's Guide To Python 3 Program,"print(apply(10, square))",printfunc,154 2019 Book A Beginner's Guide To Python 3 Program,"print(apply(10, add_one))",printfunc,154 2019 Book A Beginner's Guide To Python 3 Program,"print(apply(10, mult_by_two))",printfunc,154 2019 Book A Beginner's Guide To Python 3 Program,"print(calculate_tax(45000.0, simple_tax_calculator))",printfunc,155 2019 Book A Beginner's Guide To Python 3 Program,print(f1(3)),printfunc,156 2019 Book A Beginner's Guide To Python 3 Program,print(f2(3)),printfunc,156 2019 Book A Beginner's Guide To Python 3 Program,print(f3(3)),printfunc,156 2019 Book A Beginner's Guide To Python 3 Program,"print(f1(3, 2))",printfunc,157 2019 Book A Beginner's Guide To Python 3 Program,"print(f1(3, 3))",printfunc,157 2019 Book A Beginner's Guide To Python 3 Program,"print(f1(3, 1))",printfunc,157 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function(2, double))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function(2, triple))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function(16, square_root))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function(2, is_prime))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function(4, is_prime))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function('2', is_integer))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function('A', is_integer))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function('A', is_letter))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(my_higher_order_function('1', is_letter))",printfunc,158 2019 Book A Beginner's Guide To Python 3 Program,"print(multiply(2, 5))",printfunc,161 2019 Book A Beginner's Guide To Python 3 Program,print(double(5)),printfunc,161 2019 Book A Beginner's Guide To Python 3 Program,print(triple(5)),printfunc,161 2019 Book A Beginner's Guide To Python 3 Program,print(increase(10)),printfunc,163 2019 Book A Beginner's Guide To Python 3 Program,print(increase(10)),printfunc,163 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,163 2019 Book A Beginner's Guide To Python 3 Program,print(increment(5)),printfunc,163 2019 Book A Beginner's Guide To Python 3 Program,print(dollars_to_sterling(5)),printfunc,165 2019 Book A Beginner's Guide To Python 3 Program,print(euro_to_sterling(15)),printfunc,165 2019 Book A Beginner's Guide To Python 3 Program,print(sterling_to_dollars(7)),printfunc,165 2019 Book A Beginner's Guide To Python 3 Program,print(sterling_to_euro(9)),printfunc,165 2019 Book A Beginner's Guide To Python 3 Program,print(type(4)),printfunc,180 2019 Book A Beginner's Guide To Python 3 Program,print(type(5.6)),printfunc,180 2019 Book A Beginner's Guide To Python 3 Program,print(type(True)),printfunc,180 2019 Book A Beginner's Guide To Python 3 Program,print(type('Ewan')),printfunc,180 2019 Book A Beginner's Guide To Python 3 Program,"print(type([1, 2, 3, 4]))",printfunc,180 2019 Book A Beginner's Guide To Python 3 Program,"print('id(p1):', id(p1))",printfunc,183 2019 Book A Beginner's Guide To Python 3 Program,"print('id(p2):', id(p2))",printfunc,183 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,184 2019 Book A Beginner's Guide To Python 3 Program,print(px),printfunc,184 2019 Book A Beginner's Guide To Python 3 Program,"print('id(p1):', id(p1))",printfunc,184 2019 Book A Beginner's Guide To Python 3 Program,"print('id(px):', id(px))",printfunc,184 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,185 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,185 2019 Book A Beginner's Guide To Python 3 Program,print(p2),printfunc,185 2019 Book A Beginner's Guide To Python 3 Program,"print(p1.name, 'is', p1.age)",printfunc,185 2019 Book A Beginner's Guide To Python 3 Program,"print(p2.name, 'is', p2.age)",printfunc,185 2019 Book A Beginner's Guide To Python 3 Program,"print(p1.name, 'is', p1.age)",printfunc,186 2019 Book A Beginner's Guide To Python 3 Program,print(),printfunc,187 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,187 2019 Book A Beginner's Guide To Python 3 Program,print(p2),printfunc,187 2019 Book A Beginner's Guide To Python 3 Program,print(p3),printfunc,188 2019 Book A Beginner's Guide To Python 3 Program,print(p3),printfunc,188 2019 Book A Beginner's Guide To Python 3 Program,"print('Pay', p2.name, pay)",printfunc,189 2019 Book A Beginner's Guide To Python 3 Program,"print('Pay', p3.name, pay)",printfunc,189 2019 Book A Beginner's Guide To Python 3 Program,"print('You are now', self.age)",printfunc,190 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,191 2019 Book A Beginner's Guide To Python 3 Program,"print('p1.is_teenager', p1.is_teenager())",printfunc,191 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,191 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,191 2019 Book A Beginner's Guide To Python 3 Program,print(p1),printfunc,192 2019 Book A Beginner's Guide To Python 3 Program,print('Class attributes'),printfunc,193 2019 Book A Beginner's Guide To Python 3 Program,print(Person.__name__),printfunc,193 2019 Book A Beginner's Guide To Python 3 Program,print(Person.__module__),printfunc,193 2019 Book A Beginner's Guide To Python 3 Program,print(Person.__doc__),printfunc,193 2019 Book A Beginner's Guide To Python 3 Program,print('Object attributes'),printfunc,193 2019 Book A Beginner's Guide To Python 3 Program,print(acc1),printfunc,195 2019 Book A Beginner's Guide To Python 3 Program,print(acc2),printfunc,195 2019 Book A Beginner's Guide To Python 3 Program,print(acc3),printfunc,195 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.get_balance())",printfunc,195 2019 Book A Beginner's Guide To Python 3 Program,print(Person.instance_count),printfunc,197 2019 Book A Beginner's Guide To Python 3 Program,print('Static method'),printfunc,199 2019 Book A Beginner's Guide To Python 3 Program,"print('Happy birthday you were', self.age)",printfunc,202 2019 Book A Beginner's Guide To Python 3 Program,"print('You are now', self.age)",printfunc,202 2019 Book A Beginner's Guide To Python 3 Program,print('Person'),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print(p),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print('Employee'),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,"print('e.calculate_pay(40):', e.calculate_pay(40))",printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print('SalesPerson'),printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,"print('s.calculate_pay(40):', s.calculate_pay(40))",printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,"print('s.bonus():', s.bonus())",printfunc,204 2019 Book A Beginner's Guide To Python 3 Program,print(p),printfunc,211 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,211 2019 Book A Beginner's Guide To Python 3 Program,print(p),printfunc,212 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,212 2019 Book A Beginner's Guide To Python 3 Program,print('Car - move()'),printfunc,215 2019 Book A Beginner's Guide To Python 3 Program,print('Toy - move()'),printfunc,215 2019 Book A Beginner's Guide To Python 3 Program,"print('print(x):', x)",printfunc,217 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,217 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,217 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,217 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,218 2019 Book A Beginner's Guide To Python 3 Program,print('A'),printfunc,219 2019 Book A Beginner's Guide To Python 3 Program,print('D'),printfunc,219 2019 Book A Beginner's Guide To Python 3 Program,print('E'),printfunc,219 2019 Book A Beginner's Guide To Python 3 Program,print('F' + self.get_data()),printfunc,219 2019 Book A Beginner's Guide To Python 3 Program,print('H' + self.get_data()),printfunc,219 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.get_balance())",printfunc,221 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.get_balance())",printfunc,221 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 =', q1, ', q2 =', q2)",printfunc,232 2019 Book A Beginner's Guide To Python 3 Program,"print('q3 =', q3)",printfunc,232 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 =', q1, ', q2 =', q2)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q3 =', q3)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q2 - q1 =', q2 - q1)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 * q2 =', q1 * q2)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 / q2 =', q1 / q2)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 * 2', q1 * 2)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q2 / 2', q2 / 2)",printfunc,235 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 =', q1, ',q2 =', q2)",printfunc,237 2019 Book A Beginner's Guide To Python 3 Program,"print('q3 =', q3)",printfunc,237 2019 Book A Beginner's Guide To Python 3 Program,"print('q1 < q2: ', q1 < q2)",printfunc,237 2019 Book A Beginner's Guide To Python 3 Program,"print('q3 > q2: ', q3 > q2)",printfunc,237 2019 Book A Beginner's Guide To Python 3 Program,"print('q3 == q1: ', q3 == q1)",printfunc,237 2019 Book A Beginner's Guide To Python 3 Program,print( d1 + d2),printfunc,239 2019 Book A Beginner's Guide To Python 3 Program,print(d2 // 2),printfunc,239 2019 Book A Beginner's Guide To Python 3 Program,print(d2 * 2),printfunc,239 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,242 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,242 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,244 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,244 2019 Book A Beginner's Guide To Python 3 Program,print(person.get_age()),printfunc,244 2019 Book A Beginner's Guide To Python 3 Program,print(person.get_name()),printfunc,244 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,245 2019 Book A Beginner's Guide To Python 3 Program,print(person.age),printfunc,245 2019 Book A Beginner's Guide To Python 3 Program,print(person.name),printfunc,245 2019 Book A Beginner's Guide To Python 3 Program,print(person),printfunc,245 2019 Book A Beginner's Guide To Python 3 Program,print('In age method'),printfunc,247 2019 Book A Beginner's Guide To Python 3 Program,print('In set_age method'),printfunc,247 2019 Book A Beginner's Guide To Python 3 Program,print('In name'),printfunc,247 2019 Book A Beginner's Guide To Python 3 Program,print(acc1),printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,print(acc2),printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,print(acc3),printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.balance)",printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.balance)",printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.balance)",printfunc,248 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,258 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,260 2019 Book A Beginner's Guide To Python 3 Program,print('Everything worked OK'),printfunc,260 2019 Book A Beginner's Guide To Python 3 Program,print('Always runs'),printfunc,260 2019 Book A Beginner's Guide To Python 3 Program,print('function_bang in'),printfunc,261 2019 Book A Beginner's Guide To Python 3 Program,print('function_bang'),printfunc,261 2019 Book A Beginner's Guide To Python 3 Program,print(ve),printfunc,261 2019 Book A Beginner's Guide To Python 3 Program,print('In age method'),printfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"print('In set_age method(', value, ')')",printfunc,263 2019 Book A Beginner's Guide To Python 3 Program,print('In name'),printfunc,263 2019 Book A Beginner's Guide To Python 3 Program,print('In here'),printfunc,263 2019 Book A Beginner's Guide To Python 3 Program,"print('In set_age method(', value, ')')",printfunc,264 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,266 2019 Book A Beginner's Guide To Python 3 Program,print('Handling Exception'),printfunc,267 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,267 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am the utils module'),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print('printer'),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print(some_object),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print('done'),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print('In id method'),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print('In set_age method'),printfunc,270 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am the utils module')),printfunc,272 2019 Book A Beginner's Guide To Python 3 Program,print(s),printfunc,273 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am the utils module'),printfunc,274 2019 Book A Beginner's Guide To Python 3 Program,print('Special function'),printfunc,274 2019 Book A Beginner's Guide To Python 3 Program,print(utils.__name__),printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,print(utils.__doc__),printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,print(utils.__file__),printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,print(dir(utils)),printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,"print('sys.version: ', sys.version)",printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,"print('sys.maxsize: ', sys.maxsize)",printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,"print('sys.path: ', sys.path)",printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,"print('sys.platform: ', sys.platform)",printfunc,276 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am module 1'),printfunc,279 2019 Book A Beginner's Guide To Python 3 Program,print('f1[1]'),printfunc,279 2019 Book A Beginner's Guide To Python 3 Program,print('f2[1]'),printfunc,279 2019 Book A Beginner's Guide To Python 3 Program,"print('x is', x)",printfunc,279 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am module 1'),printfunc,280 2019 Book A Beginner's Guide To Python 3 Program,print('f1[1]'),printfunc,280 2019 Book A Beginner's Guide To Python 3 Program,print('f2[1]'),printfunc,280 2019 Book A Beginner's Guide To Python 3 Program,"print('x is', x)",printfunc,280 2019 Book A Beginner's Guide To Python 3 Program,print('Hello I am module 1'),printfunc,281 2019 Book A Beginner's Guide To Python 3 Program,print('f1[1]'),printfunc,281 2019 Book A Beginner's Guide To Python 3 Program,print('f2[1]'),printfunc,281 2019 Book A Beginner's Guide To Python 3 Program,"print('x is', x)",printfunc,281 2019 Book A Beginner's Guide To Python 3 Program,print('utils package'),printfunc,282 2019 Book A Beginner's Guide To Python 3 Program,print(acc1),printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,print(acc2),printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,print(acc3),printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,"print('balance:', acc1.balance)",printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,print('Handling Exception'),printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,284 2019 Book A Beginner's Guide To Python 3 Program,"print('Circle: ', self._id)",printfunc,290 2019 Book A Beginner's Guide To Python 3 Program,print(c.id),printfunc,290 2019 Book A Beginner's Guide To Python 3 Program,print('Happy Birthday'),printfunc,291 2019 Book A Beginner's Guide To Python 3 Program,print('Its your birthday'),printfunc,291 2019 Book A Beginner's Guide To Python 3 Program,"print(issubclass(Employee, Person))",printfunc,292 2019 Book A Beginner's Guide To Python 3 Program,"print(isinstance(e, Person))",printfunc,292 2019 Book A Beginner's Guide To Python 3 Program,"print(issubclass(Employee, Person))",printfunc,292 2019 Book A Beginner's Guide To Python 3 Program,"print(isinstance(e, Person))",printfunc,292 2019 Book A Beginner's Guide To Python 3 Program,print(self),printfunc,293 2019 Book A Beginner's Guide To Python 3 Program,print(self.id),printfunc,293 2019 Book A Beginner's Guide To Python 3 Program,"print('calc.add(3, 4):', calc.add(3, 4))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print('calc.add(3, 4.5):', calc.add(3, 4.5))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print('calc.add(4.5, 6.2):', calc.add(4.5, 6.2))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print('calc.add(2.3, 7):', calc.add(2.3, 7))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print('calc.add(-1, 4):', calc.add(-1, 4))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print(calc.add(q1, q2))",printfunc,297 2019 Book A Beginner's Guide To Python 3 Program,"print(calc.add(d1, d2))",printfunc,299 2019 Book A Beginner's Guide To Python 3 Program,"print(calc.subtract(d1, d2))",printfunc,299 2019 Book A Beginner's Guide To Python 3 Program,"print(calc.divide(d1, d2))",printfunc,299 2019 Book A Beginner's Guide To Python 3 Program,"print('In with block', cmc)",printfunc,301 2019 Book A Beginner's Guide To Python 3 Program,print('Existing'),printfunc,301 2019 Book A Beginner's Guide To Python 3 Program,print('__init__'),printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,print('__enter__'),printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,"print('__exit__:', args)",printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,"print('In with block', cmc)",printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,print('Exiting'),printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,302 2019 Book A Beginner's Guide To Python 3 Program,print('Person - Eat'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Person - Drink'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Person - Sleep'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Employee - Eat'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Employee - Drink'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Employee - Sleep'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('SalesPerson - Eat'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('SalesPerson - Drink'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Dog - Eat'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Dog - Drink'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,print('Dog - Sleep'),printfunc,303 2019 Book A Beginner's Guide To Python 3 Program,"print('__set__:', inst, '-', self.name, '=', value)",printfunc,305 2019 Book A Beginner's Guide To Python 3 Program,"print('__delete__', instance)",printfunc,305 2019 Book A Beginner's Guide To Python 3 Program,"print('__set_name__', 'owner', owner, 'setting', name)",printfunc,305 2019 Book A Beginner's Guide To Python 3 Program,"print('move_by', dx, ',', dy)",printfunc,305 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,"print('p1:', cursor)",printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,"print('p1 updated:', cursor)",printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,"print('p1.x:', cursor.x)",printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 25),printfunc,306 2019 Book A Beginner's Guide To Python 3 Program,print(acc.balance),printfunc,308 2019 Book A Beginner's Guide To Python 3 Program,print(b),printfunc,310 2019 Book A Beginner's Guide To Python 3 Program,print(len(b)),printfunc,310 2019 Book A Beginner's Guide To Python 3 Program,print(len(b)),printfunc,310 2019 Book A Beginner's Guide To Python 3 Program,print(len(b)),printfunc,311 2019 Book A Beginner's Guide To Python 3 Program,print(b.name),printfunc,312 2019 Book A Beginner's Guide To Python 3 Program,print(b.name),printfunc,312 2019 Book A Beginner's Guide To Python 3 Program,print(b.name),printfunc,312 2019 Book A Beginner's Guide To Python 3 Program,print(b2.name),printfunc,312 2019 Book A Beginner's Guide To Python 3 Program,"print('Student.count:', Student.count)",printfunc,313 2019 Book A Beginner's Guide To Python 3 Program,"print('student.name:', student.name)",printfunc,313 2019 Book A Beginner's Guide To Python 3 Program,"print('student.count:', student.count)",printfunc,313 2019 Book A Beginner's Guide To Python 3 Program,"print('Student.count:', Student.count)",printfunc,314 2019 Book A Beginner's Guide To Python 3 Program,"print('student.name:', student.name)",printfunc,314 2019 Book A Beginner's Guide To Python 3 Program,"print('student.name:', student.name)",printfunc,314 2019 Book A Beginner's Guide To Python 3 Program,"print('p.dummy_attribute:', res1)",printfunc,315 2019 Book A Beginner's Guide To Python 3 Program,"print('__getattr__: ', attribute)",printfunc,315 2019 Book A Beginner's Guide To Python 3 Program,"print('p.dummy_attribute:', res1)",printfunc,315 2019 Book A Beginner's Guide To Python 3 Program,"print('__getattr__: ', attribute)",printfunc,316 2019 Book A Beginner's Guide To Python 3 Program,"print(‘student.dummy_method():', res2)",printfunc,316 2019 Book A Beginner's Guide To Python 3 Program,"print('__getattr__: ', attribute)",printfunc,317 2019 Book A Beginner's Guide To Python 3 Program,"print('__getattribute__()', name)",printfunc,317 2019 Book A Beginner's Guide To Python 3 Program,"print('student.name:', student.name)",printfunc,318 2019 Book A Beginner's Guide To Python 3 Program,"print('student.dummy_attribute:', res1)",printfunc,318 2019 Book A Beginner's Guide To Python 3 Program,"print('__setattr__:', name, value)",printfunc,318 2019 Book A Beginner's Guide To Python 3 Program,"print('student.name:', student.name)",printfunc,319 2019 Book A Beginner's Guide To Python 3 Program,"print('acc1.branch:', acc1.branch)",printfunc,319 2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__)",printfunc,322 2019 Book A Beginner's Guide To Python 3 Program,"print('called ', func.__name__)",printfunc,322 2019 Book A Beginner's Guide To Python 3 Program,print('In target function'),printfunc,323 2019 Book A Beginner's Guide To Python 3 Program,print('In target function'),printfunc,323 2019 Book A Beginner's Guide To Python 3 Program,"print(x, y)",printfunc,324 2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__, 'with', x, 'and', y)",printfunc,324 2019 Book A Beginner's Guide To Python 3 Program,"print('returned from ', func.__name__)",printfunc,324 2019 Book A Beginner's Guide To Python 3 Program,print(hello()),printfunc,325 2019 Book A Beginner's Guide To Python 3 Program,print(hello()),printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,"print('Called ', func.__name__)",printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,"print('Skipped ', func.__name__)",printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,print('func1'),printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,print('func2'),printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,print('-' * 10),printfunc,326 2019 Book A Beginner's Guide To Python 3 Program,"print('Person - ', self.name, ', ', self.age)",printfunc,327 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,328 2019 Book A Beginner's Guide To Python 3 Program,print(p.get_fullname()),printfunc,328 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,328 2019 Book A Beginner's Guide To Python 3 Program,"print('Calling', method, 'with', x, y)",printfunc,328 2019 Book A Beginner's Guide To Python 3 Program,"print('Called', method, 'with', x, y)",printfunc,328 2019 Book A Beginner's Guide To Python 3 Program,print(p),printfunc,329 2019 Book A Beginner's Guide To Python 3 Program,print(p),printfunc,329 2019 Book A Beginner's Guide To Python 3 Program,"print('In singleton for: ', cls)",printfunc,329 2019 Book A Beginner's Guide To Python 3 Program,print(self),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print(s1),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print(s2),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print(f1),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print(f2),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,330 2019 Book A Beginner's Guide To Python 3 Program,print('In Logger'),printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,"print('In inner calling ', func.__name__)",printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,"print('In inner called ', func.__name__)",printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,print('Finishing Logger'),printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,print('Print It'),printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,print('Start'),printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,331 2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__)",printfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"print('called ', func.__name__)",printfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"print('name:', get_text.__name__)",printfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"print('doc: ', get_text.__doc__)",printfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"print('module; ', get_text.__module__)",printfunc,332 2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__)",printfunc,333 2019 Book A Beginner's Guide To Python 3 Program,"print('called ', func.__name__)",printfunc,333 2019 Book A Beginner's Guide To Python 3 Program,print('Start'),printfunc,338 2019 Book A Beginner's Guide To Python 3 Program,"print(i, end=', ')",printfunc,338 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,338 2019 Book A Beginner's Guide To Python 3 Program,print(i),printfunc,340 2019 Book A Beginner's Guide To Python 3 Program,print('Continue'),printfunc,340 2019 Book A Beginner's Guide To Python 3 Program,print('Final'),printfunc,340 2019 Book A Beginner's Guide To Python 3 Program,print('End'),printfunc,340 2019 Book A Beginner's Guide To Python 3 Program,print(i),printfunc,340 2019 Book A Beginner's Guide To Python 3 Program,"print(i, end=', ')",printfunc,341 2019 Book A Beginner's Guide To Python 3 Program,"print('i:', i)",printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,"print('j:', j, end=', ')",printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,print(''),printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,"print(next(evens), end=', ')",printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,"print(next(evens), end=', ')",printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,print(next(evens)),printfunc,342 2019 Book A Beginner's Guide To Python 3 Program,"print('Looking for', pattern)",printfunc,343 2019 Book A Beginner's Guide To Python 3 Program,print('Exiting the Co-routine'),printfunc,343 2019 Book A Beginner's Guide To Python 3 Program,print('Starting'),printfunc,344 2019 Book A Beginner's Guide To Python 3 Program,print('Done'),printfunc,344 2019 Book A Beginner's Guide To Python 3 Program,print('Number must be greater than 2'),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,"print(prime, end=', ')",printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print('Must be a positive integer'),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(next(prime)),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(next(prime)),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(next(prime)),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(next(prime)),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(next(prime)),printfunc,345 2019 Book A Beginner's Guide To Python 3 Program,print(t1),printfunc,348 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[0]:\t', tup1[0])",printfunc,348 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[1]:\t', tup1[1])",printfunc,348 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[2]:\t', tup1[2])",printfunc,348 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[3]:\t', tup1[3])",printfunc,348 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[1:3]:\t', tup1[1:3])",printfunc,349 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[:3]:\t', tup1[:3])",printfunc,349 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[1:]:\t', tup1[1:])",printfunc,349 2019 Book A Beginner's Guide To Python 3 Program,"print('tup1[::-1]:\t', tup1[::-1])",printfunc,349 2019 Book A Beginner's Guide To Python 3 Program,print(tup2),printfunc,349 2019 Book A Beginner's Guide To Python 3 Program,print(x),printfunc,350 2019 Book A Beginner's Guide To Python 3 Program,"print('len(tup3):\t', len(tup3))",printfunc,350 2019 Book A Beginner's Guide To Python 3 Program,print(tup3.count('apple')),printfunc,350 2019 Book A Beginner's Guide To Python 3 Program,print(tup3.index('pear')),printfunc,350 2019 Book A Beginner's Guide To Python 3 Program,print('orange is in the Tuple'),printfunc,351 2019 Book A Beginner's Guide To Python 3 Program,print(tuple3),printfunc,351 2019 Book A Beginner's Guide To Python 3 Program,print(root_list),printfunc,353 2019 Book A Beginner's Guide To Python 3 Program,print(t2),printfunc,354 2019 Book A Beginner's Guide To Python 3 Program,print(list(vowelTuple)),printfunc,354 2019 Book A Beginner's Guide To Python 3 Program,print(list1[1]),printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,"print('list1[1]:', list1[1])",printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,"print('list1[-1]:', list1[-1])",printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,"print('list1[1:3]:', list1[1:3])",printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,"print('list[:3]:', list1[:3])",printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,"print('list[1:]:', list1[1:])",printfunc,355 2019 Book A Beginner's Guide To Python 3 Program,print(list1),printfunc,356 2019 Book A Beginner's Guide To Python 3 Program,print(list1),printfunc,356 2019 Book A Beginner's Guide To Python 3 Program,print(list1),printfunc,356 2019 Book A Beginner's Guide To Python 3 Program,print(list1),printfunc,356 2019 Book A Beginner's Guide To Python 3 Program,print(a_list),printfunc,357 2019 Book A Beginner's Guide To Python 3 Program,print(a_list),printfunc,357 2019 Book A Beginner's Guide To Python 3 Program,print(list3),printfunc,357 2019 Book A Beginner's Guide To Python 3 Program,print(another_list),printfunc,358 2019 Book A Beginner's Guide To Python 3 Program,print(another_list),printfunc,358 2019 Book A Beginner's Guide To Python 3 Program,print(list6),printfunc,358 2019 Book A Beginner's Guide To Python 3 Program,print(list6.pop(2)),printfunc,358 2019 Book A Beginner's Guide To Python 3 Program,print(list6),printfunc,358 2019 Book A Beginner's Guide To Python 3 Program,print(list6),printfunc,359 2019 Book A Beginner's Guide To Python 3 Program,print(list6.pop()),printfunc,359 2019 Book A Beginner's Guide To Python 3 Program,print(list6),printfunc,359 2019 Book A Beginner's Guide To Python 3 Program,print(my_list),printfunc,359 2019 Book A Beginner's Guide To Python 3 Program,print(my_list),printfunc,359 2019 Book A Beginner's Guide To Python 3 Program,print(my_list),printfunc,360 2019 Book A Beginner's Guide To Python 3 Program,print(my_list),printfunc,360 2019 Book A Beginner's Guide To Python 3 Program,print(transaction),printfunc,361 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,362 2019 Book A Beginner's Guide To Python 3 Program,print(set1),printfunc,363 2019 Book A Beginner's Guide To Python 3 Program,print(item),printfunc,363 2019 Book A Beginner's Guide To Python 3 Program,print('apple' in basket),printfunc,364 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,364 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,364 2019 Book A Beginner's Guide To Python 3 Program,print(len(basket)),printfunc,365 2019 Book A Beginner's Guide To Python 3 Program,print(max(a_set)),printfunc,365 2019 Book A Beginner's Guide To Python 3 Program,print(min(a_set)),printfunc,365 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,365 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,365 2019 Book A Beginner's Guide To Python 3 Program,print(basket),printfunc,366 2019 Book A Beginner's Guide To Python 3 Program,print(s1),printfunc,366 2019 Book A Beginner's Guide To Python 3 Program,print(s2),printfunc,366 2019 Book A Beginner's Guide To Python 3 Program,print(s3),printfunc,366 2019 Book A Beginner's Guide To Python 3 Program,print(s2),printfunc,367 2019 Book A Beginner's Guide To Python 3 Program,print(s3),printfunc,367 2019 Book A Beginner's Guide To Python 3 Program,"print('Union:', s1 | s2)",printfunc,367 2019 Book A Beginner's Guide To Python 3 Program,"print('Intersection:', s1 & s2)",printfunc,368 2019 Book A Beginner's Guide To Python 3 Program,"print('Difference:', s1 - s2)",printfunc,368 2019 Book A Beginner's Guide To Python 3 Program,"print('Symmetric Difference:', s1 ^ s2)",printfunc,368 2019 Book A Beginner's Guide To Python 3 Program,"print('exam:', exam)",printfunc,370 2019 Book A Beginner's Guide To Python 3 Program,"print('project:', project)",printfunc,370 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,371 2019 Book A Beginner's Guide To Python 3 Program,"print('dict1:', dict1)",printfunc,372 2019 Book A Beginner's Guide To Python 3 Program,"print('dict2:', dict2)",printfunc,372 2019 Book A Beginner's Guide To Python 3 Program,"print('dict3:', dict3)",printfunc,372 2019 Book A Beginner's Guide To Python 3 Program,"print('cities[Wales]:', cities['Wales'])",printfunc,373 2019 Book A Beginner's Guide To Python 3 Program,"print('cities.get(Ireland):', cities.get('Ireland'))",printfunc,373 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,373 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,374 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,374 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,374 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,374 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,375 2019 Book A Beginner's Guide To Python 3 Program,print(cities),printfunc,375 2019 Book A Beginner's Guide To Python 3 Program,"print(country, end=', ')",printfunc,375 2019 Book A Beginner's Guide To Python 3 Program,print(cities[country]),printfunc,375 2019 Book A Beginner's Guide To Python 3 Program,print(e),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print(cities.values()),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print(cities.keys()),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print(cities.items()),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print('Wales' in cities),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print('France' not in cities),printfunc,376 2019 Book A Beginner's Guide To Python 3 Program,print(len(cities)),printfunc,377 2019 Book A Beginner's Guide To Python 3 Program,print(seasons['Spring']),printfunc,377 2019 Book A Beginner's Guide To Python 3 Program,print(seasons['Spring'][1]),printfunc,377 2019 Book A Beginner's Guide To Python 3 Program,"print('key.__hash__():', key.__hash__())",printfunc,378 2019 Book A Beginner's Guide To Python 3 Program,"print(""key.__eq__('England'):"", key.__eq__('England'))",printfunc,378 2019 Book A Beginner's Guide To Python 3 Program,"print('calling ', func.__name__, 'with', value)",printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(150000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(80000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(120000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(150000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(120000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,print(factorial(80000)),printfunc,380 2019 Book A Beginner's Guide To Python 3 Program,"print('list1:', list1)",printfunc,383 2019 Book A Beginner's Guide To Python 3 Program,"print('list2:', list2)",printfunc,383 2019 Book A Beginner's Guide To Python 3 Program,"print('list3:', list3)",printfunc,384 2019 Book A Beginner's Guide To Python 3 Program,print(fruit),printfunc,385 2019 Book A Beginner's Guide To Python 3 Program,print(fruit['orange']),printfunc,385 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit.most_common(1):', fruit.most_common(1))",printfunc,385 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit1:', fruit1)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit2:', fruit2)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit1 + fruit2:', fruit1 + fruit2)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit1 - fruit2:', fruit1 - fruit2)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit1 | fruit2:', fruit1 | fruit2)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,"print('fruit1 & fruit2:', fruit1 & fruit2)",printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,print('apple'in fruit),printfunc,386 2019 Book A Beginner's Guide To Python 3 Program,print(r1),printfunc,387 2019 Book A Beginner's Guide To Python 3 Program,print(r2),printfunc,387 2019 Book A Beginner's Guide To Python 3 Program,print(r3),printfunc,387 2019 Book A Beginner's Guide To Python 3 Program,print(r4),printfunc,387 2019 Book A Beginner's Guide To Python 3 Program,"print('initial queue:', queue)",printfunc,391 2019 Book A Beginner's Guide To Python 3 Program,"print('queue after additions:', queue)",printfunc,391 2019 Book A Beginner's Guide To Python 3 Program,"print('element retrieved from queue:', element1)",printfunc,391 2019 Book A Beginner's Guide To Python 3 Program,"print('queue after removal', queue)",printfunc,391 2019 Book A Beginner's Guide To Python 3 Program,"print('queue.is_empty():', queue.is_empty())",printfunc,392 2019 Book A Beginner's Guide To Python 3 Program,"print('len(queue):', len(queue))",printfunc,392 2019 Book A Beginner's Guide To Python 3 Program,"print('queue:', queue)",printfunc,392 2019 Book A Beginner's Guide To Python 3 Program,"print('queue.peek():', queue.peek())",printfunc,393 2019 Book A Beginner's Guide To Python 3 Program,"print('queue.dequeue():', queue.dequeue())",printfunc,393 2019 Book A Beginner's Guide To Python 3 Program,"print('queue:', queue)",printfunc,393 2019 Book A Beginner's Guide To Python 3 Program,"print('stack:', stack)",printfunc,394 2019 Book A Beginner's Guide To Python 3 Program,"print('top_element:', top_element)",printfunc,394 2019 Book A Beginner's Guide To Python 3 Program,"print('stack:', stack)",printfunc,394 2019 Book A Beginner's Guide To Python 3 Program,"print('stack:', stack)",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('stack.is_empty():', stack.is_empty())",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('stack.length():', stack.length())",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('stack.top():', stack.top())",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('stack.pop():', stack.pop())",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('stack:', stack)",printfunc,396 2019 Book A Beginner's Guide To Python 3 Program,"print('data:', data)",printfunc,398 2019 Book A Beginner's Guide To Python 3 Program,"print('d1:', d1)",printfunc,398 2019 Book A Beginner's Guide To Python 3 Program,"print('d2:', d2)",printfunc,398 2019 Book A Beginner's Guide To Python 3 Program,"print(p, end=', ')",printfunc,399 2019 Book A Beginner's Guide To Python 3 Program,print('\n-----'),printfunc,399 2019 Book A Beginner's Guide To Python 3 Program,"print(p, end=', ')",printfunc,399 2019 Book A Beginner's Guide To Python 3 Program,"print('data:', data)",printfunc,400 2019 Book A Beginner's Guide To Python 3 Program,"print('d1', d1)",printfunc,400 2019 Book A Beginner's Guide To Python 3 Program,"print('d2:', d2)",printfunc,400 2019 Book A Beginner's Guide To Python 3 Program,print(result),printfunc,400 2019 Book A Beginner's Guide To Python 3 Program,print(ages),printfunc,401 2019 Book A Beginner's Guide To Python 3 Program,print(result),printfunc,401 2019 Book A Beginner's Guide To Python 3 Program,"print('Average age:', average_age)",printfunc,402 2019 Book A Beginner's Guide To Python 3 Program,"print('stack contents:', stack)",printfunc,403 2019 Book A Beginner's Guide To Python 3 Program,"print('new_list:', new_list)",printfunc,403 2019 Book A Beginner's Guide To Python 3 Program,"print('filtered_list: ', filtered_list)",printfunc,403 2019 Book A Beginner's Guide To Python 3 Program,print('That position is not free'),printfunc,409 2019 Book A Beginner's Guide To Python 3 Program,print('Please try again'),printfunc,409 2019 Book A Beginner's Guide To Python 3 Program,print('Do you want to be X or O?'),printfunc,412 2019 Book A Beginner's Guide To Python 3 Program,print('Input must be X or O'),printfunc,412 2019 Book A Beginner's Guide To Python 3 Program,print('Welcome to TicTacToe'),printfunc,413 2019 Book A Beginner's Guide To Python 3 Program,"print(self.next_player, 'will play first first')",printfunc,413 2019 Book A Beginner's Guide To Python 3 Program,print('The Winner is the ' + str(self.winner)),printfunc,413 2019 Book A Beginner's Guide To Python 3 Program,print(self.board),printfunc,413 2019 Book A Beginner's Guide To Python 3 Program,"tup1 = (1, 3, 5, 7)",simpleTuple,347 2019 Book A Beginner's Guide To Python 3 Program,"tup2 = (1, 'John', Person('Phoebe', 21), True, -23.45)",simpleTuple,349 2019 Book A Beginner's Guide To Python 3 Program,"tup3 = ('apple', 'pear', 'orange', 'plum', 'apple')",simpleTuple,350 2019 Book A Beginner's Guide To Python 3 Program,"tuple1 = (1, 3, 5, 7)",simpleTuple,351 2019 Book A Beginner's Guide To Python 3 Program,"tuple2 = ('John', 'Denise', 'Phoebe', 'Adam')",simpleTuple,351 2019 Book A Beginner's Guide To Python 3 Program,"tuple3 = (42, tuple1, tuple2, 5.5)",simpleTuple,351 2019 Book A Beginner's Guide To Python 3 Program,"t1 = (1, 'John', 34.5)",simpleTuple,354 2019 Book A Beginner's Guide To Python 3 Program,"t2 = (l2, 'apple')",simpleTuple,354 2019 Book A Beginner's Guide To Python 3 Program,"vowelTuple = ('a', 'e', 'i', 'o', 'u')",simpleTuple,354 2019 Book A Beginner's Guide To Python 3 Program,"list1 = [1, 2, 3]",simpleList,348 2019 Book A Beginner's Guide To Python 3 Program,"list1 = ['John', 'Paul', 'George', 'Ringo']",simpleList,352 2019 Book A Beginner's Guide To Python 3 Program,"l1 = [1, 43.5, Person('Phoebe', 21), True]",simpleList,353 2019 Book A Beginner's Guide To Python 3 Program,"l2 = ['apple', 'orange', 31]",simpleList,353 2019 Book A Beginner's Guide To Python 3 Program,"root_list = ['John', l1, l2, 'Denise']",simpleList,353 2019 Book A Beginner's Guide To Python 3 Program,"l1 = ['Smith', 'Jones']",simpleList,354 2019 Book A Beginner's Guide To Python 3 Program,"l2 = [t1, l1]",simpleList,354 2019 Book A Beginner's Guide To Python 3 Program,"list1 = ['John', 'Paul', 'George', 'Ringo']",simpleList,355 2019 Book A Beginner's Guide To Python 3 Program,"list1 = ['John', 'Paul', 'George', 'Ringo']",simpleList,355 2019 Book A Beginner's Guide To Python 3 Program,"list1 = ['John', 'Paul', 'George', 'Ringo']",simpleList,356 2019 Book A Beginner's Guide To Python 3 Program,"list1 = ['John', 'Paul', 'George', 'Ringo', 'Pete']",simpleList,356 2019 Book A Beginner's Guide To Python 3 Program,"list1 += ['Ginger', 'Sporty']",simpleList,356 2019 Book A Beginner's Guide To Python 3 Program,"a_list = ['Adele', 'Madonna', 'Cher']",simpleList,357 2019 Book A Beginner's Guide To Python 3 Program,"list1 = [3, 2, 1]",simpleList,357 2019 Book A Beginner's Guide To Python 3 Program,"list2 = [6, 5, 4]",simpleList,357 2019 Book A Beginner's Guide To Python 3 Program,"another_list = ['Gary', 'Mark', 'Robbie', 'Jason', 'Howard']",simpleList,358 2019 Book A Beginner's Guide To Python 3 Program,"list6 = ['Once', 'Upon', 'a', 'Time']",simpleList,358 2019 Book A Beginner's Guide To Python 3 Program,"list6 = ['Once', 'Upon', 'a', 'Time']",simpleList,359 2019 Book A Beginner's Guide To Python 3 Program,"my_list = ['A', 'B', 'C', 'D', 'E']",simpleList,359 2019 Book A Beginner's Guide To Python 3 Program,"my_list = ['A', 'B', 'C', 'D', 'E']",simpleList,360 2019 Book A Beginner's Guide To Python 3 Program,"list1 = [1, 2, 3, 4, 5,6]",simpleList,383 2019 Book A Beginner's Guide To Python 3 Program,"values = [1, 3, 5, 7, 9, 3, 1]",simpleList,387 2019 Book A Beginner's Guide To Python 3 Program,queue = [],simpleList,391 2019 Book A Beginner's Guide To Python 3 Program,stack = [],simpleList,394 2019 Book A Beginner's Guide To Python 3 Program,"data = [1, 3, 5, 2, 7, 4, 10]",simpleList,398 2019 Book A Beginner's Guide To Python 3 Program,"data = [1, 3, 5, 2, 7, 4, 10]",simpleList,400 2019 Book A Beginner's Guide To Python 3 Program,"data1 = [1, 3, 5, 7]",simpleList,400 2019 Book A Beginner's Guide To Python 3 Program,"data2 = [2, 4, 6, 8]",simpleList,400 2019 Book A Beginner's Guide To Python 3 Program,"data = [1, 3, 5, 2, 7, 4, 10]",simpleList,401 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(0, 10):",forsimple,74 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(0, 10, 2):",forsimple,74 2019 Book A Beginner's Guide To Python 3 Program,"for _ in range(0,10):",forsimple,75 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(0, 6):",forsimple,76 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(0, 10):",forsimple,77 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(0, 6):",forsimple,78 2019 Book A Beginner's Guide To Python 3 Program,for row in triangle:,forsimple,100 2019 Book A Beginner's Guide To Python 3 Program,for name in args:,forsimple,121 2019 Book A Beginner's Guide To Python 3 Program,for key in kwargs.keys():,forsimple,123 2019 Book A Beginner's Guide To Python 3 Program,for dening a property in this way is:,forsimple,245 2019 Book A Beginner's Guide To Python 3 Program,for i in Evens(6):,forsimple,338 2019 Book A Beginner's Guide To Python 3 Program,for i in gen_numbers():,forsimple,340 2019 Book A Beginner's Guide To Python 3 Program,for i in gen_numbers():,forsimple,340 2019 Book A Beginner's Guide To Python 3 Program,for i in evens_up_to(6):,forsimple,341 2019 Book A Beginner's Guide To Python 3 Program,for i in evens_up_to(4):,forsimple,342 2019 Book A Beginner's Guide To Python 3 Program,for j in evens_up_to(6):,forsimple,342 2019 Book A Beginner's Guide To Python 3 Program,for prime in prime_number_generator(num):,forsimple,345 2019 Book A Beginner's Guide To Python 3 Program,for x in tup3:,forsimple,350 2019 Book A Beginner's Guide To Python 3 Program,for transaction in acc1:,forsimple,361 2019 Book A Beginner's Guide To Python 3 Program,for item in basket:,forsimple,363 2019 Book A Beginner's Guide To Python 3 Program,for country in cities:,forsimple,375 2019 Book A Beginner's Guide To Python 3 Program,for e in d.values():,forsimple,376 2019 Book A Beginner's Guide To Python 3 Program,"for i in range(1, num + 1):",forsimple,380 2019 Book A Beginner's Guide To Python 3 Program,for p in data:,forsimple,399 2019 Book A Beginner's Guide To Python 3 Program,for p in d3:,forsimple,399 2019 Book A Beginner's Guide To Python 3 Program,"for row in range(0, 3):",forsimple,411 2019 Book A Beginner's Guide To Python 3 Program,"for column in range(0, 3):",forsimple,411 2019 Book A Beginner's Guide To Python 3 Program,string_3 = string_1 + string_2,assignwithSum,34 2019 Book A Beginner's Guide To Python 3 Program,x = x + 2,assignwithSum,59 2019 Book A Beginner's Guide To Python 3 Program,count = count + 1,assignwithSum,91 2019 Book A Beginner's Guide To Python 3 Program,Remember this is just a shorthand form of count = count + 1 and thus still,assignwithSum,91 2019 Book A Beginner's Guide To Python 3 Program,"result = n * factorial(n-1, depth + 1)",assignwithSum,97 2019 Book A Beginner's Guide To Python 3 Program,"func3 = lambda x, y, z: x + y + z",assignwithSum,124 2019 Book A Beginner's Guide To Python 3 Program,max = max + 1,assignwithSum,128 2019 Book A Beginner's Guide To Python 3 Program,max = max + 1,assignwithSum,128 2019 Book A Beginner's Guide To Python 3 Program,max = max + 1,assignwithSum,129 2019 Book A Beginner's Guide To Python 3 Program,increment = lambda num: num + addition,assignwithSum,163 2019 Book A Beginner's Guide To Python 3 Program,q3 = q1 + q2,assignwithSum,230 2019 Book A Beginner's Guide To Python 3 Program,p3 = p1 + p2,assignwithSum,231 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value + other.value,assignwithSum,232 2019 Book A Beginner's Guide To Python 3 Program,q3 = q1 + q2,assignwithSum,232 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value + other.value,assignwithSum,234 2019 Book A Beginner's Guide To Python 3 Program,q3 = q1 + q2,assignwithSum,235 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value + other.value,assignwithSum,237 2019 Book A Beginner's Guide To Python 3 Program,q3 = q1 + q2,assignwithSum,237 2019 Book A Beginner's Guide To Python 3 Program,x = 1 + 2,assignwithSum,279 2019 Book A Beginner's Guide To Python 3 Program,x = 1 + 2,assignwithSum,280 2019 Book A Beginner's Guide To Python 3 Program,x = 1 + 2,assignwithSum,281 2019 Book A Beginner's Guide To Python 3 Program,list3 = list1 + list2,assignwithSum,357 2019 Book A Beginner's Guide To Python 3 Program,"d1 = list(map(lambda i: i + 1, data))",assignwithSum,400 2019 Book A Beginner's Guide To Python 3 Program,"result = list(map(lambda x, y: x + y, data1, data2))",assignwithSum,400 2019 Book A Beginner's Guide To Python 3 Program,"result = reduce(lambda total, value: total + value, data)",assignwithSum,401 2019 Book A Beginner's Guide To Python 3 Program,user_name = input('Enter your name: '),simpleAssign,24 2019 Book A Beginner's Guide To Python 3 Program,user_name = input('Enter your name: '),simpleAssign,24 2019 Book A Beginner's Guide To Python 3 Program,name = input('Enter your name: '),simpleAssign,25 2019 Book A Beginner's Guide To Python 3 Program,name = input('What is the name of your best friend: '),simpleAssign,25 2019 Book A Beginner's Guide To Python 3 Program,my_variable = 42,simpleAssign,26 2019 Book A Beginner's Guide To Python 3 Program,my_variable = True,simpleAssign,26 2019 Book A Beginner's Guide To Python 3 Program,user_name = input('Enter your name: '),simpleAssign,28 2019 Book A Beginner's Guide To Python 3 Program,name = input('Enter your name: '),simpleAssign,29 2019 Book A Beginner's Guide To Python 3 Program,age = 20,simpleAssign,41 2019 Book A Beginner's Guide To Python 3 Program,example {artist}. Then in the format() method a key=value pair is provided,simpleAssign,42 2019 Book A Beginner's Guide To Python 3 Program,"song='Guilty', year=2017))",simpleAssign,42 2019 Book A Beginner's Guide To Python 3 Program,template = string.Template('$artist sang $song in $year'),simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,"function. The substitute function takes a set of key=value pairs, in which the key is the",simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,"Great Pretender', year=1987))",simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,template = string.Template('$artist sang $song in $year'),simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,Can use a key = value pairs where the key is the name of,simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,"Great Pretender', year=1987))",simpleAssign,44 2019 Book A Beginner's Guide To Python 3 Program,"Girl', year=2017))",simpleAssign,45 2019 Book A Beginner's Guide To Python 3 Program,"song='Havana', year=2018))",simpleAssign,45 2019 Book A Beginner's Guide To Python 3 Program,"d = dict(artist = 'Billy Idol', song='Eyes Without a Face',",simpleAssign,45 2019 Book A Beginner's Guide To Python 3 Program,year = 1984),simpleAssign,45 2019 Book A Beginner's Guide To Python 3 Program,x = 1,simpleAssign,49 2019 Book A Beginner's Guide To Python 3 Program,"x = 100000000000000000000000000000000000000000000000000000000001",simpleAssign,49 2019 Book A Beginner's Guide To Python 3 Program,total = int('100'),simpleAssign,50 2019 Book A Beginner's Guide To Python 3 Program,age = int(input('Please enter your age:')),simpleAssign,50 2019 Book A Beginner's Guide To Python 3 Program,i = int(1.0),simpleAssign,50 2019 Book A Beginner's Guide To Python 3 Program,exchange_rate = 1.83,simpleAssign,50 2019 Book A Beginner's Guide To Python 3 Program,int_value = 1,simpleAssign,51 2019 Book A Beginner's Guide To Python 3 Program,float_value = float(int_value),simpleAssign,51 2019 Book A Beginner's Guide To Python 3 Program,float_value = float(string_value),simpleAssign,51 2019 Book A Beginner's Guide To Python 3 Program,"exchange_rate = float(input(""Please enter the exchange rate to",simpleAssign,51 2019 Book A Beginner's Guide To Python 3 Program,c1 = 1j,simpleAssign,52 2019 Book A Beginner's Guide To Python 3 Program,c2 = 2j,simpleAssign,52 2019 Book A Beginner's Guide To Python 3 Program,all_ok = True,simpleAssign,53 2019 Book A Beginner's Guide To Python 3 Program,all_ok = False,simpleAssign,53 2019 Book A Beginner's Guide To Python 3 Program,status = bool(input('OK to proceed: ')),simpleAssign,53 2019 Book A Beginner's Guide To Python 3 Program,home = 10,simpleAssign,54 2019 Book A Beginner's Guide To Python 3 Program,away = 15,simpleAssign,54 2019 Book A Beginner's Guide To Python 3 Program,goals_for = 10,simpleAssign,54 2019 Book A Beginner's Guide To Python 3 Program,goals_against = 7,simpleAssign,54 2019 Book A Beginner's Guide To Python 3 Program,res1 = 3/2,simpleAssign,55 2019 Book A Beginner's Guide To Python 3 Program,res1 = 3//2,simpleAssign,55 2019 Book A Beginner's Guide To Python 3 Program,a = 5,simpleAssign,56 2019 Book A Beginner's Guide To Python 3 Program,b = 3,simpleAssign,56 2019 Book A Beginner's Guide To Python 3 Program,i = 3 * 0.1,simpleAssign,57 2019 Book A Beginner's Guide To Python 3 Program,c1 = 1j,simpleAssign,58 2019 Book A Beginner's Guide To Python 3 Program,c2 = 2j,simpleAssign,58 2019 Book A Beginner's Guide To Python 3 Program,c3 = c1 * c2,simpleAssign,58 2019 Book A Beginner's Guide To Python 3 Program,operator and the = operator such that,simpleAssign,58 2019 Book A Beginner's Guide To Python 3 Program,x = 0,simpleAssign,58 2019 Book A Beginner's Guide To Python 3 Program,x −= 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x *= 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x /= 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x //= 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x – 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x * 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x/2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x//2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x %= 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x % 2,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x **= 3,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,x = x **,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,winner = None,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,winner = None,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,winner = True,simpleAssign,59 2019 Book A Beginner's Guide To Python 3 Program,3 == 3,simpleAssign,63 2019 Book A Beginner's Guide To Python 3 Program,2 != 3,simpleAssign,63 2019 Book A Beginner's Guide To Python 3 Program,Tests if the left-hand value is less than or equal to the right-hand value 3 <= 4,simpleAssign,63 2019 Book A Beginner's Guide To Python 3 Program,Tests if the left-hand value is greater than or equal to the right-hand value 5 >= 4,simpleAssign,63 2019 Book A Beginner's Guide To Python 3 Program,num = int(input('Enter a number: ')),simpleAssign,64 2019 Book A Beginner's Guide To Python 3 Program,num = int(input('Enter another number: ')),simpleAssign,64 2019 Book A Beginner's Guide To Python 3 Program,num = int(input('Enter yet another number: ')),simpleAssign,65 2019 Book A Beginner's Guide To Python 3 Program,"savings = float(input(""Enter how much you have in savings: ""))",simpleAssign,66 2019 Book A Beginner's Guide To Python 3 Program,snowing = True,simpleAssign,67 2019 Book A Beginner's Guide To Python 3 Program,snowing = True,simpleAssign,67 2019 Book A Beginner's Guide To Python 3 Program,age = 15,simpleAssign,68 2019 Book A Beginner's Guide To Python 3 Program,status = None,simpleAssign,68 2019 Book A Beginner's Guide To Python 3 Program,num % 2) == 0,simpleAssign,70 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,72 2019 Book A Beginner's Guide To Python 3 Program,for i = from 0 to 10,simpleAssign,73 2019 Book A Beginner's Guide To Python 3 Program,num = int(input('Enter a number to check for: ')),simpleAssign,76 2019 Book A Beginner's Guide To Python 3 Program,if i == num:,simpleAssign,76 2019 Book A Beginner's Guide To Python 3 Program,if i % 2 == 1:,simpleAssign,77 2019 Book A Beginner's Guide To Python 3 Program,num = int(input('Enter a number to check for: ')),simpleAssign,78 2019 Book A Beginner's Guide To Python 3 Program,if i == num:,simpleAssign,78 2019 Book A Beginner's Guide To Python 3 Program,MIN = 1,simpleAssign,79 2019 Book A Beginner's Guide To Python 3 Program,MAX = 6,simpleAssign,79 2019 Book A Beginner's Guide To Python 3 Program,"dice1 = random.randint(MIN, MAX)",simpleAssign,79 2019 Book A Beginner's Guide To Python 3 Program,"dice2 = random.randint(MIN, MAX)",simpleAssign,79 2019 Book A Beginner's Guide To Python 3 Program,roll_again = input('Roll the dices again? (y / n): '),simpleAssign,79 2019 Book A Beginner's Guide To Python 3 Program,that is 0! = 1.,simpleAssign,80 2019 Book A Beginner's Guide To Python 3 Program,"number_to_guess = random.randint(1,10)",simpleAssign,86 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,86 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,86 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,86 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,87 2019 Book A Beginner's Guide To Python 3 Program,count_number_of_tries = 1,simpleAssign,88 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,88 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess again: ')),simpleAssign,88 2019 Book A Beginner's Guide To Python 3 Program,"number_to_guess = random.randint(1,10)",simpleAssign,89 2019 Book A Beginner's Guide To Python 3 Program,count_number_of_tries = 1,simpleAssign,89 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess a number between 1 and 10: ')),simpleAssign,89 2019 Book A Beginner's Guide To Python 3 Program,if count_number_of_tries == 4:,simpleAssign,90 2019 Book A Beginner's Guide To Python 3 Program,guess = int(input('Please guess again: ')),simpleAssign,90 2019 Book A Beginner's Guide To Python 3 Program,if number_to_guess == guess:,simpleAssign,90 2019 Book A Beginner's Guide To Python 3 Program,If current_node.value == value_to_find:,simpleAssign,95 2019 Book A Beginner's Guide To Python 3 Program,if n == 1: # The termination condition,simpleAssign,97 2019 Book A Beginner's Guide To Python 3 Program,res = n * factorial(n-1) # The recursive call,simpleAssign,97 2019 Book A Beginner's Guide To Python 3 Program,if n == 1:,simpleAssign,97 2019 Book A Beginner's Guide To Python 3 Program,if n == 0:,simpleAssign,98 2019 Book A Beginner's Guide To Python 3 Program,triangle = pascals_triangle(5),simpleAssign,100 2019 Book A Beginner's Guide To Python 3 Program,result = square( 4),simpleAssign,115 2019 Book A Beginner's Guide To Python 3 Program,a = 2,simpleAssign,116 2019 Book A Beginner's Guide To Python 3 Program,b = 3,simpleAssign,116 2019 Book A Beginner's Guide To Python 3 Program,"x, y = swap(a, b)",simpleAssign,116 2019 Book A Beginner's Guide To Python 3 Program,"z = swap(a, b)",simpleAssign,116 2019 Book A Beginner's Guide To Python 3 Program,value_as_string = input(message),simpleAssign,117 2019 Book A Beginner's Guide To Python 3 Program,value_as_string = input(message),simpleAssign,117 2019 Book A Beginner's Guide To Python 3 Program,age = get_integer_input('Please input your age: '),simpleAssign,117 2019 Book A Beginner's Guide To Python 3 Program,"named(a=1, b=2, c=3)",simpleAssign,123 2019 Book A Beginner's Guide To Python 3 Program,double = lambda i : i * i,simpleAssign,124 2019 Book A Beginner's Guide To Python 3 Program,func0 = lambda: print('no args'),simpleAssign,124 2019 Book A Beginner's Guide To Python 3 Program,func1 = lambda x: x * x,simpleAssign,124 2019 Book A Beginner's Guide To Python 3 Program,"func2 = lambda x, y: x * y",simpleAssign,124 2019 Book A Beginner's Guide To Python 3 Program,a_variable = 100,simpleAssign,127 2019 Book A Beginner's Guide To Python 3 Program,a_variable = 25,simpleAssign,127 2019 Book A Beginner's Guide To Python 3 Program,max = 100,simpleAssign,128 2019 Book A Beginner's Guide To Python 3 Program,max = 100,simpleAssign,129 2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,134 2019 Book A Beginner's Guide To Python 3 Program,result = 0,simpleAssign,134 2019 Book A Beginner's Guide To Python 3 Program,user_input = input('Do you want to finish (y/n): '),simpleAssign,135 2019 Book A Beginner's Guide To Python 3 Program,ok_to_finish = True,simpleAssign,136 2019 Book A Beginner's Guide To Python 3 Program,user_input_accepted = False,simpleAssign,136 2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,137 2019 Book A Beginner's Guide To Python 3 Program,result = 0,simpleAssign,137 2019 Book A Beginner's Guide To Python 3 Program,finished = check_if_user_has_finished((),simpleAssign,137 2019 Book A Beginner's Guide To Python 3 Program,input_ok = False,simpleAssign,138 2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,138 2019 Book A Beginner's Guide To Python 3 Program,result = 0,simpleAssign,138 2019 Book A Beginner's Guide To Python 3 Program,menu_choice = get_operation_choice(),simpleAssign,138 2019 Book A Beginner's Guide To Python 3 Program,finished = check_if_user_has_finished((),simpleAssign,138 2019 Book A Beginner's Guide To Python 3 Program,num1 = get_integer_input('Input the first number: '),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,num2 = get_integer_input('Input the second number: '),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,value_as_string = input(message),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,value_as_string = input(message),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,"n1, n2 = get_numbers_from_user()",simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,result = 0,simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,menu_choice = get_operation_choice(),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,"n1, n2 = get_numbers_from_user()",simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,finished = check_if_user_has_finished((),simpleAssign,139 2019 Book A Beginner's Guide To Python 3 Program,"result = add(n1, n2)",simpleAssign,140 2019 Book A Beginner's Guide To Python 3 Program,"result = subtract(n1, n2)",simpleAssign,140 2019 Book A Beginner's Guide To Python 3 Program,"result = divide(n1, n2)",simpleAssign,140 2019 Book A Beginner's Guide To Python 3 Program,finished = False,simpleAssign,140 2019 Book A Beginner's Guide To Python 3 Program,int sizeOfContainer = container.length,simpleAssign,144 2019 Book A Beginner's Guide To Python 3 Program,for (int i = 1 to sizeOfContainer) do,simpleAssign,144 2019 Book A Beginner's Guide To Python 3 Program,element = container.get(i),simpleAssign,144 2019 Book A Beginner's Guide To Python 3 Program,amount = 1,simpleAssign,147 2019 Book A Beginner's Guide To Python 3 Program,amount = 2,simpleAssign,147 2019 Book A Beginner's Guide To Python 3 Program,message = get_msg(),simpleAssign,150 2019 Book A Beginner's Guide To Python 3 Program,message = get_msg,simpleAssign,150 2019 Book A Beginner's Guide To Python 3 Program,another_reference = get_msg,simpleAssign,151 2019 Book A Beginner's Guide To Python 3 Program,get_msg = get_some_other_msg,simpleAssign,152 2019 Book A Beginner's Guide To Python 3 Program,result = function(x),simpleAssign,153 2019 Book A Beginner's Guide To Python 3 Program,"result = apply(10, mult_by_two)",simpleAssign,154 2019 Book A Beginner's Guide To Python 3 Program,f1 = make_checker('even'),simpleAssign,156 2019 Book A Beginner's Guide To Python 3 Program,f2 = make_checker('positive'),simpleAssign,156 2019 Book A Beginner's Guide To Python 3 Program,f3 = make_checker('negative'),simpleAssign,156 2019 Book A Beginner's Guide To Python 3 Program,f1 = make_function(),simpleAssign,157 2019 Book A Beginner's Guide To Python 3 Program,"total = operation(2, 5)",simpleAssign,159 2019 Book A Beginner's Guide To Python 3 Program,"total = operation(10, 5)",simpleAssign,160 2019 Book A Beginner's Guide To Python 3 Program,"double = operation(2, *)",simpleAssign,160 2019 Book A Beginner's Guide To Python 3 Program,"double = multby(multiply, 2)",simpleAssign,161 2019 Book A Beginner's Guide To Python 3 Program,"triple = multby(multiply, 3)",simpleAssign,161 2019 Book A Beginner's Guide To Python 3 Program,more = 100,simpleAssign,163 2019 Book A Beginner's Guide To Python 3 Program,more = 50,simpleAssign,163 2019 Book A Beginner's Guide To Python 3 Program,addition = 50,simpleAssign,163 2019 Book A Beginner's Guide To Python 3 Program,"dollars_to_sterling = curry(convert, 0.77)",simpleAssign,165 2019 Book A Beginner's Guide To Python 3 Program,"euro_to_sterling = curry(convert, 0.88)",simpleAssign,165 2019 Book A Beginner's Guide To Python 3 Program,"sterling_to_dollars = curry(convert, 1.3)",simpleAssign,165 2019 Book A Beginner's Guide To Python 3 Program,"sterling_to_euro = curry(convert, 1.14)",simpleAssign,165 2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('John', 36)",simpleAssign,182 2019 Book A Beginner's Guide To Python 3 Program,"p2 = Person('Phoebe', 21)",simpleAssign,182 2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('John', 36)",simpleAssign,183 2019 Book A Beginner's Guide To Python 3 Program,px = p1,simpleAssign,183 2019 Book A Beginner's Guide To Python 3 Program,"ran p1 = p2) then this would have no effect on the value held in px; indeed, we",simpleAssign,184 2019 Book A Beginner's Guide To Python 3 Program,p1.age = 54,simpleAssign,186 2019 Book A Beginner's Guide To Python 3 Program,"p3 = Person('Adam', 19)",simpleAssign,188 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay = 7.50,simpleAssign,189 2019 Book A Beginner's Guide To Python 3 Program,if self.age >= 21:,simpleAssign,189 2019 Book A Beginner's Guide To Python 3 Program,pay = p2.calculate_pay(40),simpleAssign,189 2019 Book A Beginner's Guide To Python 3 Program,pay = p3.calculate_pay(40),simpleAssign,189 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay = 7.50,simpleAssign,190 2019 Book A Beginner's Guide To Python 3 Program,if self.age >= 21:,simpleAssign,190 2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('John', 36)",simpleAssign,191 2019 Book A Beginner's Guide To Python 3 Program,p1.age = 18,simpleAssign,191 2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('John', 36)",simpleAssign,192 2019 Book A Beginner's Guide To Python 3 Program,"acc1 = Account('123', 'John', 10.05, 'current')",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,"acc2 = Account('345', 'John', 23.55, 'savings')",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,"acc3 = Account('567', 'Phoebe', 12.45, 'investment')",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,"Account[123] - John, current account = 10.05",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,"Account[345] - John, savings account = 23.55",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,"Account[567] - Phoebe, investment account = 12.45",simpleAssign,195 2019 Book A Beginner's Guide To Python 3 Program,instance_count = 0,simpleAssign,196 2019 Book A Beginner's Guide To Python 3 Program,"p1 = Person('Jason', 36)",simpleAssign,197 2019 Book A Beginner's Guide To Python 3 Program,"p2 = Person('Carol', 21)",simpleAssign,197 2019 Book A Beginner's Guide To Python 3 Program,"p3 = Person('James', 19)",simpleAssign,197 2019 Book A Beginner's Guide To Python 3 Program,"p4 = Person('Tom', 31)",simpleAssign,197 2019 Book A Beginner's Guide To Python 3 Program,instance_count = 0,simpleAssign,197 2019 Book A Beginner's Guide To Python 3 Program,html?highlight=classmethod documentation on class methods.,simpleAssign,200 2019 Book A Beginner's Guide To Python 3 Program,rate_of_pay = 7.50,simpleAssign,203 2019 Book A Beginner's Guide To Python 3 Program,if self.age >= 21:,simpleAssign,203 2019 Book A Beginner's Guide To Python 3 Program,"p = Person('John', 54)",simpleAssign,204 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Denise', 51, 7468)",simpleAssign,204 2019 Book A Beginner's Guide To Python 3 Program,"s = SalesPerson('Phoebe', 21, 4712, 'UK', 30000.0)",simpleAssign,204 2019 Book A Beginner's Guide To Python 3 Program,"p = Person('John', 54)",simpleAssign,211 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Denise', 51, 1234)",simpleAssign,211 2019 Book A Beginner's Guide To Python 3 Program,"p = Person('John', 54)",simpleAssign,212 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Denise', 51, 1234)",simpleAssign,212 2019 Book A Beginner's Guide To Python 3 Program,tc = ToyCar(),simpleAssign,215 2019 Book A Beginner's Guide To Python 3 Program,x = X(),simpleAssign,217 2019 Book A Beginner's Guide To Python 3 Program,"acc1 = CurrentAccount('123', 'John', 10.05, 100.0)",simpleAssign,221 2019 Book A Beginner's Guide To Python 3 Program,"acc2 = DepositAccount('345', 'John', 23.55, 0.5)",simpleAssign,221 2019 Book A Beginner's Guide To Python 3 Program,"acc3 = InvestmentAccount('567', 'Phoebe', 12.45, 'high risk')",simpleAssign,221 2019 Book A Beginner's Guide To Python 3 Program,"day = 01, month = 13, year = 9999). This is because the structure only knows it is",simpleAssign,224 2019 Book A Beginner's Guide To Python 3 Program,"date = Date(12, 2, 1998)",simpleAssign,227 2019 Book A Beginner's Guide To Python 3 Program,age = 0,simpleAssign,227 2019 Book A Beginner's Guide To Python 3 Program,"birthday = Birthday(12, 3, 1974)",simpleAssign,228 2019 Book A Beginner's Guide To Python 3 Program,"using operators such as +, −, <, > or == as well as logical operators such as &",simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,q3 = q1.add(q2),simpleAssign,230 2019 Book A Beginner's Guide To Python 3 Program,p1 = Person('John'),simpleAssign,231 2019 Book A Beginner's Guide To Python 3 Program,p2 = Person('Denise'),simpleAssign,231 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value - other.value,simpleAssign,232 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,232 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,232 2019 Book A Beginner's Guide To Python 3 Program,"q1 = Quantity[5] , q2 = Quantity[10]",simpleAssign,232 2019 Book A Beginner's Guide To Python 3 Program,q3 = Quantity[15],simpleAssign,232 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value - other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value * other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value ** other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value / other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value // other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value % other.value,simpleAssign,234 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,"q1 = Quantity[5] ,q2 = Quantity[10]",simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,q3 = Quantity[15],simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,q2 - q1 = Quantity[5],simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,q1 * q2 = Quantity[50],simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,q1 / q2 = Quantity[0.5],simpleAssign,235 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value * other,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value * other.value,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value / other,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,new_value = self.value / other.value,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,q1 <= q2,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,q1 == q2,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,q1 != q2,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,q1 >= q2,simpleAssign,236 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,237 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,237 2019 Book A Beginner's Guide To Python 3 Program,"q1 = Quantity[5] ,q2 = Quantity[10]",simpleAssign,238 2019 Book A Beginner's Guide To Python 3 Program,q3 = Quantity[15],simpleAssign,238 2019 Book A Beginner's Guide To Python 3 Program,q3 == q1: False,simpleAssign,238 2019 Book A Beginner's Guide To Python 3 Program,d1 = Distance(6),simpleAssign,239 2019 Book A Beginner's Guide To Python 3 Program,d2 = Distance(3),simpleAssign,239 2019 Book A Beginner's Guide To Python 3 Program,"person = Person('John', 54)",simpleAssign,242 2019 Book A Beginner's Guide To Python 3 Program,person.name = 42,simpleAssign,242 2019 Book A Beginner's Guide To Python 3 Program,"person = Person('John', 54)",simpleAssign,242 2019 Book A Beginner's Guide To Python 3 Program,"person = Person('John', 54)",simpleAssign,244 2019 Book A Beginner's Guide To Python 3 Program,"person = Person('John', 54)",simpleAssign,244 2019 Book A Beginner's Guide To Python 3 Program,"property_name> = property(fget=None, fset=None,",simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,"fdel=None, doc=None)",simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,"age = property(get_age, set_age, doc=""An age property"")",simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,"name = property(get_name, doc=""A name property"")",simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,"person = Person('John', 54)",simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,person.age = 21,simpleAssign,245 2019 Book A Beginner's Guide To Python 3 Program,Notice how we can now write person.age and person.age = 21; in both,simpleAssign,246 2019 Book A Beginner's Guide To Python 3 Program,"name = property(get_name, fdel=del_name, doc=""A name",simpleAssign,246 2019 Book A Beginner's Guide To Python 3 Program,"acc1 = CurrentAccount('123', 'John', 10.05, 100.0)",simpleAssign,248 2019 Book A Beginner's Guide To Python 3 Program,"acc2 = DepositAccount('345', 'John', 23.55, 0.5)",simpleAssign,248 2019 Book A Beginner's Guide To Python 3 Program,"acc3 = acc3 = InvestmentAccount('567', 'Phoebe', 12.45,",simpleAssign,248 2019 Book A Beginner's Guide To Python 3 Program,"Account[123] - John, current account = 10.05overdraft",simpleAssign,249 2019 Book A Beginner's Guide To Python 3 Program,"Account[345] - John, savings account = 23.55interest",simpleAssign,249 2019 Book A Beginner's Guide To Python 3 Program,"Account[567] - Phoebe, investment account = 12.45",simpleAssign,249 2019 Book A Beginner's Guide To Python 3 Program,"p = Person('Adam', 21)",simpleAssign,263 2019 Book A Beginner's Guide To Python 3 Program,result = x /y,simpleAssign,265 2019 Book A Beginner's Guide To Python 3 Program,result = x /y,simpleAssign,265 2019 Book A Beginner's Guide To Python 3 Program,"John, current account = 21.17overdraft limit: -100.0",simpleAssign,266 2019 Book A Beginner's Guide To Python 3 Program,default_shape = Shape('square'),simpleAssign,270 2019 Book A Beginner's Guide To Python 3 Program,shape = utils.Shape('circle'),simpleAssign,271 2019 Book A Beginner's Guide To Python 3 Program,shape = Shape('circle'),simpleAssign,273 2019 Book A Beginner's Guide To Python 3 Program,s = Shape('rectangle'),simpleAssign,273 2019 Book A Beginner's Guide To Python 3 Program,s = Shape('oval'),simpleAssign,274 2019 Book A Beginner's Guide To Python 3 Program,s = Shape('line'),simpleAssign,275 2019 Book A Beginner's Guide To Python 3 Program,set PYTHONPATH = c:\python30\lib;,simpleAssign,279 2019 Book A Beginner's Guide To Python 3 Program,p = Processor(),simpleAssign,282 2019 Book A Beginner's Guide To Python 3 Program,"acc1 = accounts.CurrentAccount('123', 'John', 10.05, 100.0)",simpleAssign,284 2019 Book A Beginner's Guide To Python 3 Program,"acc2 = accounts.DepositAccount('345', 'John', 23.55, 0.5)",simpleAssign,284 2019 Book A Beginner's Guide To Python 3 Program,"acc3 = accounts.InvestmentAccount('567', 'Phoebe', 12.45, 'high",simpleAssign,284 2019 Book A Beginner's Guide To Python 3 Program,bag = Bag(),simpleAssign,287 2019 Book A Beginner's Guide To Python 3 Program,bag = Bag(),simpleAssign,288 2019 Book A Beginner's Guide To Python 3 Program,"c = Circle(""circle1"")",simpleAssign,290 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Megan', 21, 'MS123')",simpleAssign,292 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Megan', 21, 'MS123')",simpleAssign,292 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Megan', 21, 'MS123')",simpleAssign,293 2019 Book A Beginner's Guide To Python 3 Program,"e = Employee('Megan', 21, 'MS123')",simpleAssign,294 2019 Book A Beginner's Guide To Python 3 Program,"acc1 = accounts.CurrentAccount('123', 'John', 10.05, 100.0)",simpleAssign,295 2019 Book A Beginner's Guide To Python 3 Program,"acc2 = accounts.DepositAccount('345', 'John', 23.55, 0.5)",simpleAssign,295 2019 Book A Beginner's Guide To Python 3 Program,"acc3 = accounts.InvestmentAccount('567', 'Phoebe', 12.45,",simpleAssign,295 2019 Book A Beginner's Guide To Python 3 Program,calc = Calculator(),simpleAssign,297 2019 Book A Beginner's Guide To Python 3 Program,q1 = Quantity(5),simpleAssign,297 2019 Book A Beginner's Guide To Python 3 Program,q2 = Quantity(10),simpleAssign,297 2019 Book A Beginner's Guide To Python 3 Program,d1 = Distance(6),simpleAssign,299 2019 Book A Beginner's Guide To Python 3 Program,d2 = Distance(3),simpleAssign,299 2019 Book A Beginner's Guide To Python 3 Program,x = Logger('x'),simpleAssign,305 2019 Book A Beginner's Guide To Python 3 Program,y = Logger('y'),simpleAssign,305 2019 Book A Beginner's Guide To Python 3 Program,x'] = x0,simpleAssign,305 2019 Book A Beginner's Guide To Python 3 Program,y'] = y0,simpleAssign,305 2019 Book A Beginner's Guide To Python 3 Program,dot notation (such as curser.x = 10). This means that it will not be intercepted by,simpleAssign,306 2019 Book A Beginner's Guide To Python 3 Program,"cursor = Cursor(15, 25)",simpleAssign,306 2019 Book A Beginner's Guide To Python 3 Program,cursor.x = 20,simpleAssign,306 2019 Book A Beginner's Guide To Python 3 Program,cursor.y = 35,simpleAssign,306 2019 Book A Beginner's Guide To Python 3 Program,"__set__: Point[15, 25] - x = 20",simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,"__set__: Point[20, 25] - y = 35",simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,x = 20,simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,x = 20,simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,"__set__: Point[20, 35] - x = 21",simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,y = 35,simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,"__set__: Point[21, 35] - y = 36",simpleAssign,307 2019 Book A Beginner's Guide To Python 3 Program,b = Bag(),simpleAssign,310 2019 Book A Beginner's Guide To Python 3 Program,Bag.__len__ = get_length,simpleAssign,311 2019 Book A Beginner's Guide To Python 3 Program,b2 = Bag(),simpleAssign,312 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,312 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,313 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,313 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,res1 = student.dummy_attribute,simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,res1 = student.dummy_attribute,simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,res1 = student.dummy_attribute,simpleAssign,315 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,316 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,316 2019 Book A Beginner's Guide To Python 3 Program,res2 = student.dummy_method(),simpleAssign,316 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,317 2019 Book A Beginner's Guide To Python 3 Program,student = Student('Katie'),simpleAssign,318 2019 Book A Beginner's Guide To Python 3 Program,res1 = student.dummy_attribute # invoke missing attribute,simpleAssign,318 2019 Book A Beginner's Guide To Python 3 Program,count = 0,simpleAssign,318 2019 Book A Beginner's Guide To Python 3 Program,student = Student('John'),simpleAssign,319 2019 Book A Beginner's Guide To Python 3 Program,t1 = logger(target),simpleAssign,323 2019 Book A Beginner's Guide To Python 3 Program,"p = Person('John', 'Smith', 21)",simpleAssign,328 2019 Book A Beginner's Guide To Python 3 Program,"p = Point(1, 1)",simpleAssign,329 2019 Book A Beginner's Guide To Python 3 Program,instance = None,simpleAssign,329 2019 Book A Beginner's Guide To Python 3 Program,instance = cls(),simpleAssign,329 2019 Book A Beginner's Guide To Python 3 Program,s1 = Service(),simpleAssign,330 2019 Book A Beginner's Guide To Python 3 Program,s2 = Service(),simpleAssign,330 2019 Book A Beginner's Guide To Python 3 Program,f1 = Foo(),simpleAssign,330 2019 Book A Beginner's Guide To Python 3 Program,f2 = Foo(),simpleAssign,330 2019 Book A Beginner's Guide To Python 3 Program,start = default_timer(),simpleAssign,334 2019 Book A Beginner's Guide To Python 3 Program,end = default_timer(),simpleAssign,334 2019 Book A Beginner's Guide To Python 3 Program,"calling deposit on Account[123] - John, current account = 10.05overdraft limit: -100.0 with 23.45",simpleAssign,335 2019 Book A Beginner's Guide To Python 3 Program,"calling withdraw on Account[123] - John, current account = 33.5overdraft limit: -100.0 with 12.33",simpleAssign,335 2019 Book A Beginner's Guide To Python 3 Program,return_val = self.val,simpleAssign,338 2019 Book A Beginner's Guide To Python 3 Program,value = 0,simpleAssign,341 2019 Book A Beginner's Guide To Python 3 Program,evens = evens_up_to(4),simpleAssign,342 2019 Book A Beginner's Guide To Python 3 Program,g = grep('Python'),simpleAssign,344 2019 Book A Beginner's Guide To Python 3 Program,number = input('Please input the number:'),simpleAssign,345 2019 Book A Beginner's Guide To Python 3 Program,prime = infinite_prime_number_generator(),simpleAssign,345 2019 Book A Beginner's Guide To Python 3 Program,t1 = tuple(list1),simpleAssign,348 2019 Book A Beginner's Guide To Python 3 Program,"set1 = set((1, 2, 3)",simpleAssign,363 2019 Book A Beginner's Guide To Python 3 Program,"dict1 = dict(uk='London', ireland='Dublin', france='Paris')",simpleAssign,372 2019 Book A Beginner's Guide To Python 3 Program,"dict2 = dict([('uk', 'London'), ('ireland', 'Dublin'),",simpleAssign,372 2019 Book A Beginner's Guide To Python 3 Program,"dict3 = dict((['uk', 'London'], ['ireland', 'Dublin'],",simpleAssign,372 2019 Book A Beginner's Guide To Python 3 Program,__hash__ = None,simpleAssign,378 2019 Book A Beginner's Guide To Python 3 Program,start = default_timer(),simpleAssign,380 2019 Book A Beginner's Guide To Python 3 Program,end = default_timer(),simpleAssign,380 2019 Book A Beginner's Guide To Python 3 Program,if num == 0:,simpleAssign,380 2019 Book A Beginner's Guide To Python 3 Program,Factorial_value = 1,simpleAssign,380 2019 Book A Beginner's Guide To Python 3 Program,Factorial_value = factorial_value * i,simpleAssign,380 2019 Book A Beginner's Guide To Python 3 Program,"fruit = collections.Counter(['apple', 'orange', 'pear',",simpleAssign,385 2019 Book A Beginner's Guide To Python 3 Program,"fruit1 = collections.Counter(['apple', 'orange', 'pear',",simpleAssign,386 2019 Book A Beginner's Guide To Python 3 Program,"fruit2 = collections.Counter(['banana', 'apple', 'apple'])",simpleAssign,386 2019 Book A Beginner's Guide To Python 3 Program,fruit['apple'] = 1 # initialises the number of apples,simpleAssign,386 2019 Book A Beginner's Guide To Python 3 Program,"r1 = list(itertools.chain([1, 2, 3], [2, 3, 4]))",simpleAssign,387 2019 Book A Beginner's Guide To Python 3 Program,"r2 = list(itertools.repeat('hello', 5))",simpleAssign,387 2019 Book A Beginner's Guide To Python 3 Program,"r3 = list(itertools.dropwhile(lambda x: x < 5, values))",simpleAssign,387 2019 Book A Beginner's Guide To Python 3 Program,"r4 = list(itertools.islice(values, 3, 6))",simpleAssign,387 2019 Book A Beginner's Guide To Python 3 Program,element1 = queue.pop(0),simpleAssign,391 2019 Book A Beginner's Guide To Python 3 Program,queue = Queue(),simpleAssign,392 2019 Book A Beginner's Guide To Python 3 Program,top_element = stack.pop(),simpleAssign,394 2019 Book A Beginner's Guide To Python 3 Program,stack = Stack(),simpleAssign,396 2019 Book A Beginner's Guide To Python 3 Program,"d1 = list(filter(lambda i: i % 2 == 0, data))",simpleAssign,398 2019 Book A Beginner's Guide To Python 3 Program,"d2 = list(filter(is_even, data))",simpleAssign,398 2019 Book A Beginner's Guide To Python 3 Program,"d3 = list(filter(lambda p: p.age <= 21, data))",simpleAssign,399 2019 Book A Beginner's Guide To Python 3 Program,"d2 = list(map(add_one, data))",simpleAssign,400 2019 Book A Beginner's Guide To Python 3 Program,"ages = list(map(lambda p: p.age, data))",simpleAssign,401 2019 Book A Beginner's Guide To Python 3 Program,"total_age = reduce(lambda running_total, person: running_total",simpleAssign,402 2019 Book A Beginner's Guide To Python 3 Program,average_age = total_age // len(data),simpleAssign,402 2019 Book A Beginner's Guide To Python 3 Program,stack = Stack(),simpleAssign,403 2019 Book A Beginner's Guide To Python 3 Program,"new_list = list(map(add_item, stack))",simpleAssign,403 2019 Book A Beginner's Guide To Python 3 Program,"filtered_list = list(filter(is_job, stack))",simpleAssign,403 2019 Book A Beginner's Guide To Python 3 Program,X = Counter('X'),simpleAssign,407 2019 Book A Beginner's Guide To Python 3 Program,O = Counter('O'),simpleAssign,407 2019 Book A Beginner's Guide To Python 3 Program,invalid_input = True,simpleAssign,409 2019 Book A Beginner's Guide To Python 3 Program,row = self.cells[move.x],simpleAssign,411 2019 Book A Beginner's Guide To Python 3 Program,row[move.y] = move.counter,simpleAssign,411 2019 Book A Beginner's Guide To Python 3 Program,c = player.counter,simpleAssign,411 2019 Book A Beginner's Guide To Python 3 Program,counter = input().upper(),simpleAssign,412 2019 Book A Beginner's Guide To Python 3 Program,game = Game(),simpleAssign,414 "Think Python, 2nd Edition","zip(s, t)",zip,143 "Think Python, 2nd Edition","zip(s, t))",zip,143 "Think Python, 2nd Edition","zip('Anne', 'Elk'))",zip,143 "Think Python, 2nd Edition","map(self, k)",map,252 "Think Python, 2nd Edition",g = (x**2 for x in range(5)),generatorExpression,225 "Think Python, 2nd Edition",pickle.dumps(t),pickle,170 "Think Python, 2nd Edition",pickle.loads (“load string”),pickle,171 "Think Python, 2nd Edition",import dbm,importdbm,170 "Think Python, 2nd Edition",if __name__ == '__main__':,__name__,173 "Think Python, 2nd Edition",if meth_name in ty.__dict__,__dict__,217 "Think Python, 2nd Edition","if x % 2 == 0: print('x is even') else:",ifelse,50 "Think Python, 2nd Edition","if x > y: print('x is greater than y') else:",ifelse,50 "Think Python, 2nd Edition","if x == y: print('x and y are equal') else:",ifelse,50 "Think Python, 2nd Edition","if word > 'banana': print('Your word, ' + word + ', comes after banana.') else:",ifelse,92 "Think Python, 2nd Edition","if x > 0: y = math.log(x) else:",ifelse,223 "Think Python, 2nd Edition","while n != 1: print(n) if n % 2 == 0: # n is even n = n / 2 else:",whileelse,78 "Think Python, 2nd Edition","while True: line = input('> ') if line == 'done': break",whilebreak,78 "Think Python, 2nd Edition","while True: print(x) y = (x + a/x) / 2 if y == x: break x = y For most values of a this works fine, but in general it is dangerous to test float equalߚ ity. Floating-point values are only approximately right: most rational numbers, like 1/3, and irrational numbers, like 2, can’t be represented exactly with a float. Rather than checking whether x and y are exactly equal, it is safer to use the built-in function abs to compute the absolute value, or magnitude, of the difference between them: if abs(y-x) < epsilon: break",whilebreak,80 "Think Python, 2nd Edition","while index < len(word): if word[index] == letter: return index index = index + 1 return -1 In a sense, find is the inverse of the [] operator. Instead of taking an index and extracting the corresponding character, it takes a character and finds the index where that character appears. If the character is not found, the function returns -1. This is the first example we have seen of a return statement inside a loop. If word[index] == letter, the function break",whilebreak,89 "Think Python, 2nd Edition","while loop: def is_abecedarian(word): i = 0 while i < len(word)-1: if word[i+1] < word[i]: return False i = i+1 return True The loop starts at i=0 and ends when i=len(word)-1. Each time through the loop, it compares the ith character (which you can think of as the current character) to the i +1th character (which you can think of as the next). If the next character is less than (alphabetically before) the current one, then we have discovered a break",whilebreak,103 "Think Python, 2nd Edition","while statement:",whilesimple,77 "Think Python, 2nd Edition",while n > 0:,whilesimple,77 "Think Python, 2nd Edition",while statement:,whilesimple,77 "Think Python, 2nd Edition",while loop:,whilesimple,86 "Think Python, 2nd Edition",while index < len(fruit):,whilesimple,87 "Think Python, 2nd Edition",while j > 0:,whilesimple,92 "Think Python, 2nd Edition",while j > 0:,whilesimple,93 "Think Python, 2nd Edition",while i<j:,whilesimple,104 "Think Python, 2nd Edition","while and then produce a “RuntimeError:",whilesimple,238 "Think Python, 2nd Edition",while x > 0 and y < 0 :,whilesimple,238 "Think Python, 2nd Edition","def __init__(self, hour=0, minute=0, second=0)",__init__,199 "Think Python, 2nd Edition","def __init__(self, suit=0, rank=2)",__init__,208 "Think Python, 2nd Edition",def __init__(self),__init__,211 "Think Python, 2nd Edition","def __init__(self, label='')",__init__,213 "Think Python, 2nd Edition",def __init__(self),__init__,216 "Think Python, 2nd Edition","def __init__(self, pong)",__init__,219 "Think Python, 2nd Edition","def __init__(self, pings=None)",__init__,219 "Think Python, 2nd Edition","def __init__(self, name, contents=None)",__init__,224 "Think Python, 2nd Edition","def __init__(self, name, contents=None)",__init__,224 "Think Python, 2nd Edition","def __init__(self, x=0, y=0)",__init__,230 "Think Python, 2nd Edition",def __init__(self),__init__,252 "Think Python, 2nd Edition","def __init__(self, n=100)",__init__,252 "Think Python, 2nd Edition",def __init__(self),__init__,253 "Think Python, 2nd Edition","try: x = p.x except AttributeError:",tryexcept,184 "Think Python, 2nd Edition","def printall(*args, **kwargs):",funcwith2star,232 "Think Python, 2nd Edition",def printall(*args):,funcwithstar,142 "Think Python, 2nd Edition",def printall(*args):,funcwithstar,232 "Think Python, 2nd Edition",class Hand(Deck):,simpleclass,213 "Think Python, 2nd Edition",class Ping(PingPongParent):,simpleclass,219 "Think Python, 2nd Edition",class Pong(PingPongParent):,simpleclass,219 "Think Python, 2nd Edition",class Pointier(Point):,simpleclass,231 "Think Python, 2nd Edition",raise LookupError(),raise,129 "Think Python, 2nd Edition",raise LookupError('value does not appear in the dictionary'),raise,130 "Think Python, 2nd Edition","if x < 0: pass",pass,49 "Think Python, 2nd Edition","class PingPongParent: pass",pass,219 "Think Python, 2nd Edition",for x in []:,forwithlist,109 "Think Python, 2nd Edition","t = [[1, 2], [3], [4, 5, 6]]",nestedList,120 "Think Python, 2nd Edition","t2 = [[1,2], [3,4], [5,6]]",nestedList,147 "Think Python, 2nd Edition","t3 = [1, 2, 3, 4.0, '5', '6', [7], [8], 9]",nestedList,147 "Think Python, 2nd Edition","for suit in range(4): for rank in range(1, 14):",fornested,211 "Think Python, 2nd Edition","for m in self.maps.maps: for k, v in m.items:",fornested,254 "Think Python, 2nd Edition","eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'}",simpleDict,126 "Think Python, 2nd Edition","known = {0:0, 1:1}",simpleDict,132 "Think Python, 2nd Edition","known = {0:0, 1:1}",simpleDict,134 "Think Python, 2nd Edition","d = {'a':0, 'b':1, 'c':2}",simpleDict,144 "Think Python, 2nd Edition",fin = open('words.txt'),openfunc,99 "Think Python, 2nd Edition",fin = open('words.txt'),openfunc,100 "Think Python, 2nd Edition",fp = open(filename),openfunc,154 "Think Python, 2nd Edition","fout = open('output.txt', 'w')",openfunc,166 "Think Python, 2nd Edition",fin = open('bad_file'),openfunc,169 "Think Python, 2nd Edition","fout = open('/etc/passwd', 'w')",openfunc,169 "Think Python, 2nd Edition",fin = open('/home'),openfunc,169 "Think Python, 2nd Edition",fin = open('bad_file'),openfunc,169 "Think Python, 2nd Edition","db = dbm.open('captions', 'c')",openfunc,170 "Think Python, 2nd Edition",fp = os.popen(cmd),openfunc,171 "Think Python, 2nd Edition",fp = os.popen(cmd),openfunc,172 "Think Python, 2nd Edition",for line in open(filename),openfunc,172 "Think Python, 2nd Edition",for line in open(filename),openfunc,229 "Think Python, 2nd Edition",for line in open(filename),openfunc,230 "Think Python, 2nd Edition",for line in open(filename),openfunc,230 "Think Python, 2nd Edition",fout.write(line1),write,166 "Think Python, 2nd Edition",fout.write(line2),write,166 "Think Python, 2nd Edition",fout.write(str(x)),write,166 "Think Python, 2nd Edition",res = fp.read(),read,171 "Think Python, 2nd Edition",res = fp.read(),read,172 "Think Python, 2nd Edition",fin.readline(),readline,99 "Think Python, 2nd Edition",fin.readline(),readline,100 "Think Python, 2nd Edition",line = fin.readline(),readline,100 "Think Python, 2nd Edition",import pass,importfunc,12 "Think Python, 2nd Edition",import it,importfunc,22 "Think Python, 2nd Edition",import math,importfunc,22 "Think Python, 2nd Edition",import statement,importfunc,32 "Think Python, 2nd Edition",import turtle,importfunc,35 "Think Python, 2nd Edition",import turtle,importfunc,35 "Think Python, 2nd Edition",import math,importfunc,40 "Think Python, 2nd Edition",import stateߚ,importfunc,40 "Think Python, 2nd Edition",import math,importfunc,55 "Think Python, 2nd Edition",import time,importfunc,57 "Think Python, 2nd Edition",import math,importfunc,83 "Think Python, 2nd Edition",import string,importfunc,151 "Think Python, 2nd Edition",import random,importfunc,153 "Think Python, 2nd Edition",import string,importfunc,154 "Think Python, 2nd Edition",import os,importfunc,167 "Think Python, 2nd Edition",import pickle,importfunc,170 "Think Python, 2nd Edition",import it,importfunc,172 "Think Python, 2nd Edition",import wc,importfunc,172 "Think Python, 2nd Edition",import the,importfunc,173 "Think Python, 2nd Edition",import a,importfunc,173 "Think Python, 2nd Edition",import a,importfunc,173 "Think Python, 2nd Edition",import the,importfunc,173 "Think Python, 2nd Edition",import copy,importfunc,182 "Think Python, 2nd Edition",import to,importfunc,237 "Think Python, 2nd Edition",import the,importfunc,237 "Think Python, 2nd Edition",import this,importfunc,237 "Think Python, 2nd Edition",from structshape import structshape,importfromsimple,147 "Think Python, 2nd Edition",from collections import Counter,importfromsimple,228 "Think Python, 2nd Edition",from collections import defaultdict,importfromsimple,229 "Think Python, 2nd Edition",from collections import namedtuple,importfromsimple,231 "Think Python, 2nd Edition",self.hour = hour,simpleattr,199 "Think Python, 2nd Edition",self.minute = minute,simpleattr,199 "Think Python, 2nd Edition",self.second = second,simpleattr,199 "Think Python, 2nd Edition",self.hour = hour,simpleattr,199 "Think Python, 2nd Edition",self.suit = suit,simpleattr,208 "Think Python, 2nd Edition",self.rank = rank,simpleattr,208 "Think Python, 2nd Edition",self.cards = [],simpleattr,211 "Think Python, 2nd Edition",self.cards = [],simpleattr,213 "Think Python, 2nd Edition",self.label = label,simpleattr,213 "Think Python, 2nd Edition",self.suffix_map = {},simpleattr,216 "Think Python, 2nd Edition",self.prefix = (),simpleattr,216 "Think Python, 2nd Edition",self.suffix_map[self.prefix] = [word],simpleattr,216 "Think Python, 2nd Edition","self.prefix = shift(self.prefix, word)",simpleattr,216 "Think Python, 2nd Edition",self.pong = pong,simpleattr,219 "Think Python, 2nd Edition",self.pings = pings,simpleattr,219 "Think Python, 2nd Edition",self.name = name,simpleattr,224 "Think Python, 2nd Edition",self.pouch_contents = contents,simpleattr,224 "Think Python, 2nd Edition",self.name = name,simpleattr,224 "Think Python, 2nd Edition",self.pouch_contents = [] if contents == None else contents,simpleattr,224 "Think Python, 2nd Edition",self.x = x,simpleattr,230 "Think Python, 2nd Edition",self.y = y,simpleattr,230 "Think Python, 2nd Edition",self.items = [],simpleattr,252 "Think Python, 2nd Edition",self.maps = [],simpleattr,252 "Think Python, 2nd Edition",self.maps = BetterMap(2),simpleattr,253 "Think Python, 2nd Edition",self.num = 0,simpleattr,253 "Think Python, 2nd Edition",self.num += 1,simpleattr,253 "Think Python, 2nd Edition",self.maps = new_maps,simpleattr,254 "Think Python, 2nd Edition",total += x,assignIncrement,111 "Think Python, 2nd Edition",The += operator provides a short way to update a variable. This augmented assignߚ,assignIncrement,111 "Think Python, 2nd Edition",total += x,assignIncrement,111 "Think Python, 2nd Edition",d[c] += 1,assignIncrement,127 "Think Python, 2nd Edition",count += 1,assignIncrement,134 "Think Python, 2nd Edition",count += 1,assignIncrement,172 "Think Python, 2nd Edition",rect.width += dwidth,assignIncrement,181 "Think Python, 2nd Edition",rect.height += dheight,assignIncrement,181 "Think Python, 2nd Edition",sum.minute += 1,assignIncrement,189 "Think Python, 2nd Edition",sum.hour += 1,assignIncrement,189 "Think Python, 2nd Edition",time.second += seconds,assignIncrement,189 "Think Python, 2nd Edition",time.minute += 1,assignIncrement,189 "Think Python, 2nd Edition",time.hour += 1,assignIncrement,190 "Think Python, 2nd Edition",seconds += self.time_to_int(),assignIncrement,198 "Think Python, 2nd Edition",seconds += self.time_to_int(),assignIncrement,201 "Think Python, 2nd Edition",total += x,assignIncrement,249 "Think Python, 2nd Edition","def print_most_common(hist, num=10):",funcdefault,156 "Think Python, 2nd Edition","def process_word(self, word, order=2):",funcdefault,216 "Think Python, 2nd Edition",range(5)),rangefunc,226 "Think Python, 2nd Edition",def print_lyrics():,simplefunc,23 "Think Python, 2nd Edition",def print_lyrics():,simplefunc,24 "Think Python, 2nd Edition",def repeat_lyrics():,simplefunc,24 "Think Python, 2nd Edition",def print_lyrics():,simplefunc,25 "Think Python, 2nd Edition",def repeat_lyrics():,simplefunc,25 "Think Python, 2nd Edition",def print_twice(bruce):,simplefunc,26 "Think Python, 2nd Edition",def do_twice(f):,simplefunc,33 "Think Python, 2nd Edition",def print_spam():,simplefunc,33 "Think Python, 2nd Edition",def square(t):,simplefunc,38 "Think Python, 2nd Edition",def countdown(n):,simplefunc,51 "Think Python, 2nd Edition",def recurse():,simplefunc,53 "Think Python, 2nd Edition",def area(radius):,simplefunc,61 "Think Python, 2nd Edition",def area(radius):,simplefunc,61 "Think Python, 2nd Edition",def absolute_value(x):,simplefunc,62 "Think Python, 2nd Edition",def absolute_value(x):,simplefunc,62 "Think Python, 2nd Edition",def factorial(n):,simplefunc,67 "Think Python, 2nd Edition",def factorial(n):,simplefunc,67 "Think Python, 2nd Edition",def factorial(n):,simplefunc,67 "Think Python, 2nd Edition",def fibonacci (n):,simplefunc,69 "Think Python, 2nd Edition",def factorial (n):,simplefunc,69 "Think Python, 2nd Edition",def factorial(n):,simplefunc,70 "Think Python, 2nd Edition",def b(z):,simplefunc,72 "Think Python, 2nd Edition",def first(word):,simplefunc,73 "Think Python, 2nd Edition",def last(word):,simplefunc,73 "Think Python, 2nd Edition",def middle(word):,simplefunc,73 "Think Python, 2nd Edition",def countdown(n):,simplefunc,77 "Think Python, 2nd Edition",def sequence(n):,simplefunc,78 "Think Python, 2nd Edition",def any_lowercase1(s):,simplefunc,96 "Think Python, 2nd Edition",def any_lowercase2(s):,simplefunc,96 "Think Python, 2nd Edition",def any_lowercase3(s):,simplefunc,96 "Think Python, 2nd Edition",def any_lowercase4(s):,simplefunc,96 "Think Python, 2nd Edition",def any_lowercase5(s):,simplefunc,96 "Think Python, 2nd Edition",def has_no_e(word):,simplefunc,101 "Think Python, 2nd Edition",def is_abecedarian(word):,simplefunc,103 "Think Python, 2nd Edition",def is_abecedarian(word):,simplefunc,103 "Think Python, 2nd Edition",def is_palindrome(word):,simplefunc,104 "Think Python, 2nd Edition",def is_palindrome(word):,simplefunc,104 "Think Python, 2nd Edition",def add_all(t):,simplefunc,111 "Think Python, 2nd Edition",def capitalize_all(t):,simplefunc,112 "Think Python, 2nd Edition",def only_upper(t):,simplefunc,112 "Think Python, 2nd Edition",def delete_head(t):,simplefunc,116 "Think Python, 2nd Edition",def bad_delete_head(t):,simplefunc,117 "Think Python, 2nd Edition",def tail(t):,simplefunc,118 "Think Python, 2nd Edition",def histogram(s):,simplefunc,127 "Think Python, 2nd Edition",def print_hist(h):,simplefunc,128 "Think Python, 2nd Edition",def invert_dict(d):,simplefunc,130 "Think Python, 2nd Edition",def fibonacci(n):,simplefunc,132 "Think Python, 2nd Edition",def example1():,simplefunc,133 "Think Python, 2nd Edition",def example2():,simplefunc,133 "Think Python, 2nd Edition",def example2():,simplefunc,133 "Think Python, 2nd Edition",def example3():,simplefunc,134 "Think Python, 2nd Edition",def example3():,simplefunc,134 "Think Python, 2nd Edition",def example4():,simplefunc,134 "Think Python, 2nd Edition",def example5():,simplefunc,134 "Think Python, 2nd Edition",def min_max(t):,simplefunc,142 "Think Python, 2nd Edition",def process_file(filename):,simplefunc,154 "Think Python, 2nd Edition",def total_words(hist):,simplefunc,154 "Think Python, 2nd Edition",def different_words(hist):,simplefunc,154 "Think Python, 2nd Edition",def most_common(hist):,simplefunc,155 "Think Python, 2nd Edition",def random_word(h):,simplefunc,157 "Think Python, 2nd Edition",def walk(dirname):,simplefunc,168 "Think Python, 2nd Edition",def linecount(filename):,simplefunc,172 "Think Python, 2nd Edition",def print_point(p):,simplefunc,179 "Think Python, 2nd Edition",def find_center(rect):,simplefunc,181 "Think Python, 2nd Edition",def time_to_int(time):,simplefunc,191 "Think Python, 2nd Edition",def int_to_time(seconds):,simplefunc,191 "Think Python, 2nd Edition",def valid_time(time):,simplefunc,192 "Think Python, 2nd Edition",def print_time(time):,simplefunc,196 "Think Python, 2nd Edition",def print_time(time):,simplefunc,197 "Think Python, 2nd Edition",def print_time(self):,simplefunc,197 "Think Python, 2nd Edition",def __str__(self):,simplefunc,200 "Think Python, 2nd Edition",def histogram(s):,simplefunc,202 "Think Python, 2nd Edition",def print_attributes(obj):,simplefunc,204 "Think Python, 2nd Edition",def __str__(self):,simplefunc,209 "Think Python, 2nd Edition",def __str__(self):,simplefunc,211 "Think Python, 2nd Edition",def pop_card(self):,simplefunc,212 "Think Python, 2nd Edition",def shuffle(self):,simplefunc,212 "Think Python, 2nd Edition",def factorial(n):,simplefunc,224 "Think Python, 2nd Edition",def factorial(n):,simplefunc,224 "Think Python, 2nd Edition",def capitalize_all(t):,simplefunc,224 "Think Python, 2nd Edition",def capitalize_all(t):,simplefunc,224 "Think Python, 2nd Edition",def only_upper(t):,simplefunc,225 "Think Python, 2nd Edition",def only_upper(t):,simplefunc,225 "Think Python, 2nd Edition",def has_duplicates(t):,simplefunc,227 "Think Python, 2nd Edition",def has_duplicates(t):,simplefunc,227 "Think Python, 2nd Edition",def all_anagrams(filename):,simplefunc,229 "Think Python, 2nd Edition",def all_anagrams(filename):,simplefunc,230 "Think Python, 2nd Edition",def all_anagrams(filename):,simplefunc,230 "Think Python, 2nd Edition",def __str__(self):,simplefunc,230 "Think Python, 2nd Edition",def resize(self):,simplefunc,253 "Think Python, 2nd Edition","return None continue for lambda try",return,12 "Think Python, 2nd Edition",return value.,return,21 "Think Python, 2nd Edition",return results; for,return,29 "Think Python, 2nd Edition",return a value. They are called void funcߚ,return,29 "Think Python, 2nd Edition",return value is lost forߚ,return,29 "Think Python, 2nd Edition","return value. If you assign the result to a variable, you get a special",return,29 "Think Python, 2nd Edition",return value:,return,31 "Think Python, 2nd Edition","return value is the value of the expression.",return,31 "Think Python, 2nd Edition",return value? An interface is “clean” if it,return,40 "Think Python, 2nd Edition",return value.,return,44 "Think Python, 2nd Edition",return value to,return,54 "Think Python, 2nd Edition",return statement:,return,57 "Think Python, 2nd Edition",return to the caller.,return,57 "Think Python, 2nd Edition","return values. But the functions we’ve written are all void: they have an effect, like",return,61 "Think Python, 2nd Edition",return value. In this chapter,return,61 "Think Python, 2nd Edition","return value, which we usually assign to a variable or",return,61 "Think Python, 2nd Edition","return value; more precisely, their return value is None.",return,61 "Think Python, 2nd Edition",return a,return,61 "Think Python, 2nd Edition","return statement before, but in a fruitful function the return stateߚ",return,61 "Think Python, 2nd Edition",return value.” The expression can be,return,61 "Think Python, 2nd Edition",return math.pi * radius**2,return,61 "Think Python, 2nd Edition","return statements, one in each branch of a",return,62 "Think Python, 2nd Edition",return x,return,62 "Think Python, 2nd Edition","return statements are in an alternative conditional, only one runs.",return,62 "Think Python, 2nd Edition","return statement runs, the function terminates without executing any",return,62 "Think Python, 2nd Edition","return statement, or any other place",return,62 "Think Python, 2nd Edition",return statement. For example:,return,62 "Think Python, 2nd Edition",return statement. If the flow of execution gets to,return,62 "Think Python, 2nd Edition","return value is None, which is not the absolute value of 0:",return,62 "Think Python, 2nd Edition",return value)?,return,63 "Think Python, 2nd Edition",return value is the distance represented by a floating-point value.,return,63 "Think Python, 2nd Edition",return 0.0,return,63 "Think Python, 2nd Edition",return 0.0,return,63 "Think Python, 2nd Edition",return 0.0,return,63 "Think Python, 2nd Edition",return the result:,return,64 "Think Python, 2nd Edition",return result,return,64 "Think Python, 2nd Edition",return statement.,return,64 "Think Python, 2nd Edition",return result,return,65 "Think Python, 2nd Edition","return area(distance(xc, yc, xp, yp))",return,65 "Think Python, 2nd Edition","return booleans, which is often convenient for hiding complicated tests",return,65 "Think Python, 2nd Edition",return False,return,65 "Think Python, 2nd Edition",return x % y == 0,return,65 "Think Python, 2nd Edition",return 1:,return,67 "Think Python, 2nd Edition",return result,return,67 "Think Python, 2nd Edition",return 1 without makߚ,return,67 "Think Python, 2nd Edition","return value, 1, is multiplied by n, which is 1, and the result is returned.",return,67 "Think Python, 2nd Edition","return value, 1, is multiplied by n, which is 2, and the result is returned.",return,67 "Think Python, 2nd Edition","return value (2) is multiplied by n, which is 3, and the result, 6, becomes the",return,67 "Think Python, 2nd Edition",return value of the function call that started the whole process.,return,67 "Think Python, 2nd Edition","return values are shown being passed back up the stack. In each frame, the",return,68 "Think Python, 2nd Edition","return value is the value of result, which is the product of n and recurse.",return,68 "Think Python, 2nd Edition",return 1,return,69 "Think Python, 2nd Edition",return fibonacci(n-1) + fibonacci(n-2),return,69 "Think Python, 2nd Edition",return None,return,69 "Think Python, 2nd Edition",return None,return,69 "Think Python, 2nd Edition",return 1,return,69 "Think Python, 2nd Edition",return n * factorial(n-1),return,69 "Think Python, 2nd Edition",return value or the way it is being used.,return,70 "Think Python, 2nd Edition",return statement and,return,70 "Think Python, 2nd Edition","return value. If possible, check the result by hand. Consider calling the",return,70 "Think Python, 2nd Edition","return value is being used correctly (or used at all!).",return,70 "Think Python, 2nd Edition",return 1,return,71 "Think Python, 2nd Edition",return result,return,71 "Think Python, 2nd Edition","return statement.",return,71 "Think Python, 2nd Edition",return prod,return,72 "Think Python, 2nd Edition",return x * y,return,72 "Think Python, 2nd Edition",return square,return,72 "Think Python, 2nd Edition","return the first, last, and",return,72 "Think Python, 2nd Edition",return word[0],return,73 "Think Python, 2nd Edition",return word[-1],return,73 "Think Python, 2nd Edition",return word[1:-1],return,73 "Think Python, 2nd Edition",return the value of the last,return,83 "Think Python, 2nd Edition",return an,return,83 "Think Python, 2nd Edition","return True if one of the words is the reverse of the other, but it conߚ",return,92 "Think Python, 2nd Edition",return True,return,92 "Think Python, 2nd Edition","return False immediately. Otherwise, for the rest of the function, we can assume that",return,92 "Think Python, 2nd Edition",return False immediately. If we get through,return,93 "Think Python, 2nd Edition",return True.,return,93 "Think Python, 2nd Edition",return value,return,93 "Think Python, 2nd Edition",return False,return,96 "Think Python, 2nd Edition",return 'True',return,96 "Think Python, 2nd Edition",return 'False',return,96 "Think Python, 2nd Edition",return flag,return,96 "Think Python, 2nd Edition",return flag,return,96 "Think Python, 2nd Edition",return True,return,96 "Think Python, 2nd Edition","return and a newline, that separate",return,100 "Think Python, 2nd Edition",return True,return,101 "Think Python, 2nd Edition",return False; otherwise we have to go to the next letter. If we exit the loop norߚ,return,102 "Think Python, 2nd Edition",return True.,return,102 "Think Python, 2nd Edition",return True,return,102 "Think Python, 2nd Edition",return False as soon as we find a forbidden letter; if we get to the end of the,return,102 "Think Python, 2nd Edition",return True.,return,102 "Think Python, 2nd Edition",return True,return,102 "Think Python, 2nd Edition",return False.,return,102 "Think Python, 2nd Edition",return True,return,102 "Think Python, 2nd Edition",return False.,return,102 "Think Python, 2nd Edition","return uses_only(required, word)",return,102 "Think Python, 2nd Edition",return True,return,103 "Think Python, 2nd Edition",return is_abecedarian(word[1:]),return,103 "Think Python, 2nd Edition",return False.,return,103 "Think Python, 2nd Edition",return True,return,104 "Think Python, 2nd Edition","return is_reverse(word, word)",return,104 "Think Python, 2nd Edition","return False, and words that don’t should return True. You should have",return,104 "Think Python, 2nd Edition",return None. If you accidentally,return,111 "Think Python, 2nd Edition",return total,return,111 "Think Python, 2nd Edition",return res,return,112 "Think Python, 2nd Edition",return a,return,112 "Think Python, 2nd Edition",return res,return,112 "Think Python, 2nd Edition",return value from remove is None.,return,113 "Think Python, 2nd Edition",return t[1:],return,118 "Think Python, 2nd Edition",return None. This is the opposite of,return,118 "Think Python, 2nd Edition",return a new string and leave the original alone.,return,118 "Think Python, 2nd Edition",return d,return,127 "Think Python, 2nd Edition",return inverse,return,130 "Think Python, 2nd Edition",return res,return,132 "Think Python, 2nd Edition","return immediately. Otherwise it has to compute the new value, add it to the dictioߚ",return,133 "Think Python, 2nd Edition",return it.,return,133 "Think Python, 2nd Edition",return value from split is a list with two elements; the first element is assigned,return,141 "Think Python, 2nd Edition","return one value, but if the value is a tuple, the",return,141 "Think Python, 2nd Edition","return min(t), max(t)",return,142 "Think Python, 2nd Edition",return False,return,144 "Think Python, 2nd Edition","return statement, it is syntactically simpler to create a",return,146 "Think Python, 2nd Edition",return 'a' with probability 2/3 and 'b' with probability 1/3.,return,153 "Think Python, 2nd Edition",return hist,return,154 "Think Python, 2nd Edition",return new strings.),return,154 "Think Python, 2nd Edition",return sum(hist.values()),return,154 "Think Python, 2nd Edition",return len(hist),return,154 "Think Python, 2nd Edition",return t,return,155 "Think Python, 2nd Edition",return res,return,156 "Think Python, 2nd Edition",return random.choice(t),return,157 "Think Python, 2nd Edition","return prefix[1:] + (word,)",return,160 "Think Python, 2nd Edition",return value is the number of characters that were written. The file object keeps,return,166 "Think Python, 2nd Edition",return value is an object,return,171 "Think Python, 2nd Edition",return value is the final status of the ls process; None means that it ended norߚ,return,172 "Think Python, 2nd Edition",return count,return,172 "Think Python, 2nd Edition","return character, represented \r. Some use both. If you move files between difߚ",return,174 "Think Python, 2nd Edition",return a list of its anagrams.,return,175 "Think Python, 2nd Edition","return value is a reference to a Point object, which we assign to blank.",return,178 "Think Python, 2nd Edition","return instances. For example, find_center takes a Rectangle as an",return,181 "Think Python, 2nd Edition",return p,return,181 "Think Python, 2nd Edition",return True if any part of the Rectangle falls inside the,return,185 "Think Python, 2nd Edition",return them as results. In this,return,187 "Think Python, 2nd Edition",return sum,return,188 "Think Python, 2nd Edition",return sum,return,189 "Think Python, 2nd Edition",return seconds,return,191 "Think Python, 2nd Edition",return time,return,191 "Think Python, 2nd Edition",return int_to_time(seconds),return,191 "Think Python, 2nd Edition",return True,return,192 "Think Python, 2nd Edition",return int_to_time(seconds),return,192 "Think Python, 2nd Edition",return int_to_time(seconds),return,192 "Think Python, 2nd Edition",return None.,return,193 "Think Python, 2nd Edition",return int_to_time(seconds),return,198 "Think Python, 2nd Edition",return self.time_to_int() > other.time_to_int(),return,198 "Think Python, 2nd Edition",return a string repreߚ,return,200 "Think Python, 2nd Edition","return '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second)",return,200 "Think Python, 2nd Edition",return int_to_time(seconds),return,200 "Think Python, 2nd Edition",return self.increment(other),return,201 "Think Python, 2nd Edition",return int_to_time(seconds),return,201 "Think Python, 2nd Edition",return int_to_time(seconds),return,201 "Think Python, 2nd Edition",return self.__add__(other),return,202 "Think Python, 2nd Edition",return a new Point whose x,return,202 "Think Python, 2nd Edition","return a new Point with the result.",return,202 "Think Python, 2nd Edition",return d,return,202 "Think Python, 2nd Edition","return '%s of %s' % (Card.rank_names[self.rank],",return,209 "Think Python, 2nd Edition",return True,return,210 "Think Python, 2nd Edition",return False,return,210 "Think Python, 2nd Edition",return self.rank < other.rank,return,210 "Think Python, 2nd Edition",return t1 < t2,return,211 "Think Python, 2nd Edition",return '\n'.join(res),return,211 "Think Python, 2nd Edition",return self.cards.pop(),return,212 "Think Python, 2nd Edition","return try:",return,216 "Think Python, 2nd Edition",return ty,return,217 "Think Python, 2nd Edition",return the,return,218 "Think Python, 2nd Edition",return a list of,return,219 "Think Python, 2nd Edition","return True or False according to whether or not the hand meets the relevant criteria.",return,220 "Think Python, 2nd Edition",return n * factorial(n-1),return,224 "Think Python, 2nd Edition",return 1 if n == 0 else n * factorial(n-1),return,224 "Think Python, 2nd Edition",return res,return,224 "Think Python, 2nd Edition",return [s.capitalize() for s in t],return,224 "Think Python, 2nd Edition",return res,return,225 "Think Python, 2nd Edition",return [s for s in t if s.isupper()],return,225 "Think Python, 2nd Edition",return not any(letter in forbidden for letter in word),return,226 "Think Python, 2nd Edition",return res,return,227 "Think Python, 2nd Edition",return set(d1) - set(d2),return,227 "Think Python, 2nd Edition",return False,return,227 "Think Python, 2nd Edition",return len(set(t)) < len(t),return,227 "Think Python, 2nd Edition",return True,return,228 "Think Python, 2nd Edition",return set(word) <= set(available),return,228 "Think Python, 2nd Edition",return 0:,return,228 "Think Python, 2nd Edition",return Counter(word1) == Counter(word2),return,228 "Think Python, 2nd Edition",return d,return,230 "Think Python, 2nd Edition",return d,return,230 "Think Python, 2nd Edition",return d,return,230 "Think Python, 2nd Edition","return '(%g, %g)' % (self.x, self.y)",return,230 "Think Python, 2nd Edition",return value from namedtuple,return,231 "Think Python, 2nd Edition",return res,return,233 "Think Python, 2nd Edition","return without making a recursive invocation. If not, you need to rethink the algorithm and",return,239 "Think Python, 2nd Edition",return a value from a,return,240 "Think Python, 2nd Edition","return statement, it",return,240 "Think Python, 2nd Edition",return what I expect.,return,243 "Think Python, 2nd Edition","return statement with a complex expression, you don’t have a chance to",return,243 "Think Python, 2nd Edition",return self.hands[i].removeMatches(),return,243 "Think Python, 2nd Edition",return count,return,243 "Think Python, 2nd Edition",return iterators. But if,return,250 "Think Python, 2nd Edition",return the value that corresponds to key k. With a Python dictioߚ,return,251 "Think Python, 2nd Edition",return self.maps[index],return,252 "Think Python, 2nd Edition",return m.get(k),return,252 "Think Python, 2nd Edition","return the same hash value, but the",return,253 "Think Python, 2nd Edition",return the same,return,253 "Think Python, 2nd Edition",return self.maps.get(k),return,253 "Think Python, 2nd Edition","return value, 141",return,261 "Think Python, 2nd Edition","return value, 181",return,262 "Think Python, 2nd Edition","return statement, 52, 61, 243",return,266 "Think Python, 2nd Edition","return value, 21, 31, 61, 181",return,266 "Think Python, 2nd Edition","if you are using Python as a calculator, you might type:",simpleif,13 "Think Python, 2nd Edition","if you try to access cat from within print_twice, you get a NameError:",simpleif,28 "Think Python, 2nd Edition","if they are equal and False otherwise:",simpleif,48 "Think Python, 2nd Edition",if statement:,simpleif,49 "Think Python, 2nd Edition","if x > 0: print('x is positive')",simpleif,49 "Think Python, 2nd Edition","if x < y: print('x is less than y')",simpleif,50 "Think Python, 2nd Edition","if choice == 'a': draw_a()",simpleif,50 "Think Python, 2nd Edition","if choice == 'b': draw_b()",simpleif,50 "Think Python, 2nd Edition","if choice == 'c': draw_c()",simpleif,50 "Think Python, 2nd Edition","if x < y: print('x is less than y')",simpleif,50 "Think Python, 2nd Edition","if 0 < x: if x < 10:",simpleif,51 "Think Python, 2nd Edition","if 0 < x and x < 10: print('x is a positive single-digit number.')",simpleif,51 "Think Python, 2nd Edition","if 0 < x < 10: print('x is a positive single-digit number.')",simpleif,51 "Think Python, 2nd Edition","if n <= 0: print('Blastoff!')",simpleif,51 "Think Python, 2nd Edition","if n <= 0: return",simpleif,52 "Think Python, 2nd Edition","if the user types something other than a string of digits, you get an error:",simpleif,55 "Think Python, 2nd Edition",if it is possible to form a triangle:,simpleif,58 "Think Python, 2nd Edition","if n == 0: print(s)",simpleif,58 "Think Python, 2nd Edition","if n == 0: return",simpleif,59 "Think Python, 2nd Edition","if x < 0: return -x",simpleif,62 "Think Python, 2nd Edition","if x < 0: return -x",simpleif,62 "Think Python, 2nd Edition","if x > 0: return x",simpleif,62 "Think Python, 2nd Edition","if x % y == 0: return True",simpleif,65 "Think Python, 2nd Edition","if is_divisible(x, y): print('x is divisible by y')",simpleif,65 "Think Python, 2nd Edition","if is_divisible(x, y) == True: print('x is divisible by y')",simpleif,65 "Think Python, 2nd Edition","if n == 0: return 1",simpleif,67 "Think Python, 2nd Edition","if n == 0: return 1",simpleif,67 "Think Python, 2nd Edition","if n == 0: return 0",simpleif,69 "Think Python, 2nd Edition","if not isinstance(n, int): print('Factorial is only defined for integers.')",simpleif,69 "Think Python, 2nd Edition","if n < 0: print('Factorial is not defined for negative integers.')",simpleif,69 "Think Python, 2nd Edition","if n == 0: print(space, 'returning 1')",simpleif,70 "Think Python, 2nd Edition",if a is 4 and x is 3:,simpleif,79 "Think Python, 2nd Edition","if letter == 'a': count = count + 1",simpleif,90 "Think Python, 2nd Edition","if letter in word2: print(letter)",simpleif,91 "Think Python, 2nd Edition",if you compare apples and oranges:,simpleif,91 "Think Python, 2nd Edition",if two strings are equal:,simpleif,92 "Think Python, 2nd Edition","if word == 'banana': print('All right, bananas.')",simpleif,92 "Think Python, 2nd Edition","if word < 'banana': print('Your word, ' + word + ', comes before banana.')",simpleif,92 "Think Python, 2nd Edition","if len(word1) != len(word2): return False",simpleif,92 "Think Python, 2nd Edition","if word1[i] != word2[j]: return False",simpleif,92 "Think Python, 2nd Edition","if word1[i] != word2[j]: IndexError: string index out of range",simpleif,93 "Think Python, 2nd Edition","if word1[i] != word2[j]: return False",simpleif,93 "Think Python, 2nd Edition","if c.islower(): return True",simpleif,96 "Think Python, 2nd Edition","if not c.islower(): return False",simpleif,96 "Think Python, 2nd Edition","if letter == 'e': return False",simpleif,101 "Think Python, 2nd Edition","if letter in forbidden: return False",simpleif,102 "Think Python, 2nd Edition","if letter not in available: return False",simpleif,102 "Think Python, 2nd Edition","if letter not in word: return False",simpleif,102 "Think Python, 2nd Edition","if c < previous: return False",simpleif,103 "Think Python, 2nd Edition","if len(word) <= 1: return True",simpleif,103 "Think Python, 2nd Edition","if word[0] > word[1]: return False",simpleif,103 "Think Python, 2nd Edition","if word[i] != word[j]: return False",simpleif,104 "Think Python, 2nd Edition","if you omit both, the slice is a copy of the whole list:",simpleif,110 "Think Python, 2nd Edition","if s.isupper(): res.append(s)",simpleif,112 "Think Python, 2nd Edition","if the list is sorted in ascending order and False otherwise. For example:",simpleif,121 "Think Python, 2nd Edition","if you print eng2sp, you might be surprised:",simpleif,126 "Think Python, 2nd Edition","if c not in d: d[c] = 1",simpleif,127 "Think Python, 2nd Edition","if d[k] == v: return k",simpleif,129 "Think Python, 2nd Edition","if val not in inverse: inverse[val] = [key]",simpleif,130 "Think Python, 2nd Edition",if you try:,simpleif,131 "Think Python, 2nd Edition","if n in known: return known[n]",simpleif,132 "Think Python, 2nd Edition","if verbose: print('Running example1')",simpleif,133 "Think Python, 2nd Edition","if you try to modify one of the elements of the tuple, you get an error:",simpleif,140 "Think Python, 2nd Edition","if you scatter the tuple, it works:",simpleif,142 "Think Python, 2nd Edition","if x == y: return True",simpleif,144 "Think Python, 2nd Edition",if we can make Python swear:,simpleif,151 "Think Python, 2nd Edition","if key not in d2: res[key] = None",simpleif,156 "Think Python, 2nd Edition","if os.path.isfile(path): print(path)",simpleif,168 "Think Python, 2nd Edition","if it were a function: >>> blank = Point()",simpleif,178 "Think Python, 2nd Edition",if the object has the attributes you need:,simpleif,184 "Think Python, 2nd Edition","if sum.second >= 60: sum.second -= 60",simpleif,189 "Think Python, 2nd Edition","if sum.minute >= 60: sum.minute -= 60",simpleif,189 "Think Python, 2nd Edition","if time.second >= 60: time.second -= 60",simpleif,189 "Think Python, 2nd Edition","if time.minute >= 60: time.minute -= 60",simpleif,190 "Think Python, 2nd Edition",if it violates an invariant:,simpleif,192 "Think Python, 2nd Edition","if time.hour < 0 or time.minute < 0 or time.second < 0: return False",simpleif,192 "Think Python, 2nd Edition","if time.minute >= 60 or time.second >= 60: return False",simpleif,192 "Think Python, 2nd Edition","if not valid_time(t1) or not valid_time(t2): raise ValueError('invalid Time object in add_time')",simpleif,192 "Think Python, 2nd Edition",if it fails:,simpleif,192 "Think Python, 2nd Edition","if you invoke increment with two arguments, you get:",simpleif,198 "Think Python, 2nd Edition","if isinstance(other, Time): return self.add_time(other)",simpleif,201 "Think Python, 2nd Edition","if c not in d: d[c] = 1",simpleif,202 "Think Python, 2nd Edition","if len(self.prefix) < order: self.prefix += (word,)",simpleif,216 "Think Python, 2nd Edition","if pings is None: self.pings = []",simpleif,219 "Think Python, 2nd Edition","if n == 0: return 1",simpleif,224 "Think Python, 2nd Edition","if contents == None: contents = []",simpleif,224 "Think Python, 2nd Edition","if s.isupper(): res.append(s)",simpleif,225 "Think Python, 2nd Edition",if any of the values are True. It works on lists:,simpleif,226 "Think Python, 2nd Edition","if key not in d2: res[key] = None",simpleif,227 "Think Python, 2nd Edition","if x in d: return True",simpleif,227 "Think Python, 2nd Edition","if letter not in available: return False",simpleif,228 "Think Python, 2nd Edition",if t not in d:,simpleif,229 "Think Python, 2nd Edition","if k == 0: return 1",simpleif,233 "Think Python, 2nd Edition","if n == 0: return 0",simpleif,233 "Think Python, 2nd Edition","if key == k: return val",simpleif,252 "Think Python, 2nd Edition","if self.num == len(self.maps.maps): self.resize()",simpleif,253 "Think Python, 2nd Edition","print('Hello, World!')",printfunc,3 "Think Python, 2nd Edition",print(n),printfunc,13 "Think Python, 2nd Edition",print(miles * 1.61),printfunc,14 "Think Python, 2nd Edition",print(1),printfunc,14 "Think Python, 2nd Edition",print(x),printfunc,14 "Think Python, 2nd Edition","print(""I'm a lumberjack, and I'm okay."")",printfunc,23 "Think Python, 2nd Edition","print(""I sleep all night and I work all day."")",printfunc,23 "Think Python, 2nd Edition","print(""I'm a lumberjack, and I'm okay."")",printfunc,24 "Think Python, 2nd Edition","print(""I sleep all night and I work all day."")",printfunc,24 "Think Python, 2nd Edition",print(print_lyrics),printfunc,24 "Think Python, 2nd Edition","print(""I'm a lumberjack, and I'm okay."")",printfunc,25 "Think Python, 2nd Edition","print(""I sleep all night and I work all day."")",printfunc,25 "Think Python, 2nd Edition",print(bruce),printfunc,26 "Think Python, 2nd Edition",print(bruce),printfunc,26 "Think Python, 2nd Edition",print(cat),printfunc,27 "Think Python, 2nd Edition",print(cat),printfunc,28 "Think Python, 2nd Edition",print(result),printfunc,29 "Think Python, 2nd Edition",print(type(None)),printfunc,29 "Think Python, 2nd Edition",print('spam'),printfunc,33 "Think Python, 2nd Edition","print('+', '-')",printfunc,34 "Think Python, 2nd Edition","print('+', end=' ')",printfunc,34 "Think Python, 2nd Edition",print('-'),printfunc,34 "Think Python, 2nd Edition",print(bob),printfunc,35 "Think Python, 2nd Edition",print('Hello!'),printfunc,37 "Think Python, 2nd Edition",print('x is odd'),printfunc,50 "Think Python, 2nd Edition",print('x and y are equal'),printfunc,50 "Think Python, 2nd Edition",print('x is greater than y'),printfunc,50 "Think Python, 2nd Edition",print('x is a positive single-digit number.'),printfunc,51 "Think Python, 2nd Edition",print(n),printfunc,51 "Think Python, 2nd Edition",print(s),printfunc,52 "Think Python, 2nd Edition",print(decibels),printfunc,55 "Think Python, 2nd Edition","print('dx is', dx)",printfunc,63 "Think Python, 2nd Edition","print('dy is', dy)",printfunc,63 "Think Python, 2nd Edition","print('dsquared is: ', dsquared)",printfunc,63 "Think Python, 2nd Edition","print(space, 'factorial', n)",printfunc,70 "Think Python, 2nd Edition","print(space, 'returning', result)",printfunc,71 "Think Python, 2nd Edition","print(z, prod)",printfunc,72 "Think Python, 2nd Edition","print(c(x, y+3, x+y))",printfunc,72 "Think Python, 2nd Edition",print(n),printfunc,77 "Think Python, 2nd Edition",print('Blastoff!'),printfunc,77 "Think Python, 2nd Edition",print(line),printfunc,78 "Think Python, 2nd Edition",print('Done!'),printfunc,78 "Think Python, 2nd Edition",print(letter),printfunc,87 "Think Python, 2nd Edition",print(letter),printfunc,87 "Think Python, 2nd Edition",print(letter + suffix),printfunc,87 "Think Python, 2nd Edition",print(count),printfunc,90 "Think Python, 2nd Edition","print('All right, bananas.')",printfunc,92 "Think Python, 2nd Edition","print(i, j)",printfunc,93 "Think Python, 2nd Edition",print(word),printfunc,100 "Think Python, 2nd Edition","print(cheeses, numbers, empty)",printfunc,107 "Think Python, 2nd Edition",print(cheese),printfunc,109 "Think Python, 2nd Edition",print('This never happens.'),printfunc,109 "Think Python, 2nd Edition","print(c, h[c])",printfunc,128 "Think Python, 2nd Edition","print(key, h[key])",printfunc,129 "Think Python, 2nd Edition",print(args),printfunc,142 "Think Python, 2nd Edition",print(pair),printfunc,143 "Think Python, 2nd Edition","print(number, letter)",printfunc,143 "Think Python, 2nd Edition","print(index, element)",printfunc,144 "Think Python, 2nd Edition","print(key, value)",printfunc,144 "Think Python, 2nd Edition","print(first, last, directory[last,first])",printfunc,145 "Think Python, 2nd Edition",print(x),printfunc,153 "Think Python, 2nd Edition","print('Total number of words:', total_words(hist))",printfunc,154 "Think Python, 2nd Edition","print('Number of different words:', different_words(hist))",printfunc,154 "Think Python, 2nd Edition",print('The most common words are:'),printfunc,155 "Think Python, 2nd Edition","print(word, freq, sep='\t')",printfunc,155 "Think Python, 2nd Edition",print('The most common words are:'),printfunc,156 "Think Python, 2nd Edition","print(word, freq, sep='\t')",printfunc,156 "Think Python, 2nd Edition","print(""Words in the book that aren't in the word list:"")",printfunc,156 "Think Python, 2nd Edition","print(word, end=' ')",printfunc,156 "Think Python, 2nd Edition",print('Something went wrong.'),printfunc,169 "Think Python, 2nd Edition","print(key, db[key])",printfunc,170 "Think Python, 2nd Edition",print(stat),printfunc,172 "Think Python, 2nd Edition",print(res),printfunc,172 "Think Python, 2nd Edition",print(stat),printfunc,172 "Think Python, 2nd Edition",print(linecount('wc.py')),printfunc,172 "Think Python, 2nd Edition",print(linecount('wc.py')),printfunc,173 "Think Python, 2nd Edition",print(s),printfunc,173 "Think Python, 2nd Edition",print(repr(s)),printfunc,173 "Think Python, 2nd Edition","print('(%g, %g)' % (p.x, p.y))",printfunc,179 "Think Python, 2nd Edition","print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second))",printfunc,196 "Think Python, 2nd Edition","print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second))",printfunc,197 "Think Python, 2nd Edition","print('%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second))",printfunc,197 "Think Python, 2nd Edition",print(time),printfunc,200 "Think Python, 2nd Edition",print(start + duration),printfunc,200 "Think Python, 2nd Edition",print(start + duration),printfunc,201 "Think Python, 2nd Edition",print(start + 1337),printfunc,201 "Think Python, 2nd Edition",print(1337 + start),printfunc,201 "Think Python, 2nd Edition",print(1337 + start),printfunc,202 "Think Python, 2nd Edition",print(total),printfunc,203 "Think Python, 2nd Edition","print(attr, getattr(obj, attr))",printfunc,204 "Think Python, 2nd Edition",print(card1),printfunc,209 "Think Python, 2nd Edition",print(deck),printfunc,212 "Think Python, 2nd Edition",print(hand),printfunc,214 "Think Python, 2nd Edition",print(val),printfunc,225 "Think Python, 2nd Edition","print(val, freq)",printfunc,229 "Think Python, 2nd Edition",print(args),printfunc,232 "Think Python, 2nd Edition","print(args, kwargs)",printfunc,232 "Think Python, 2nd Edition","print('x: ', x)",printfunc,238 "Think Python, 2nd Edition","print('y: ', y)",printfunc,238 "Think Python, 2nd Edition","print(""condition: "", (x > 0 and y < 0))",printfunc,238 "Think Python, 2nd Edition","t = ('a', 'b', 'c', 'd', 'e')",simpleTuple,139 "Think Python, 2nd Edition","t = ('a', 'b', 'c', 'd', 'e')",simpleTuple,140 "Think Python, 2nd Edition","t = ('A',)",simpleTuple,140 "Think Python, 2nd Edition","t = (7, 3)",simpleTuple,142 "Think Python, 2nd Edition","cheeses = ['Cheddar', 'Edam', 'Gouda']",simpleList,107 "Think Python, 2nd Edition","numbers = [42, 123]",simpleList,107 "Think Python, 2nd Edition",empty = [],simpleList,107 "Think Python, 2nd Edition","numbers = [42, 123]",simpleList,108 "Think Python, 2nd Edition","cheeses = ['Cheddar', 'Edam', 'Gouda']",simpleList,109 "Think Python, 2nd Edition","a = [1, 2, 3]",simpleList,110 "Think Python, 2nd Edition","b = [4, 5, 6]",simpleList,110 "Think Python, 2nd Edition","t = ['a', 'b', 'c', 'd', 'e', 'f']",simpleList,110 "Think Python, 2nd Edition","t = ['a', 'b', 'c', 'd', 'e', 'f']",simpleList,110 "Think Python, 2nd Edition","t[1:3] = ['x', 'y']",simpleList,110 "Think Python, 2nd Edition","t = ['a', 'b', 'c']",simpleList,111 "Think Python, 2nd Edition","t1 = ['a', 'b', 'c']",simpleList,111 "Think Python, 2nd Edition","t2 = ['d', 'e']",simpleList,111 "Think Python, 2nd Edition","t = ['d', 'c', 'e', 'b', 'a']",simpleList,111 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,112 "Think Python, 2nd Edition",res = [],simpleList,112 "Think Python, 2nd Edition",res = [],simpleList,112 "Think Python, 2nd Edition","t = ['a', 'b', 'c']",simpleList,113 "Think Python, 2nd Edition","t = ['a', 'b', 'c']",simpleList,113 "Think Python, 2nd Edition","t = ['a', 'b', 'c']",simpleList,113 "Think Python, 2nd Edition","t = ['a', 'b', 'c', 'd', 'e', 'f']",simpleList,113 "Think Python, 2nd Edition","t = ['pining', 'for', 'the', 'fjords']",simpleList,114 "Think Python, 2nd Edition","a = [1, 2, 3]",simpleList,115 "Think Python, 2nd Edition","b = [1, 2, 3]",simpleList,115 "Think Python, 2nd Edition","a = [1, 2, 3]",simpleList,115 "Think Python, 2nd Edition","letters = ['a', 'b', 'c']",simpleList,116 "Think Python, 2nd Edition","t1 = [1, 2]",simpleList,117 "Think Python, 2nd Edition","t4 = [1, 2, 3]",simpleList,117 "Think Python, 2nd Edition","letters = ['a', 'b', 'c']",simpleList,118 "Think Python, 2nd Edition",t += [x],simpleList,118 "Think Python, 2nd Edition","t = [3, 1, 2]",simpleList,119 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,120 "Think Python, 2nd Edition","t = [1, 2, 3, 4]",simpleList,121 "Think Python, 2nd Edition","t = [1, 2, 3, 4]",simpleList,121 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,131 "Think Python, 2nd Edition","t = [0, 1, 2]",simpleList,143 "Think Python, 2nd Edition","t = [('a', 0), ('b', 1), ('c', 2)]",simpleList,143 "Think Python, 2nd Edition","t = [('a', 0), ('c', 2), ('b', 1)]",simpleList,145 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,147 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,153 "Think Python, 2nd Edition","t = ['a', 'a', 'b']",simpleList,153 "Think Python, 2nd Edition",t = [],simpleList,155 "Think Python, 2nd Edition",t = [],simpleList,157 "Think Python, 2nd Edition","t = [1, 2, 3]",simpleList,170 "Think Python, 2nd Edition","t1 = [1, 2, 3]",simpleList,171 "Think Python, 2nd Edition","t = ['spam', 'egg', 'spam', 'spam', 'bacon', 'spam']",simpleList,203 "Think Python, 2nd Edition","suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades']",simpleList,209 "Think Python, 2nd Edition",res = [],simpleList,211 "Think Python, 2nd Edition",res = [],simpleList,224 "Think Python, 2nd Edition",res = [],simpleList,225 "Think Python, 2nd Edition",d[t] = [word],simpleList,230 "Think Python, 2nd Edition","for running in script mode at http:",forsimple,13 "Think Python, 2nd Edition",for i in range(4):,forsimple,37 "Think Python, 2nd Edition",for i in range(4):,forsimple,37 "Think Python, 2nd Edition",for i in range(4):,forsimple,38 "Think Python, 2nd Edition",for i in range(4):,forsimple,39 "Think Python, 2nd Edition",for i in range(n):,forsimple,39 "Think Python, 2nd Edition",for i in range(n):,forsimple,41 "Think Python, 2nd Edition",for i in range(n):,forsimple,41 "Think Python, 2nd Edition",for i in range(n):,forsimple,43 "Think Python, 2nd Edition",for letter in fruit:,forsimple,87 "Think Python, 2nd Edition",for letter in prefixes:,forsimple,87 "Think Python, 2nd Edition",for letter in word:,forsimple,90 "Think Python, 2nd Edition",for letter in word1:,forsimple,91 "Think Python, 2nd Edition",for putting words in alphabetical order:,forsimple,92 "Think Python, 2nd Edition",for c in s:,forsimple,96 "Think Python, 2nd Edition",for c in s:,forsimple,96 "Think Python, 2nd Edition",for c in s:,forsimple,96 "Think Python, 2nd Edition",for c in s:,forsimple,96 "Think Python, 2nd Edition",for c in s:,forsimple,96 "Think Python, 2nd Edition",for line in fin:,forsimple,100 "Think Python, 2nd Edition",for letter in word:,forsimple,101 "Think Python, 2nd Edition",for letter in word:,forsimple,102 "Think Python, 2nd Edition",for letter in word:,forsimple,102 "Think Python, 2nd Edition",for letter in required:,forsimple,102 "Think Python, 2nd Edition",for c in word:,forsimple,103 "Think Python, 2nd Edition",for the ‘i’ that sneaks in there. Or Mississippi:,forsimple,105 "Think Python, 2nd Edition",for cheese in cheeses:,forsimple,109 "Think Python, 2nd Edition",for i in range(len(numbers)):,forsimple,109 "Think Python, 2nd Edition",for x in t:,forsimple,111 "Think Python, 2nd Edition",for s in t:,forsimple,112 "Think Python, 2nd Edition",for s in t:,forsimple,112 "Think Python, 2nd Edition",for c in s:,forsimple,127 "Think Python, 2nd Edition",for c in h:,forsimple,128 "Think Python, 2nd Edition",for key in sorted(h):,forsimple,129 "Think Python, 2nd Edition",for k in d:,forsimple,129 "Think Python, 2nd Edition",for key in d:,forsimple,130 "Think Python, 2nd Edition","for pair in zip(s, t):",forsimple,143 "Think Python, 2nd Edition","for letter, number in t:",forsimple,143 "Think Python, 2nd Edition","for x, y in zip(t1, t2):",forsimple,144 "Think Python, 2nd Edition","for index, element in enumerate('abc'):",forsimple,144 "Think Python, 2nd Edition","for key, value in d.items():",forsimple,144 "Think Python, 2nd Edition","for last, first in directory:",forsimple,145 "Think Python, 2nd Edition",for i in range(10):,forsimple,153 "Think Python, 2nd Edition",for line in fp:,forsimple,154 "Think Python, 2nd Edition",for word in line.split():,forsimple,154 "Think Python, 2nd Edition","for key, value in hist.items():",forsimple,155 "Think Python, 2nd Edition","for freq, word in t[:10]:",forsimple,155 "Think Python, 2nd Edition","for freq, word in t[:num]:",forsimple,156 "Think Python, 2nd Edition",for key in d1:,forsimple,156 "Think Python, 2nd Edition",for word in diff:,forsimple,156 "Think Python, 2nd Edition","for word, freq in h.items():",forsimple,157 "Think Python, 2nd Edition",for name in os.listdir(dirname):,forsimple,168 "Think Python, 2nd Edition",for key in db:,forsimple,170 "Think Python, 2nd Edition",for c in s:,forsimple,202 "Think Python, 2nd Edition",for attr in vars(obj):,forsimple,204 "Think Python, 2nd Edition",for card in self.cards:,forsimple,211 "Think Python, 2nd Edition",for i in range(num):,forsimple,214 "Think Python, 2nd Edition",for ty in type(obj).mro():,forsimple,217 "Think Python, 2nd Edition",for s in t:,forsimple,224 "Think Python, 2nd Edition",for s in t:,forsimple,225 "Think Python, 2nd Edition",for val in g:,forsimple,225 "Think Python, 2nd Edition",for key in d1:,forsimple,227 "Think Python, 2nd Edition",for x in t:,forsimple,227 "Think Python, 2nd Edition",for letter in word:,forsimple,228 "Think Python, 2nd Edition","for val, freq in count.most_common(3):",forsimple,229 "Think Python, 2nd Edition",for x in t:,forsimple,249 "Think Python, 2nd Edition","for key, val in self.items:",forsimple,252 "Think Python, 2nd Edition",for i in range(n):,forsimple,252 "Think Python, 2nd Edition",for each add in order from left to right:,forsimple,254 "Think Python, 2nd Edition","tion 3 + = 3 is illegal because even though + and = are legal tokens, you can’t have",assignwithSum,6 "Think Python, 2nd Edition",x = math.exp(math.log(x+1)),assignwithSum,23 "Think Python, 2nd Edition",cat = part1 + part2,assignwithSum,27 "Think Python, 2nd Edition",n = int(circumference / 3) + 1,assignwithSum,41 "Think Python, 2nd Edition",n = int(arc_length / 3) + 1,assignwithSum,41 "Think Python, 2nd Edition",n = int(arc_length / 3) + 1,assignwithSum,42 "Think Python, 2nd Edition",dsquared = dx**2 + dy**2,assignwithSum,63 "Think Python, 2nd Edition",dsquared = dx**2 + dy**2,assignwithSum,64 "Think Python, 2nd Edition",fibonacci n = fibonacci n −1 + fibonacci n −2,assignwithSum,68 "Think Python, 2nd Edition",x = x + 1,assignwithSum,72 "Think Python, 2nd Edition",total = x + y + z,assignwithSum,72 "Think Python, 2nd Edition",y = x + 1,assignwithSum,72 "Think Python, 2nd Edition","A m, n = n + 1",assignwithSum,72 "Think Python, 2nd Edition",x = x + 1,assignwithSum,76 "Think Python, 2nd Edition",x = x + 1,assignwithSum,76 "Think Python, 2nd Edition",x = x + 1,assignwithSum,76 "Think Python, 2nd Edition",n = n*3 + 1,assignwithSum,78 "Think Python, 2nd Edition",y = x + a/x,assignwithSum,79 "Think Python, 2nd Edition",index = index + 1,assignwithSum,87 "Think Python, 2nd Edition",i = i+1,assignwithSum,92 "Think Python, 2nd Edition",i = i+1,assignwithSum,93 "Think Python, 2nd Edition",i = i+1,assignwithSum,104 "Think Python, 2nd Edition",c = a + b,assignwithSum,110 "Think Python, 2nd Edition",total = total + x,assignwithSum,111 "Think Python, 2nd Edition",t3 = t1 + [4],assignwithSum,117 "Think Python, 2nd Edition",t = t + [x],assignwithSum,118 "Think Python, 2nd Edition",t = t + x # WRONG!,assignwithSum,118 "Think Python, 2nd Edition",other using the idiom t = t + [x]. Which one takes longer to run? Why?,assignwithSum,122 "Think Python, 2nd Edition",res = fibonacci(n-1) + fibonacci(n-2),assignwithSum,132 "Think Python, 2nd Edition",count = count + 1 # WRONG,assignwithSum,134 "Think Python, 2nd Edition",word = word.strip(string.punctuation + string.whitespace),assignwithSum,154 "Think Python, 2nd Edition","hist[word] = hist.get(word, 0) + 1",assignwithSum,154 "Think Python, 2nd Edition",distance = math.sqrt(blank.x**2 + blank.y**2),assignwithSum,179 "Think Python, 2nd Edition",p.x = rect.corner.x + rect.width/2,assignwithSum,181 "Think Python, 2nd Edition",p.y = rect.corner.y + rect.height/2,assignwithSum,181 "Think Python, 2nd Edition",box.width = box.width + 50,assignwithSum,181 "Think Python, 2nd Edition",box.height = box.height + 100,assignwithSum,181 "Think Python, 2nd Edition",sum.hour = t1.hour + t2.hour,assignwithSum,188 "Think Python, 2nd Edition",sum.minute = t1.minute + t2.minute,assignwithSum,188 "Think Python, 2nd Edition",sum.second = t1.second + t2.second,assignwithSum,188 "Think Python, 2nd Edition",sum.hour = t1.hour + t2.hour,assignwithSum,189 "Think Python, 2nd Edition",sum.minute = t1.minute + t2.minute,assignwithSum,189 "Think Python, 2nd Edition",sum.second = t1.second + t2.second,assignwithSum,189 "Think Python, 2nd Edition",minutes = time.hour * 60 + time.minute,assignwithSum,191 "Think Python, 2nd Edition",seconds = minutes * 60 + time.second,assignwithSum,191 "Think Python, 2nd Edition",seconds = time_to_int(t1) + time_to_int(t2),assignwithSum,191 "Think Python, 2nd Edition",seconds = time_to_int(t1) + time_to_int(t2),assignwithSum,192 "Think Python, 2nd Edition",seconds = time_to_int(t1) + time_to_int(t2),assignwithSum,192 "Think Python, 2nd Edition",seconds = self.time_to_int() + other.time_to_int(),assignwithSum,200 "Think Python, 2nd Edition",seconds = self.time_to_int() + other.time_to_int(),assignwithSum,201 "Think Python, 2nd Edition",d[c] = d[c]+1,assignwithSum,202 "Think Python, 2nd Edition","res = binomial_coeff(n-1, k) + binomial_coeff(n-1, k-1)",assignwithSum,233 "Think Python, 2nd Edition","ments. For example, in mathematics the statement 3 + 3 = 6 has correct syntax, but",simpleAssign,5 "Think Python, 2nd Edition","3 + = 3$6 does not. In chemistry H2O is a syntactically correct formula, but 2Zz is",simpleAssign,5 "Think Python, 2nd Edition",of the problems with 3 + = 3$6 is that $ is not a legal token in mathematics (at least,simpleAssign,5 "Think Python, 2nd Edition",n = 17,simpleAssign,11 "Think Python, 2nd Edition",pi = 3.141592653589793,simpleAssign,11 "Think Python, 2nd Edition",more@ = 1000000,simpleAssign,12 "Think Python, 2nd Edition",n = 17,simpleAssign,13 "Think Python, 2nd Edition",miles = 26.2,simpleAssign,13 "Think Python, 2nd Edition",miles = 26.2,simpleAssign,14 "Think Python, 2nd Edition",x = 2,simpleAssign,14 "Think Python, 2nd Edition",x = 5,simpleAssign,14 "Think Python, 2nd Edition",v = 5 # assign 5 to v,simpleAssign,16 "Think Python, 2nd Edition",v = 5 # velocity in meters/second.,simpleAssign,16 "Think Python, 2nd Edition",We’ve seen that n = 42 is legal. What about 42 = n?,simpleAssign,18 "Think Python, 2nd Edition",How about x = y = 1?,simpleAssign,18 "Think Python, 2nd Edition",ratio = signal_power / noise_power,simpleAssign,22 "Think Python, 2nd Edition",decibels = 10 * math.log10(ratio),simpleAssign,22 "Think Python, 2nd Edition",radians = 0.7,simpleAssign,22 "Think Python, 2nd Edition",height = math.sin(radians),simpleAssign,22 "Think Python, 2nd Edition",degrees = 45,simpleAssign,23 "Think Python, 2nd Edition",radians = degrees / 180.0 * math.pi,simpleAssign,23 "Think Python, 2nd Edition",x = math.sin(degrees / 360.0 * 2 * math.pi),simpleAssign,23 "Think Python, 2nd Edition",minutes = hours * 60 # right,simpleAssign,23 "Think Python, 2nd Edition",hours * 60 = minutes # wrong!,simpleAssign,23 "Think Python, 2nd Edition",x = math.cos(radians),simpleAssign,29 "Think Python, 2nd Edition",result = print_twice('Bing'),simpleAssign,29 "Think Python, 2nd Edition",bob = turtle.Turtle(),simpleAssign,35 "Think Python, 2nd Edition",bob = turtle.Turtle(),simpleAssign,35 "Think Python, 2nd Edition","Hint: figure out the circumference of the circle and make sure that length * n = circumference.",simpleAssign,38 "Think Python, 2nd Edition","units of degrees, so when angle=360, arc should draw a complete circle.",simpleAssign,38 "Think Python, 2nd Edition",alice = Turtle(),simpleAssign,39 "Think Python, 2nd Edition",angle = 360 / n,simpleAssign,39 "Think Python, 2nd Edition",A simple solution is to compute angle = 360.0 / n. Because the numerator is a,simpleAssign,39 "Think Python, 2nd Edition","polygon(bob, n=7, length=70)",simpleAssign,40 "Think Python, 2nd Edition",circumference = 2 * math.pi * r,simpleAssign,40 "Think Python, 2nd Edition",n = 50,simpleAssign,40 "Think Python, 2nd Edition",length = circumference / n,simpleAssign,40 "Think Python, 2nd Edition",circumference = 2 * math.pi * r,simpleAssign,41 "Think Python, 2nd Edition",length = circumference / n,simpleAssign,41 "Think Python, 2nd Edition",arc_length = 2 * math.pi * r * angle / 360,simpleAssign,41 "Think Python, 2nd Edition",step_length = arc_length / n,simpleAssign,41 "Think Python, 2nd Edition",step_angle = angle / n,simpleAssign,41 "Think Python, 2nd Edition",angle = 360.0 / n,simpleAssign,42 "Think Python, 2nd Edition",arc_length = 2 * math.pi * r * angle / 360,simpleAssign,42 "Think Python, 2nd Edition",step_length = arc_length / n,simpleAssign,42 "Think Python, 2nd Edition",step_angle = float(angle) / n,simpleAssign,42 "Think Python, 2nd Edition",minutes = 105,simpleAssign,47 "Think Python, 2nd Edition",minutes = 105,simpleAssign,47 "Think Python, 2nd Edition",hours = minutes // 60,simpleAssign,47 "Think Python, 2nd Edition",remainder = minutes - hours * 60,simpleAssign,47 "Think Python, 2nd Edition",remainder = minutes % 60,simpleAssign,48 "Think Python, 2nd Edition",5 == 5,simpleAssign,48 "Think Python, 2nd Edition",5 == 6,simpleAssign,48 "Think Python, 2nd Edition",The == operator is one of the relational operators; the others are:,simpleAssign,48 "Think Python, 2nd Edition",x != y # x is not equal to y,simpleAssign,48 "Think Python, 2nd Edition",x >= y # x is greater than or equal to y,simpleAssign,48 "Think Python, 2nd Edition",x <= y # x is less than or equal to y,simpleAssign,48 "Think Python, 2nd Edition",instead of a double equal sign (==). Remember that = is an assignment operator,simpleAssign,48 "Think Python, 2nd Edition",and == is a relational operator. There is no such thing as =< or =>.,simpleAssign,48 "Think Python, 2nd Edition","n%2 == 0 or n%3 == 0 is true if either or both of the conditions is true, that is, if the",simpleAssign,49 "Think Python, 2nd Edition","The execution of countdown begins with n=3, and since n is greater than 0, it outputs",simpleAssign,52 "Think Python, 2nd Edition","The execution of countdown begins with n=2, and since n is greater than 0, it outputs",simpleAssign,52 "Think Python, 2nd Edition","The execution of countdown begins with n=1, and since n is greater than 0, it",simpleAssign,52 "Think Python, 2nd Edition","The execution of countdown begins with n=0, and since n is not",simpleAssign,52 "Think Python, 2nd Edition",The countdown that got n=1 returns.,simpleAssign,52 "Think Python, 2nd Edition",The countdown that got n=2 returns.,simpleAssign,52 "Think Python, 2nd Edition",The countdown that got n=3 returns.,simpleAssign,52 "Think Python, 2nd Edition",If n <= 0 the return statement exits the function. The flow of execution immediately,simpleAssign,52 "Think Python, 2nd Edition",Figure 5-1 shows a stack diagram for countdown called with n = 3.,simpleAssign,53 "Think Python, 2nd Edition","the stack, where n=0, is called the base case. It does not make a recursive call, so there",simpleAssign,53 "Think Python, 2nd Edition","As an exercise, draw a stack diagram for print_n called with s = 'Hello' and n=2.",simpleAssign,53 "Think Python, 2nd Edition",text = input(),simpleAssign,54 "Think Python, 2nd Edition",name = input('What...is your name?\n'),simpleAssign,54 "Think Python, 2nd Edition",speed = input(prompt),simpleAssign,55 "Think Python, 2nd Edition",speed = input(prompt),simpleAssign,55 "Think Python, 2nd Edition",x = 5,simpleAssign,55 "Think Python, 2nd Edition",y = 6,simpleAssign,55 "Think Python, 2nd Edition",y = 6,simpleAssign,55 "Think Python, 2nd Edition","noise ratio in decibels. The formula is SNRdb = 10 log10 Psignal/Pnoise . In Python,",simpleAssign,55 "Think Python, 2nd Edition",signal_power = 9,simpleAssign,55 "Think Python, 2nd Edition",noise_power = 10,simpleAssign,55 "Think Python, 2nd Edition",ratio = signal_power // noise_power,simpleAssign,55 "Think Python, 2nd Edition",decibels = 10 * math.log10(ratio),simpleAssign,55 "Think Python, 2nd Edition",decibels = 10 * math.log10(ratio),simpleAssign,56 "Think Python, 2nd Edition",an + bn = cn,simpleAssign,57 "Think Python, 2nd Edition",an + bn = cn,simpleAssign,58 "Think Python, 2nd Edition",angle = 50,simpleAssign,59 "Think Python, 2nd Edition",e = math.exp(1.0),simpleAssign,61 "Think Python, 2nd Edition",height = radius * math.sin(radians),simpleAssign,61 "Think Python, 2nd Edition",a = math.pi * radius**2,simpleAssign,61 "Think Python, 2nd Edition","y, 0 if x == y, and -1 if x < y.",simpleAssign,62 "Think Python, 2nd Edition","distance = x2 − x1",simpleAssign,63 "Think Python, 2nd Edition",dx = x2 - x1,simpleAssign,63 "Think Python, 2nd Edition",dy = y2 - y1,simpleAssign,63 "Think Python, 2nd Edition",dx = x2 - x1,simpleAssign,63 "Think Python, 2nd Edition",dy = y2 - y1,simpleAssign,63 "Think Python, 2nd Edition",dx = x2 - x1,simpleAssign,64 "Think Python, 2nd Edition",dy = y2 - y1,simpleAssign,64 "Think Python, 2nd Edition",result = math.sqrt(dsquared),simpleAssign,64 "Think Python, 2nd Edition","radius = distance(xc, yc, xp, yp)",simpleAssign,64 "Think Python, 2nd Edition",result = area(radius),simpleAssign,65 "Think Python, 2nd Edition","radius = distance(xc, yc, xp, yp)",simpleAssign,65 "Think Python, 2nd Edition",result = area(radius),simpleAssign,65 "Think Python, 2nd Edition","The result of the == operator is a boolean, so we can write the function more conߚ",simpleAssign,65 "Think Python, 2nd Edition",0! = 1,simpleAssign,66 "Think Python, 2nd Edition",n! = n n −1 !,simpleAssign,66 "Think Python, 2nd Edition",recurse = factorial(n-1),simpleAssign,67 "Think Python, 2nd Edition",result = n * recurse,simpleAssign,67 "Think Python, 2nd Edition",fibonacci 0 = 0,simpleAssign,68 "Think Python, 2nd Edition",fibonacci 1 = 1,simpleAssign,68 "Think Python, 2nd Edition",elif n == 1:,simpleAssign,69 "Think Python, 2nd Edition","when n == 0. But if n is not an integer, we can miss the base case and recurse forever.",simpleAssign,69 "Think Python, 2nd Edition",elif n == 0:,simpleAssign,69 "Think Python, 2nd Edition",recurse = factorial(n-1),simpleAssign,71 "Think Python, 2nd Edition",result = n * recurse,simpleAssign,71 "Think Python, 2nd Edition","prod = a(z, z)",simpleAssign,72 "Think Python, 2nd Edition",square = b(total)**2,simpleAssign,72 "Think Python, 2nd Edition",x = 1,simpleAssign,72 "Think Python, 2nd Edition",if m = 0,simpleAssign,72 "Think Python, 2nd Edition",if m > 0 and n = 0,simpleAssign,72 "Think Python, 2nd Edition","remainder when a is divided by b, then gcd a, b = gcd b, r . As a base case, we can",simpleAssign,73 "Think Python, 2nd Edition","use gcd a, 0 = a.",simpleAssign,73 "Think Python, 2nd Edition",x = 5,simpleAssign,75 "Think Python, 2nd Edition",x = 7,simpleAssign,75 "Think Python, 2nd Edition","the equal sign (=) for assignment, it is tempting to interpret a statement like a = b as",simpleAssign,75 "Think Python, 2nd Edition","mathematics, if a=7 then 7=a. But in Python, the statement a = 7 is legal and 7 = a",simpleAssign,75 "Think Python, 2nd Edition","a=b now, then a will always equal b. In Python, an assignment statement can make",simpleAssign,76 "Think Python, 2nd Edition",a = 5,simpleAssign,76 "Think Python, 2nd Edition",b = a # a and b are now equal,simpleAssign,76 "Think Python, 2nd Edition",a = 3 # a and b are no longer equal,simpleAssign,76 "Think Python, 2nd Edition",x = 0,simpleAssign,76 "Think Python, 2nd Edition",n = n - 1,simpleAssign,77 "Think Python, 2nd Edition","The condition for this loop is n != 1, so the loop will continue until n is 1, which",simpleAssign,78 "Think Python, 2nd Edition",a = 4,simpleAssign,79 "Think Python, 2nd Edition",x = 3,simpleAssign,79 "Think Python, 2nd Edition",The result is closer to the correct answer ( 4 = 2). If we repeat the process with the,simpleAssign,79 "Think Python, 2nd Edition",x = y,simpleAssign,79 "Think Python, 2nd Edition",x = y,simpleAssign,80 "Think Python, 2nd Edition",x = y,simpleAssign,80 "Think Python, 2nd Edition",x = y,simpleAssign,80 "Think Python, 2nd Edition",x = y,simpleAssign,80 "Think Python, 2nd Edition","When y == x, we can stop. Here is a loop that starts with an initial estimate, x, and",simpleAssign,80 "Think Python, 2nd Edition",9801 ∑k = 0,simpleAssign,83 "Think Python, 2nd Edition",π = 2 2,simpleAssign,83 "Think Python, 2nd Edition",letter = fruit[1],simpleAssign,85 "Think Python, 2nd Edition",letter = fruit[0],simpleAssign,85 "Think Python, 2nd Edition",i = 1,simpleAssign,86 "Think Python, 2nd Edition",letter = fruit[1.5],simpleAssign,86 "Think Python, 2nd Edition",length = len(fruit),simpleAssign,86 "Think Python, 2nd Edition",last = fruit[length],simpleAssign,86 "Think Python, 2nd Edition",last = fruit[length-1],simpleAssign,86 "Think Python, 2nd Edition",index = 0,simpleAssign,87 "Think Python, 2nd Edition",letter = fruit[index],simpleAssign,87 "Think Python, 2nd Edition",index = 0,simpleAssign,89 "Think Python, 2nd Edition",count = 0,simpleAssign,90 "Think Python, 2nd Edition",new_word = word.upper(),simpleAssign,90 "Think Python, 2nd Edition",index = word.find('a'),simpleAssign,90 "Think Python, 2nd Edition",i = 0,simpleAssign,92 "Think Python, 2nd Edition",j = len(word2),simpleAssign,92 "Think Python, 2nd Edition",j = j-1,simpleAssign,92 "Think Python, 2nd Edition",j = j-1,simpleAssign,93 "Think Python, 2nd Edition",flag = c.islower(),simpleAssign,96 "Think Python, 2nd Edition",flag = False,simpleAssign,96 "Think Python, 2nd Edition",flag = flag or c.islower(),simpleAssign,96 "Think Python, 2nd Edition",word = line.strip(),simpleAssign,100 "Think Python, 2nd Edition",word = line.strip(),simpleAssign,100 "Think Python, 2nd Edition",previous = word[0],simpleAssign,103 "Think Python, 2nd Edition",previous = c,simpleAssign,103 "Think Python, 2nd Edition",i = 0,simpleAssign,104 "Think Python, 2nd Edition",j = len(word)-1,simpleAssign,104 "Think Python, 2nd Edition",j = j-1,simpleAssign,104 "Think Python, 2nd Edition",numbers[1] = 5,simpleAssign,108 "Think Python, 2nd Edition",numbers[i] = numbers[i] * 2,simpleAssign,109 "Think Python, 2nd Edition","write t = t.sort(), you will be disappointed with the result.",simpleAssign,111 "Think Python, 2nd Edition",total = 0,simpleAssign,111 "Think Python, 2nd Edition",x = t.pop(1),simpleAssign,113 "Think Python, 2nd Edition",t = list(s),simpleAssign,113 "Think Python, 2nd Edition",t = s.split(),simpleAssign,114 "Think Python, 2nd Edition",t = s.split(delimiter),simpleAssign,114 "Think Python, 2nd Edition",s = delimiter.join(t),simpleAssign,114 "Think Python, 2nd Edition","If a refers to an object and you assign b = a, then both variables refer to the same",simpleAssign,115 "Think Python, 2nd Edition",b = a,simpleAssign,115 "Think Python, 2nd Edition",b[0] = 42,simpleAssign,116 "Think Python, 2nd Edition",t2 = t1.append(3),simpleAssign,117 "Think Python, 2nd Edition",t = t[1:] # WRONG!,simpleAssign,117 "Think Python, 2nd Edition",rest = tail(letters),simpleAssign,118 "Think Python, 2nd Edition",word = word.strip(),simpleAssign,118 "Think Python, 2nd Edition",t = t.sort() # WRONG!,simpleAssign,118 "Think Python, 2nd Edition",t = t.append(x) # WRONG!,simpleAssign,118 "Think Python, 2nd Edition",t2 = t[:],simpleAssign,119 "Think Python, 2nd Edition",t2 = sorted(t),simpleAssign,119 "Think Python, 2nd Edition",eng2sp = dict(),simpleAssign,125 "Think Python, 2nd Edition",vals = eng2sp.values(),simpleAssign,126 "Think Python, 2nd Edition",d = dict(),simpleAssign,127 "Think Python, 2nd Edition",h = histogram('brontosaurus'),simpleAssign,128 "Think Python, 2nd Edition",h = histogram('a'),simpleAssign,128 "Think Python, 2nd Edition",h = histogram('parrot'),simpleAssign,128 "Think Python, 2nd Edition","Given a dictionary d and a key k, it is easy to find the corresponding value v = d[k].",simpleAssign,129 "Think Python, 2nd Edition",h = histogram('parrot'),simpleAssign,129 "Think Python, 2nd Edition","k = reverse_lookup(h, 2)",simpleAssign,129 "Think Python, 2nd Edition","k = reverse_lookup(h, 3)",simpleAssign,129 "Think Python, 2nd Edition",inverse = dict(),simpleAssign,130 "Think Python, 2nd Edition",val = d[key],simpleAssign,130 "Think Python, 2nd Edition",hist = histogram('parrot'),simpleAssign,130 "Think Python, 2nd Edition",inverse = invert_dict(hist),simpleAssign,130 "Think Python, 2nd Edition",d = dict(),simpleAssign,131 "Think Python, 2nd Edition",with n=4.,simpleAssign,132 "Think Python, 2nd Edition","frames of the functions it calls. At the top of the graph, fibonacci with n=4 calls fibo",simpleAssign,132 "Think Python, 2nd Edition","nacci with n=3 and n=2. In turn, fibonacci with n=3 calls fibonacci with n=2 and",simpleAssign,132 "Think Python, 2nd Edition",n=1. And so on.,simpleAssign,132 "Think Python, 2nd Edition",known[n] = res,simpleAssign,132 "Think Python, 2nd Edition",verbose = True,simpleAssign,133 "Think Python, 2nd Edition",been_called = False,simpleAssign,133 "Think Python, 2nd Edition",been_called = True # WRONG,simpleAssign,133 "Think Python, 2nd Edition",been_called = False,simpleAssign,133 "Think Python, 2nd Edition",been_called = True,simpleAssign,133 "Think Python, 2nd Edition",count = 0,simpleAssign,134 "Think Python, 2nd Edition",known[2] = 1,simpleAssign,134 "Think Python, 2nd Edition",known = dict(),simpleAssign,134 "Think Python, 2nd Edition",t = tuple(),simpleAssign,140 "Think Python, 2nd Edition",t = tuple('lupins'),simpleAssign,140 "Think Python, 2nd Edition",temp = a,simpleAssign,141 "Think Python, 2nd Edition",a = b,simpleAssign,141 "Think Python, 2nd Edition",b = temp,simpleAssign,141 "Think Python, 2nd Edition","a, b = b, a",simpleAssign,141 "Think Python, 2nd Edition","a, b = 1, 2, 3",simpleAssign,141 "Think Python, 2nd Edition","uname, domain = addr.split('@')",simpleAssign,141 "Think Python, 2nd Edition","t = divmod(7, 3)",simpleAssign,141 "Think Python, 2nd Edition","quot, rem = divmod(7, 3)",simpleAssign,142 "Think Python, 2nd Edition","ces, t1 and t2, and returns True if there is an index i such that t1[i] == t2[i]:",simpleAssign,144 "Think Python, 2nd Edition",t = d.items(),simpleAssign,144 "Think Python, 2nd Edition",d = dict(t),simpleAssign,145 "Think Python, 2nd Edition","d = dict(zip('abc', range(3)))",simpleAssign,145 "Think Python, 2nd Edition","directory[last, first] = number",simpleAssign,145 "Think Python, 2nd Edition","lt = list(zip(t, s))",simpleAssign,147 "Think Python, 2nd Edition",d = dict(lt),simpleAssign,147 "Think Python, 2nd Edition",x = random.random(),simpleAssign,153 "Think Python, 2nd Edition",hist = histogram(t),simpleAssign,153 "Think Python, 2nd Edition",hist = dict(),simpleAssign,154 "Think Python, 2nd Edition","line = line.replace('-', ' ')",simpleAssign,154 "Think Python, 2nd Edition",word = word.lower(),simpleAssign,154 "Think Python, 2nd Edition",hist = process_file('emma.txt'),simpleAssign,154 "Think Python, 2nd Edition",t.sort(reverse=True),simpleAssign,155 "Think Python, 2nd Edition",t = most_common(hist),simpleAssign,155 "Think Python, 2nd Edition",t = most_common(hist),simpleAssign,156 "Think Python, 2nd Edition",res = dict(),simpleAssign,156 "Think Python, 2nd Edition",words = process_file('words.txt'),simpleAssign,156 "Think Python, 2nd Edition","diff = subtract(hist, words)",simpleAssign,156 "Think Python, 2nd Edition",f = cr−s,simpleAssign,163 "Think Python, 2nd Edition",log f = log c − s log r,simpleAssign,163 "Think Python, 2nd Edition",x = 52,simpleAssign,166 "Think Python, 2nd Edition",camels = 42,simpleAssign,167 "Think Python, 2nd Edition",cwd = os.getcwd(),simpleAssign,167 "Think Python, 2nd Edition","path = os.path.join(dirname, name)",simpleAssign,168 "Think Python, 2nd Edition",s = pickle.dumps(t1),simpleAssign,171 "Think Python, 2nd Edition",t2 = pickle.loads(s),simpleAssign,171 "Think Python, 2nd Edition",t1 == t2,simpleAssign,171 "Think Python, 2nd Edition",stat = fp.close(),simpleAssign,172 "Think Python, 2nd Edition",stat = fp.close(),simpleAssign,172 "Think Python, 2nd Edition",count = 0,simpleAssign,172 "Think Python, 2nd Edition",blank.x = 3.0,simpleAssign,178 "Think Python, 2nd Edition",blank.y = 4.0,simpleAssign,178 "Think Python, 2nd Edition",x = blank.x,simpleAssign,179 "Think Python, 2nd Edition",box = Rectangle(),simpleAssign,180 "Think Python, 2nd Edition",box.width = 100.0,simpleAssign,180 "Think Python, 2nd Edition",box.height = 200.0,simpleAssign,180 "Think Python, 2nd Edition",box.corner = Point(),simpleAssign,180 "Think Python, 2nd Edition",box.corner.x = 0.0,simpleAssign,180 "Think Python, 2nd Edition",box.corner.y = 0.0,simpleAssign,180 "Think Python, 2nd Edition",p = Point(),simpleAssign,181 "Think Python, 2nd Edition",center = find_center(box),simpleAssign,181 "Think Python, 2nd Edition",p1 = Point(),simpleAssign,182 "Think Python, 2nd Edition",p1.x = 3.0,simpleAssign,182 "Think Python, 2nd Edition",p1.y = 4.0,simpleAssign,182 "Think Python, 2nd Edition",p2 = copy.copy(p1),simpleAssign,182 "Think Python, 2nd Edition",p1 == p2,simpleAssign,182 "Think Python, 2nd Edition",expected. But you might have expected == to yield True because these points contain,simpleAssign,182 "Think Python, 2nd Edition",default behavior of the == operator is the same as the is operator; it checks object,simpleAssign,182 "Think Python, 2nd Edition",box2 = copy.copy(box),simpleAssign,182 "Think Python, 2nd Edition",box3 = copy.deepcopy(box),simpleAssign,183 "Think Python, 2nd Edition",p = Point(),simpleAssign,183 "Think Python, 2nd Edition",p.x = 3,simpleAssign,183 "Think Python, 2nd Edition",p.y = 4,simpleAssign,183 "Think Python, 2nd Edition",x = 0,simpleAssign,184 "Think Python, 2nd Edition",time = Time(),simpleAssign,187 "Think Python, 2nd Edition",time.hour = 11,simpleAssign,187 "Think Python, 2nd Edition",time.minute = 59,simpleAssign,187 "Think Python, 2nd Edition",time.second = 30,simpleAssign,187 "Think Python, 2nd Edition",sum = Time(),simpleAssign,188 "Think Python, 2nd Edition",start = Time(),simpleAssign,188 "Think Python, 2nd Edition",start.hour = 9,simpleAssign,188 "Think Python, 2nd Edition",start.minute = 45,simpleAssign,188 "Think Python, 2nd Edition",start.second = 0,simpleAssign,188 "Think Python, 2nd Edition",duration = Time(),simpleAssign,189 "Think Python, 2nd Edition",duration.hour = 1,simpleAssign,189 "Think Python, 2nd Edition",duration.minute = 35,simpleAssign,189 "Think Python, 2nd Edition",duration.second = 0,simpleAssign,189 "Think Python, 2nd Edition","done = add_time(start, duration)",simpleAssign,189 "Think Python, 2nd Edition",sum = Time(),simpleAssign,189 "Think Python, 2nd Edition",time = Time(),simpleAssign,191 "Think Python, 2nd Edition","minutes, time.second = divmod(seconds, 60)",simpleAssign,191 "Think Python, 2nd Edition","time.hour, time.minute = divmod(minutes, 60)",simpleAssign,191 "Think Python, 2nd Edition",time_to_int(int_to_time(x)) == x for many values of x. This is an example of a,simpleAssign,191 "Think Python, 2nd Edition",start = Time(),simpleAssign,196 "Think Python, 2nd Edition",start.hour = 9,simpleAssign,196 "Think Python, 2nd Edition",start.minute = 45,simpleAssign,196 "Think Python, 2nd Edition",start.second = 00,simpleAssign,196 "Think Python, 2nd Edition",end = start.increment(1337),simpleAssign,198 "Think Python, 2nd Edition","end = start.increment(1337, 460)",simpleAssign,198 "Think Python, 2nd Edition","sketch(parrot, cage, dead=True)",simpleAssign,198 "Think Python, 2nd Edition",time = Time(),simpleAssign,199 "Think Python, 2nd Edition",time = Time (9),simpleAssign,199 "Think Python, 2nd Edition","time = Time(9, 45)",simpleAssign,199 "Think Python, 2nd Edition","time = Time(9, 45)",simpleAssign,200 "Think Python, 2nd Edition","start = Time(9, 45)",simpleAssign,200 "Think Python, 2nd Edition","duration = Time(1, 35)",simpleAssign,200 "Think Python, 2nd Edition","start = Time(9, 45)",simpleAssign,201 "Think Python, 2nd Edition","duration = Time(1, 35)",simpleAssign,201 "Think Python, 2nd Edition",d = dict(),simpleAssign,202 "Think Python, 2nd Edition","t1 = Time(7, 43)",simpleAssign,203 "Think Python, 2nd Edition","t2 = Time(7, 41)",simpleAssign,203 "Think Python, 2nd Edition","t3 = Time(7, 37)",simpleAssign,203 "Think Python, 2nd Edition","total = sum([t1, t2, t3])",simpleAssign,203 "Think Python, 2nd Edition","p = Point(3, 4)",simpleAssign,204 "Think Python, 2nd Edition","queen_of_diamonds = Card(1, 12)",simpleAssign,208 "Think Python, 2nd Edition","card1 = Card(2, 11)",simpleAssign,209 "Think Python, 2nd Edition","t1 = self.suit, self.rank",simpleAssign,211 "Think Python, 2nd Edition","t2 = other.suit, other.rank",simpleAssign,211 "Think Python, 2nd Edition","card = Card(suit, rank)",simpleAssign,211 "Think Python, 2nd Edition",deck = Deck(),simpleAssign,212 "Think Python, 2nd Edition",hand = Hand('new hand'),simpleAssign,213 "Think Python, 2nd Edition",deck = Deck(),simpleAssign,214 "Think Python, 2nd Edition",card = deck.pop_card(),simpleAssign,214 "Think Python, 2nd Edition",hand = Hand(),simpleAssign,217 "Think Python, 2nd Edition",pong = Pong(),simpleAssign,219 "Think Python, 2nd Edition",ping = Ping(pong),simpleAssign,219 "Think Python, 2nd Edition",y = float('nan'),simpleAssign,223 "Think Python, 2nd Edition",y = math.log(x) if x > 0 else float('nan'),simpleAssign,223 "Think Python, 2nd Edition",res = dict(),simpleAssign,227 "Think Python, 2nd Edition",d[x] = True,simpleAssign,227 "Think Python, 2nd Edition","The <= operator checks whether one set is a subset or another, including the possibilߚ",simpleAssign,228 "Think Python, 2nd Edition",count = Counter('parrot'),simpleAssign,228 "Think Python, 2nd Edition",count = Counter('parrot'),simpleAssign,229 "Think Python, 2nd Edition",d = defaultdict(list),simpleAssign,229 "Think Python, 2nd Edition",t = d['new key'],simpleAssign,229 "Think Python, 2nd Edition",word = line.strip().lower(),simpleAssign,229 "Think Python, 2nd Edition",t = signature(word),simpleAssign,229 "Think Python, 2nd Edition",word = line.strip().lower(),simpleAssign,230 "Think Python, 2nd Edition",t = signature(word),simpleAssign,230 "Think Python, 2nd Edition",d = defaultdict(list),simpleAssign,230 "Think Python, 2nd Edition",word = line.strip().lower(),simpleAssign,230 "Think Python, 2nd Edition",t = signature(word),simpleAssign,230 "Think Python, 2nd Edition","Point = namedtuple('Point', ['x', 'y'])",simpleAssign,231 "Think Python, 2nd Edition","p = Point(1, 2)",simpleAssign,231 "Think Python, 2nd Edition","Point(x=1, y=2)",simpleAssign,231 "Think Python, 2nd Edition","x, y = p",simpleAssign,231 "Think Python, 2nd Edition","d = dict(x=1, y=2)",simpleAssign,232 "Think Python, 2nd Edition","Point(x=1, y=2)",simpleAssign,232 "Think Python, 2nd Edition","d = dict(x=1, y=2)",simpleAssign,232 "Think Python, 2nd Edition",6. Check for the classic = instead of == inside a conditional.,simpleAssign,236 "Think Python, 2nd Edition",neighbor = self.findNeighbor(i),simpleAssign,242 "Think Python, 2nd Edition",pickedCard = self.hands[neighbor].popCard(),simpleAssign,242 "Think Python, 2nd Edition",y = x / 2 * math.pi,simpleAssign,242 "Think Python, 2nd Edition",y = x / (2 * math.pi),simpleAssign,243 "Think Python, 2nd Edition",count = self.hands[i].removeMatches(),simpleAssign,243 "Think Python, 2nd Edition","At n=10, Algorithm A looks pretty bad; it takes almost 10 times longer than Algoߚ",simpleAssign,246 "Think Python, 2nd Edition","rithm B. But for n=100 they are about the same, and for larger values A is much",simpleAssign,246 "Think Python, 2nd Edition",total = 0,simpleAssign,249 "Think Python, 2nd Edition",operation is written d[k] = v.,simpleAssign,251 "Think Python, 2nd Edition",index = hash(k) % len(self.maps),simpleAssign,252 "Think Python, 2nd Edition",m = self.find_map(k),simpleAssign,252 "Think Python, 2nd Edition",m = self.find_map(k),simpleAssign,252 "Think Python, 2nd Edition",new_maps = BetterMap(self.num * 2),simpleAssign,253 "Core Python Programming, Second Edition (2006)","zip([it0, it1,... itN])",zip,166 "Core Python Programming, Second Edition (2006)",zip(),zip,186 "Core Python Programming, Second Edition (2006)","zip(s, t)",zip,186 "Core Python Programming, Second Edition (2006)","zip() example of Section 6.12.2, what does zip(fn, ln)",zip,250 "Core Python Programming, Second Edition (2006)","zip(('x', 'y'), (1, 2)))",zip,263 "Core Python Programming, Second Edition (2006)",zip()) return a real sequence (list),zip,306 "Core Python Programming, Second Edition (2006)",zip(),zip,454 "Core Python Programming, Second Edition (2006)","zip([1,3,5], [2,4,6])",zip,454 "Core Python Programming, Second Edition (2006)",zip(),zip,478 "Core Python Programming, Second Edition (2006)",zip( ),zip,1109 "Core Python Programming, Second Edition (2006)",zip( ),zip,1124 "Core Python Programming, Second Edition (2006)","map(), and filter()",map,316 "Core Python Programming, Second Edition (2006)",map(),map,316 "Core Python Programming, Second Edition (2006)","map(lambda x: x ** 2, range(6))",map,316 "Core Python Programming, Second Edition (2006)",map(),map,316 "Core Python Programming, Second Edition (2006)","map(), reduce()",map,448 "Core Python Programming, Second Edition (2006)","map(), and reduce()",map,448 "Core Python Programming, Second Edition (2006)","map( func, seq1[, seq2...])[b] Applies function func to each element of given sequence(s)",map,448 "Core Python Programming, Second Edition (2006)",map( ),map,451 "Core Python Programming, Second Edition (2006)",map() built-in function is similar to filter(),map,451 "Core Python Programming, Second Edition (2006)",map(),map,451 "Core Python Programming, Second Edition (2006)",map(),map,452 "Core Python Programming, Second Edition (2006)",map(),map,452 "Core Python Programming, Second Edition (2006)",map(),map,452 "Core Python Programming, Second Edition (2006)",map(),map,452 "Core Python Programming, Second Edition (2006)","map(func, seq)",map,452 "Core Python Programming, Second Edition (2006)","map((lambda x: x+2), [0, 1, 2, 3, 4, 5])",map,452 "Core Python Programming, Second Edition (2006)","map(lambda x: x**2, range(6))",map,452 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)",map() works with a single sequence. If we used map(),map,453 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)","map(lambda x, y: x + y, [1,3,5], [2,4,6])",map,453 "Core Python Programming, Second Edition (2006)","map(lambda x, y: (x+y, x-y), [1,3,5], [2,4,6])",map,453 "Core Python Programming, Second Edition (2006)","map(None, [1,3,5], [2,4,6])",map,453 "Core Python Programming, Second Edition (2006)",map(),map,453 "Core Python Programming, Second Edition (2006)",map(),map,478 "Core Python Programming, Second Edition (2006)",map(),map,479 "Core Python Programming, Second Edition (2006)",map(),map,624 "Core Python Programming, Second Edition (2006)",map(),map,903 "Core Python Programming, Second Edition (2006)",map( ),map,1069 "Core Python Programming, Second Edition (2006)",map( ),map,1081 "Core Python Programming, Second Edition (2006)",map( ),map,1084 "Core Python Programming, Second Edition (2006)",def __str__(self): # define for str(),privatemethod,581 "Core Python Programming, Second Edition (2006)","def __norm_cval(self, cmpres):# normalize cmp()",privatemethod,582 "Core Python Programming, Second Edition (2006)","def __cmp__(self, other): # define for cmp()",privatemethod,582 "Core Python Programming, Second Edition (2006)","def __norm_cval(self, cmpres)",privatemethod,585 "Core Python Programming, Second Edition (2006)",def __repr__(self): # repr(),privatemethod,591 "Core Python Programming, Second Edition (2006)",def __str__(self): # str(),privatemethod,591 "Core Python Programming, Second Edition (2006)","class C(P): def __init__(self): super(C, self).__init__() print ""calling C's constructor"" The nice thing about using super() is that you do not need to give any base class name explicitly... it does all the legwork for you! The importance of using super() is that you are not explicitly specifying the parent class. This means that if you change the class hierarchy, you only need to change one line (the class statement itself) rather than tracking through what could be a large amount of code in a class to find all mentions of what is now the old class name. 13.11.3. Deriving Standard Types Not being able to subclass a standard data type was one of the most significant problems of classic classes. Fortunately that was remedied back in 2.2 with the unification of types and classes and the introduction of new-style classes. Below we present two examples of subclassing a Python type, one mutable and the other not. Immutable Type Example Let us assume you wanted to work on a subclass of floating point numbers to be used for financial applications. Any time you get a monetary value (as a float), you always want to round evenly to two decimal places. (Yes, the Decimal class is a better solution than standard floats to accurately store floating point values, but you still need to round them [occasionally] to two digits!) The beginnings of your class can look like this: class RoundFloat(float): def __new__(cls, val):",metaclass3,555 "Core Python Programming, Second Edition (2006)","class RoundFloat(float): def __new__(cls, val):",metaclass3,556 "Core Python Programming, Second Edition (2006)",__metaclass__ = MetaC,metaclass2,609 "Core Python Programming, Second Edition (2006)","@decorator(dec_opt_args) def",decaratorfunc,429 "Core Python Programming, Second Edition (2006)","@staticmethod def",decaratorfunc,429 "Core Python Programming, Second Edition (2006)","@deco1 def",decaratorfunc,429 "Core Python Programming, Second Edition (2006)","@f def",decaratorfunc,430 "Core Python Programming, Second Edition (2006)","@deco def",decaratorfunc,430 "Core Python Programming, Second Edition (2006)","@decomaker(deco_args) def",decaratorfunc,430 "Core Python Programming, Second Edition (2006)","@deco2 def",decaratorfunc,430 "Core Python Programming, Second Edition (2006)","@tsfunc 13 def",decaratorfunc,431 "Core Python Programming, Second Edition (2006)","@logged(""post"") 35 def",decaratorfunc,467 "Core Python Programming, Second Edition (2006)","@staticmethod def",decaratorfunc,547 "Core Python Programming, Second Edition (2006)","@classmethod def",decaratorfunc,547 "Core Python Programming, Second Edition (2006)","@property def",decaratorfunc,606 "Core Python Programming, Second Edition (2006)",enumerate() function (introduced in Python 2.3),enumfunc,46 "Core Python Programming, Second Edition (2006)",enumerate(iter),enumfunc,166 "Core Python Programming, Second Edition (2006)",enumerate(),enumfunc,186 "Core Python Programming, Second Edition (2006)",enumerate() and zip(),enumfunc,218 "Core Python Programming, Second Edition (2006)",enumerate(),enumfunc,303 "Core Python Programming, Second Edition (2006)","enumerate(), zip()",enumfunc,305 "Core Python Programming, Second Edition (2006)",enumerate()) return iterators (sequence-like),enumfunc,306 "Core Python Programming, Second Edition (2006)","enumerate() BIF also returns an iterator. Two new BIFs, any() and all()",enumfunc,313 "Core Python Programming, Second Edition (2006)",enumerate(),enumfunc,792 "Core Python Programming, Second Edition (2006)",enumerate( ),enumfunc,1062 "Core Python Programming, Second Edition (2006)",enumerate( ),enumfunc,1108 "Core Python Programming, Second Edition (2006)",squared = [x ** 2 for x in range(4)],simpleListComp,47 "Core Python Programming, Second Edition (2006)",sqdEvens = [x ** 2 for x in range(8) if not x % 2],simpleListComp,47 "Core Python Programming, Second Edition (2006)",allLines = [x.strip() for x in f.readlines()],simpleListComp,321 "Core Python Programming, Second Edition (2006)",allLineLens = [len(x.strip()) for x in f],simpleListComp,322 "Core Python Programming, Second Edition (2006)",data = [line.strip() for line in f.readlines()],simpleListComp,335 "Core Python Programming, Second Edition (2006)","11 nums = [randint(1,10) for i in range(2)]",simpleListComp,422 "Core Python Programming, Second Edition (2006)",data = [ eachLine.strip() for eachLine in f ],simpleListComp,654 "Core Python Programming, Second Edition (2006)",deltas = [ x[1]-x[0] for x in partition() ],simpleListComp,747 "Core Python Programming, Second Edition (2006)",vals = [ start + d * random.random() for _ in range(2*eps) ],simpleListComp,749 "Core Python Programming, Second Edition (2006)",intervals = [ P[i:i+2] for i in range(len(P)-1) ],simpleListComp,749 "Core Python Programming, Second Edition (2006)",deltas = [ x[1] - x[0] for x in intervals ],simpleListComp,749 "Core Python Programming, Second Edition (2006)",deltas = [ x[1]-x[0] for x in partition() ],simpleListComp,750 "Core Python Programming, Second Edition (2006)",60 lines = (line.rstrip() for line in data),generatorExpression,748 "Core Python Programming, Second Edition (2006)",re.compile(),re,677 "Core Python Programming, Second Edition (2006)","re.match('foo', 'food on the table').group()",re,679 "Core Python Programming, Second Edition (2006)","re.match(patt, 'nobody@xxx.com').group()",re,682 "Core Python Programming, Second Edition (2006)","re.match(patt, 'nobody@www.xxx.com').group()",re,682 "Core Python Programming, Second Edition (2006)","re.match(patt, 'nobody@www.xxx.yyy.zzz.com').group()",re,682 "Core Python Programming, Second Edition (2006)","re.findall('car', 'car')",re,684 "Core Python Programming, Second Edition (2006)","re.findall('car', 'scary')",re,684 "Core Python Programming, Second Edition (2006)","re.findall('car', 'carry the barcardi to the car')",re,684 "Core Python Programming, Second Edition (2006)","re.sub('X', 'Mr. Smith', 'attn: X\n\nDear X,\n')",re,685 "Core Python Programming, Second Edition (2006)","re.subn('X', 'Mr. Smith', 'attn: X\n\nDear X,\n')",re,685 "Core Python Programming, Second Edition (2006)","re.sub('X', 'Mr. Smith', 'attn: X\n\nDear X,\n')",re,685 "Core Python Programming, Second Edition (2006)","re.sub('[ae]', 'X', 'abcdef')",re,685 "Core Python Programming, Second Edition (2006)","re.subn('[ae]', 'X', 'abcdef')",re,685 "Core Python Programming, Second Edition (2006)",re.split() works in exactly the same manner as string.split(),re,685 "Core Python Programming, Second Edition (2006)","re.split(':', 'str1:str2:str3')",re,685 "Core Python Programming, Second Edition (2006)","re.split('\s\s+', eachLine)",re,686 "Core Python Programming, Second Edition (2006)",re.split(),re,687 "Core Python Programming, Second Edition (2006)",re.split(),re,687 "Core Python Programming, Second Edition (2006)","re.search(patt, data).group()",re,693 "Core Python Programming, Second Edition (2006)","re.match(patt, data).group()",re,693 "Core Python Programming, Second Edition (2006)","re.match(patt, data).group(1)",re,693 "Core Python Programming, Second Edition (2006)","re.match(patt, data).group(1)",re,694 "Core Python Programming, Second Edition (2006)",import re,importre,184 "Core Python Programming, Second Edition (2006)",import re,importre,686 "Core Python Programming, Second Edition (2006)",import re,importre,691 "Core Python Programming, Second Edition (2006)","def simpleGen(): yield",generatorYield,473 "Core Python Programming, Second Edition (2006)","def __get__(self, obj, typ=None):",descriptorGet,599 "Core Python Programming, Second Edition (2006)","def __get__(self, obj, typ=None):",descriptorGet,600 "Core Python Programming, Second Edition (2006)","def __set__(self, obj, val):",descriptorSet,599 "Core Python Programming, Second Edition (2006)","def __set__(self, obj, val):",descriptorSet,600 "Core Python Programming, Second Edition (2006)","def __delete__(self, obj):",descriptorDelete,602 "Core Python Programming, Second Edition (2006)",property(),classprop,113 "Core Python Programming, Second Edition (2006)",property(),classprop,595 "Core Python Programming, Second Edition (2006)",property(),classprop,604 "Core Python Programming, Second Edition (2006)",property(),classprop,604 "Core Python Programming, Second Edition (2006)","property(fget=None, fset=None, fdel=None, doc=None)",classprop,604 "Core Python Programming, Second Edition (2006)",property(),classprop,604 "Core Python Programming, Second Edition (2006)","property() can accept functions. In fact, at the time that property()",classprop,604 "Core Python Programming, Second Edition (2006)",property(),classprop,606 "Core Python Programming, Second Edition (2006)",property(),classprop,606 "Core Python Programming, Second Edition (2006)",property( ),classprop,1097 "Core Python Programming, Second Edition (2006)",classmethod(),classmethod2,113 "Core Python Programming, Second Edition (2006)",classmethod(),classmethod2,595 "Core Python Programming, Second Edition (2006)",classmethod( ),classmethod2,1053 "Core Python Programming, Second Edition (2006)",staticmethod(),staticmethod2,113 "Core Python Programming, Second Edition (2006)",staticmethod(),staticmethod2,429 "Core Python Programming, Second Edition (2006)",staticmethod() and classmethod(),staticmethod2,546 "Core Python Programming, Second Edition (2006)",staticmethod(),staticmethod2,595 "Core Python Programming, Second Edition (2006)",staticmethod( ),staticmethod2,1108 "Core Python Programming, Second Edition (2006)","__slots__ = ('foo', 'bar')",__slots__,596 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,225 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,228 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,271 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,383 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,422 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,438 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,444 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,638 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,645 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,740 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,749 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,776 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,779 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,781 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,786 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,787 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,789 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,791 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,794 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,815 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,824 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,826 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,843 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,860 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,864 "Core Python Programming, Second Edition (2006)",if __name__ == '__main__':,__name__,880 "Core Python Programming, Second Edition (2006)","print 'My name is', self.__class__",__class__,53 "Core Python Programming, Second Edition (2006)","showname() method, we displayed the self.__class__",__class__,54 "Core Python Programming, Second Edition (2006)",represents the name of the class from which it has been instantiated. (self.__class__,__class__,54 "Core Python Programming, Second Edition (2006)","__add__', '__class__",__class__,220 "Core Python Programming, Second Edition (2006)","in other words, this is equivalent to raising the class with this instance, i.e., raise instance.__class__",__class__,394 "Core Python Programming, Second Edition (2006)",print '%s: %s' % (args.__class__,__class__,397 "Core Python Programming, Second Edition (2006)",followed by its arguments. The __class__,__class__,407 "Core Python Programming, Second Edition (2006)",C.__class__,__class__,527 "Core Python Programming, Second Edition (2006)",MyClass.__class__,__class__,527 "Core Python Programming, Second Edition (2006)","Finally, because of the unification of types and classes, when you access the __class__",__class__,529 "Core Python Programming, Second Edition (2006)",other than an instance's __class__,__class__,531 "Core Python Programming, Second Edition (2006)",I.__class__,__class__,538 "Core Python Programming, Second Edition (2006)",c.__class__,__class__,538 "Core Python Programming, Second Edition (2006)",x.__class__,__class__,539 "Core Python Programming, Second Edition (2006)","__abs__', '__add__', '__class__",__class__,539 "Core Python Programming, Second Edition (2006)",c.__class__,__class__,551 "Core Python Programming, Second Edition (2006)",self.__class__,__class__,551 "Core Python Programming, Second Edition (2006)",p.__class__,__class__,551 "Core Python Programming, Second Edition (2006)",c.__class__,__class__,552 "Core Python Programming, Second Edition (2006)","There are more details; in particular, for objects that override __dict__ or __class__",__class__,564 "Core Python Programming, Second Edition (2006)",return self.__class__,__class__,575 "Core Python Programming, Second Edition (2006)","Because self.__class__ is the same as Time60, calling self.__class__",__class__,575 "Core Python Programming, Second Edition (2006)","else, we would have to perform very careful global search-and-replace. By using self.__class__",__class__,575 "Core Python Programming, Second Edition (2006)",19 return self.__class__,__class__,577 "Core Python Programming, Second Edition (2006)",objectcreated as the results are passed to a call for instantiation as calling self.__class__,__class__,584 "Core Python Programming, Second Edition (2006)",22 (self.__class__,__class__,591 "Core Python Programming, Second Edition (2006)",self.__class__,__class__,609 "Core Python Programming, Second Edition (2006)",27 self.__class__,__class__,610 "Core Python Programming, Second Edition (2006)",30 return self.__class__,__class__,610 "Core Python Programming, Second Edition (2006)",39 self.__class__,__class__,610 "Core Python Programming, Second Edition (2006)","__call__', '__class__",__class__,624 "Core Python Programming, Second Edition (2006)","__call__', '__class__",__class__,627 "Core Python Programming, Second Edition (2006)",declaration so that you can make an assignment like __dict__,__dict__,427 "Core Python Programming, Second Edition (2006)",as well as for special attributes like __dict__,__dict__,521 "Core Python Programming, Second Edition (2006)",in function. An alternative is to access the class dictionary attribute __dict__,__dict__,526 "Core Python Programming, Second Edition (2006)","Using the class defined above, let us use dir() and the special class attribute __dict__",__dict__,526 "Core Python Programming, Second Edition (2006)","__class__', '__delattr__', '__dict__",__dict__,526 "Core Python Programming, Second Edition (2006)",MyClass.__dict__,__dict__,526 "Core Python Programming, Second Edition (2006)",print MyClass.__dict__,__dict__,526 "Core Python Programming, Second Edition (2006)",__dict__': <attribute '__dict__,__dict__,526 "Core Python Programming, Second Edition (2006)",MyClass.__dict__,__dict__,526 "Core Python Programming, Second Edition (2006)","As you can tell, dir() returns a list of (just the) names of an object's attributes while __dict__",__dict__,527 "Core Python Programming, Second Edition (2006)",classes have (in addition to __dict__,__dict__,527 "Core Python Programming, Second Edition (2006)",C.__dict__,__dict__,527 "Core Python Programming, Second Edition (2006)",print MyClass.__dict__,__dict__,527 "Core Python Programming, Second Edition (2006)",The aforementioned __dict__,__dict__,528 "Core Python Programming, Second Edition (2006)",found in __dict__,__dict__,528 "Core Python Programming, Second Edition (2006)",dictionary; no base class __dict__,__dict__,528 "Core Python Programming, Second Edition (2006)","__class__', '__delattr__', '__dict__",__dict__,538 "Core Python Programming, Second Edition (2006)","Similar to classes, instances also have a __dict__",__dict__,538 "Core Python Programming, Second Edition (2006)",c.__dict__,__dict__,538 "Core Python Programming, Second Edition (2006)",I.__dict__,__dict__,538 "Core Python Programming, Second Edition (2006)",c.__dict__,__dict__,538 "Core Python Programming, Second Edition (2006)","As you can see, c currently has no data attributes, but we can add some and recheck the __dict__",__dict__,538 "Core Python Programming, Second Edition (2006)",c.__dict__,__dict__,538 "Core Python Programming, Second Edition (2006)",The __dict__,__dict__,539 "Core Python Programming, Second Edition (2006)",Core Style: Modifying __dict__,__dict__,539 "Core Python Programming, Second Edition (2006)",Although the __dict__,__dict__,539 "Core Python Programming, Second Edition (2006)",where you would modify the __dict__,__dict__,539 "Core Python Programming, Second Edition (2006)",Attempting to access __dict__,__dict__,540 "Core Python Programming, Second Edition (2006)",x.__dict__,__dict__,540 "Core Python Programming, Second Edition (2006)",AttributeError: __dict__,__dict__,540 "Core Python Programming, Second Edition (2006)","class's dictionary [__dict__]. With the assignment, one is now added to the instance's __dict__",__dict__,541 "Core Python Programming, Second Edition (2006)",dir() on a class (classic or new-style) shows the contents of the __dict__,__dict__,564 "Core Python Programming, Second Edition (2006)",dir() on a module shows the contents of the module's __dict__,__dict__,564 "Core Python Programming, Second Edition (2006)",based on the values in its __dict__,__dict__,565 "Core Python Programming, Second Edition (2006)",c.__dict__,__dict__,566 "Core Python Programming, Second Edition (2006)",A dictionary is at the heart of all instances. The __dict__,__dict__,596 "Core Python Programming, Second Edition (2006)",inst.foo is the same as doing it with inst.__dict__,__dict__,596 "Core Python Programming, Second Edition (2006)",users are now able to use the __slots__ attribute to substitute for __dict__,__dict__,596 "Core Python Programming, Second Edition (2006)",a __slots__ attribute will not have a __dict__ (unless you add '__dict__,__dict__,597 "Core Python Programming, Second Edition (2006)","cannot be found in an instance's __dict__ or its class (class's __dict__), or ancestor class (its __dict__",__dict__,597 "Core Python Programming, Second Edition (2006)",type(x).__dict__,__dict__,598 "Core Python Programming, Second Edition (2006)",X.__dict__,__dict__,598 "Core Python Programming, Second Edition (2006)",X.__dict__,__dict__,598 "Core Python Programming, Second Edition (2006)","Otherwise, it should just default to the local object's __dict__",__dict__,599 "Core Python Programming, Second Edition (2006)",c3.__dict__,__dict__,600 "Core Python Programming, Second Edition (2006)","print ""c3.__dict__",__dict__,600 "Core Python Programming, Second Edition (2006)",c3.__dict__,__dict__,600 "Core Python Programming, Second Edition (2006)",c3.__dict__,__dict__,600 "Core Python Programming, Second Edition (2006)","try: A except MyException: B else: C finally: D The equivalent in Python 0.9.6 through 2.4.x. is the longer: try: try: A except MyException: B else: C finally:",tryexceptelsefinally,385 "Core Python Programming, Second Edition (2006)","try: try_suite finally: finally_suite # executes regardless When an exception does occur within the try suite, execution jumps immediately to the finally suite. When all the code in the finally suite completes, the exception is reraised for handling at the next higher layer. Thus it is common to see a try-finally nested as part of a TRy-except suite. One place where we can add a TRy-finally statement is by improving our code in cardrun.py so that we catch any problems that may arise from reading the data from the carddata.txt file. In the current code in Example 10.1, we do not detect errors during the read phase (using readlines()): try: ccfile = open('carddata.txt') except IOError: log.write('no txns this month\n') txns = ccfile.readlines() ccfile.close() It is possible for readlines() to fail for any number of reasons, one of which is if carddata.txt was a file on the network (or a floppy) that became inaccessible. Regardless, we should improve this piece of code so that the entire input of data is enclosed in the try clause: try: ccfile = open('carddata.txt', 'r') txns = ccfile.readlines() ccfile.close() except IOError: log.write('no txns this month\n') All we did was to move the readlines() and close() method calls to the TRy suite. Although our code is more robust now, there is still room for improvement. Notice what happens if there was an error of some sort. If the open succeeds, but for some reason th readlines() call does not, the exception will continue with the except clause. No attempt is made to close the file. Wouldn't it be nice if we closed the file regardless of whether an error occurred or not? We can make it a reality using TRy-finally:",tryexceptfinally,386 "Core Python Programming, Second Edition (2006)","try: try: ccfile = open('carddata.txt', 'r') txns = ccfile.readlines() finally: ccfile.close() except IOError: log.write('no txns this month\n') The code works virtually the same with some differences. The most obvious one is that the closing of the file happens before the exception handler writes out the error to the log. This is because finally automatically reraises the exception. One argument for doing it this way is that if an exception happens within the finally block, you are able to create another handler at the same outer level as the one we have, so in essence, be able to handle errors in both the original try block as well as the finally block. The only thing you lose when you do this is that if the finally block does raise an exception, you have lost context of the original exception unless you have saved it somewhere. An argument against having the finally inside the except is that in many cases, the exception handler needs to perform some cleanup tasks as well, and if you release those resources with a finally block that comes before the exception handler, you have lost the ability to do so. In other words, the finally block is not as ""final"" as one would think. One final note: If the code in the finally suite raises another exception, or is aborted due to a return, break, or continue statement, the original exception is lost and cannot be reraised. 10.3.11. try-except-else-finally:",tryexceptfinally,387 "Core Python Programming, Second Edition (2006)","try: 22 return f(*args, **kargs) 23 finally:",tryfinally,467 "Core Python Programming, Second Edition (2006)","try: 18 f = open(self.name, 'r') 19 val = pickle.load(f) 20 f.close() 21 return val 22 except (pickle.UnpicklingError, IOError, 23 EOFError, AttributeError, 24 ImportError, IndexError), e: 25 raise AttributeError, \ 26 ""could not read %r: %s"" % self.name 27 28 def __set__(self, obj, val): 29 f = open(self.name, 'w') 30 try: 31 try: 32 pickle.dump(val, f) 33 FileDescr.saved.append(self.name) 34 except (TypeError, pickle.PicklingError), e: 35 raise AttributeError, \ 36 ""could not pickle %r"" % self.name 37 finally:",tryfinally,602 "Core Python Programming, Second Edition (2006)","with open('/etc/passwd', 'r') as f:",withfunc,390 "Core Python Programming, Second Edition (2006)","if expression: expr_true_suite else:",ifelse,293 "Core Python Programming, Second Edition (2006)","if expressionN: exprN_true_suite else:",ifelse,295 "Core Python Programming, Second Edition (2006)","if user.cmd == 'update': action = 'update item' else:",ifelse,295 "Core Python Programming, Second Edition (2006)","if user.cmd in ('create', 'delete', 'update'): action = '%s item' % user.cmd else:",ifelse,295 "Core Python Programming, Second Edition (2006)","if user_choice == 'do_calc': pass else:",ifelse,309 "Core Python Programming, Second Edition (2006)","if hasattr(sys, 'exitfunc'): prev_exit_func = sys.exitfunc # getattr(sys, 'exitfunc') else:",ifelse,658 "Core Python Programming, Second Edition (2006)","if form.has_key('who'): who = form['who'].value else:",ifelse,891 "Core Python Programming, Second Edition (2006)","while True: 10 11 if os.path.exists(fname): 12 print ""ERROR: '%s' already exists"" % fname 13 else: 14 break 15 16 # get file content (text) lines 17 all = [] 18 print ""\nEnter lines ('.' by itself to quit).\n"" 19 20 # loop until user terminates input 21 while True: 22 entry = raw_input('> ') 23 if entry == '.': 24 break 25 else:",whileelse,84 "Core Python Programming, Second Edition (2006)","while True: 29 while True: 30 try: 31 choice = raw_input(pr).strip()[0].lower() 32 except (EOFError,KeyboardInterrupt,IndexError): 33 choice = 'q' 34 35 print '\nYou picked: [%s]' % choice 36 if choice not in 'uovq': 37 print 'Invalid option, try again' 38 else:",whileelse,225 "Core Python Programming, Second Edition (2006)","while True: 29 while True: 30 try: 31 choice = raw_input(pr).strip()[0].lower() 32 except (EOFError,KeyboardInterrupt,IndexError): 33 choice = 'q' 34 35 print '\nYou picked: [%s]' % choice 36 if choice not in 'devq': 37 print 'Invalid option, try again' 38 else:",whileelse,228 "Core Python Programming, Second Edition (2006)","while True: 8 name = raw_input(prompt) 9 if db.has_key(name): 10 prompt = 'name taken, try another: ' 11 continue 12 else: 13 break 14 pwd = raw_input('passwd: ') 15 db[name] = pwd 16 17 def olduser(): 18 name = raw_input('login: ') 19 pwd = raw_input('passwd: ') 20 passwd = db.get(name) 21 if passwd == pwd: 22 print 'welcome back', name 23 else:",whileelse,270 "Core Python Programming, Second Edition (2006)","while count > 0: input = raw_input(""enter password"") # check for valid passwd for eachPasswd in passwdList: if input == eachPasswd: valid = True break if not valid: # (or valid == 0) print ""invalid input"" count -= 1 continue else:",whileelse,308 "Core Python Programming, Second Edition (2006)","while count > 1: 6 if num % count == 0: 7 print 'largest factor of %d is %d' % \ 8 (num, count) 9 break 10 count -= 1 11 else:",whileelse,310 "Core Python Programming, Second Edition (2006)","while True: aLine = raw_input(""Enter a line ('.' to quit): "") if aLine != ""."": fobj.write('%s%s' % (aLine, os.linesep) else:",whileelse,338 "Core Python Programming, Second Edition (2006)","while True: 17 try: 18 if int(raw_input(pr)) == ans: 19 print 'correct' 20 break 21 if oops == MAXTRIES: 22 print 'answer\n%s%d'%(pr, ans) 23 else:",whileelse,422 "Core Python Programming, Second Edition (2006)","while True: val = (yield count) if val is not None: count = val else:",whileelse,475 "Core Python Programming, Second Edition (2006)","while self.q: 97 url = self.q.pop() 98 self.getPage(url) 99 100 def main(): 101 if len(argv) > 1: 102 url = argv[1] 103 else:",whileelse,843 "Core Python Programming, Second Edition (2006)","while len(filedata) < MAXBYTES:# read file chunks 120 data = self.fp.readline() 121 if data == '': break 122 filedata += data 123 else: # truncate if too long 124 filedata += \ 125 '... <B><I>(file truncated due to size)</I></B>' 126 self.fp.close() 127 if filedata == '': 128 filedata = \ 129 <B><I>(file upload error or file not given)</I></B>' 130 filename = self.fn 131 132 if not self.cookies.has_key('user') or \ 133 self.cookies['user'] == '': 134 cookStatus = '<I>(cookie has not been set yet)</I>' 135 userCook = '' 136 else: 137 userCook = cookStatus = self.cookies['user'] 138 139 self.cookies['info'] = join([self.who, \ 140 join(self.langs, ','), filename], ':') 141 self.setCPPCookies() 142 print AdvCGI.header + AdvCGI.reshtml % \ 143 (cookStatus, self.who, langlist, 144 filename, filedata, AdvCGI.url) 145 146 def go(self): # determine which page to return 147 self.cookies = {} 148 self.error = '' 149 form = FieldStorage() 150 if form.keys() == []: 151 self.showForm() 152 return 153 154 if form.has_key('person'): 155 self.who = capwords(strip(form['person'].value)) 156 if self.who == '': 157 self.error = 'Your name is required. (blank)' 158 else: 159 self.error = 'Your name is required. (missing)' 160 161 if form.has_key('cookie'): 162 self.cookies['user'] = unquote(strip(\ 163 form['cookie'].value)) 164 else:",whileelse,879 "Core Python Programming, Second Edition (2006)","while i < 11: i += 1 b. for i in range(11): pass 6. Conditionals n = int(raw_input('enter a number: ')) if n < 0: print 'negative' elif n > 0: print 'positive' else:",whileelse,982 "Core Python Programming, Second Edition (2006)","while count > 1: if num % count == 0: return False count -= 1 else:",whileelse,991 "Core Python Programming, Second Edition (2006)","while count > 0: if num % count == 0: print count, 'is the largest factor of', num break count -= 1 The task of this piece of code is to find the largest divisor of a given number num. We iterate through all possible numbers that could possibly be factors of num, using the count variable and decrementing for every value that does not divide num. The first number that evenly divides num is the largest factor, and once that number is found, we no longer need to continue and use break to terminate the loop. phone2remove = '555-1212' for eachPhone in phoneList: if eachPhone == phone2remove: print ""found"", phone2remove, '... deleting' deleteFromPhoneDB(phone2remove) break The break statement here is used to interrupt the iteration of the list. The goal is to find a target element in the list, and, if found, to remove it from the database and break",whilebreak,307 "Core Python Programming, Second Edition (2006)","while True: linelen = len(f.readline().strip()) if not linelen: break",whilebreak,321 "Core Python Programming, Second Edition (2006)","while True: 32 doprob() 33 try: 34 opt = raw_input('Again? [y]').lower() 35 if opt and opt[0] == 'n': 36 break 37 except (KeyboardInterrupt, EOFError): 38 break",whilebreak,422 "Core Python Programming, Second Edition (2006)","while True: 14 data = raw_input('> ') 15 if not data: 16 break 17 tcpCliSock.send(data) 18 data = tcpCliSock.recv(BUFSIZ) 19 if not data: 20 break",whilebreak,711 "Core Python Programming, Second Edition (2006)","while True: 13 data = raw_input('> ') 14 if not data: 15 break 16 udpCliSock.sendto(data, ADDR) 17 data, ADDR = udpCliSock.recvfrom(BUFSIZ) 18 if not data: 19 break",whilebreak,715 "Core Python Programming, Second Edition (2006)","while True: 11 tcpCliSock = socket(AF_INET, SOCK_STREAM) 12 tcpCliSock.connect(ADDR) 13 data = raw_input('> ') 14 if not data: 15 break 16 tcpCliSock.send('%s\r\n' % data) 17 data = tcpCliSock.recv(BUFSIZ) 18 if not data: 19 break",whilebreak,722 "Core Python Programming, Second Edition (2006)",while expression:,whilesimple,43 "Core Python Programming, Second Edition (2006)",while counter < 3:,whilesimple,43 "Core Python Programming, Second Edition (2006)",while the other is being exchanged:,whilesimple,70 "Core Python Programming, Second Edition (2006)",while i < len(myString):,whilesimple,175 "Core Python Programming, Second Edition (2006)",while i < length:,whilesimple,175 "Core Python Programming, Second Edition (2006)",while i < len(fac_list):,whilesimple,248 "Core Python Programming, Second Edition (2006)",while not done:,whilesimple,270 "Core Python Programming, Second Edition (2006)",while not chosen:,whilesimple,270 "Core Python Programming, Second Edition (2006)",while loop:,whilesimple,299 "Core Python Programming, Second Edition (2006)",while expression:,whilesimple,299 "Core Python Programming, Second Edition (2006)",while (count < 9):,whilesimple,299 "Core Python Programming, Second Edition (2006)",while (count < 9):,whilesimple,299 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,300 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,313 "Core Python Programming, Second Edition (2006)",while len(aList) > 0:,whilesimple,474 "Core Python Programming, Second Edition (2006)",while x < 5:,whilesimple,635 "Core Python Programming, Second Edition (2006)",while input() returns the actual list:,whilesimple,636 "Core Python Programming, Second Edition (2006)",while %s < len(%s):,whilesimple,637 "Core Python Programming, Second Edition (2006)",while %s < %d:,whilesimple,637 "Core Python Programming, Second Edition (2006)",while counter < 4:,whilesimple,639 "Core Python Programming, Second Edition (2006)",while eachIndex < len(myList):,whilesimple,640 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,709 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,709 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,714 "Core Python Programming, Second Edition (2006)",while len(pick) > 0:,whilesimple,912 "Core Python Programming, Second Edition (2006)",while True:,whilesimple,920 "Core Python Programming, Second Edition (2006)","while Python lets you concentrate on the important parts of your application:",whilesimple,973 "Core Python Programming, Second Edition (2006)",while i < slen:,whilesimple,982 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,73 "Core Python Programming, Second Edition (2006)",from Tkinter import *,fromstarstatements,490 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,492 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,492 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,493 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,493 "Core Python Programming, Second Edition (2006)",from package.module import *,fromstarstatements,500 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,503 "Core Python Programming, Second Edition (2006)","from module import *",fromstarstatements,508 "Core Python Programming, Second Edition (2006)",from mymodule import *,fromstarstatements,586 "Core Python Programming, Second Edition (2006)","from module import *",fromstarstatements,706 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,706 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,709 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,711 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,714 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,715 "Core Python Programming, Second Edition (2006)",from socket import *,fromstarstatements,722 "Core Python Programming, Second Edition (2006)",from Tkinter import *,fromstarstatements,802 "Core Python Programming, Second Edition (2006)",from Tkinter import *,fromstarstatements,809 "Core Python Programming, Second Edition (2006)",from Tkinter import *,fromstarstatements,809 "Core Python Programming, Second Edition (2006)",from Tkinter import *,fromstarstatements,813 "Core Python Programming, Second Edition (2006)",from sqlalchemy import *,fromstarstatements,918 "Core Python Programming, Second Edition (2006)",from sqlobject import *,fromstarstatements,920 "Core Python Programming, Second Edition (2006)",from module import *,fromstarstatements,1068 "Core Python Programming, Second Edition (2006)",from random import randint as ri,asextension,451 "Core Python Programming, Second Edition (2006)","can be replaced by . . . import Tkinter as tk",asextension,491 "Core Python Programming, Second Edition (2006)",from cgi import FieldStorage as form,asextension,491 "Core Python Programming, Second Edition (2006)",from smtplib import SMTP as smtp,asextension,755 "Core Python Programming, Second Edition (2006)",3 from functools import partial as pto,asextension,811 "Core Python Programming, Second Edition (2006)",10 from urlparse import urlparse as up,asextension,846 "Core Python Programming, Second Edition (2006)",4 from random import randrange as rrange,asextension,910 "Core Python Programming, Second Edition (2006)",4 from random import randrange as rrange,asextension,918 "Core Python Programming, Second Edition (2006)",4 from random import randrange as rrange,asextension,920 "Core Python Programming, Second Edition (2006)","def __init__(self, nm='John Doe')",__init__,53 "Core Python Programming, Second Edition (2006)",The __init__(),__init__,53 "Core Python Programming, Second Edition (2006)",The __init__(),__init__,53 "Core Python Programming, Second Edition (2006)",own __init__(),__init__,53 "Core Python Programming, Second Edition (2006)",the __init__(),__init__,54 "Core Python Programming, Second Edition (2006)",method __init__(),__init__,514 "Core Python Programming, Second Edition (2006)",calls __init__(),__init__,514 "Core Python Programming, Second Edition (2006)","def __init__(self, nm, ph)",__init__,515 "Core Python Programming, Second Edition (2006)",to __init__() because the arguments given to AddrBookEntry(),__init__,515 "Core Python Programming, Second Edition (2006)",by __init__(),__init__,515 "Core Python Programming, Second Edition (2006)",our __init__(),__init__,515 "Core Python Programming, Second Edition (2006)",invoke __init__(),__init__,515 "Core Python Programming, Second Edition (2006)",to __init__(),__init__,515 "Core Python Programming, Second Edition (2006)","def __init__(self, nm, ph, id, em)",__init__,516 "Core Python Programming, Second Edition (2006)",an __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",method __init__(). Any special action desired requires the programmer to implement __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",If __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",if __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",to __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",as __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",of __init__(),__init__,531 "Core Python Programming, Second Edition (2006)",than __init__(),__init__,532 "Core Python Programming, Second Edition (2006)",than __init__(),__init__,532 "Core Python Programming, Second Edition (2006)",and __init__() are both passed the (same),__init__,532 "Core Python Programming, Second Edition (2006)",the __init__() and __del__(),__init__,532 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,532 "Core Python Programming, Second Edition (2006)",perhaps __init__() and __del__(),__init__,533 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,533 "Core Python Programming, Second Edition (2006)",because __init__(),__init__,535 "Core Python Programming, Second Edition (2006)",Once __init__(),__init__,535 "Core Python Programming, Second Edition (2006)",use __init__(),__init__,535 "Core Python Programming, Second Edition (2006)",The __init__(),__init__,536 "Core Python Programming, Second Edition (2006)",by __init__(),__init__,536 "Core Python Programming, Second Edition (2006)",of __init__(),__init__,536 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,537 "Core Python Programming, Second Edition (2006)","def __init__(self, nm, ph, em)",__init__,545 "Core Python Programming, Second Edition (2006)",constructor __init__(),__init__,545 "Core Python Programming, Second Edition (2006)",and __init__(),__init__,545 "Core Python Programming, Second Edition (2006)",of __init__(),__init__,545 "Core Python Programming, Second Edition (2006)",to __init__(),__init__,545 "Core Python Programming, Second Edition (2006)","def __init__(self, nm, ph)",__init__,548 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,551 "Core Python Programming, Second Edition (2006)",from __init__(),__init__,551 "Core Python Programming, Second Edition (2006)",the __init__(),__init__,551 "Core Python Programming, Second Edition (2006)",method __init__(),__init__,552 "Core Python Programming, Second Edition (2006)",inherits __init__(),__init__,552 "Core Python Programming, Second Edition (2006)","constructor __init__(), if you do not override __init__()",__init__,554 "Core Python Programming, Second Edition (2006)","override __init__() in a subclass, the base class __init__()",__init__,554 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,554 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,554 "Core Python Programming, Second Edition (2006)",class __init__(),__init__,554 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,554 "Core Python Programming, Second Edition (2006)",class __init__(),__init__,554 "Core Python Programming, Second Edition (2006)",own __init__(),__init__,554 "Core Python Programming, Second Edition (2006)","like __init__()",__init__,555 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,560 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,561 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,564 "Core Python Programming, Second Edition (2006)",namely __init__() and __del__(),__init__,567 "Core Python Programming, Second Edition (2006)","def __init__(self, val)",__init__,572 "Core Python Programming, Second Edition (2006)","def __init__(self, val)",__init__,574 "Core Python Programming, Second Edition (2006)","def __init__(self, hr, min)",__init__,574 "Core Python Programming, Second Edition (2006)","def __init__(self, hr, min)",__init__,577 "Core Python Programming, Second Edition (2006)","def __init__(self, seq)",__init__,577 "Core Python Programming, Second Edition (2006)",The __init__() method does the aforementioned assignment. The __iter__(),__init__,578 "Core Python Programming, Second Edition (2006)",constructor __init__(),__init__,583 "Core Python Programming, Second Edition (2006)","def __init__(self, obj)",__init__,588 "Core Python Programming, Second Edition (2006)","def __init__(self, obj)",__init__,591 "Core Python Programming, Second Edition (2006)","def __init__(self, fn, mode='r', buf=-1)",__init__,593 "Core Python Programming, Second Edition (2006)","def __init__(self, name=None)",__init__,600 "Core Python Programming, Second Edition (2006)","def __init__(self, x)",__init__,604 "Core Python Programming, Second Edition (2006)","def __init__(self, x)",__init__,605 "Core Python Programming, Second Edition (2006)","def __init__(self, x)",__init__,606 "Core Python Programming, Second Edition (2006)","def __init__(cls, name, bases, attrd)",__init__,608 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,609 "Core Python Programming, Second Edition (2006)","def __init__(cls, name, bases, attrd)",__init__,609 "Core Python Programming, Second Edition (2006)","def __init__(cls, name, bases, attrd)",__init__,610 "Core Python Programming, Second Edition (2006)",The __init__(),__init__,615 "Core Python Programming, Second Edition (2006)",an __init__(),__init__,629 "Core Python Programming, Second Edition (2006)","def __init__(self, func, args, name='')",__init__,787 "Core Python Programming, Second Edition (2006)",constructor __init__(),__init__,788 "Core Python Programming, Second Edition (2006)","def __init__(self, func, args, name='')",__init__,788 "Core Python Programming, Second Edition (2006)","def __init__(self, func, args, name='')",__init__,790 "Core Python Programming, Second Edition (2006)",def __init__(self),__init__,825 "Core Python Programming, Second Edition (2006)","def __init__(self, url)",__init__,841 "Core Python Programming, Second Edition (2006)","def __init__(self, db, dbName)",__init__,918 "Core Python Programming, Second Edition (2006)","def __init__(self, db, dbName)",__init__,920 "Core Python Programming, Second Edition (2006)","function __init__( )",__init__,1044 "Core Python Programming, Second Edition (2006)","instantiation __init__( )",__init__,1076 "Core Python Programming, Second Edition (2006)","try: try_suite # watch for exceptions here except Exception[, reason]: except_suite # exception-handling code Let us give one example, then explain how things work. We will use our IOError example from above. We can make our code more robust by adding a try-except ""wrapper"" around the code: >>> try: ... f = open('blah', 'r') ... except IOError, e: ... print 'could not open file:', e ... could not open file: [Errno 2] No such file or directory file:///D|/1/0132269937/ch10lev1sec3.html (1 von 17) [13.11.2007 16:23:43]",trytry,372 "Core Python Programming, Second Edition (2006)","try: return float(obj) except ValueError: pass The first step we take is to just ""stop the bleeding."" In this case, we make the error go away by just ""swallowing it."" In other words, the error will be detected, but since we have nothing in the except suite (except the pass statement, which does nothing but serve as a syntactical placeholder for where code is supposed to go), no handling takes place. We just ignore the error. One obvious problem with this solution is that we did not explicitly return anything to the function caller in the error situation. Even though None is returned (when a function does not return any value explicitly, i.e., completing execution without encountering a return object statement), we give little or no hint that anything wrong took place. The very least we should do is to explicitly return None so that our function returns a value in both cases and makes our code somewhat easier to understand: def safe_float(obj): try: retval = float(obj) except ValueError: file:///D|/1/0132269937/ch10lev1sec3.html (3 von 17) [13.11.2007 16:23:43]",trytry,374 "Core Python Programming, Second Edition (2006)","try: retval = float(obj) except (ValueError, TypeError): retval = 'argument must be a number or numeric string' return retval Now there is only the single error string returned on erroneous input: >>> safe_float('Spanish Inquisition') 'argument must be a number or numeric string' >>> safe_float([]) 'argument must be a number or numeric string' >>> safe_float('1.6') 1.6 >>> safe_float(1.6) 1.6 >>> safe_float(932) 932.0 10.3.5. Catching All Exceptions Using the code we saw in the previous section, we are able to catch any number of specific exceptions and handle them. What about cases where we want to catch all exceptions? The short answer is yes, we can definitely do it. The code for doing it was significantly improved in 1.5 when exceptions became classes. Because of this, we now have an exception hierarchy to follow. If we go all the way up the exception tree, we find Exception at the top, so our code will look like this: try: : except Exception, e: # error occurred, log 'e', etc. Less preferred is the bare except clause: try: : except: # error occurred, etc. This syntax is not as ""Pythonic"" as the other. Although this code catches the most exceptions, it does file:///D|/1/0132269937/ch10lev1sec3.html (6 von 17) [13.11.2007 16:23:43]",trytry,377 "Core Python Programming, Second Edition (2006)","try: : except (KeyboardInterupt, SystemExit): # user wants to quit raise # reraise back to caller except Exception: # handle real errors A few things regarding exceptions did change in Python 2.5. Exceptions were moved to new-style classes, a new ""mother of all exception"" classes named BaseException was installed, and the exception hierarchy was switched around (very slightly) to get rid of that idiom of having to create two handlers. Both KeyboardInterrupt and SystemExit have been pulled out from being children of Exception to being its peers: - BaseException |- KeyboardInterrupt |- SystemExit |- Exception |- (all other current built-in exceptions) You can find the entire exception hierarchy (before and after these changes) in Table 10.2. The end result is that now you do not have to write the extra handler for those two exceptions if you have a handler for just Exception. This code will suffice: try: : file:///D|/1/0132269937/ch10lev1sec3.html (7 von 17) [13.11.2007 16:23:43]",trytry,378 "Core Python Programming, Second Edition (2006)","try: : except BaseException, e: # handle all errors And of course, there is the less preferred bare except. Core Style: Do not handle and ignore all errors The try-except statement has been included in Python to provide a powerful mechanism for programmers to track down potential errors and perhaps to provide logic within the code to handle situations where it may not otherwise be possible, for example, in C. The main idea is to minimize the number of errors and still maintain program correctness. As with all tools, they must be used properly. One incorrect use of TRy-except is to serve as a giant bandage over large pieces of code. By that we mean putting large blocks, if not your entire source code, within a try and/or have a large generic except to ""filter"" any fatal errors by ignoring them: # this is really bad code try: large_block_of_code # bandage of large piece of code except Exception: # same as except: pass # blind eye ignoring all errors Obviously, errors cannot be avoided, and the job of TRy-except is to provide a mechanism whereby an acceptable problem can be remedied or properly dealt with, and not be used as a filter. The construct above will hide many errors, but this type of usage promotes a poor engineering practice that we certainly cannot endorse. Bottom line: Avoid using try-except around a large block of code with a pass just to hide errors. Instead, either handle specific exceptions and ignore them (pass), or handle all errors and take a specific action. Do not do both (handle all errors, ignore all errors). 10.3.6. ""Exceptional Arguments"" No, the title of this section has nothing to do with having a major fight. Instead, we are referring to the fact that an exception may have an argument or reason passed along to the exception handler when they are raised. When an exception is raised, parameters are generally provided as an additional aid for file:///D|/1/0132269937/ch10lev1sec3.html (8 von 17) [13.11.2007 16:23:43]",trytry,379 "Core Python Programming, Second Edition (2006)","try: ... float(['float() does not', 'like lists', 2]) ... except TypeError, diag:# capture diagnostic info ... pass ... >>> type(diag) <class 'exceptions.TypeError'> >>> >>> print diag float() argument must be a string or a number The first thing we did was cause an exception to be raised from within the try statement. Then we passed cleanly through by ignoring but saving the error information. Calling the type() built-in function, we were able to confirm that our exception was indeed an instance of the TypeError exception class. Finally, we displayed the error by calling print with our diagnostic exception argument. To obtain more information regarding the exception, we can use the special __class__ instance attribute, which identifies which class an instance was instantiated from. Class objects also have attributes, such as a documentation string and a string name that further illuminate the error type: >>> diag # exception instance object <exceptions.TypeError instance at 8121378> >>> diag.__class__ # exception class object <class exceptions.TypeError at 80f6d50> >>> diag.__class__.__doc__ # exception class documentation string 'Inappropriate argument type.' >>> diag.__class__.__name__ # exception class name 'TypeError' As we will discover in Chapter 13Classes and OOP the special instance attribute __class__ exists for all class instances, and the __doc__ class attribute is available for all classes that define their documentation strings. We will now update our safe_float() one more time to include the exception argument, which is passed from the interpreter from within float()when exceptions are generated. In our last modification to safe_float(), we merged both the handlers for the ValueError and TypeError exceptions into one because we had to satisfy some requirement. The problem, if any, with this solution is that no clue is given as to which exception was raised or what caused the error. The only thing returned is an error string that indicated some form of invalid argument. Now that we have the exception argument, this no longer has to be the case. Because each exception will generate its own exception argument, if we chose to return this string rather than a generic one we made up, it would provide a better clue as to the source of the problem. In the following code snippet, we replace our single error string with the string representation of the exception argument. def safe_float(object): try: retval = float(object) except (ValueError, TypeError), diag: retval = str(diag) file:///D|/1/0132269937/ch10lev1sec3.html (10 von 17) [13.11.2007 16:23:43]",trytry,381 "Core Python Programming, Second Edition (2006)","try: try: ccfile = open('carddata.txt', 'r') txns = ccfile.readlines() except IOError: file:///D|/1/0132269937/ch10lev1sec3.html (15 von 17) [13.11.2007 16:23:43]",trytry,386 "Core Python Programming, Second Edition (2006)","try: 57 sock.connect((host, port)) 58 59 except socket.error, args: 60 myargs = updArgs(args) # conv inst2tuple 61 if len(myargs) == 1: # no #s on some errs 62 myargs = (errno.ENXIO, myargs[0]) 63 64 raise NetworkError, \ 65 updArgs(myargs, host + ':' + str(port)) 66 67 def myopen(file, mode='r'): 68 try: 69 fo = open(file, mode) 70 except IOError, args: 71 raise FileError, fileArgs(file, mode, args) 72 73 return fo 74 75 def testfile(): 76 77 file = mktemp() 78 f = open(file, 'w') file:///D|/1/0132269937/ch10lev1sec9.html (2 von 6) [13.11.2007 16:23:47]",trytry,404 "Core Python Programming, Second Edition (2006)","try: 84 os.chmod(file, eachTest[0]) 85 f = myopen(file, eachTest[1]) 86 87 except FileError, args: 88 print ""%s: %s"" % \ 89 (args.__class__.__name__, args) 90 else: 91 print file, ""opened ok... perm ignored"" 92 f.close() 93 94 os.chmod(file, 0777) # enable all perms 95 os.unlink(file) 96 97 def testnet(): 98 s = socket.socket(socket.AF_INET, 99 socket.SOCK_STREAM) 100 101 for eachHost in ('deli', 'www'): 102 try: 103 myconnect(s, 'deli', 8080) 104 except NetworkError, args: 105 print ""%s: %s"" % \ 106 (args.__class__.__name__, args) 107 108 if __name__ == '__main__': 109 testfile() 110 testnet() Lines 13 The Unix startup script and importation of the socket, os, errno, types, and tempfile modules help us start this module. Lines 59 Believe it or not, these five lines make up our new exceptions. Not just one, but both of them. Unless new functionality is going to be introduced, creating a new exception is just a matter of subclassing from an already existing exception. In our case, that would be IOError. EnvironmentError, from which IOError is derived, would also work, but we wanted to convey that our exceptions were definitely I/O-related. We chose IOError because it provides two arguments, an error number and an error string. File-related [uses open()] IOError exceptions even support a third argument that is not part of the main set of exception arguments, and that would be the filename. Special handling is done for this third argument, which lives outside the main tuple pair and has the name filename. Lines 1121 file:///D|/1/0132269937/ch10lev1sec9.html (3 von 6) [13.11.2007 16:23:47]",trytry,405 "Core Python Programming, Second Edition (2006)","try: statement_A except . . .: . . . else: statement_B (b) try: statement_A statement_B except . . .: . . . 10-8. Improving raw_input(). At the beginning of this chapter, we presented a ""safe"" version of the float() built-in function to detect and handle two different types of exceptions that float() generates. Likewise, the raw_input() function can generate two different exceptions, either EOFError or KeyboardInterrupt on end-of-file (EOF) or cancelled input, respectively. Create a wrapper function, perhaps safe_ input(); rather than raising an exception if the user entered EOF (^D in Unix or ^Z in DOS) or attempted to break out using ^C, have your function return None that the calling function can check for. file:///D|/1/0132269937/ch10lev1sec14.html (2 von 3) [13.11.2007 16:23:48]",trytry,414 "Core Python Programming, Second Edition (2006)","try: 13 f = ftplib.FTP(HOST) 14 except (socket.error, socket.gaierror), e: 15 print 'ERROR: cannot reach ""%s""' % HOST 16 return 17 print '*** Connected to host ""%s""' % HOST 18 19 try: 20 f.login() 21 except ftplib.error_perm: 22 print 'ERROR: cannot login anonymously' 23 f.quit() 24 return 25 print '*** Logged in as ""anonymous""' 26 27 try: 28 f.cwd(DIRN) 29 except ftplib.error_perm: 30 print 'ERROR: cannot CD to ""%s""' % DIRN file:///D|/1/0132269937/ch17lev1sec2.html (5 von 8) [13.11.2007 16:24:47]",trytry,739 "Core Python Programming, Second Edition (2006)","try: 11 f = open(curdir + sep + self.path) 12 self.send_response(200) 13 self.send_header('Content-type', 14 'text/html') 15 self.end_headers() 16 self.wfile.write(f.read()) 17 f.close() 18 except IOError: 19 self.send_error(404, 20 'File Not Found: %s' % self.path) 21 22 def main(): 23 try: 24 server = HTTPServer(('', 80), MyHandler) 25 print 'Welcome to the machine...', 26 print 'Press ^C once or twice to quit.' 27 server.serve_forever() 28 except KeyboardInterrupt: 29 print '^C received, shutting down server' 30 server.socket.close() 31 32 if __name__ == '__main__': file:///D|/1/0132269937/ch20lev1sec8.html (2 von 3) [13.11.2007 16:25:11]",trytry,884 "Core Python Programming, Second Edition (2006)","try: 29 from pysqlite2 import dbapi2 as sqlite3 30 except ImportError, e: 31 return None 32 33 DB_EXC = sqlite3 34 if not os.path.isdir(dbDir): 35 os.mkdir(dbDir) 36 cxn = sqlite.connect(os.path.join(dbDir, dbName)) 37 38 elif db == 'mysql': 39 try: 40 import MySQLdb 41 import _mysql_exceptions as DB_EXC 42 except ImportError, e: 43 return None 44 45 try: 46 cxn = MySQLdb.connect(db=dbName) 47 except _mysql_exceptions.OperationalError, e: 48 cxn = MySQLdb.connect(user='root') 49 try: 50 cxn.query('DROP DATABASE %s' % dbName) 51 except DB_EXC.OperationalError, e: 52 pass 53 cxn.query('CREATE DATABASE %s' % dbName) 54 cxn.query(""GRANT ALL ON %s.* to ''@'localhost'"" % dbName) 55 cxn.commit() 56 cxn.close() 57 cxn = MySQLdb.connect(db=dbName) 58 59 elif db == 'gadfly': 60 try: 61 from gadfly import gadfly 62 DB_EXC = gadfly 63 except ImportError, e: 64 return None 65 66 try: 67 cxn = gadfly(dbName, dbDir) 68 except IOError, e: 69 cxn = gadfly() 70 if not os.path.isdir(dbDir): 71 os.mkdir(dbDir) 72 cxn.startup(dbName, dbDir) 73 else: 74 return None 75 return cxn 76 77 def create(cur): 78 try 79 cur.execute(''' 80 CREATE TABLE users ( 81 login VARCHAR(8), file:///D|/1/0132269937/ch21lev1sec2.html (14 von 19) [13.11.2007 16:25:17]",trytry,911 "Core Python Programming, Second Edition (2006)","try: 20 cxn = eng.connection() 21 except _mysql_exceptions.OperationalError, e: 22 eng1 = create_engine('mysql://user=root') 23 try: 24 eng1.execute('DROP DATABASE %s' % DBNAME) 25 except _mysql_exceptions.OperationalError, e: 26 pass 27 eng1.execute('CREATE DATABASE %s' % DBNAME) 28 eng1.execute( 29 ""GRANT ALL ON %s.* TO ''@'localhost'"" % DBNAME) 30 eng1.commit() 31 cxn = eng.connection() 32 33 try: 34 users = Table('users', eng, autoload=True) 35 except exceptions.SQLError, e: 36 users = Table('users', eng, 37 Column('login', String(8)), 38 Column('uid', Integer), 39 Column('prid', Integer), 40 redefine=True) 41 42 self.eng = eng 43 self.cxn = cxn 44 self.users = users 45 46 def create(self): 47 users = self.users 48 try: 49 users.drop() 50 except exceptions.SQLError, e: 51 pass 52 users.create() 53 file:///D|/1/0132269937/ch21lev1sec3.html (2 von 11) [13.11.2007 16:25:19]",trytry,918 "Core Python Programming, Second Edition (2006)","try: 11 fobj = open(fname, 'r') 12 except IOError, e: 13 print ""*** file open error:"", e 14 else:",tryexceptelse,87 "Core Python Programming, Second Edition (2006)","try: 15 ccfile = open('carddata.txt', 'r') 16 except IOError, e: 17 log.write('no txns this month\n') 18 log.close() 19 return 20 21 txns = ccfile.readlines() 22 ccfile.close() 23 total = 0.00 24 log.write('account log:\n') 25 26 for eachTxn in txns: 27 result = safe_float(eachTxn) 28 if isinstance(result, float): 29 total += result 30 log.write('data... processed\n') 31 else:",tryexceptelse,383 "Core Python Programming, Second Edition (2006)","try: 6 retval = func(*nkwargs, **kwargs) 7 result = (True, retval) 8 except Exception, diag: 9 result = (False, str(diag)) 10 return result 11 12 def test(): 13 funcs = (int, long, float) 14 vals = (1234, 12.34, '1234', '12.34') 15 16 for eachFunc in funcs: 17 print '-' * 20 18 for eachVal in vals: 19 retval = testit(eachFunc, 20 eachVal) 21 if retval[0]: 22 print '%s(%s) =' % \ 23 (eachFunc.__name__, `eachVal`), retval[1] 24 else:",tryexceptelse,444 "Core Python Programming, Second Edition (2006)","try: 15 retval.append(self.iter.next()) 16 except StopIteration: 17 if self.safe: 18 break 19 else:",tryexceptelse,579 "Core Python Programming, Second Edition (2006)","try: 36 f.retrbinary('RETR %s' % FILE, 37 open(FILE, 'wb').write) 38 except ftplib.error_perm: 39 print 'ERROR: cannot read file ""%s""' % FILE 40 os.unlink(FILE) 41 else:",tryexceptelse,740 "Core Python Programming, Second Edition (2006)","try: 38 retval = urlretrieve(self.url, self.file) 39 except IOError: 40 retval = ('*** ERROR: invalid URL ""%s""' %\ 41 self.url,) 42 return retval 43 44 def parseAndGetLinks(self):# parse HTML, save links 45 self.parser = HTMLParser(AbstractFormatter(\ 46 DumbWriter(StringIO()))) 47 self.parser.feed(open(self.file).read()) 48 self.parser.close() 49 return self.parser.anchorlist 50 51 class Crawler(object):# manage entire crawling process 52 53 count = 0 # static downloaded page counter 54 55 def __init__(self, url): 56 self.q = [url] 57 self.seen = [] 58 self.dom = urlparse(url)[1] 59 60 def getPage(self, url): 61 r = Retriever(url) 62 retval = r.download() 63 if retval[0] == '*': # error situation, do not parse 64 print retval, '... skipping parse' 65 return 66 Crawler.count += 1 67 print '\n(', Crawler.count, ')' 68 print 'URL:', url 69 print 'FILE:', retval[0] 70 self.seen.append(url) 71 72 links = r.parseAndGetLinks() # get and process links 73 for eachLink in links: 74 if eachLink[:4] != 'http' and \ 75 find(eachLink, '://') == -1: 76 eachLink = urljoin(url, eachLink) 77 print '* ', eachLink, 78 79 if find(lower(eachLink), 'mailto:') != -1: 80 print '... discarded, mailto link' 81 continue 82 83 if eachLink not in self.seen: 84 if find(eachLink, self.dom) == -1: 85 print '... discarded, not in domain' 86 else:",tryexceptelse,842 "Core Python Programming, Second Edition (2006)","try: filename = raw_input('Enter file name: ') fobj = open(filename, 'r') for eachLine in fobj: print eachLine, fobj.close() except IOError, e:",tryexcept,50 "Core Python Programming, Second Edition (2006)","try: i = fetch.next() except StopIteration:",tryexcept,313 "Core Python Programming, Second Edition (2006)","try: retval = float(obj) except ValueError: retval = 'could not convert non-number to float' return retval The only thing we changed in the example was to return an error string as opposed to just None. We should take our function out for a test drive to see how well it works so far: >>> safe_float('12.34') 12.34 >>> safe_float('bad input') 'could not convert non-number to float' We made a good startnow we can detect invalid string input, but we are still vulnerable to invalid objects being passed in: >>> safe_float({'a': 'Dict'}) Traceback (innermost last): File ""<stdin>"", line 3, in ? retval = float(obj) TypeError: float() argument must be a string or a number We will address this final shortcoming momentarily, but before we further modify our example, we would like to highlight the flexibility of the try-except syntax, especially the except statement, which comes in a few more flavors. 10.3.3. try Statement with Multiple excepts Earlier in this chapter, we introduced the following general syntax for except: except Exception[, reason]: suite_for_exception_Exception The except statement in such formats specifically detects exceptions named Exception. You can chain multiple except statements together to handle different types of exceptions with the same TRy:",tryexcept,375 "Core Python Programming, Second Edition (2006)","try: retval = float(obj) except ValueError: retval = 'could not convert non-number to float' except TypeError:",tryexcept,376 "Core Python Programming, Second Edition (2006)","try: try_suite except Exception1: suite_for_Exception1 except (Exception2, Exception3, Exception4): suite_for_Exceptions_2_3_and_4 except Exception5, Argument5:",tryexcept,387 "Core Python Programming, Second Edition (2006)","try: assert 1 == 0, 'One does not equal zero silly!' except AssertionError, args:",tryexcept,397 "Core Python Programming, Second Edition (2006)","try: 23 retval = urlretrieve(url)[0] 24 except IOError:",tryexcept,438 "Core Python Programming, Second Edition (2006)","try: 29 return {""pre"": pre_logged, 30 ""post"": post_logged}[when] 31 except KeyError, e:",tryexcept,467 "Core Python Programming, Second Edition (2006)","try: 27 rsp, ct, fst, lst, grp = n.group(GRNM) 28 except nntplib.NNTPTemporaryError, e: 29 print 'ERROR: cannot load group ""%s""' % GRNM 30 print ' (""%s"")' % str(e) 31 print ' Server may require authentication' 32 print ' Uncomment/edit login line above' 33 n.quit() 34 return 35 except nntplib.NNTPTemporaryError, e:",tryexcept,748 "Core Python Programming, Second Edition (2006)","try: 23 class Users(SQLObject): 24 class sqlmeta: 25 fromDatabase = True 26 login = StringCol(length=8) 27 uid = IntCol() 28 prid = IntCol() 29 break 30 except _mysql_exceptions.ProgrammingError, e: 31 class Users(SQLObject): 32 login = StringCol(length=8) 33 uid = IntCol() 34 prid = IntCol() 35 break 36 except _mysql_exceptions.OperationalError, e:",tryexcept,920 "Core Python Programming, Second Edition (2006)","lambda x: x % 2, seq)",lambda,317 "Core Python Programming, Second Edition (2006)","lambda x,y: cmp(y, x), or",lambda,423 "Core Python Programming, Second Edition (2006)","lambda [arg1[, arg2, ... argN]]: expression",lambda,446 "Core Python Programming, Second Edition (2006)",lambda is:,lambda,447 "Core Python Programming, Second Edition (2006)",lambda :True,lambda,447 "Core Python Programming, Second Edition (2006)","lambda function by itself serves no purpose, as we see here:",lambda,447 "Core Python Programming, Second Edition (2006)",lambda :True,lambda,447 "Core Python Programming, Second Edition (2006)","lambda x, y: x + y",lambda,447 "Core Python Programming, Second Edition (2006)","lambda x, y=2: x+y",lambda,447 "Core Python Programming, Second Edition (2006)",lambda *z: z,lambda,447 "Core Python Programming, Second Edition (2006)",lambda expression:,lambda,451 "Core Python Programming, Second Edition (2006)","lambda n: n%2, allNums)",lambda,451 "Core Python Programming, Second Edition (2006)",lambda functions to show you how map() works on real data:,lambda,452 "Core Python Programming, Second Edition (2006)",lambda equivalent seen earlier in this chapter:,lambda,454 "Core Python Programming, Second Edition (2006)","lambda x,y: x+y",lambda,455 "Core Python Programming, Second Edition (2006)","lambda and reduce(), we can do the same thing on a single line:",lambda,455 "Core Python Programming, Second Edition (2006)","lambda x,y: x+y), range(5))",lambda,456 "Core Python Programming, Second Edition (2006)",lambda to look like this:,lambda,469 "Core Python Programming, Second Edition (2006)",lambda expression:,lambda,626 "Core Python Programming, Second Edition (2006)","lambda self, connector, reason: reactor.stop()",lambda,726 "Core Python Programming, Second Edition (2006)","lambda e: self.Close(True), qb)",lambda,824 "Core Python Programming, Second Edition (2006)","def function_name([ formal_args,][ *vargst,] **vargsd):",funcwith2star,441 "Core Python Programming, Second Edition (2006)","def dictVarArgs(arg1, arg2='defaultB', **theRest):",funcwith2star,441 "Core Python Programming, Second Edition (2006)","def newfoo(arg1, arg2, *nkw, **kw):",funcwith2star,442 "Core Python Programming, Second Edition (2006)","def testit(func, *nkwargs, **kwargs):",funcwith2star,444 "Core Python Programming, Second Edition (2006)","def log(f, *args, **kargs):",funcwith2star,466 "Core Python Programming, Second Edition (2006)","def wrapper(*args, **kargs):",funcwith2star,466 "Core Python Programming, Second Edition (2006)","def wrapper(*args, **kargs):",funcwith2star,466 "Core Python Programming, Second Edition (2006)","def function_name([formal_args,] *vargs_tuple):",funcwithstar,440 "Core Python Programming, Second Edition (2006)","def tupleVarArgs(arg1, arg2='defaultB', *theRest):",funcwithstar,440 "Core Python Programming, Second Edition (2006)",def showAllAsTuple(*z):,funcwithstar,447 "Core Python Programming, Second Edition (2006)","def __call__(self, *args):",funcwithstar,629 "Core Python Programming, Second Edition (2006)","def printf(string, *args):",funcwithstar,995 "Core Python Programming, Second Edition (2006)",class FooClass(object):,simpleclass,53 "Core Python Programming, Second Edition (2006)",class Bar(object):,simpleclass,108 "Core Python Programming, Second Edition (2006)",class MyClass(object):,simpleclass,429 "Core Python Programming, Second Edition (2006)",class MyClass(object):,simpleclass,429 "Core Python Programming, Second Edition (2006)",class MyUltimatePythonStorageDevice(object):,simpleclass,487 "Core Python Programming, Second Edition (2006)",class MyNewObjectType(bases):,simpleclass,512 "Core Python Programming, Second Edition (2006)",class MyData(object):,simpleclass,513 "Core Python Programming, Second Edition (2006)",class MyDataWithMethod(object):,simpleclass,514 "Core Python Programming, Second Edition (2006)","class def printFoo(self):",simpleclass,514 "Core Python Programming, Second Edition (2006)",class AddrBookEntry(object):,simpleclass,515 "Core Python Programming, Second Edition (2006)",class EmplAddrBookEntry(AddrBookEntry):,simpleclass,516 "Core Python Programming, Second Edition (2006)",class ClassName(object):,simpleclass,522 "Core Python Programming, Second Edition (2006)",class ClassName(bases):,simpleclass,522 "Core Python Programming, Second Edition (2006)",class data attribute (foo):,simpleclass,524 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,524 "Core Python Programming, Second Edition (2006)",class MyClass(object):,simpleclass,525 "Core Python Programming, Second Edition (2006)",class MyClass(object):,simpleclass,526 "Core Python Programming, Second Edition (2006)",class MyClass(object):,simpleclass,530 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,532 "Core Python Programming, Second Edition (2006)",class InstCt(object):,simpleclass,533 "Core Python Programming, Second Edition (2006)",class HotelRoomCalc(object):,simpleclass,536 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,538 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,540 "Core Python Programming, Second Edition (2006)",class Foo(object):,simpleclass,541 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,542 "Core Python Programming, Second Edition (2006)",class EmplAddrBookEntry(AddrBookEntry):,simpleclass,545 "Core Python Programming, Second Edition (2006)",class NewAddrBookEntry(object):,simpleclass,548 "Core Python Programming, Second Edition (2006)",class Parent(object):,simpleclass,549 "Core Python Programming, Second Edition (2006)","class def parentMethod(self):",simpleclass,549 "Core Python Programming, Second Edition (2006)",class Child(Parent):,simpleclass,550 "Core Python Programming, Second Edition (2006)","class def childMethod(self):",simpleclass,550 "Core Python Programming, Second Edition (2006)",class P(object):,simpleclass,551 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,551 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,551 "Core Python Programming, Second Edition (2006)",class A(object):,simpleclass,552 "Core Python Programming, Second Edition (2006)",class B(A):,simpleclass,552 "Core Python Programming, Second Edition (2006)",class C(B):,simpleclass,552 "Core Python Programming, Second Edition (2006)",class P(object):,simpleclass,552 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,553 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,553 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,553 "Core Python Programming, Second Edition (2006)",class P(object):,simpleclass,554 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,554 "Core Python Programming, Second Edition (2006)",class C(P):,simpleclass,554 "Core Python Programming, Second Edition (2006)",class SortedKeyDict(dict):,simpleclass,556 "Core Python Programming, Second Edition (2006)",class P1: #(object):,simpleclass,558 "Core Python Programming, Second Edition (2006)",class P2: #(object):,simpleclass,558 "Core Python Programming, Second Edition (2006)",class B(object):,simpleclass,561 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,561 "Core Python Programming, Second Edition (2006)",class C1(object):,simpleclass,562 "Core Python Programming, Second Edition (2006)",class C2(object):,simpleclass,562 "Core Python Programming, Second Edition (2006)",class myClass(object):,simpleclass,564 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,565 "Core Python Programming, Second Edition (2006)",class RoundFloatManual(object):,simpleclass,572 "Core Python Programming, Second Edition (2006)",class RoundFloatManual(object):,simpleclass,574 "Core Python Programming, Second Edition (2006)",class Time60(object):,simpleclass,574 "Core Python Programming, Second Edition (2006)",class Time60(object):,simpleclass,577 "Core Python Programming, Second Edition (2006)",class RandSeq(object):,simpleclass,577 "Core Python Programming, Second Edition (2006)",class AnyIter(object):,simpleclass,579 "Core Python Programming, Second Edition (2006)",class NumStr(object):,simpleclass,581 "Core Python Programming, Second Edition (2006)",class WrapMe(object):,simpleclass,588 "Core Python Programming, Second Edition (2006)",class TimedWrapMe(object):,simpleclass,591 "Core Python Programming, Second Edition (2006)",class CapOpen(object):,simpleclass,593 "Core Python Programming, Second Edition (2006)",class SlottedClass(object):,simpleclass,596 "Core Python Programming, Second Edition (2006)",class DevNull1(object):,simpleclass,599 "Core Python Programming, Second Edition (2006)",class C1(object):,simpleclass,599 "Core Python Programming, Second Edition (2006)",class DevNull2(object):,simpleclass,599 "Core Python Programming, Second Edition (2006)",class C2(object):,simpleclass,600 "Core Python Programming, Second Edition (2006)",class DevNull3(object):,simpleclass,600 "Core Python Programming, Second Edition (2006)",class C3(object):,simpleclass,600 "Core Python Programming, Second Edition (2006)",class FooFoo(object):,simpleclass,601 "Core Python Programming, Second Edition (2006)",class FileDescr(object):,simpleclass,602 "Core Python Programming, Second Edition (2006)",class MyFileVarClass(object):,simpleclass,603 "Core Python Programming, Second Edition (2006)",class ProtectAndHideX(object):,simpleclass,604 "Core Python Programming, Second Edition (2006)",class HideX(object):,simpleclass,605 "Core Python Programming, Second Edition (2006)",class PI(object):,simpleclass,606 "Core Python Programming, Second Edition (2006)",class HideX(object):,simpleclass,606 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,607 "Core Python Programming, Second Edition (2006)",class MetaC(type):,simpleclass,608 "Core Python Programming, Second Edition (2006)",class Foo(object):,simpleclass,609 "Core Python Programming, Second Edition (2006)",class ReqStrSugRepr(type):,simpleclass,609 "Core Python Programming, Second Edition (2006)",class ReqStrSugRepr(type):,simpleclass,610 "Core Python Programming, Second Edition (2006)",class Foo(object):,simpleclass,610 "Core Python Programming, Second Edition (2006)",class Bar(object):,simpleclass,610 "Core Python Programming, Second Edition (2006)",class FooBar(object):,simpleclass,610 "Core Python Programming, Second Edition (2006)",class FooBar(object):,simpleclass,611 "Core Python Programming, Second Edition (2006)",class MoneyFmt(object):,simpleclass,616 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,628 "Core Python Programming, Second Edition (2006)","class ... def foo(self):",simpleclass,628 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,629 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,629 "Core Python Programming, Second Edition (2006)",class C(object):,simpleclass,632 "Core Python Programming, Second Edition (2006)",class MyRequestHandler(SRH):,simpleclass,720 "Core Python Programming, Second Edition (2006)",class ThreadFunc(object):,simpleclass,787 "Core Python Programming, Second Edition (2006)",class DirList(object):,simpleclass,813 "Core Python Programming, Second Edition (2006)",class GTKapp(object):,simpleclass,825 "Core Python Programming, Second Edition (2006)",class Retriever(object):,simpleclass,841 "Core Python Programming, Second Edition (2006)",class AdvCGI(object):,simpleclass,877 "Core Python Programming, Second Edition (2006)",class MyHandler(BaseHTTPRequestHandler):,simpleclass,884 "Core Python Programming, Second Edition (2006)",class MySQLAlchemy(object):,simpleclass,918 "Core Python Programming, Second Edition (2006)",class MySQLObject(object):,simpleclass,920 "Core Python Programming, Second Edition (2006)",raise exclass(),raise,394 "Core Python Programming, Second Edition (2006)","raise exclass, instance Raise exception using instance (normally an instance of exclass)",raise,394 "Core Python Programming, Second Edition (2006)",raise ValueError(e),raise,467 "Core Python Programming, Second Edition (2006)",raise error_proto(resp),raise,758 "Core Python Programming, Second Edition (2006)",assert 1 == 1,assert,396 "Core Python Programming, Second Edition (2006)",assert 2 + 2 == 2 * 2,assert,396 "Core Python Programming, Second Edition (2006)","assert len(['my list', 12]) < 10",assert,396 "Core Python Programming, Second Edition (2006)","assert range(3) == [0, 1, 2]",assert,396 "Core Python Programming, Second Edition (2006)",assert 1 == 0,assert,396 "Core Python Programming, Second Edition (2006)","assert command: >>> assert 1 == 0, 'One does not equal zero silly!'",assert,396 "Core Python Programming, Second Edition (2006)","Now we have the obligatory usage example: if passwd == user.pass",pass,293 "Core Python Programming, Second Edition (2006)","wd: ret_str = ""pass",pass,293 "Core Python Programming, Second Edition (2006)","else: ret_str = ""invalid pass",pass,293 "Core Python Programming, Second Edition (2006)","def foo_func(): pass",pass,309 "Core Python Programming, Second Edition (2006)",">>> class myClass(object): ... pass",pass,370 "Core Python Programming, Second Edition (2006)","5 class NetworkError(IOError): 6 pass",pass,403 "Core Python Programming, Second Edition (2006)","8 class FileError(IOError): 9 pass",pass,403 "Core Python Programming, Second Edition (2006)","def bar(): pass",pass,427 "Core Python Programming, Second Edition (2006)","def foo(): pass",pass,487 "Core Python Programming, Second Edition (2006)","def cli_util(): pass",pass,504 "Core Python Programming, Second Edition (2006)","def myNoActionMethod(self): pass",pass,525 "Core Python Programming, Second Edition (2006)",">>> class C(object): ... pass",pass,528 "Core Python Programming, Second Edition (2006)",">>> class MyClass(object): ... pass",pass,537 "Core Python Programming, Second Edition (2006)",">>> class C(object): ... pass",pass,537 "Core Python Programming, Second Edition (2006)","class ClassicClassWithoutSuperclasses: pass",pass,549 "Core Python Programming, Second Edition (2006)","class B: pass",pass,560 "Core Python Programming, Second Edition (2006)","class D(B, C): pass",pass,560 "Core Python Programming, Second Edition (2006)","def __get__(self, obj, typ=None): pass",pass,599 "Core Python Programming, Second Edition (2006)","def __set__(self, obj, val): pass",pass,599 "Core Python Programming, Second Edition (2006)","44 except (OSError, ValueError), e: 45 pass",pass,603 "Core Python Programming, Second Edition (2006)","class CC: pass",pass,607 "Core Python Programming, Second Edition (2006)","def handle(self): pass",pass,721 "Core Python Programming, Second Edition (2006)","28 for i in nloops: 29 while locks[i].locked(): pass",pass,781 "Core Python Programming, Second Edition (2006)","for item in ['e-mail', 'net-surfing', 'homework', 'chat']:",forwithlist,44 "Core Python Programming, Second Edition (2006)","for eachNum in [0, 1, 2]:",forwithlist,45 "Core Python Programming, Second Edition (2006)","for counter in [0, 1, 2, 3]:",forwithlist,639 "Core Python Programming, Second Edition (2006)","for eachItem in [932, 'grail', 3.0, 'arrrghhh']:",forwithlist,639 "Core Python Programming, Second Edition (2006)","for i in [0, 10, 25, 50, 100]:",forwithlist,859 "Core Python Programming, Second Edition (2006)","for i in [0, 10, 25, 50, 100]:",forwithlist,863 "Core Python Programming, Second Edition (2006)","for eachNum in (.2, .7, 1.2, 1.7, -.2, -.7, -1.2, -1.7):",forwithtuple,143 "Core Python Programming, Second Edition (2006)","for eachMediaType in (45, '8-track tape', 'cassette'):",forwithtuple,222 "Core Python Programming, Second Edition (2006)","for tmpdir in ('/tmp', r'c:\temp'):",forwithtuple,348 "Core Python Programming, Second Edition (2006)","for animal in ('dog', 'cat', 'hamster', 'python'):",forwithtuple,822 "Core Python Programming, Second Edition (2006)","for animal in ('dog', 'cat', 'hamster', 'python'):",forwithtuple,823 "Core Python Programming, Second Edition (2006)","for animal in ('dog', 'cat','hamster', 'python'):",forwithtuple,826 "Core Python Programming, Second Edition (2006)","for funcType in ('handler', 'request'):",forwithtuple,846 "Core Python Programming, Second Edition (2006)","aList = [123, 'abc', 4.56, ['inner', 'list'], 7-9j]",nestedList,209 "Core Python Programming, Second Edition (2006)","mixup_list = [4.0, [1, 'x'], 'beef', -1.9+6j]",nestedList,211 "Core Python Programming, Second Edition (2006)","mixup_list = [4.0, [1, 'x'], 'beef', -1.9+6j]",nestedList,213 "Core Python Programming, Second Edition (2006)","person = ['name', ['savings', 100.00]]",nestedList,240 "Core Python Programming, Second Edition (2006)","person = ['name', ['savings', 100.00]]",nestedList,241 "Core Python Programming, Second Edition (2006)","setup(name=MOD, ext_modules=[ Extension(MOD, sources=['Extest2.c'])]",nestedList,942 "Core Python Programming, Second Edition (2006)","6 setup(name=MOD, ext_modules=[ 7 Extension(MOD, sources=['Extest2.c'])]",nestedList,942 "Core Python Programming, Second Edition (2006)","for i in vec1: ... for j in vec2:",fornested,612 "Core Python Programming, Second Edition (2006)",aDict = {'host': 'earth'},simpleDict,40 "Core Python Programming, Second Edition (2006)","17 CMDs = {'u': pushit, 'o': popit, 'v': viewstack}",simpleDict,224 "Core Python Programming, Second Edition (2006)","17 CMDs = {'e': enQ, 'd': deQ, 'v': viewQ}",simpleDict,228 "Core Python Programming, Second Edition (2006)","dict2 = {'name': 'earth', 'port': 80}",simpleDict,254 "Core Python Programming, Second Edition (2006)","dict2 = {'name': 'earth', 'port': 80}",simpleDict,255 "Core Python Programming, Second Edition (2006)","dict2 = {'name': 'earth', 'port': 80}",simpleDict,255 "Core Python Programming, Second Edition (2006)","dict3 = {3.2: 'xyz', 1: 'abc', '1': 3.14159}",simpleDict,256 "Core Python Programming, Second Edition (2006)",dict4 = {'abc': 123},simpleDict,258 "Core Python Programming, Second Edition (2006)",dict5 = {'abc': 456},simpleDict,258 "Core Python Programming, Second Edition (2006)","dict6 = {'abc': 123, 98.6: 37}",simpleDict,258 "Core Python Programming, Second Edition (2006)",dict7 = {'xyz': 123},simpleDict,258 "Core Python Programming, Second Edition (2006)","dict2 = {'host': 'earth', 'port': 80}",simpleDict,260 "Core Python Programming, Second Edition (2006)",cdict = {'fruits':1},simpleDict,261 "Core Python Programming, Second Edition (2006)",ddict = {'fruits':1},simpleDict,261 "Core Python Programming, Second Edition (2006)","dict2 = {'name': 'earth', 'port': 80}",simpleDict,263 "Core Python Programming, Second Edition (2006)","dict2= {'host':'earth', 'port':80}",simpleDict,267 "Core Python Programming, Second Edition (2006)","dict3= {'host':'venus', 'server':'http'}",simpleDict,267 "Core Python Programming, Second Edition (2006)","myDict = {'host': 'earth', 'port': 80}",simpleDict,267 "Core Python Programming, Second Edition (2006)","dict1 = {' foo':789, 'foo': 'xyz'}",simpleDict,269 "Core Python Programming, Second Edition (2006)","myDict = {'a': 1, 'b': 2, 'c': 3, 'd': 4}",simpleDict,315 "Core Python Programming, Second Edition (2006)","aDict = {'host': 'earth', 'port': 80}",simpleDict,370 "Core Python Programming, Second Edition (2006)","6 ops = {'+': add, '-': sub}",simpleDict,422 "Core Python Programming, Second Edition (2006)",aDict = {'z': 9},simpleDict,443 "Core Python Programming, Second Edition (2006)",x = {2003: 'poe2'},simpleDict,542 "Core Python Programming, Second Edition (2006)","14 increment=2, entryfield_validate={'validator': 15 'integer', 'min': 2, 'max': 12}",simpleDict,823 "Core Python Programming, Second Edition (2006)","aDict = { 'name': 'Georgina Garcia', 'hmdir': '~ggarcia' }",simpleDict,844 "Core Python Programming, Second Edition (2006)","7 RDBMSs = {'s': 'sqlite', 'm': 'mysql', 'g': 'gadfly'}",simpleDict,910 "Core Python Programming, Second Edition (2006)","logfile = open('/tmp/mylog.txt', 'a')",openfunc,29 "Core Python Programming, Second Edition (2006)",Section 2.15. Files and the open() and file(),openfunc,48 "Core Python Programming, Second Edition (2006)",2.15. Files and the open() and file(),openfunc,48 "Core Python Programming, Second Edition (2006)","handle = open(file_name, access_mode = 'r')",openfunc,48 "Core Python Programming, Second Edition (2006)","If open() is successful, a file object will be returned as the handle (handle)",openfunc,48 "Core Python Programming, Second Edition (2006)","fobj = open(filename, 'r')",openfunc,48 "Core Python Programming, Second Edition (2006)",Section 2.15. Files and the open() and file(),openfunc,49 "Core Python Programming, Second Edition (2006)",The file() built-in function was recently added to Python. It is identical to open(),openfunc,49 "Core Python Programming, Second Edition (2006)","29 fobj = open(fname, 'w')",openfunc,84 "Core Python Programming, Second Edition (2006)","errors occur. In this case (lines 1213), we are checking to see if the file open()",openfunc,87 "Core Python Programming, Second Edition (2006)","As you can imagine, here is what urlopen()",openfunc,177 "Core Python Programming, Second Edition (2006)","f = open('C:\windows\temp\readme.txt', 'r')",openfunc,184 "Core Python Programming, Second Edition (2006)","f = open('C:\windows\temp\readme.txt', 'r')",openfunc,184 "Core Python Programming, Second Edition (2006)","f = open(r'C:\windows\temp\readme.txt', 'r')",openfunc,184 "Core Python Programming, Second Edition (2006)","11 f = open(FILE, ""w"")",openfunc,200 "Core Python Programming, Second Edition (2006)","15 f = open(FILE, ""r"")",openfunc,200 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,223 "Core Python Programming, Second Edition (2006)","f = open('numbers', 'w')",openfunc,280 "Core Python Programming, Second Edition (2006)","f = open('numbers', 'r')",openfunc,280 "Core Python Programming, Second Edition (2006)",myFile = open('config-win.txt'),openfunc,314 "Core Python Programming, Second Edition (2006)","f = open('hhga.txt', 'r')",openfunc,318 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,321 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,321 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,321 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,322 "Core Python Programming, Second Edition (2006)","f = open('/etc/motd', 'r')",openfunc,322 "Core Python Programming, Second Edition (2006)",return max(len(x.strip()) for x in open('/etc/motd')),openfunc,322 "Core Python Programming, Second Edition (2006)",The open() built-in function (see below),openfunc,330 "Core Python Programming, Second Edition (2006)",Section 9.2. File Built-in Functions [open() and file(),openfunc,331 "Core Python Programming, Second Edition (2006)",9.2. File Built-in Functions [open() and file(),openfunc,331 "Core Python Programming, Second Edition (2006)","As the key to opening file doors, the open() [and file()",openfunc,331 "Core Python Programming, Second Edition (2006)",initiate the file input/output (I/O) process. The open(),openfunc,331 "Core Python Programming, Second Edition (2006)",IOError exceptionwe will cover errors and exceptions in the next chapter. The basic syntax of the open(),openfunc,331 "Core Python Programming, Second Edition (2006)","file_object = open(file_name, access_mode='r', buffering=-1)",openfunc,331 "Core Python Programming, Second Edition (2006)","programmer, these are the same file open modes used for the C library function fopen()",openfunc,331 "Core Python Programming, Second Edition (2006)",There are other modes supported by fopen() that will work with Python's open(),openfunc,331 "Core Python Programming, Second Edition (2006)",including text files. Here is an entry from the Linux manual page for fopen(),openfunc,331 "Core Python Programming, Second Edition (2006)",Section 9.2. File Built-in Functions [open() and file(),openfunc,332 "Core Python Programming, Second Edition (2006)",fp = open('/etc/motd'),openfunc,332 "Core Python Programming, Second Edition (2006)","fp = open('test', 'w')",openfunc,332 "Core Python Programming, Second Edition (2006)","fp = open('data', 'r+')",openfunc,332 "Core Python Programming, Second Edition (2006)","fp = open(r'c:\io.sys', 'rb')",openfunc,332 "Core Python Programming, Second Edition (2006)",Both open() and file(),openfunc,332 "Core Python Programming, Second Edition (2006)",Section 9.2. File Built-in Functions [open() and file(),openfunc,333 "Core Python Programming, Second Edition (2006)","you see references to open(), you can mentally substitute file()",openfunc,333 "Core Python Programming, Second Edition (2006)","For foreseeable versions of Python, both open() and file()",openfunc,333 "Core Python Programming, Second Edition (2006)","same thing. Generally, the accepted style is that you use open() for reading/writing files, while file()",openfunc,333 "Core Python Programming, Second Edition (2006)",Once open(),openfunc,334 "Core Python Programming, Second Edition (2006)","f = open('myFile', 'r')",openfunc,335 "Core Python Programming, Second Edition (2006)","only one reference exists to a file, say, fp = open(...)",openfunc,336 "Core Python Programming, Second Edition (2006)","f = open(filename, 'r')",openfunc,336 "Core Python Programming, Second Edition (2006)","f = open(filename, 'r')",openfunc,337 "Core Python Programming, Second Edition (2006)","fobj = open(filename, 'w')",openfunc,338 "Core Python Programming, Second Edition (2006)","f = open('/tmp/x', 'w+')",openfunc,338 "Core Python Programming, Second Edition (2006)",that third argument to open()),openfunc,342 "Core Python Programming, Second Edition (2006)","Low-level operating system open [for files, use the standard open()",openfunc,346 "Core Python Programming, Second Edition (2006)","27 fobj = open('test', 'w')",openfunc,348 "Core Python Programming, Second Edition (2006)",48 fobj = open(path),openfunc,348 "Core Python Programming, Second Edition (2006)","fobj = open('test', 'w')",openfunc,351 "Core Python Programming, Second Edition (2006)",fobj = open(path),openfunc,351 "Core Python Programming, Second Edition (2006)","and popen2 modules), the fdopen() file object used in low-level file access (os module)",openfunc,359 "Core Python Programming, Second Edition (2006)",find out more about file()/open(),openfunc,359 "Core Python Programming, Second Edition (2006)","f = open(""blah"")",openfunc,370 "Core Python Programming, Second Edition (2006)","13 log = open('cardlog.txt', 'w')",openfunc,383 "Core Python Programming, Second Edition (2006)","log = open('logfile.txt', 'w')",openfunc,384 "Core Python Programming, Second Edition (2006)",reimplements more diagnostic versions of open() [myopen()] and socket.connect(),openfunc,403 "Core Python Programming, Second Edition (2006)",The fileArgs() function is used only by myopen() (see below),openfunc,406 "Core Python Programming, Second Edition (2006)","Like its sibling myconnect(), myopen()",openfunc,407 "Core Python Programming, Second Edition (2006)",need the name for now and use our new myopen(),openfunc,407 "Core Python Programming, Second Edition (2006)",Improving open(). Create a wrapper for the open(),openfunc,414 "Core Python Programming, Second Edition (2006)",13 f = open(webpage),openfunc,438 "Core Python Programming, Second Edition (2006)","myList.extend(map(upper, open('x').readlines()))",openfunc,524 "Core Python Programming, Second Edition (2006)",f = WrapMe(open('/etc/motd')),openfunc,590 "Core Python Programming, Second Edition (2006)",difference is that rather than using the open(),openfunc,593 "Core Python Programming, Second Edition (2006)",class. Even the parameters are exactly the same as for open(),openfunc,593 "Core Python Programming, Second Edition (2006)","5 self.file = open(fn, mode, buf)",openfunc,593 "Core Python Programming, Second Edition (2006)","As you can see, the only call out of the ordinary is the first one to CapOpen() rather than open()",openfunc,593 "Core Python Programming, Second Edition (2006)","can use either open() or CapOpen(), but chose only CapOpen()",openfunc,594 "Core Python Programming, Second Edition (2006)",either CapOpen() or open(),openfunc,620 "Core Python Programming, Second Edition (2006)",f = open('xcount.py'),openfunc,635 "Core Python Programming, Second Edition (2006)","f = open(filename, 'r')",openfunc,646 "Core Python Programming, Second Edition (2006)",14.5.2. os.popen(),openfunc,650 "Core Python Programming, Second Edition (2006)",The popen() function is a combination of a file object and the system(),openfunc,650 "Core Python Programming, Second Edition (2006)","program and then to access it like a file. If the program requires input, then you would call popen()",openfunc,650 "Core Python Programming, Second Edition (2006)","internal manipulation or store that string to a log file, we could, using popen()",openfunc,650 "Core Python Programming, Second Edition (2006)",f = os.popen('uname -a'),openfunc,650 "Core Python Programming, Second Edition (2006)","As you can see, popen() returns a file-like object; also notice that readline()",openfunc,651 "Core Python Programming, Second Edition (2006)",Replacing os.popen(),openfunc,653 "Core Python Programming, Second Edition (2006)",The syntax for creating an instance of Popen is only slightly more complex than calling the os.popen(),openfunc,653 "Core Python Programming, Second Edition (2006)","f = Popen(('uname', '-a'), stdout=PIPE)",openfunc,653 "Core Python Programming, Second Edition (2006)","f = Popen('who', stdout=PIPE)",openfunc,654 "Core Python Programming, Second Edition (2006)",Provides additional functionality on top of os.popen(),openfunc,661 "Core Python Programming, Second Edition (2006)",standard input and manipulates or otherwise outputs the data. Use os.popen(),openfunc,662 "Core Python Programming, Second Edition (2006)","f = open('whodata.txt', 'r')",openfunc,686 "Core Python Programming, Second Edition (2006)","invoking another program from within ours, we call upon the os.popen()",openfunc,687 "Core Python Programming, Second Edition (2006)",Section 14.5.2. Although os.popen(),openfunc,687 "Core Python Programming, Second Edition (2006)","6 f = popen('who', 'r')",openfunc,687 "Core Python Programming, Second Edition (2006)",urllib.urlopen() or urllib.urlretrieve(),openfunc,836 "Core Python Programming, Second Edition (2006)","be looking at in this upcoming section include: urlopen(), urlretrieve(), quote(), unquote()",openfunc,839 "Core Python Programming, Second Edition (2006)",object returned by urlopen(),openfunc,839 "Core Python Programming, Second Edition (2006)",urllib.urlopen(),openfunc,839 "Core Python Programming, Second Edition (2006)",urlopen(),openfunc,839 "Core Python Programming, Second Edition (2006)","urlopen(urlstr, postQueryData=None)",openfunc,839 "Core Python Programming, Second Edition (2006)",urlopen(),openfunc,839 "Core Python Programming, Second Edition (2006)","scheme is passed in, urlopen()",openfunc,839 "Core Python Programming, Second Edition (2006)","When a successful connection is made, urlopen()",openfunc,840 "Core Python Programming, Second Edition (2006)",Table 20.4. urllib.urlopen(),openfunc,840 "Core Python Programming, Second Edition (2006)",urlopen(),openfunc,840 "Core Python Programming, Second Edition (2006)","module, introduced back in the 1.6 days (mostly as an experimental module). It too, has a urlopen()",openfunc,840 "Core Python Programming, Second Edition (2006)","Rather than reading from the URL like urlopen() does, urlretrieve()",openfunc,841 "Core Python Programming, Second Edition (2006)","urlopen(urlstr, postQueryData=None)",openfunc,845 "Core Python Programming, Second Edition (2006)",27 f = urllib2.urlopen(url),openfunc,846 "Core Python Programming, Second Edition (2006)",calling urlopen(),openfunc,846 "Core Python Programming, Second Edition (2006)",that you use urlopen() instead of urlretrieve(),openfunc,889 "Core Python Programming, Second Edition (2006)",If we use our friend urllib.urlopen(),openfunc,953 "Core Python Programming, Second Edition (2006)","12 u = urlopen(URL % ','.join(ticks))",openfunc,955 "Core Python Programming, Second Edition (2006)","34 u = urlopen(URL % ','.join(TICKS))",openfunc,968 "Core Python Programming, Second Edition (2006)",f = open(raw_input('enter filename: ')),openfunc,992 "Core Python Programming, Second Edition (2006)",It makes no difference whether we use open() or capOpen(),openfunc,997 "Core Python Programming, Second Edition (2006)",os.popen( ),openfunc,1095 "Core Python Programming, Second Edition (2006)",sys.stdout.write('Hello World!\n'),write,56 "Core Python Programming, Second Edition (2006)",that the standard output write(),write,56 "Core Python Programming, Second Edition (2006)","explicitly because, unlike the print statement, write()",write,56 "Core Python Programming, Second Edition (2006)",import sys; x = 'foo'; sys.stdout.write(x + '\n'),write,66 "Core Python Programming, Second Edition (2006)",12 f.write(bytes_out),write,200 "Core Python Programming, Second Edition (2006)",f.write('%d\n' % i),write,280 "Core Python Programming, Second Edition (2006)",The write() built-in method has the opposite functionality as read() and readline(),write,334 "Core Python Programming, Second Edition (2006)","Note that there is no ""writeline()"" method since it would be equivalent to calling write()",write,335 "Core Python Programming, Second Edition (2006)","Similarly, output methods like write() or writelines()",write,335 "Core Python Programming, Second Edition (2006)","Here we ask the user for one line at a time, and send them out to the file. Our call to the write()",write,338 "Core Python Programming, Second Edition (2006)",f.write('test line 1\n'),write,338 "Core Python Programming, Second Edition (2006)",f.write('test line 2\n'),write,338 "Core Python Programming, Second Edition (2006)",file.write(str),write,340 "Core Python Programming, Second Edition (2006)",read()/write(),write,346 "Core Python Programming, Second Edition (2006)",28 fobj.write('foo\n'),write,348 "Core Python Programming, Second Edition (2006)",29 fobj.write('bar\n'),write,348 "Core Python Programming, Second Edition (2006)",fobj.write('foo\n'),write,351 "Core Python Programming, Second Edition (2006)",fobj.write('bar\n'),write,351 "Core Python Programming, Second Edition (2006)",32 log.write('ignored: %s' % result),write,383 "Core Python Programming, Second Edition (2006)","log.write(""*** caught exception in module\n"")",write,384 "Core Python Programming, Second Edition (2006)","log.write(""*** no exceptions caught\n"")",write,384 "Core Python Programming, Second Edition (2006)",log.write('no txns this month\n'),write,387 "Core Python Programming, Second Edition (2006)",sys.stdout.write('foo'),write,524 "Core Python Programming, Second Edition (2006)",f.write('delegation example\n'),write,593 "Core Python Programming, Second Edition (2006)",f.write('faye is good\n'),write,593 "Core Python Programming, Second Edition (2006)",f.write('at delegating\n'),write,593 "Core Python Programming, Second Edition (2006)","13 def write(self, line)",write,593 "Core Python Programming, Second Edition (2006)",14 self.file.write(line.upper()),write,593 "Core Python Programming, Second Edition (2006)",instance that behaves like a file object. All attributes other than write(),write,594 "Core Python Programming, Second Edition (2006)",14 self.wfile.write('[%s] %s' % (ctime(),write,720 "Core Python Programming, Second Edition (2006)",to get the client message and write(),write,721 "Core Python Programming, Second Edition (2006)",13 self.transport.write(data),write,726 "Core Python Programming, Second Edition (2006)",calling the write(),write,727 "Core Python Programming, Second Edition (2006)",data downloaded. This is the write(),write,740 "Core Python Programming, Second Edition (2006)",sys.stdout.write('Hello World!\n'),write,971 "Core Python Programming, Second Edition (2006)",System.out.write('Hello World!\n'),write,971 "Core Python Programming, Second Edition (2006)",file.write(str),write,1029 "Core Python Programming, Second Edition (2006)","30 fobj.writelines(['%s%s' % (x, ls) for x in all])",writelines,84 "Core Python Programming, Second Edition (2006)",The file object's writelines() method then takes the resulting list of lines (now with terminators),writelines,86 "Core Python Programming, Second Edition (2006)",The writelines() method operates on a list just like readlines(),writelines,334 "Core Python Programming, Second Edition (2006)",must be added to the end of each line before writelines(),writelines,334 "Core Python Programming, Second Edition (2006)",file.writelines(seq),writelines,340 "Core Python Programming, Second Edition (2006)",Implement a writelines(),writelines,620 "Core Python Programming, Second Edition (2006)","uppercase, similar to the way the regular writelines()",writelines,620 "Core Python Programming, Second Edition (2006)","write(). Note that once you are done, writelines()",writelines,620 "Core Python Programming, Second Edition (2006)",Add an argument to the writelines(),writelines,620 "Core Python Programming, Second Edition (2006)",file.writelines(seq),writelines,1029 "Core Python Programming, Second Edition (2006)",16 bytes_in = f.read(),read,200 "Core Python Programming, Second Edition (2006)","StringIO/cStringIO Treats long strings just like a file object, i.e., read(), seek()",read,239 "Core Python Programming, Second Edition (2006)",The read(),read,334 "Core Python Programming, Second Edition (2006)",When reading lines in from a file using file input methods like read(),read,335 "Core Python Programming, Second Edition (2006)","can be used in lower-level operations such as those featured in the os module, i.e., os.read()",read,336 "Core Python Programming, Second Edition (2006)",file.read(size=-1),read,339 "Core Python Programming, Second Edition (2006)","start_new_thread(function, args, kwargs=None)",read,778 "Core Python Programming, Second Edition (2006)",The key function of the thread module is start_new_thread(). Its syntax is exactly that of the apply(),read,778 "Core Python Programming, Second Edition (2006)","18 thread.start_new_thread(loop0, ())",read,779 "Core Python Programming, Second Edition (2006)","19 thread.start_new_thread(loop1, ())",read,779 "Core Python Programming, Second Edition (2006)",start_new_thread(),read,779 "Core Python Programming, Second Edition (2006)",between instantiating Thread [calling Thread()] and invoking thread.start_new_thread(),read,786 "Core Python Programming, Second Edition (2006)",8 class MyThread(threading.Thread),read,788 "Core Python Programming, Second Edition (2006)","29 t = MyThread(loop, (i, loops[i])",read,789 "Core Python Programming, Second Edition (2006)",6 class MyThread(threading.Thread),read,790 "Core Python Programming, Second Edition (2006)","38 t = MyThread(funcs[i], (n,)",read,791 "Core Python Programming, Second Edition (2006)",currentThread(),read,792 "Core Python Programming, Second Edition (2006)","37 t = MyThread(funcs[i], (q, nloops)",read,794 "Core Python Programming, Second Edition (2006)","read methods such as f.read(), f.readline(), f.readlines(), f.close(), and f.fileno()",read,840 "Core Python Programming, Second Edition (2006)",f.read([bytes]),read,840 "Core Python Programming, Second Edition (2006)","be executed, i.e., none of read(), readline(), or readlines()",read,997 "Core Python Programming, Second Edition (2006)",file.read(size=-1),read,1029 "Core Python Programming, Second Edition (2006)",f.readline(),readline,184 "Core Python Programming, Second Edition (2006)",File objects produce an iterator that calls the readline(),readline,314 "Core Python Programming, Second Edition (2006)",len(string.strip(f.readline())),readline,321 "Core Python Programming, Second Edition (2006)",The readline(),readline,334 "Core Python Programming, Second Edition (2006)","not a concern, then programmers could call file.readline()",readline,335 "Core Python Programming, Second Edition (2006)",the call to readline(),readline,336 "Core Python Programming, Second Edition (2006)",for eachLine in f.readline(),readline,336 "Core Python Programming, Second Edition (2006)",because every line from the text file already contains a NEWLINE. readline() and readlines(),readline,338 "Core Python Programming, Second Edition (2006)",f.readline(),readline,339 "Core Python Programming, Second Edition (2006)",f.readline(),readline,339 "Core Python Programming, Second Edition (2006)",f.readline(),readline,339 "Core Python Programming, Second Edition (2006)",file.readline(size=-1),readline,339 "Core Python Programming, Second Edition (2006)",Returns the next line in the file [similar to file.readline(),readline,339 "Core Python Programming, Second Edition (2006)",f.readline(),readline,590 "Core Python Programming, Second Edition (2006)",print f.readline(),readline,590 "Core Python Programming, Second Edition (2006)",data = f.readline(),readline,650 "Core Python Programming, Second Edition (2006)",data = f.readline(),readline,653 "Core Python Programming, Second Edition (2006)",15 self.rfile.readline())),readline,720 "Core Python Programming, Second Edition (2006)","StreamRequestHandler class treats input and output sockets as file-like objects, so we will use readline()",readline,721 "Core Python Programming, Second Edition (2006)",Upload data from ufile file object (using ufile.readline()),readline,746 "Core Python Programming, Second Edition (2006)",f.readline(),readline,840 "Core Python Programming, Second Edition (2006)",28 print f.readline(),readline,846 "Core Python Programming, Second Edition (2006)",file.readline(size=-1),readline,1029 "Core Python Programming, Second Edition (2006)",Returns the next line in the file [similar to file.readline(),readline,1029 "Core Python Programming, Second Edition (2006)",import sys,importfunc,29 "Core Python Programming, Second Edition (2006)",import the,importfunc,36 "Core Python Programming, Second Edition (2006)",import that,importfunc,56 "Core Python Programming, Second Edition (2006)",import module_name,importfunc,56 "Core Python Programming, Second Edition (2006)",import sys,importfunc,56 "Core Python Programming, Second Edition (2006)",import the,importfunc,62 "Core Python Programming, Second Edition (2006)",import sys,importfunc,62 "Core Python Programming, Second Edition (2006)","import not",importfunc,72 "Core Python Programming, Second Edition (2006)",import with,importfunc,73 "Core Python Programming, Second Edition (2006)",import this,importfunc,75 "Core Python Programming, Second Edition (2006)",import use,importfunc,77 "Core Python Programming, Second Edition (2006)",import any,importfunc,78 "Core Python Programming, Second Edition (2006)",import of,importfunc,78 "Core Python Programming, Second Edition (2006)",import the,importfunc,78 "Core Python Programming, Second Edition (2006)",import os,importfunc,84 "Core Python Programming, Second Edition (2006)",import the,importfunc,85 "Core Python Programming, Second Edition (2006)",import types,importfunc,110 "Core Python Programming, Second Edition (2006)",import the,importfunc,119 "Core Python Programming, Second Edition (2006)",import division,importfunc,134 "Core Python Programming, Second Edition (2006)",import new,importfunc,135 "Core Python Programming, Second Edition (2006)",import math,importfunc,142 "Core Python Programming, Second Edition (2006)",import math,importfunc,143 "Core Python Programming, Second Edition (2006)",import the,importfunc,149 "Core Python Programming, Second Edition (2006)",import string,importfunc,173 "Core Python Programming, Second Edition (2006)",import string,importfunc,174 "Core Python Programming, Second Edition (2006)",import string,importfunc,176 "Core Python Programming, Second Edition (2006)",import the,importfunc,177 "Core Python Programming, Second Edition (2006)",import string,importfunc,177 "Core Python Programming, Second Edition (2006)",import copy,importfunc,241 "Core Python Programming, Second Edition (2006)",import os,importfunc,318 "Core Python Programming, Second Edition (2006)",import string,importfunc,321 "Core Python Programming, Second Edition (2006)",import the,importfunc,338 "Core Python Programming, Second Edition (2006)",import sys,importfunc,343 "Core Python Programming, Second Edition (2006)",import those,importfunc,345 "Core Python Programming, Second Edition (2006)",import os,importfunc,345 "Core Python Programming, Second Edition (2006)",import os,importfunc,348 "Core Python Programming, Second Edition (2006)",import os,importfunc,350 "Core Python Programming, Second Edition (2006)",import modules,importfunc,358 "Core Python Programming, Second Edition (2006)",import sys,importfunc,378 "Core Python Programming, Second Edition (2006)",import 3rd_party_module,importfunc,384 "Core Python Programming, Second Edition (2006)",import an,importfunc,384 "Core Python Programming, Second Edition (2006)",import it,importfunc,389 "Core Python Programming, Second Edition (2006)",import module,importfunc,399 "Core Python Programming, Second Edition (2006)",import sys,importfunc,411 "Core Python Programming, Second Edition (2006)",import this,importfunc,412 "Core Python Programming, Second Edition (2006)",import math,importfunc,414 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,458 "Core Python Programming, Second Edition (2006)",import generators,importfunc,473 "Core Python Programming, Second Edition (2006)",import modules,importfunc,483 "Core Python Programming, Second Edition (2006)",import xxx,importfunc,483 "Core Python Programming, Second Edition (2006)",import mymodule,importfunc,484 "Core Python Programming, Second Edition (2006)",import mymodule,importfunc,484 "Core Python Programming, Second Edition (2006)",import the,importfunc,488 "Core Python Programming, Second Edition (2006)",import Statement,importfunc,489 "Core Python Programming, Second Edition (2006)",import module1,importfunc,489 "Core Python Programming, Second Edition (2006)",import moduleN,importfunc,489 "Core Python Programming, Second Edition (2006)",import multiple,importfunc,489 "Core Python Programming, Second Edition (2006)",import statements,importfunc,489 "Core Python Programming, Second Edition (2006)",import statements,importfunc,489 "Core Python Programming, Second Edition (2006)",import tips,importfunc,489 "Core Python Programming, Second Edition (2006)",import Statement,importfunc,489 "Core Python Programming, Second Edition (2006)",import specific,importfunc,490 "Core Python Programming, Second Edition (2006)",import feature,importfunc,490 "Core Python Programming, Second Edition (2006)",import longmodulename,importfunc,491 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,491 "Core Python Programming, Second Edition (2006)",import brings,importfunc,492 "Core Python Programming, Second Edition (2006)",import all,importfunc,492 "Core Python Programming, Second Edition (2006)",import and,importfunc,493 "Core Python Programming, Second Edition (2006)",import imptee,importfunc,494 "Core Python Programming, Second Edition (2006)",import statement,importfunc,494 "Core Python Programming, Second Edition (2006)",import __future__,importfunc,494 "Core Python Programming, Second Edition (2006)",import specific,importfunc,494 "Core Python Programming, Second Edition (2006)",import of,importfunc,495 "Core Python Programming, Second Edition (2006)",import speed,importfunc,495 "Core Python Programming, Second Edition (2006)",import from,importfunc,495 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,495 "Core Python Programming, Second Edition (2006)",import of,importfunc,495 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,495 "Core Python Programming, Second Edition (2006)",import statement,importfunc,497 "Core Python Programming, Second Edition (2006)",import the,importfunc,497 "Core Python Programming, Second Edition (2006)",import sys,importfunc,497 "Core Python Programming, Second Edition (2006)",import on,importfunc,498 "Core Python Programming, Second Edition (2006)",import does,importfunc,498 "Core Python Programming, Second Edition (2006)",import and,importfunc,499 "Core Python Programming, Second Edition (2006)","import like",importfunc,499 "Core Python Programming, Second Edition (2006)",import in,importfunc,499 "Core Python Programming, Second Edition (2006)",import to,importfunc,500 "Core Python Programming, Second Edition (2006)",import subpackages,importfunc,500 "Core Python Programming, Second Edition (2006)",import with,importfunc,500 "Core Python Programming, Second Edition (2006)",import all,importfunc,500 "Core Python Programming, Second Edition (2006)",import of,importfunc,500 "Core Python Programming, Second Edition (2006)",import Analog,importfunc,501 "Core Python Programming, Second Edition (2006)",import feature,importfunc,501 "Core Python Programming, Second Edition (2006)",import feature,importfunc,501 "Core Python Programming, Second Edition (2006)",import comes,importfunc,501 "Core Python Programming, Second Edition (2006)",import feature,importfunc,501 "Core Python Programming, Second Edition (2006)","import syntax",importfunc,501 "Core Python Programming, Second Edition (2006)",import statements,importfunc,501 "Core Python Programming, Second Edition (2006)",import Analog,importfunc,501 "Core Python Programming, Second Edition (2006)",import dial,importfunc,501 "Core Python Programming, Second Edition (2006)",import setup,importfunc,501 "Core Python Programming, Second Edition (2006)","import in",importfunc,501 "Core Python Programming, Second Edition (2006)",import sys,importfunc,503 "Core Python Programming, Second Edition (2006)",import sys,importfunc,503 "Core Python Programming, Second Edition (2006)",import a,importfunc,503 "Core Python Programming, Second Edition (2006)",import the,importfunc,504 "Core Python Programming, Second Edition (2006)",import the,importfunc,504 "Core Python Programming, Second Edition (2006)",import modules,importfunc,504 "Core Python Programming, Second Edition (2006)",import omh4cli,importfunc,505 "Core Python Programming, Second Edition (2006)",import fails,importfunc,505 "Core Python Programming, Second Edition (2006)",import a,importfunc,505 "Core Python Programming, Second Edition (2006)",import omh4cli,importfunc,505 "Core Python Programming, Second Edition (2006)",import name,importfunc,505 "Core Python Programming, Second Edition (2006)",import of,importfunc,505 "Core Python Programming, Second Edition (2006)",import of,importfunc,505 "Core Python Programming, Second Edition (2006)",import statements,importfunc,506 "Core Python Programming, Second Edition (2006)","import statements",importfunc,506 "Core Python Programming, Second Edition (2006)",import of,importfunc,506 "Core Python Programming, Second Edition (2006)",import omh4cli,importfunc,506 "Core Python Programming, Second Edition (2006)",import statement,importfunc,506 "Core Python Programming, Second Edition (2006)",import omh4cli,importfunc,506 "Core Python Programming, Second Edition (2006)",import of,importfunc,506 "Core Python Programming, Second Edition (2006)",import of,importfunc,507 "Core Python Programming, Second Edition (2006)",import are,importfunc,507 "Core Python Programming, Second Edition (2006)",import it,importfunc,507 "Core Python Programming, Second Edition (2006)",import is,importfunc,507 "Core Python Programming, Second Edition (2006)",import this,importfunc,507 "Core Python Programming, Second Edition (2006)",import Python,importfunc,507 "Core Python Programming, Second Edition (2006)",import this,importfunc,507 "Core Python Programming, Second Edition (2006)",import a,importfunc,508 "Core Python Programming, Second Edition (2006)",import only,importfunc,508 "Core Python Programming, Second Edition (2006)",import a,importfunc,509 "Core Python Programming, Second Edition (2006)",import syntax,importfunc,509 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,509 "Core Python Programming, Second Edition (2006)",import them,importfunc,509 "Core Python Programming, Second Edition (2006)","import of",importfunc,571 "Core Python Programming, Second Edition (2006)",import the,importfunc,586 "Core Python Programming, Second Edition (2006)",import the,importfunc,595 "Core Python Programming, Second Edition (2006)",import os,importfunc,602 "Core Python Programming, Second Edition (2006)",import pickle,importfunc,602 "Core Python Programming, Second Edition (2006)",import types,importfunc,607 "Core Python Programming, Second Edition (2006)",import the,importfunc,616 "Core Python Programming, Second Edition (2006)",import moneyfmt,importfunc,616 "Core Python Programming, Second Edition (2006)",import the,importfunc,644 "Core Python Programming, Second Edition (2006)",import statements,importfunc,644 "Core Python Programming, Second Edition (2006)",import import1,importfunc,644 "Core Python Programming, Second Edition (2006)",import import2,importfunc,645 "Core Python Programming, Second Edition (2006)",import import1,importfunc,645 "Core Python Programming, Second Edition (2006)",import import1,importfunc,645 "Core Python Programming, Second Edition (2006)",import import2,importfunc,645 "Core Python Programming, Second Edition (2006)",import import1,importfunc,645 "Core Python Programming, Second Edition (2006)",import import1,importfunc,645 "Core Python Programming, Second Edition (2006)",import mechanism,importfunc,647 "Core Python Programming, Second Edition (2006)",import and,importfunc,647 "Core Python Programming, Second Edition (2006)",import a,importfunc,649 "Core Python Programming, Second Edition (2006)",import os,importfunc,650 "Core Python Programming, Second Edition (2006)",import os,importfunc,650 "Core Python Programming, Second Edition (2006)",import os,importfunc,650 "Core Python Programming, Second Edition (2006)",import os,importfunc,653 "Core Python Programming, Second Edition (2006)",import sys,importfunc,657 "Core Python Programming, Second Edition (2006)",import sys,importfunc,657 "Core Python Programming, Second Edition (2006)",import lines,importfunc,690 "Core Python Programming, Second Edition (2006)",import the,importfunc,691 "Core Python Programming, Second Edition (2006)",import all,importfunc,711 "Core Python Programming, Second Edition (2006)",import all,importfunc,715 "Core Python Programming, Second Edition (2006)",import our,importfunc,720 "Core Python Programming, Second Edition (2006)",import of,importfunc,726 "Core Python Programming, Second Edition (2006)",import the,importfunc,737 "Core Python Programming, Second Edition (2006)",import the,importfunc,737 "Core Python Programming, Second Edition (2006)",import ftplib,importfunc,739 "Core Python Programming, Second Edition (2006)",import os,importfunc,739 "Core Python Programming, Second Edition (2006)",import socket,importfunc,739 "Core Python Programming, Second Edition (2006)",import the,importfunc,740 "Core Python Programming, Second Edition (2006)",import that,importfunc,744 "Core Python Programming, Second Edition (2006)",import nntplib,importfunc,747 "Core Python Programming, Second Edition (2006)",import socket,importfunc,747 "Core Python Programming, Second Edition (2006)",import random,importfunc,749 "Core Python Programming, Second Edition (2006)",import statements,importfunc,750 "Core Python Programming, Second Edition (2006)",import poplib,importfunc,757 "Core Python Programming, Second Edition (2006)",import statements,importfunc,760 "Core Python Programming, Second Edition (2006)",import the,importfunc,775 "Core Python Programming, Second Edition (2006)",import thread,importfunc,775 "Core Python Programming, Second Edition (2006)",import thread,importfunc,775 "Core Python Programming, Second Edition (2006)",import thread,importfunc,779 "Core Python Programming, Second Edition (2006)",import thread,importfunc,780 "Core Python Programming, Second Edition (2006)",import the,importfunc,781 "Core Python Programming, Second Edition (2006)",import threading,importfunc,785 "Core Python Programming, Second Edition (2006)",import threading,importfunc,787 "Core Python Programming, Second Edition (2006)",import threading,importfunc,788 "Core Python Programming, Second Edition (2006)",import this,importfunc,789 "Core Python Programming, Second Edition (2006)",import threading,importfunc,790 "Core Python Programming, Second Edition (2006)",import the,importfunc,800 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,800 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,800 "Core Python Programming, Second Edition (2006)",import _tkinter,importfunc,800 "Core Python Programming, Second Edition (2006)",import the,importfunc,802 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,804 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,806 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,807 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,808 "Core Python Programming, Second Edition (2006)",import the,importfunc,809 "Core Python Programming, Second Edition (2006)",import os,importfunc,813 "Core Python Programming, Second Edition (2006)",import wx,importfunc,824 "Core Python Programming, Second Edition (2006)",import pygtk,importfunc,825 "Core Python Programming, Second Edition (2006)",import gtk,importfunc,825 "Core Python Programming, Second Edition (2006)",import pango,importfunc,825 "Core Python Programming, Second Edition (2006)",import three,importfunc,826 "Core Python Programming, Second Edition (2006)",import urllib2,importfunc,846 "Core Python Programming, Second Edition (2006)",import cgi,importfunc,857 "Core Python Programming, Second Edition (2006)",import cgi,importfunc,859 "Core Python Programming, Second Edition (2006)",import cgi,importfunc,862 "Core Python Programming, Second Edition (2006)",import lines,importfunc,880 "Core Python Programming, Second Edition (2006)",import MySQLdb,importfunc,906 "Core Python Programming, Second Edition (2006)",import psycopg,importfunc,908 "Core Python Programming, Second Edition (2006)",import pgdb,importfunc,908 "Core Python Programming, Second Edition (2006)",import the,importfunc,909 "Core Python Programming, Second Edition (2006)",import sqlite3,importfunc,909 "Core Python Programming, Second Edition (2006)",import os,importfunc,910 "Core Python Programming, Second Edition (2006)",import sqlite3,importfunc,911 "Core Python Programming, Second Edition (2006)",import the,importfunc,917 "Core Python Programming, Second Edition (2006)",import os,importfunc,918 "Core Python Programming, Second Edition (2006)",import MySQLdb,importfunc,918 "Core Python Programming, Second Edition (2006)",import _mysql_exceptions,importfunc,918 "Core Python Programming, Second Edition (2006)",import os,importfunc,920 "Core Python Programming, Second Edition (2006)",import MySQLdb,importfunc,920 "Core Python Programming, Second Edition (2006)",import _mysql_exceptions,importfunc,920 "Core Python Programming, Second Edition (2006)",import hides,importfunc,932 "Core Python Programming, Second Edition (2006)",import from,importfunc,937 "Core Python Programming, Second Edition (2006)",import and,importfunc,940 "Core Python Programming, Second Edition (2006)",import Extest,importfunc,943 "Core Python Programming, Second Edition (2006)",import csv,importfunc,953 "Core Python Programming, Second Edition (2006)",import the,importfunc,958 "Core Python Programming, Second Edition (2006)",import Tkinter,importfunc,959 "Core Python Programming, Second Edition (2006)",import all,importfunc,969 "Core Python Programming, Second Edition (2006)",import sys,importfunc,971 "Core Python Programming, Second Edition (2006)",import sys,importfunc,973 "Core Python Programming, Second Edition (2006)",import math,importfunc,986 "Core Python Programming, Second Edition (2006)",import string,importfunc,988 "Core Python Programming, Second Edition (2006)",import keyword,importfunc,988 "Core Python Programming, Second Edition (2006)",import math,importfunc,991 "Core Python Programming, Second Edition (2006)",import sys,importfunc,992 "Core Python Programming, Second Edition (2006)",import mymodule,importfunc,996 "Core Python Programming, Second Edition (2006)",import socket,importfunc,1001 "Core Python Programming, Second Edition (2006)",import csv,importfunc,1008 "Core Python Programming, Second Edition (2006)","import not",importfunc,1010 "Core Python Programming, Second Edition (2006)","import module",importfunc,1032 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1046 "Core Python Programming, Second Edition (2006)","import extensions",importfunc,1060 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1065 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1068 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1074 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1074 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1074 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1074 "Core Python Programming, Second Edition (2006)",import cycles,importfunc,1075 "Core Python Programming, Second Edition (2006)","import names",importfunc,1075 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,1075 "Core Python Programming, Second Edition (2006)","import cProfile",importfunc,1087 "Core Python Programming, Second Edition (2006)","import extended",importfunc,1087 "Core Python Programming, Second Edition (2006)",import statement,importfunc,1087 "Core Python Programming, Second Edition (2006)",import cycles,importfunc,1087 "Core Python Programming, Second Edition (2006)","import names",importfunc,1087 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,1087 "Core Python Programming, Second Edition (2006)","import profile",importfunc,1087 "Core Python Programming, Second Edition (2006)",import hooks,importfunc,1089 "Core Python Programming, Second Edition (2006)",import 2nd,importfunc,1124 "Core Python Programming, Second Edition (2006)",from types import IntType,importfromsimple,111 "Core Python Programming, Second Edition (2006)",from __future__ import division,importfromsimple,134 "Core Python Programming, Second Edition (2006)",from decimal import Decimal,importfromsimple,149 "Core Python Programming, Second Edition (2006)",from string import Template,importfromsimple,182 "Core Python Programming, Second Edition (2006)",from urllib import urlretrieve,importfromsimple,438 "Core Python Programming, Second Edition (2006)",from random import randint,importfromsimple,450 "Core Python Programming, Second Edition (2006)",from random import randint,importfromsimple,451 "Core Python Programming, Second Edition (2006)",from random import randint,importfromsimple,451 "Core Python Programming, Second Edition (2006)",from functools import partial,importfromsimple,456 "Core Python Programming, Second Edition (2006)",from functools import partial,importfromsimple,458 "Core Python Programming, Second Edition (2006)",from time import time,importfromsimple,466 "Core Python Programming, Second Edition (2006)",from random import randint,importfromsimple,474 "Core Python Programming, Second Edition (2006)","from the same module, import lines",importfromsimple,490 "Core Python Programming, Second Edition (2006)",from Python programmers: the ability to import modules,importfromsimple,490 "Core Python Programming, Second Edition (2006)",from cgi import FieldStorage,importfromsimple,491 "Core Python Programming, Second Edition (2006)",from module import var,importfromsimple,492 "Core Python Programming, Second Edition (2006)",from __future__ import new_feature,importfromsimple,494 "Core Python Programming, Second Edition (2006)",from Phone import Mobile,importfromsimple,499 "Core Python Programming, Second Edition (2006)",from Phone.Mobile import Analog,importfromsimple,500 "Core Python Programming, Second Edition (2006)",from Phone.Mobile.Analog import dial,importfromsimple,500 "Core Python Programming, Second Edition (2006)",from __future__ starting in version 2.5.) You can read more about absolute import in,importfromsimple,501 "Core Python Programming, Second Edition (2006)",from Analog import dial,importfromsimple,501 "Core Python Programming, Second Edition (2006)",from Phone.Mobile.Analog import dial,importfromsimple,501 "Core Python Programming, Second Edition (2006)",from cli4vof import cli4vof,importfromsimple,504 "Core Python Programming, Second Edition (2006)","from the main handler, we import the",importfromsimple,505 "Core Python Programming, Second Edition (2006)",from cli4vof import cli4vof,importfromsimple,505 "Core Python Programming, Second Edition (2006)",from cli4vof import cli4vof,importfromsimple,505 "Core Python Programming, Second Edition (2006)",from cli4vof import cli4vof,importfromsimple,506 "Core Python Programming, Second Edition (2006)","from cli4vof, the import of",importfromsimple,506 "Core Python Programming, Second Edition (2006)",from mymod import C,importfromsimple,528 "Core Python Programming, Second Edition (2006)",from random import choice,importfromsimple,577 "Core Python Programming, Second Edition (2006)",from randseq import RandSeq,importfromsimple,579 "Core Python Programming, Second Edition (2006)",from math import pi,importfromsimple,605 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,608 "Core Python Programming, Second Edition (2006)",from warnings import warn,importfromsimple,609 "Core Python Programming, Second Edition (2006)",from warnings import warn,importfromsimple,610 "Core Python Programming, Second Edition (2006)",from os.path import getsize,importfromsimple,636 "Core Python Programming, Second Edition (2006)",from subprocess import call,importfromsimple,653 "Core Python Programming, Second Edition (2006)","from Python in 2.5, and import either",importfromsimple,676 "Core Python Programming, Second Edition (2006)",from os import popen,importfromsimple,687 "Core Python Programming, Second Edition (2006)",from re import split,importfromsimple,687 "Core Python Programming, Second Edition (2006)",from string import lowercase,importfromsimple,689 "Core Python Programming, Second Edition (2006)",from sys import maxint,importfromsimple,689 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,689 "Core Python Programming, Second Edition (2006)","from these modules, rather than importing the entire module, we choose in this case to import only",importfromsimple,690 "Core Python Programming, Second Edition (2006)",from these modules. Our decision to use from-import rather than import was,importfromsimple,690 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,709 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,714 "Core Python Programming, Second Edition (2006)",from SocketServer import TCPServer,importfromsimple,720 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,720 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,725 "Core Python Programming, Second Edition (2006)",from ftplib import FTP,importfromsimple,737 "Core Python Programming, Second Edition (2006)",from ftplib import FTP,importfromsimple,738 "Core Python Programming, Second Edition (2006)",from nntplib import NNTP,importfromsimple,745 "Core Python Programming, Second Edition (2006)",from nntplib import NNTP,importfromsimple,746 "Core Python Programming, Second Edition (2006)",from smtplib import SMTP,importfromsimple,754 "Core Python Programming, Second Edition (2006)",from poplib import POP3,importfromsimple,757 "Core Python Programming, Second Edition (2006)",from poplib import POP3,importfromsimple,758 "Core Python Programming, Second Edition (2006)",from smtplib import SMTP,importfromsimple,760 "Core Python Programming, Second Edition (2006)",from poplib import POP3,importfromsimple,760 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,760 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,790 "Core Python Programming, Second Edition (2006)",from myThread import MyThread,importfromsimple,790 "Core Python Programming, Second Edition (2006)",from random import randint,importfromsimple,793 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,793 "Core Python Programming, Second Edition (2006)",from Queue import Queue,importfromsimple,793 "Core Python Programming, Second Edition (2006)",from myThread import MyThread,importfromsimple,793 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,813 "Core Python Programming, Second Edition (2006)",from sys import argv,importfromsimple,841 "Core Python Programming, Second Edition (2006)",from htmllib import HTMLParser,importfromsimple,841 "Core Python Programming, Second Edition (2006)",from urllib import urlretrieve,importfromsimple,841 "Core Python Programming, Second Edition (2006)",from cStringIO import StringIO,importfromsimple,841 "Core Python Programming, Second Edition (2006)",from base64 import encodestring,importfromsimple,846 "Core Python Programming, Second Edition (2006)",from urllib import quote_plus,importfromsimple,862 "Core Python Programming, Second Edition (2006)",from string import capwords,importfromsimple,862 "Core Python Programming, Second Edition (2006)",from cgi import FieldStorage,importfromsimple,877 "Core Python Programming, Second Edition (2006)",from os import environ,importfromsimple,877 "Core Python Programming, Second Edition (2006)",from cStringIO import StringIO,importfromsimple,877 "Core Python Programming, Second Edition (2006)",from pyPgSQL import PgSQL,importfromsimple,908 "Core Python Programming, Second Edition (2006)",from urllib import urlopen,importfromsimple,953 "Core Python Programming, Second Edition (2006)",from time import ctime,importfromsimple,955 "Core Python Programming, Second Edition (2006)",from urllib import urlopen,importfromsimple,955 "Core Python Programming, Second Edition (2006)",from Tkinter import Tk,importfromsimple,959 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,959 "Core Python Programming, Second Edition (2006)",from tkMessageBox import showwarning,importfromsimple,959 "Core Python Programming, Second Edition (2006)",from Tkinter import Tk,importfromsimple,961 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,961 "Core Python Programming, Second Edition (2006)",from tkMessageBox import showwarning,importfromsimple,961 "Core Python Programming, Second Edition (2006)",from Tkinter import Tk,importfromsimple,963 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,963 "Core Python Programming, Second Edition (2006)",from tkMessageBox import showwarning,importfromsimple,963 "Core Python Programming, Second Edition (2006)",from Tkinter import Tk,importfromsimple,965 "Core Python Programming, Second Edition (2006)",from time import sleep,importfromsimple,965 "Core Python Programming, Second Edition (2006)",from tkMessageBox import showwarning,importfromsimple,965 "Core Python Programming, Second Edition (2006)",from Tkinter import Tk,importfromsimple,968 "Core Python Programming, Second Edition (2006)",from tkMessageBox import showwarning,importfromsimple,968 "Core Python Programming, Second Edition (2006)",from urllib import urlopen,importfromsimple,968 "Core Python Programming, Second Edition (2006)",from java.lang import System,importfromsimple,971 "Core Python Programming, Second Edition (2006)",from pawt import swing,importfromsimple,973 "Core Python Programming, Second Edition (2006)",from mymodule import foo,importfromsimple,996 "Core Python Programming, Second Edition (2006)",self.name = nm # class instance (data) attribute,simpleattr,53 "Core Python Programming, Second Edition (2006)",self.name = nm # set name,simpleattr,515 "Core Python Programming, Second Edition (2006)",self.phone = ph # set phone#,simpleattr,515 "Core Python Programming, Second Edition (2006)",self.phone = newph,simpleattr,515 "Core Python Programming, Second Edition (2006)",self.empid = id,simpleattr,516 "Core Python Programming, Second Edition (2006)",self.email = em,simpleattr,516 "Core Python Programming, Second Edition (2006)",self.email = newem,simpleattr,516 "Core Python Programming, Second Edition (2006)",self.empid = id,simpleattr,545 "Core Python Programming, Second Edition (2006)",self.email = em,simpleattr,545 "Core Python Programming, Second Edition (2006)",self.name = Name(nm) # create Name instance,simpleattr,548 "Core Python Programming, Second Edition (2006)",self.phone = Phone(ph) # create Phone instance,simpleattr,548 "Core Python Programming, Second Edition (2006)",self.foo = 100,simpleattr,564 "Core Python Programming, Second Edition (2006)","self.value = round(val, 2)",simpleattr,572 "Core Python Programming, Second Edition (2006)",self.hr = hr # assign hours,simpleattr,574 "Core Python Programming, Second Edition (2006)",self.min = min # assign minutes,simpleattr,574 "Core Python Programming, Second Edition (2006)",self.hr += other.hr,simpleattr,576 "Core Python Programming, Second Edition (2006)",self.min += other.min,simpleattr,576 "Core Python Programming, Second Edition (2006)",self.__data = obj,simpleattr,588 "Core Python Programming, Second Edition (2006)",self.name = name,simpleattr,600 "Core Python Programming, Second Edition (2006)",self.__x = ~x,simpleattr,604 "Core Python Programming, Second Edition (2006)",self.x = x,simpleattr,605 "Core Python Programming, Second Edition (2006)",self.__x = ~x,simpleattr,605 "Core Python Programming, Second Edition (2006)",self.x = x,simpleattr,606 "Core Python Programming, Second Edition (2006)",self.__x = ~x,simpleattr,607 "Core Python Programming, Second Edition (2006)",self.res = self.func(*self.args),simpleattr,788 "Core Python Programming, Second Edition (2006)",self.dirs.config(selectbackground='red'),simpleattr,814 "Core Python Programming, Second Edition (2006)",self.cookies[tag] = \,simpleattr,877 "Core Python Programming, Second Edition (2006)",self.cookies[tag] = \,simpleattr,877 "Core Python Programming, Second Edition (2006)",self.cookies['user'] == '':,simpleattr,878 "Core Python Programming, Second Edition (2006)",self.cookies['user'] = '',simpleattr,879 "Core Python Programming, Second Edition (2006)",self.error = 'At least one language required.',simpleattr,880 "Core Python Programming, Second Edition (2006)",self.fn = '',simpleattr,880 "Core Python Programming, Second Edition (2006)",counter += 1,assignIncrement,43 "Core Python Programming, Second Edition (2006)",x += 1,assignIncrement,69 "Core Python Programming, Second Edition (2006)",anInt += 1,assignIncrement,123 "Core Python Programming, Second Edition (2006)",warn += 1,assignIncrement,292 "Core Python Programming, Second Edition (2006)",count += 1,assignIncrement,299 "Core Python Programming, Second Edition (2006)",count += 1,assignIncrement,299 "Core Python Programming, Second Edition (2006)",for (eachVal = 2; eachVal < 19; eachVal += 3) {,assignIncrement,304 "Core Python Programming, Second Edition (2006)",25 oops += 1,assignIncrement,422 "Core Python Programming, Second Edition (2006)",count[0] += 1,assignIncrement,463 "Core Python Programming, Second Edition (2006)",count += 1,assignIncrement,475 "Core Python Programming, Second Edition (2006)",InstCt.count += 1,assignIncrement,533 "Core Python Programming, Second Edition (2006)",C.version += 0.1 # update (only) via class,assignIncrement,540 "Core Python Programming, Second Edition (2006)",C.spam += 100 # update class attribute,assignIncrement,542 "Core Python Programming, Second Edition (2006)",C.spam += 200 # update class attribute again,assignIncrement,542 "Core Python Programming, Second Edition (2006)","place"" operators, for example, __iadd__(). This is for supporting an operation like mon += tue and having",assignIncrement,576 "Core Python Programming, Second Edition (2006)",mon += tue,assignIncrement,576 "Core Python Programming, Second Edition (2006)",24 self.hr += other.hr,assignIncrement,577 "Core Python Programming, Second Edition (2006)",25 self.min += other.min,assignIncrement,577 "Core Python Programming, Second Edition (2006)",x += 1,assignIncrement,635 "Core Python Programming, Second Edition (2006)",17 em += choice(lowercase),assignIncrement,689 "Core Python Programming, Second Edition (2006)",22 dn += choice(lowercase),assignIncrement,689 "Core Python Programming, Second Edition (2006)",75 count += 1,assignIncrement,749 "Core Python Programming, Second Edition (2006)",69 langStr += AdvCGI.langItem % \,assignIncrement,878 "Core Python Programming, Second Edition (2006)",41 row += 1,assignIncrement,968 "Core Python Programming, Second Edition (2006)",subtot += int(raw_input('enter a number: ')),assignIncrement,983 "Core Python Programming, Second Edition (2006)",i += 1,assignIncrement,992 "Core Python Programming, Second Edition (2006)",def foo(debug=True):,funcdefault,52 "Core Python Programming, Second Edition (2006)","def func(posargs, defarg1=dval1, defarg2=dval2,...):",funcdefault,436 "Core Python Programming, Second Edition (2006)","def taxMe(cost, rate=0.0825):",funcdefault,436 "Core Python Programming, Second Edition (2006)","def net_conn(host, port=80, stype='tcp'):",funcdefault,437 "Core Python Programming, Second Edition (2006)","def usuallyAdd2(x, y=2):",funcdefault,447 "Core Python Programming, Second Edition (2006)","def reduce(bin_func, seq, init=None):",funcdefault,454 "Core Python Programming, Second Edition (2006)",def counter(start_at=0):,funcdefault,463 "Core Python Programming, Second Edition (2006)",def counter(start_at=0):,funcdefault,475 "Core Python Programming, Second Edition (2006)",def countToFour3(n=1):,funcdefault,477 "Core Python Programming, Second Edition (2006)",def my_exit_func(old_exit = prev_exit_func):,funcdefault,657 "Core Python Programming, Second Edition (2006)",def partition(N=5):,funcdefault,747 "Core Python Programming, Second Edition (2006)","def partition(start=0,stop=1,eps=5):",funcdefault,749 "Core Python Programming, Second Edition (2006)",def partition(N=5):,funcdefault,749 "Core Python Programming, Second Edition (2006)","def filename(self, url, deffile='index.htm'):",funcdefault,841 "Core Python Programming, Second Edition (2006)",range(),rangefunc,44 "Core Python Programming, Second Edition (2006)",range(),rangefunc,44 "Core Python Programming, Second Edition (2006)",range(),rangefunc,45 "Core Python Programming, Second Edition (2006)",range(),rangefunc,45 "Core Python Programming, Second Edition (2006)",range() function has been often seen with len(),rangefunc,45 "Core Python Programming, Second Edition (2006)",range(),rangefunc,46 "Core Python Programming, Second Edition (2006)","range([[start, ]stop[,step])",rangefunc,58 "Core Python Programming, Second Edition (2006)",range(),rangefunc,60 "Core Python Programming, Second Edition (2006)","range(), a sibling of the range()",rangefunc,98 "Core Python Programming, Second Edition (2006)",range() generates an unusually large data set. You can find out more about range(),rangefunc,98 "Core Python Programming, Second Edition (2006)",range(),rangefunc,98 "Core Python Programming, Second Edition (2006)","range(-1, 100)",rangefunc,103 "Core Python Programming, Second Edition (2006)",range() Takes the same input as range(),rangefunc,150 "Core Python Programming, Second Edition (2006)",range(),rangefunc,163 "Core Python Programming, Second Edition (2006)","range(-1, -len(s), -1)",rangefunc,164 "Core Python Programming, Second Edition (2006)",range(),rangefunc,164 "Core Python Programming, Second Edition (2006)","range(-1, -len(s), -1))",rangefunc,164 "Core Python Programming, Second Edition (2006)","range(256) (e.g., between 0 and 255)",rangefunc,187 "Core Python Programming, Second Edition (2006)",range(65536),rangefunc,187 "Core Python Programming, Second Edition (2006)",range(1114112) or 0x000000-0x110000. If a value does not fall within the allowable range(s),rangefunc,187 "Core Python Programming, Second Edition (2006)",range(256),rangefunc,187 "Core Python Programming, Second Edition (2006)",range(1114112),rangefunc,197 "Core Python Programming, Second Edition (2006)",range(),rangefunc,219 "Core Python Programming, Second Edition (2006)",range(),rangefunc,219 "Core Python Programming, Second Edition (2006)","range(1,3)])",rangefunc,263 "Core Python Programming, Second Edition (2006)",range(),rangefunc,289 "Core Python Programming, Second Edition (2006)",range() built-in function (which we will discuss in more detail below),rangefunc,302 "Core Python Programming, Second Edition (2006)",range(len(nameList)),rangefunc,302 "Core Python Programming, Second Edition (2006)",range(),rangefunc,302 "Core Python Programming, Second Edition (2006)",range(),rangefunc,303 "Core Python Programming, Second Edition (2006)",range(),rangefunc,303 "Core Python Programming, Second Edition (2006)",range(),rangefunc,303 "Core Python Programming, Second Edition (2006)",range(),rangefunc,303 "Core Python Programming, Second Edition (2006)","range(start, end, step=1)",rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,304 "Core Python Programming, Second Edition (2006)","range(2, 19, 3)",rangefunc,304 "Core Python Programming, Second Edition (2006)","range(3, 7)",rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,304 "Core Python Programming, Second Edition (2006)",range(end),rangefunc,304 "Core Python Programming, Second Edition (2006)","range(start, end)",rangefunc,304 "Core Python Programming, Second Edition (2006)",range(),rangefunc,305 "Core Python Programming, Second Edition (2006)",range(5),rangefunc,305 "Core Python Programming, Second Edition (2006)",range() is exactly the same as the long version of range(),rangefunc,305 "Core Python Programming, Second Edition (2006)",range(),rangefunc,305 "Core Python Programming, Second Edition (2006)",range(),rangefunc,305 "Core Python Programming, Second Edition (2006)","range(start=0, end, step=1)",rangefunc,305 "Core Python Programming, Second Edition (2006)",range(),rangefunc,305 "Core Python Programming, Second Edition (2006)","range() is similar to range() except that if you have a really large range list, xrange()",rangefunc,305 "Core Python Programming, Second Edition (2006)",range() will eventually become like xrange(),rangefunc,305 "Core Python Programming, Second Edition (2006)",range(6),rangefunc,316 "Core Python Programming, Second Edition (2006)","range()) is made (as opposed to threerange(), map()",rangefunc,316 "Core Python Programming, Second Edition (2006)",range(3) for y in range(5),rangefunc,317 "Core Python Programming, Second Edition (2006)",range(). What argument(s) could we give to the range(),rangefunc,325 "Core Python Programming, Second Edition (2006)",range(9),rangefunc,451 "Core Python Programming, Second Edition (2006)",range(6),rangefunc,452 "Core Python Programming, Second Edition (2006)",range(6),rangefunc,452 "Core Python Programming, Second Edition (2006)",range(len(pick))),rangefunc,912 "Core Python Programming, Second Edition (2006)","range(1,5)) for who, uid in randName()])",rangefunc,912 "Core Python Programming, Second Edition (2006)","range(1,5)))",rangefunc,912 "Core Python Programming, Second Edition (2006)","range(1,5)) for who, uid in randName()])",rangefunc,912 "Core Python Programming, Second Edition (2006)","range(1,5))",rangefunc,915 "Core Python Programming, Second Edition (2006)","range(1,5)])) for who, uid in randName()",rangefunc,919 "Core Python Programming, Second Edition (2006)","range(1,5)])))",rangefunc,921 "Core Python Programming, Second Edition (2006)",range(5)),rangefunc,983 "Core Python Programming, Second Edition (2006)","range(0, 21, 2)",rangefunc,986 "Core Python Programming, Second Edition (2006)",range(21),rangefunc,986 "Core Python Programming, Second Edition (2006)","range(1, 21, 2)",rangefunc,986 "Core Python Programming, Second Edition (2006)",range(21),rangefunc,986 "Core Python Programming, Second Edition (2006)",range(),rangefunc,991 "Core Python Programming, Second Edition (2006)",range(10),rangefunc,991 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1068 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1068 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1081 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1083 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1100 "Core Python Programming, Second Edition (2006)",range( ),rangefunc,1122 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,32 "Core Python Programming, Second Edition (2006)",def addMe2Me(x):,simplefunc,51 "Core Python Programming, Second Edition (2006)",def showname(self):,simplefunc,53 "Core Python Programming, Second Edition (2006)",def showver(self):,simplefunc,53 "Core Python Programming, Second Edition (2006)",def displayNumType(num):,simplefunc,109 "Core Python Programming, Second Edition (2006)",def displayNumType(num):,simplefunc,110 "Core Python Programming, Second Edition (2006)",def __nonzero__(self):,simplefunc,148 "Core Python Programming, Second Edition (2006)",def pushit():,simplefunc,224 "Core Python Programming, Second Edition (2006)",def popit():,simplefunc,224 "Core Python Programming, Second Edition (2006)",def viewstack():,simplefunc,224 "Core Python Programming, Second Edition (2006)",def showmenu():,simplefunc,224 "Core Python Programming, Second Edition (2006)",def enQ():,simplefunc,228 "Core Python Programming, Second Edition (2006)",def deQ():,simplefunc,228 "Core Python Programming, Second Edition (2006)",def viewQ():,simplefunc,228 "Core Python Programming, Second Edition (2006)",def showmenu():,simplefunc,228 "Core Python Programming, Second Edition (2006)",def foo1():,simplefunc,236 "Core Python Programming, Second Edition (2006)",def foo2():,simplefunc,236 "Core Python Programming, Second Edition (2006)",def foo3():,simplefunc,236 "Core Python Programming, Second Edition (2006)",def newuser():,simplefunc,270 "Core Python Programming, Second Edition (2006)",def showmenu():,simplefunc,270 "Core Python Programming, Second Edition (2006)",def showMaxFactor(num):,simplefunc,310 "Core Python Programming, Second Edition (2006)",def odd(n):,simplefunc,317 "Core Python Programming, Second Edition (2006)",def safe_float(obj):,simplefunc,374 "Core Python Programming, Second Edition (2006)",def safe_float(obj):,simplefunc,375 "Core Python Programming, Second Edition (2006)",def safe_float(obj):,simplefunc,376 "Core Python Programming, Second Edition (2006)",def safe_float(obj):,simplefunc,377 "Core Python Programming, Second Edition (2006)",def safe_float(obj):,simplefunc,382 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,382 "Core Python Programming, Second Edition (2006)",def hello():,simplefunc,417 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,418 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,418 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,418 "Core Python Programming, Second Edition (2006)",def foo(x):,simplefunc,420 "Core Python Programming, Second Edition (2006)",def doprob():,simplefunc,422 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,422 "Core Python Programming, Second Edition (2006)",def function_name(arguments):,simplefunc,425 "Core Python Programming, Second Edition (2006)",def helloSomeone(who):,simplefunc,425 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,425 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,426 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,426 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,426 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,426 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,427 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,428 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,428 "Core Python Programming, Second Edition (2006)",def staticFoo():,simplefunc,429 "Core Python Programming, Second Edition (2006)",def tsfunc(func):,simplefunc,431 "Core Python Programming, Second Edition (2006)",def wrappedFunc():,simplefunc,431 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,433 "Core Python Programming, Second Edition (2006)",def bar(argfunc):,simplefunc,433 "Core Python Programming, Second Edition (2006)",def firstNonBlank(lines):,simplefunc,438 "Core Python Programming, Second Edition (2006)",def firstLast(webpage):,simplefunc,438 "Core Python Programming, Second Edition (2006)",def true():,simplefunc,446 "Core Python Programming, Second Edition (2006)",def odd(n):,simplefunc,450 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,460 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,461 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,461 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,462 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,462 "Core Python Programming, Second Edition (2006)",def incr():,simplefunc,463 "Core Python Programming, Second Edition (2006)",def f1():,simplefunc,464 "Core Python Programming, Second Edition (2006)",def f2():,simplefunc,464 "Core Python Programming, Second Edition (2006)",def f3():,simplefunc,464 "Core Python Programming, Second Edition (2006)",def logged(when):,simplefunc,466 "Core Python Programming, Second Edition (2006)",def pre_logged(f):,simplefunc,466 "Core Python Programming, Second Edition (2006)",def post_logged(f):,simplefunc,466 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,468 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,469 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,469 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,470 "Core Python Programming, Second Edition (2006)",def proc1():,simplefunc,470 "Core Python Programming, Second Edition (2006)",def proc2():,simplefunc,470 "Core Python Programming, Second Edition (2006)",def factorial(n):,simplefunc,472 "Core Python Programming, Second Edition (2006)",def randGen(aList):,simplefunc,474 "Core Python Programming, Second Edition (2006)",def countToFour1():,simplefunc,477 "Core Python Programming, Second Edition (2006)",def countToFour2(n):,simplefunc,477 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,486 "Core Python Programming, Second Edition (2006)",def show():,simplefunc,493 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,497 "Core Python Programming, Second Edition (2006)",def omh4cli():,simplefunc,505 "Core Python Programming, Second Edition (2006)",def cli4vof():,simplefunc,505 "Core Python Programming, Second Edition (2006)",def cli4vof():,simplefunc,506 "Core Python Programming, Second Edition (2006)",def functionName(args):,simplefunc,522 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,546 "Core Python Programming, Second Edition (2006)",def foo(cls):,simplefunc,546 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,552 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,553 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,553 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,553 "Core Python Programming, Second Edition (2006)",def keys(self):,simplefunc,556 "Core Python Programming, Second Edition (2006)",def keys(self):,simplefunc,557 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,558 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,558 "Core Python Programming, Second Edition (2006)",def bar(self):,simplefunc,558 "Core Python Programming, Second Edition (2006)",def bar(self):,simplefunc,558 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,572 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,573 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,574 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,574 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,577 "Core Python Programming, Second Edition (2006)",def __iter__(self):,simplefunc,577 "Core Python Programming, Second Edition (2006)",def next(self):,simplefunc,577 "Core Python Programming, Second Edition (2006)",def __iter__(self):,simplefunc,579 "Core Python Programming, Second Edition (2006)",def get(self):,simplefunc,588 "Core Python Programming, Second Edition (2006)",def __repr__(self):,simplefunc,588 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,588 "Core Python Programming, Second Edition (2006)",def get(self):,simplefunc,591 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,593 "Core Python Programming, Second Edition (2006)",def __repr__(self):,simplefunc,593 "Core Python Programming, Second Edition (2006)",def foo(self):,simplefunc,601 "Core Python Programming, Second Edition (2006)",def barBar():,simplefunc,601 "Core Python Programming, Second Edition (2006)",def get_x(self):,simplefunc,604 "Core Python Programming, Second Edition (2006)",def get_x(self):,simplefunc,605 "Core Python Programming, Second Edition (2006)",def get_pi(dummy):,simplefunc,605 "Core Python Programming, Second Edition (2006)",def fget(self):,simplefunc,607 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,610 "Core Python Programming, Second Edition (2006)",def __repr__(self):,simplefunc,610 "Core Python Programming, Second Edition (2006)",def __str__(self):,simplefunc,610 "Core Python Programming, Second Edition (2006)",def foo(data):,simplefunc,612 "Core Python Programming, Second Edition (2006)",def keys(self):,simplefunc,621 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,638 "Core Python Programming, Second Edition (2006)",def foo():,simplefunc,642 "Core Python Programming, Second Edition (2006)",def bar():,simplefunc,642 "Core Python Programming, Second Edition (2006)",def usage():,simplefunc,657 "Core Python Programming, Second Edition (2006)",def handle(self):,simplefunc,720 "Core Python Programming, Second Edition (2006)",def connectionMade(self):,simplefunc,725 "Core Python Programming, Second Edition (2006)",def sendData(self):,simplefunc,726 "Core Python Programming, Second Edition (2006)",def connectionMade(self):,simplefunc,726 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,739 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,747 "Core Python Programming, Second Edition (2006)",def displayFirst20(data):,simplefunc,748 "Core Python Programming, Second Edition (2006)",def loop0():,simplefunc,776 "Core Python Programming, Second Edition (2006)",def loop1():,simplefunc,776 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,776 "Core Python Programming, Second Edition (2006)",def loop0():,simplefunc,779 "Core Python Programming, Second Edition (2006)",def loop1():,simplefunc,779 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,779 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,780 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,785 "Core Python Programming, Second Edition (2006)",def __call__(self):,simplefunc,787 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,787 "Core Python Programming, Second Edition (2006)",def run(self):,simplefunc,788 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,789 "Core Python Programming, Second Edition (2006)",def getResult(self):,simplefunc,790 "Core Python Programming, Second Edition (2006)",def run(self):,simplefunc,790 "Core Python Programming, Second Edition (2006)",def fib(x):,simplefunc,790 "Core Python Programming, Second Edition (2006)",def fac(x):,simplefunc,790 "Core Python Programming, Second Edition (2006)",def sum(x):,simplefunc,791 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,791 "Core Python Programming, Second Edition (2006)",def writeQ(queue):,simplefunc,793 "Core Python Programming, Second Edition (2006)",def readQ(queue):,simplefunc,793 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,794 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,815 "Core Python Programming, Second Edition (2006)",def OnInit(self):,simplefunc,824 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,824 "Core Python Programming, Second Edition (2006)",def handler_version(url):,simplefunc,846 "Core Python Programming, Second Edition (2006)",def request_version(url):,simplefunc,846 "Core Python Programming, Second Edition (2006)",def showForm():,simplefunc,859 "Core Python Programming, Second Edition (2006)",def process():,simplefunc,859 "Core Python Programming, Second Edition (2006)",def showError(error_str):,simplefunc,863 "Core Python Programming, Second Edition (2006)",def process():,simplefunc,863 "Core Python Programming, Second Edition (2006)",def showError(self):,simplefunc,878 "Core Python Programming, Second Edition (2006)",def do_GET(self):,simplefunc,884 "Core Python Programming, Second Edition (2006)",def setup():,simplefunc,910 "Core Python Programming, Second Edition (2006)",def randName():,simplefunc,912 "Core Python Programming, Second Edition (2006)",def update(cur):,simplefunc,912 "Core Python Programming, Second Edition (2006)",def delete(cur):,simplefunc,912 "Core Python Programming, Second Edition (2006)",def dbDump(cur):,simplefunc,912 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,912 "Core Python Programming, Second Edition (2006)",def insert(self):,simplefunc,919 "Core Python Programming, Second Edition (2006)",def update(self):,simplefunc,919 "Core Python Programming, Second Edition (2006)",def delete(self):,simplefunc,919 "Core Python Programming, Second Edition (2006)",def dbDump(self):,simplefunc,919 "Core Python Programming, Second Edition (2006)",def finish(self):,simplefunc,919 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,919 "Core Python Programming, Second Edition (2006)",def create(self):,simplefunc,921 "Core Python Programming, Second Edition (2006)",def insert(self):,simplefunc,921 "Core Python Programming, Second Edition (2006)",def update(self):,simplefunc,921 "Core Python Programming, Second Edition (2006)",def delete(self):,simplefunc,921 "Core Python Programming, Second Edition (2006)",def dbDump(self):,simplefunc,921 "Core Python Programming, Second Edition (2006)",def main():,simplefunc,921 "Core Python Programming, Second Edition (2006)",def drop(self):,simplefunc,922 "Core Python Programming, Second Edition (2006)",def excel():,simplefunc,959 "Core Python Programming, Second Edition (2006)",def word():,simplefunc,961 "Core Python Programming, Second Edition (2006)",def ppoint():,simplefunc,963 "Core Python Programming, Second Edition (2006)",def outlook():,simplefunc,965 "Core Python Programming, Second Edition (2006)",def excel():,simplefunc,968 "Core Python Programming, Second Edition (2006)",def quit(e):,simplefunc,973 "Core Python Programming, Second Edition (2006)",def sqcube():,simplefunc,986 "Core Python Programming, Second Edition (2006)",def cirsph():,simplefunc,986 "Core Python Programming, Second Edition (2006)",def isprime(num):,simplefunc,991 "Core Python Programming, Second Edition (2006)",return a (meaningful) value. (Functions that do not explicitly,return,26 "Core Python Programming, Second Edition (2006)","return a value by the programmer automatically return None, Python's equivalent to NULL.) An example",return,26 "Core Python Programming, Second Edition (2006)","return value is the abs() function, which takes a number and",return,26 "Core Python Programming, Second Edition (2006)",return values. Get all the,return,31 "Core Python Programming, Second Edition (2006)","return value, and then display the results to the user. This will",return,31 "Core Python Programming, Second Edition (2006)",return True,return,32 "Core Python Programming, Second Edition (2006)",return a Boolean value indicating the,return,33 "Core Python Programming, Second Edition (2006)","return values (None, Python's NULL object is returned by default if one is not given.)",return,51 "Core Python Programming, Second Edition (2006)",return (x + x),return,51 "Core Python Programming, Second Edition (2006)",return x + x,return,53 "Core Python Programming, Second Edition (2006)","return yield[d]",return,72 "Core Python Programming, Second Edition (2006)",return that which we borrowed back to the,return,81 "Core Python Programming, Second Edition (2006)","return value of raw_input(), which in",return,85 "Core Python Programming, Second Edition (2006)",return the user to,return,85 "Core Python Programming, Second Edition (2006)","return value of the call. We get the seemingly innocent output of <type 'int'>, but what you need to realize is",return,95 "Core Python Programming, Second Edition (2006)",return a zero value.,return,96 "Core Python Programming, Second Edition (2006)",return values,return,97 "Core Python Programming, Second Edition (2006)",return type object,return,105 "Core Python Programming, Second Edition (2006)",return value is a type object.,return,105 "Core Python Programming, Second Edition (2006)",return values as C's strcmp(). The comparison used is the one that applies for that type,return,106 "Core Python Programming, Second Edition (2006)","return values from repr() can be evaluated, not",return,107 "Core Python Programming, Second Edition (2006)",return the exact same string.,return,107 "Core Python Programming, Second Edition (2006)",return either TRue or False.,return,112 "Core Python Programming, Second Edition (2006)",return a long in Python 2.4,return,127 "Core Python Programming, Second Edition (2006)",return the numerical value,return,139 "Core Python Programming, Second Edition (2006)",return the,return,142 "Core Python Programming, Second Edition (2006)",return string,return,144 "Core Python Programming, Second Edition (2006)",return a string with,return,144 "Core Python Programming, Second Edition (2006)",return Booleans.,return,147 "Core Python Programming, Second Edition (2006)",return False,return,148 "Core Python Programming, Second Edition (2006)",return False,return,148 "Core Python Programming, Second Edition (2006)",return a calculation. The caller can perform any output desired with the return value.,return,153 "Core Python Programming, Second Edition (2006)",return the product of two numbers.,return,153 "Core Python Programming, Second Edition (2006)",return the total time in minutes only.,return,155 "Core Python Programming, Second Edition (2006)",return the Annual,return,155 "Core Python Programming, Second Edition (2006)",return true if the membership is confirmed and False otherwise.,return,159 "Core Python Programming, Second Edition (2006)","return value (or more accurately, a return value of None). There is",return,159 "Core Python Programming, Second Edition (2006)",return value but are only interested in one or more elements and not the,return,160 "Core Python Programming, Second Edition (2006)","return value, so we could not have used:",return,164 "Core Python Programming, Second Edition (2006)",return a signed string in Python 2.4.,return,180 "Core Python Programming, Second Edition (2006)",return an,return,182 "Core Python Programming, Second Edition (2006)","return self.pattern.sub(convert, self.template)",return,183 "Core Python Programming, Second Edition (2006)","return Escape",return,193 "Core Python Programming, Second Edition (2006)",return an equivalent decoded/encoded,return,202 "Core Python Programming, Second Edition (2006)",return match objects,return,206 "Core Python Programming, Second Edition (2006)",return a specific object from a list.,return,210 "Core Python Programming, Second Edition (2006)",return the result.,return,217 "Core Python Programming, Second Edition (2006)",return values diminishes as mixed objects come into,return,217 "Core Python Programming, Second Edition (2006)",return value!,return,222 "Core Python Programming, Second Edition (2006)",return a value. The most,return,222 "Core Python Programming, Second Edition (2006)","return None! Yes, it does fly in the face of string methods that do",return,222 "Core Python Programming, Second Edition (2006)",return values:,return,222 "Core Python Programming, Second Edition (2006)",return a new object. If returning an,return,222 "Core Python Programming, Second Edition (2006)","return objects. However, obviously the",return,222 "Core Python Programming, Second Edition (2006)",return the last or requested item from a list and return it to the,return,223 "Core Python Programming, Second Edition (2006)","return argument from a function that we would like to manipulate,",return,235 "Core Python Programming, Second Edition (2006)","return obj1, obj2, obj3",return,236 "Core Python Programming, Second Edition (2006)","return [obj1, obj2, obj3]",return,236 "Core Python Programming, Second Edition (2006)","return (obj1, obj2, obj3)",return,236 "Core Python Programming, Second Edition (2006)","return of three objects, which come back as a tuple of three",return,236 "Core Python Programming, Second Edition (2006)",return a string with the equivalent English text of each,return,247 "Core Python Programming, Second Edition (2006)","return the same time interval in hours and minutes,",return,247 "Core Python Programming, Second Edition (2006)","return another string similar to the input string, but",return,247 "Core Python Programming, Second Edition (2006)",return the index of the first,return,249 "Core Python Programming, Second Edition (2006)",return value.,return,249 "Core Python Programming, Second Edition (2006)",return it.,return,250 "Core Python Programming, Second Edition (2006)",return entry w/key,return,257 "Core Python Programming, Second Edition (2006)","return values other than -1, 0, or 1. The algorithm pursues",return,261 "Core Python Programming, Second Edition (2006)",return a positive number if,return,261 "Core Python Programming, Second Edition (2006)",return a,return,261 "Core Python Programming, Second Edition (2006)","return a positive number if, using the same key, the value in dict1 is",return,261 "Core Python Programming, Second Edition (2006)",return an iterator instead of a list,return,265 "Core Python Programming, Second Edition (2006)",return it.,return,267 "Core Python Programming, Second Edition (2006)",return lists. This can be unwieldy if such data,return,268 "Core Python Programming, Second Edition (2006)","return iterators, which by lazier",return,268 "Core Python Programming, Second Edition (2006)",return an integer.,return,269 "Core Python Programming, Second Edition (2006)",return as long as the user gives the login and correct password. New users cannot,return,270 "Core Python Programming, Second Edition (2006)",return as long as they remember their login,return,270 "Core Python Programming, Second Edition (2006)",return (shallow) copy of,return,284 "Core Python Programming, Second Edition (2006)",return an,return,284 "Core Python Programming, Second Edition (2006)","return one as output, but the",return,288 "Core Python Programming, Second Edition (2006)",return value or data is returned to the client who may either drop,return,300 "Core Python Programming, Second Edition (2006)","return true if any or all items traversed across an iterator have a Boolean true value,",return,313 "Core Python Programming, Second Edition (2006)",return n % 2,return,317 "Core Python Programming, Second Edition (2006)","return a value and ""pause"" the execution of that code and resume",return,319 "Core Python Programming, Second Edition (2006)",return a generator that,return,319 "Core Python Programming, Second Edition (2006)",return longest,return,321 "Core Python Programming, Second Edition (2006)",return longest,return,321 "Core Python Programming, Second Edition (2006)",return longest,return,321 "Core Python Programming, Second Edition (2006)",return max(allLineLens),return,322 "Core Python Programming, Second Edition (2006)",return longest,return,322 "Core Python Programming, Second Edition (2006)",return a file or file-,return,330 "Core Python Programming, Second Edition (2006)","return a string like the other two input methods. Instead, it reads all",return,334 "Core Python Programming, Second Edition (2006)",return it,return,339 "Core Python Programming, Second Edition (2006)",return leaf name,return,347 "Core Python Programming, Second Edition (2006)",return directory path,return,347 "Core Python Programming, Second Edition (2006)",return retval,return,375 "Core Python Programming, Second Edition (2006)",return value more flexible. Perhaps you documented that if a proper argument was passed to,return,375 "Core Python Programming, Second Edition (2006)",return a string indicating the problem with the input value. We modify our code one more time,return,375 "Core Python Programming, Second Edition (2006)",return retval,return,376 "Core Python Programming, Second Edition (2006)",return retval,return,382 "Core Python Programming, Second Edition (2006)",return retval,return,382 "Core Python Programming, Second Edition (2006)",return value of this method is the context object that will,return,390 "Core Python Programming, Second Edition (2006)",return value,return,390 "Core Python Programming, Second Edition (2006)","return value is thrown away. So for our file object example, its context",return,390 "Core Python Programming, Second Edition (2006)",return anything from __exit__() or return None or some other Boolean False,return,391 "Core Python Programming, Second Edition (2006)",return any object that has a Boolean TRue value. If an exception did,return,391 "Core Python Programming, Second Edition (2006)",return tuple(myargs),return,404 "Core Python Programming, Second Edition (2006)",return tuple(myargs),return,404 "Core Python Programming, Second Edition (2006)",return the set of arguments as a,return,406 "Core Python Programming, Second Edition (2006)",return an error message to present to the,return,409 "Core Python Programming, Second Edition (2006)","return a ""special"" value in the",return,410 "Core Python Programming, Second Edition (2006)",return value from a function call. This may be cumbersome because you may have to check return,return,410 "Core Python Programming, Second Edition (2006)",return None as a valid data value? Then you would have to come up with,return,410 "Core Python Programming, Second Edition (2006)","return value, perhaps a negative number. We probably do not need to remind you that negative",return,410 "Core Python Programming, Second Edition (2006)",return error,return,410 "Core Python Programming, Second Edition (2006)",return None to the callers so that they can open files without an,return,414 "Core Python Programming, Second Edition (2006)",return a complex number,return,415 "Core Python Programming, Second Edition (2006)",return value to the caller. Some functions are Boolean in,return,417 "Core Python Programming, Second Edition (2006)","return a value. As you will see below, Python",return,417 "Core Python Programming, Second Edition (2006)",return a value back to their callers and those that are more procedural in nature do not,return,417 "Core Python Programming, Second Edition (2006)",return anything at all. Languages that treat procedures as functions usually have a special type,return,417 "Core Python Programming, Second Edition (2006)","return nothing."" These functions default to a return type of ""void"" in",return,417 "Core Python Programming, Second Edition (2006)",return object type is None.,return,417 "Core Python Programming, Second Edition (2006)",return value is,return,417 "Core Python Programming, Second Edition (2006)",return only one value/object from a function in Python. One,return,418 "Core Python Programming, Second Edition (2006)",return more than a,return,418 "Core Python Programming, Second Edition (2006)","return ['xyz', 1000000, -98.6]",return,418 "Core Python Programming, Second Edition (2006)","return 'abc', [42, 'python'], ""Guido""",return,418 "Core Python Programming, Second Edition (2006)","return ('abc', [4-2j, 'python'], ""Guido"")",return,418 "Core Python Programming, Second Edition (2006)","return values are concerned, tuples can be saved in a number of ways. The following three",return,418 "Core Python Programming, Second Edition (2006)",return values are equivalent:,return,418 "Core Python Programming, Second Edition (2006)",return value in the,return,418 "Core Python Programming, Second Edition (2006)","return value is allowed, but in all honesty, Python follows the same tradition. The programmer is just",return,418 "Core Python Programming, Second Edition (2006)",return more than one object. Table 11.1 summarizes the,return,418 "Core Python Programming, Second Edition (2006)","return value. In Python, no direct type correlation can be made since Python is dynamically typed and functions",return,419 "Core Python Programming, Second Edition (2006)","return values of different types. Because overloading is not a feature, the programmer can use the",return,419 "Core Python Programming, Second Edition (2006)",return it.,return,423 "Core Python Programming, Second Edition (2006)","return ""Hello "" + str(who)",return,425 "Core Python Programming, Second Edition (2006)","return a decorator that takes the function as an argument. In other words, decomaker()",return,430 "Core Python Programming, Second Edition (2006)",return func(),return,431 "Core Python Programming, Second Edition (2006)",return wrappedFunc,return,431 "Core Python Programming, Second Edition (2006)",return value of the decorator is the,return,432 "Core Python Programming, Second Edition (2006)",return [func(eachNum) for eachNum in seq],return,434 "Core Python Programming, Second Edition (2006)",return cost + (cost * rate),return,436 "Core Python Programming, Second Edition (2006)",return cost * (1.0 + rate),return,437 "Core Python Programming, Second Edition (2006)",return eachLine,return,438 "Core Python Programming, Second Edition (2006)",return value packaged with the return,return,444 "Core Python Programming, Second Edition (2006)",return value of the function on success or False with the cause of failure.,return,444 "Core Python Programming, Second Edition (2006)",return the evaluation of an,return,446 "Core Python Programming, Second Edition (2006)",return True,return,446 "Core Python Programming, Second Edition (2006)",return True,return,446 "Core Python Programming, Second Edition (2006)",return x + y,return,447 "Core Python Programming, Second Edition (2006)",return x+y,return,447 "Core Python Programming, Second Edition (2006)",return z,return,447 "Core Python Programming, Second Edition (2006)",return value is the return value of,return,448 "Core Python Programming, Second Edition (2006)","return values in a list; if func is None, func behaves as the",return,448 "Core Python Programming, Second Edition (2006)","return value; if initial value init given, first compare will be of init and first",return,448 "Core Python Programming, Second Edition (2006)",return filtered_seq,return,449 "Core Python Programming, Second Edition (2006)",return value of False or true comes back (as per the definition of a Boolean functionensure that indeed,return,450 "Core Python Programming, Second Edition (2006)","return one or the other). If bool_func() returns TRue for any sequence item, that",return,450 "Core Python Programming, Second Edition (2006)",return sequence. When iteration over the entire sequence has been,return,450 "Core Python Programming, Second Edition (2006)",return n % 2,return,450 "Core Python Programming, Second Edition (2006)",return values.,return,452 "Core Python Programming, Second Edition (2006)",return value list that is comprised of each application of the function. So if your,return,452 "Core Python Programming, Second Edition (2006)",return mapped_seq,return,452 "Core Python Programming, Second Edition (2006)",return the result as a tuple into,return,453 "Core Python Programming, Second Edition (2006)",return res # return result,return,454 "Core Python Programming, Second Edition (2006)",return x+y,return,455 "Core Python Programming, Second Edition (2006)",return x+y,return,455 "Core Python Programming, Second Edition (2006)",return value.,return,456 "Core Python Programming, Second Edition (2006)",return global_str + local_str,return,460 "Core Python Programming, Second Edition (2006)",return count[0],return,463 "Core Python Programming, Second Edition (2006)",return incr,return,463 "Core Python Programming, Second Edition (2006)","return f(*args, **kargs)",return,466 "Core Python Programming, Second Edition (2006)",return wrapper,return,466 "Core Python Programming, Second Edition (2006)",return wrapper,return,467 "Core Python Programming, Second Edition (2006)","return the wrapped function object, which then is reassigned to the",return,468 "Core Python Programming, Second Edition (2006)",return 1,return,472 "Core Python Programming, Second Edition (2006)",return (n * factorial(n-1)),return,472 "Core Python Programming, Second Edition (2006)","return value from it, and when calling back into one,",return,473 "Core Python Programming, Second Edition (2006)",return a value to the caller and to pause,return,473 "Core Python Programming, Second Edition (2006)",return or end-of-function is,return,473 "Core Python Programming, Second Edition (2006)",return the,return,478 "Core Python Programming, Second Edition (2006)","return 8 and 4,",return,478 "Core Python Programming, Second Edition (2006)",return the largest and smallest,return,478 "Core Python Programming, Second Edition (2006)",return a list of only leap,return,478 "Core Python Programming, Second Edition (2006)","return value, time elapsed. You can use time.clock() or",return,479 "Core Python Programming, Second Edition (2006)",return a loader object. The finder can also take a path for finding subpackages. The loader is,return,496 "Core Python Programming, Second Edition (2006)","return dictionaries of the global and local namespaces,",return,497 "Core Python Programming, Second Edition (2006)",return those,return,497 "Core Python Programming, Second Edition (2006)",return the same dictionary because the,return,497 "Core Python Programming, Second Edition (2006)","return a valid instance so that the interpreter can then call __init__() with that instance as self. Calling a",return,532 "Core Python Programming, Second Edition (2006)",return count,return,533 "Core Python Programming, Second Edition (2006)",return InstCt.count,return,533 "Core Python Programming, Second Edition (2006)",return float(days) * daily,return,536 "Core Python Programming, Second Edition (2006)",return home.,return,537 "Core Python Programming, Second Edition (2006)",return any object because the instance object is automatically,return,537 "Core Python Programming, Second Edition (2006)",return any object (or return,return,537 "Core Python Programming, Second Edition (2006)",return any object other than None will result in a TypeError exception:,return,537 "Core Python Programming, Second Edition (2006)",return 1,return,537 "Core Python Programming, Second Edition (2006)",return None,return,537 "Core Python Programming, Second Edition (2006)","return float.__new__(cls, round(val, 2))",return,555 "Core Python Programming, Second Edition (2006)","return super(RoundFloat, cls).__new__(",return,556 "Core Python Programming, Second Edition (2006)",return sorted(super(,return,556 "Core Python Programming, Second Edition (2006)",return sorted(self.keys()),return,557 "Core Python Programming, Second Edition (2006)",return true if the first argument is a subclass of any of the candidate classes in the given,return,562 "Core Python Programming, Second Edition (2006)",return TRue if the first argument is an instance of any of the candidate types and,return,563 "Core Python Programming, Second Edition (2006)",return a dictionary of the attributes (keys) and values of the given object,return,565 "Core Python Programming, Second Edition (2006)",return TRue if obj1 is of type,return,566 "Core Python Programming, Second Edition (2006)",return obj.attr; if attr is not,return,566 "Core Python Programming, Second Edition (2006)","return a floating point value, regardless of whether floats or integers make up the",return,571 "Core Python Programming, Second Edition (2006)",return str(self.value),return,572 "Core Python Programming, Second Edition (2006)",return '%.2f' % self.value,return,573 "Core Python Programming, Second Edition (2006)",return '%.2f' % self.value,return,574 "Core Python Programming, Second Edition (2006)","return '%d:%d' % (self.hr, self.min)",return,574 "Core Python Programming, Second Edition (2006)",return a new object:,return,575 "Core Python Programming, Second Edition (2006)","return self. Let us add the following bits of code to our example, fixing our repr() issue above as well as",return,576 "Core Python Programming, Second Edition (2006)",return self,return,576 "Core Python Programming, Second Edition (2006)","return '%d:%d' % (self.hr, self.min)",return,577 "Core Python Programming, Second Edition (2006)",return self,return,577 "Core Python Programming, Second Edition (2006)",return self,return,577 "Core Python Programming, Second Edition (2006)",return choice(self.data),return,577 "Core Python Programming, Second Edition (2006)",return self,return,579 "Core Python Programming, Second Edition (2006)",return retval,return,579 "Core Python Programming, Second Edition (2006)",return any,return,579 "Core Python Programming, Second Edition (2006)",return and call the object's next() for each item. If,return,580 "Core Python Programming, Second Edition (2006)",return whatever items we have saved up (break and,return,580 "Core Python Programming, Second Edition (2006)","return an integer less than zero if obj1 < obj2, greater than zero if obj1 > obj2, or equal to zero if the",return,581 "Core Python Programming, Second Edition (2006)",return the result. The interesting thing is,return,581 "Core Python Programming, Second Edition (2006)","return -1, 0, or 1 for us. It is, as described above, an integer less than, equal",return,581 "Core Python Programming, Second Edition (2006)",return a value of 1 if (n1 > n2) and (s1,return,581 "Core Python Programming, Second Edition (2006)",return '[%d :: %r]' % \,return,581 "Core Python Programming, Second Edition (2006)",return self.__num or len(self.__string),return,582 "Core Python Programming, Second Edition (2006)","return cmp(cmpres, 0)",return,582 "Core Python Programming, Second Edition (2006)",return self.__norm_cval(,return,582 "Core Python Programming, Second Edition (2006)","return '[%d :: %s]' % (self.__num, self.__string)",return,584 "Core Python Programming, Second Edition (2006)","return values of cmp() to 1, and",return,585 "Core Python Programming, Second Edition (2006)","return values to only -1, 0,",return,585 "Core Python Programming, Second Edition (2006)",return 0,return,585 "Core Python Programming, Second Edition (2006)",return it for access or invocation. The way the special method,return,588 "Core Python Programming, Second Edition (2006)",return self.__data,return,588 "Core Python Programming, Second Edition (2006)",return 'self.__data',return,588 "Core Python Programming, Second Edition (2006)",return str(self.__data),return,588 "Core Python Programming, Second Edition (2006)","return getattr(self.__data, attr)",return,588 "Core Python Programming, Second Edition (2006)","return getattr(self.data, attr)",return,589 "Core Python Programming, Second Edition (2006)",return self.__data,return,591 "Core Python Programming, Second Edition (2006)","return getattr(self, '_%s__%stime' % \",return,591 "Core Python Programming, Second Edition (2006)",return ctime(self.gettimeval(t_type)),return,591 "Core Python Programming, Second Edition (2006)",return 'self.__data',return,591 "Core Python Programming, Second Edition (2006)",return str(self.__data),return,591 "Core Python Programming, Second Edition (2006)","return getattr(self.__data, attr)",return,592 "Core Python Programming, Second Edition (2006)",return str(self.file),return,593 "Core Python Programming, Second Edition (2006)",return 'self.file',return,593 "Core Python Programming, Second Edition (2006)","return getattr(self.file, attr)",return,593 "Core Python Programming, Second Edition (2006)",return true if obj is an instance of the given type or an instance of a subclass of the given type.,return,596 "Core Python Programming, Second Edition (2006)",return the desired object.,return,598 "Core Python Programming, Second Edition (2006)",return ~self.__x,return,604 "Core Python Programming, Second Edition (2006)",return ~self.__x,return,605 "Core Python Programming, Second Edition (2006)",return pi,return,605 "Core Python Programming, Second Edition (2006)",return ~self.__x,return,607 "Core Python Programming, Second Edition (2006)",return locals(),return,607 "Core Python Programming, Second Edition (2006)","return 'Instance of class:', \",return,610 "Core Python Programming, Second Edition (2006)","return 'Instance of class:', \",return,610 "Core Python Programming, Second Edition (2006)",return 'self.value',return,616 "Core Python Programming, Second Edition (2006)",return val,return,616 "Core Python Programming, Second Edition (2006)",return int(self.value),return,616 "Core Python Programming, Second Edition (2006)",return sorted(self.keys()),return,621 "Core Python Programming, Second Edition (2006)",return True,return,642 "Core Python Programming, Second Edition (2006)",return True,return,642 "Core Python Programming, Second Edition (2006)",return true. The one difference between the two is that foo() has no attributes while bar() gets a,return,642 "Core Python Programming, Second Edition (2006)",return output as well as,return,648 "Core Python Programming, Second Edition (2006)","return the exit code (on Windows, the exit code",return,648 "Core Python Programming, Second Edition (2006)",return twice... once for the parent,return,648 "Core Python Programming, Second Edition (2006)",return value from system() and,return,649 "Core Python Programming, Second Edition (2006)",return value is always,return,651 "Core Python Programming, Second Edition (2006)","return value is always the process identifier (aka process ID,",return,651 "Core Python Programming, Second Edition (2006)",return value of 0. This is how we can differentiate the two processes.,return,651 "Core Python Programming, Second Edition (2006)",return to Python (since Python,return,652 "Core Python Programming, Second Edition (2006)",return to the calling program is the exit() function,return,656 "Core Python Programming, Second Edition (2006)",return a new one,return,659 "Core Python Programming, Second Edition (2006)",return a,return,676 "Core Python Programming, Second Edition (2006)","return match object on success, None on failure",return,677 "Core Python Programming, Second Edition (2006)","return match object on success, None on",return,677 "Core Python Programming, Second Edition (2006)",return a list of matches,return,677 "Core Python Programming, Second Edition (2006)","return list of successful matches, splitting at most max times",return,677 "Core Python Programming, Second Edition (2006)","return the entire match, or a specific subgroup, if requested. groups() will simply",return,678 "Core Python Programming, Second Edition (2006)","return a tuple consisting of only/all the subgroups. If there are no subgroups requested, then groups()",return,678 "Core Python Programming, Second Edition (2006)",return a,return,690 "Core Python Programming, Second Edition (2006)","return ""int"". (Ditto for all",return,696 "Core Python Programming, Second Edition (2006)","return the same data but prepended with the current timestamp. The final line is never executed, but is there",return,710 "Core Python Programming, Second Edition (2006)",return and NEWLINE characters in both the client and server,return,721 "Core Python Programming, Second Edition (2006)",return and NEWLINE) each way. The server just retains and,return,722 "Core Python Programming, Second Edition (2006)",return data back to the client.,return,725 "Core Python Programming, Second Edition (2006)","return its current date/timestamp, i.e., time.ctime(time.time())",return,730 "Core Python Programming, Second Edition (2006)","return dir's file listing.",return,730 "Core Python Programming, Second Edition (2006)",return a message to the client indicating success. The client should have slept or,return,731 "Core Python Programming, Second Edition (2006)","return 33 print '*** Changed to ""%s"" folder' % DIRN",return,740 "Core Python Programming, Second Edition (2006)","return 45",return,740 "Core Python Programming, Second Edition (2006)",return and) quit on any failure. We attempt to login as,return,740 "Core Python Programming, Second Edition (2006)","return a tuple (rsp, ct, fst, lst, group):",return,745 "Core Python Programming, Second Edition (2006)","return 20 except nntplib.NNTPPermanentError, e:",return,748 "Core Python Programming, Second Edition (2006)","return 24 print '*** Connected to host ""%s""' % HOST",return,748 "Core Python Programming, Second Edition (2006)","return 40 print '*** Found newsgroup ""%s""' % GRNM",return,748 "Core Python Programming, Second Edition (2006)",return vals,return,749 "Core Python Programming, Second Edition (2006)",return and NEWLINE \r\n pairs.,return,754 "Core Python Programming, Second Edition (2006)",return self._shortcmd('PASS %s' % pswd),return,758 "Core Python Programming, Second Edition (2006)",return self._getresp(),return,758 "Core Python Programming, Second Edition (2006)",return data for that message only,return,759 "Core Python Programming, Second Edition (2006)",return values.,return,790 "Core Python Programming, Second Edition (2006)",return self.res,return,790 "Core Python Programming, Second Edition (2006)",return 1,return,790 "Core Python Programming, Second Edition (2006)",return (fib(x-2) + fib(x-1)),return,790 "Core Python Programming, Second Edition (2006)",return 1,return,790 "Core Python Programming, Second Edition (2006)",return (x * fac(x-1)),return,790 "Core Python Programming, Second Edition (2006)",return 1,return,791 "Core Python Programming, Second Edition (2006)",return (x + sum(x-1)),return,791 "Core Python Programming, Second Edition (2006)",return values of,return,791 "Core Python Programming, Second Edition (2006)","return 93",return,815 "Core Python Programming, Second Edition (2006)",return True,return,824 "Core Python Programming, Second Edition (2006)",return the,return,833 "Core Python Programming, Second Edition (2006)",return path,return,842 "Core Python Programming, Second Edition (2006)","return 110 robot = Crawler(url)",return,843 "Core Python Programming, Second Edition (2006)",return the resulting string.,return,844 "Core Python Programming, Second Edition (2006)",return url,return,846 "Core Python Programming, Second Edition (2006)",return req,return,846 "Core Python Programming, Second Edition (2006)",return HTML back to the server.,return,852 "Core Python Programming, Second Edition (2006)","return the resulting HTML page back to the user. All the ""real"" work in this script takes place in only four lines",return,857 "Core Python Programming, Second Edition (2006)",return the appropriate HTTP headers first,return,857 "Core Python Programming, Second Edition (2006)","return to the form page with information already provided, we have",return,862 "Core Python Programming, Second Edition (2006)",return to a form page to update the data he or,return,864 "Core Python Programming, Second Edition (2006)",return to the client must embed these,return,871 "Core Python Programming, Second Edition (2006)",return to form.,return,878 "Core Python Programming, Second Edition (2006)",return it,return,884 "Core Python Programming, Second Edition (2006)","return an ""OK"" status (200) and forward the downloaded Web page. If the file was not found,",return,885 "Core Python Programming, Second Edition (2006)","return code of 200 (OK [no error]) and how many times each link was accessed.",return,890 "Core Python Programming, Second Edition (2006)",return codes in the 400s or,return,890 "Core Python Programming, Second Edition (2006)","return a ""thank you"" screen.",return,890 "Core Python Programming, Second Edition (2006)","return a ""thanks for filling out a guestbook entry"" page. Also provide a link",return,890 "Core Python Programming, Second Edition (2006)",return them to the calling client. Add support for plain text files with,return,891 "Core Python Programming, Second Edition (2006)","return the correct MIME type of ""text/plain.""",return,891 "Core Python Programming, Second Edition (2006)",return a real 404 error. You must set urllib._urlopener with an,return,892 "Core Python Programming, Second Edition (2006)",return an object that faithfully emulates or,return,902 "Core Python Programming, Second Edition (2006)",return value of execute() redefined,return,904 "Core Python Programming, Second Edition (2006)",return value for nextset() when there is a new result set,return,904 "Core Python Programming, Second Edition (2006)",return RDBMSs[raw_input(''',return,910 "Core Python Programming, Second Edition (2006)","return fr, to, getRC(cur)",return,912 "Core Python Programming, Second Edition (2006)","return rm, getRC(cur)",return,912 "Core Python Programming, Second Edition (2006)","return 146 cur = cxn.cursor()",return,913 "Core Python Programming, Second Edition (2006)",return self.users.insert().execute(*d).rowcount,return,919 "Core Python Programming, Second Edition (2006)","return fr, to, \",return,919 "Core Python Programming, Second Edition (2006)","return rm, \",return,919 "Core Python Programming, Second Edition (2006)","return getattr(self.users, attr)",return,919 "Core Python Programming, Second Edition (2006)","return fr, to, i+1",return,921 "Core Python Programming, Second Edition (2006)","return rm, i+1",return,921 "Core Python Programming, Second Edition (2006)",return a string whose,return,934 "Core Python Programming, Second Edition (2006)",return s;,return,935 "Core Python Programming, Second Edition (2006)",return 0;,return,935 "Core Python Programming, Second Edition (2006)",return to the world of,return,937 "Core Python Programming, Second Edition (2006)","return values we designate, convert them to",return,937 "Core Python Programming, Second Edition (2006)","return value, convert it back to a Python integer, then return from the",return,937 "Core Python Programming, Second Edition (2006)",return 1 on successful parsing and 0 otherwise.,return,937 "Core Python Programming, Second Edition (2006)","return object, either a single",return,938 "Core Python Programming, Second Edition (2006)",return value,return,938 "Core Python Programming, Second Edition (2006)",return NULL;,return,939 "Core Python Programming, Second Edition (2006)",return retval;,return,939 "Core Python Programming, Second Edition (2006)","return a NULL, in which case we also return one. In our",return,939 "Core Python Programming, Second Edition (2006)","return object, a Python integer, again using a conversion code of ""i."" Py_BuildValue() creates",return,939 "Core Python Programming, Second Edition (2006)",return NULL;,return,939 "Core Python Programming, Second Edition (2006)","return (PyObject*)Py_BuildValue(""i"", fac(num));",return,939 "Core Python Programming, Second Edition (2006)","return a single value, we are going to",return,939 "Core Python Programming, Second Edition (2006)",return a pair of,return,939 "Core Python Programming, Second Edition (2006)",return NULL;,return,939 "Core Python Programming, Second Edition (2006)","return (PyObject*)Py_BuildValue(""ss"", orig_str, \",return,939 "Core Python Programming, Second Edition (2006)","return the original one as well, we need a string to reverse, so the best candidate is just a copy",return,939 "Core Python Programming, Second Edition (2006)",return object and then free the memory that we allocated in our wrapper. We,return,940 "Core Python Programming, Second Edition (2006)",return NULL;,return,940 "Core Python Programming, Second Edition (2006)",return retval;,return,940 "Core Python Programming, Second Edition (2006)",return object.,return,940 "Core Python Programming, Second Edition (2006)",return back to the caller. Now we are done.,return,940 "Core Python Programming, Second Edition (2006)","return (PyObject*)Py_BuildValue("""");",return,944 "Core Python Programming, Second Edition (2006)",return (n)*fac(n-1);,return,945 "Core Python Programming, Second Edition (2006)",return s;,return,945 "Core Python Programming, Second Edition (2006)",return 0;,return,945 "Core Python Programming, Second Edition (2006)",return NULL;,return,945 "Core Python Programming, Second Edition (2006)","return (PyObject*)Py_BuildValue(""i"", fac(num));}",return,945 "Core Python Programming, Second Edition (2006)",return NULL;,return,946 "Core Python Programming, Second Edition (2006)",return retval;,return,946 "Core Python Programming, Second Edition (2006)","return (PyObject*)Py_BuildValue("""");",return,946 "Core Python Programming, Second Edition (2006)",return None by building a PyObject with an empty string;,return,947 "Core Python Programming, Second Edition (2006)",return PyNone;,return,947 "Core Python Programming, Second Edition (2006)",return a string representation of an,return,985 "Core Python Programming, Second Edition (2006)","return an evaluatable string representation of an object,",return,985 "Core Python Programming, Second Edition (2006)",return True,return,991 "Core Python Programming, Second Edition (2006)","return (x+y, x*y)",return,995 "Core Python Programming, Second Edition (2006)","return with[b]",return,1010 "Core Python Programming, Second Edition (2006)",return either true or False.,return,1012 "Core Python Programming, Second Edition (2006)",return a signed string in Python 2.4+.,return,1019 "Core Python Programming, Second Edition (2006)",return an iterator instead of a list,return,1025 "Core Python Programming, Second Edition (2006)",return (shallow) copy of s,return,1028 "Core Python Programming, Second Edition (2006)",return an,return,1028 "Core Python Programming, Second Edition (2006)",return it,return,1029 "Core Python Programming, Second Edition (2006)",return value,return,1044 "Core Python Programming, Second Edition (2006)",return values,return,1070 "Core Python Programming, Second Edition (2006)",return value,return,1081 "Core Python Programming, Second Edition (2006)",return value(s) 2nd 3rd 4th,return,1102 "Core Python Programming, Second Edition (2006)",return values and function,return,1114 "Core Python Programming, Second Edition (2006)",if it is both in your path and available. Just type:,simpleif,8 "Core Python Programming, Second Edition (2006)",if conditional statement follows this syntax:,simpleif,42 "Core Python Programming, Second Edition (2006)","if expression: if_suite",simpleif,42 "Core Python Programming, Second Edition (2006)","if x < .0: print '""x"" must be atleast 0!'",simpleif,42 "Core Python Programming, Second Edition (2006)",if in the following manner:,simpleif,42 "Core Python Programming, Second Edition (2006)","if expression: if_suite",simpleif,42 "Core Python Programming, Second Edition (2006)",if with the following syntax:,simpleif,42 "Core Python Programming, Second Edition (2006)","if expression1: if_suite",simpleif,42 "Core Python Programming, Second Edition (2006)","if expression2: elif_suite",simpleif,42 "Core Python Programming, Second Edition (2006)",if the exception you are anticipating occurs:,simpleif,50 "Core Python Programming, Second Edition (2006)","if debug: ... print 'in debug mode'",simpleif,52 "Core Python Programming, Second Edition (2006)","if isinstance(num, (int, long, float, complex)): 6 print 'a number of type:', type(num).__name__",simpleif,109 "Core Python Programming, Second Edition (2006)","if type(num) == type(0): print 'an integer'",simpleif,110 "Core Python Programming, Second Edition (2006)","if len(myInput) > 1: 13",simpleif,174 "Core Python Programming, Second Edition (2006)","if myInput[0] not in alphas: 15 print '''invalid: first symbol must be",simpleif,174 "Core Python Programming, Second Edition (2006)","if otherChar not in alphas + nums: 21 print '''invalid: remaining",simpleif,174 "Core Python Programming, Second Edition (2006)",if otherChar not in alphas + nums:,simpleif,175 "Core Python Programming, Second Edition (2006)","if otherChar not in alphnums: :",simpleif,176 "Core Python Programming, Second Edition (2006)","if they do want to explicitly remove an entire list, they use the del statement:",simpleif,210 "Core Python Programming, Second Edition (2006)",if needed:,simpleif,214 "Core Python Programming, Second Edition (2006)","if eachMediaType in music_media: print music_media.index(eachMediaType)",simpleif,222 "Core Python Programming, Second Edition (2006)","if choice == 'q': 42 break",simpleif,225 "Core Python Programming, Second Edition (2006)","if choice == 'q': 42 break",simpleif,228 "Core Python Programming, Second Edition (2006)","if not given), fromkeys():",simpleif,254 "Core Python Programming, Second Edition (2006)","if choice not in 'neq': 45 print 'invalid option, try again'",simpleif,271 "Core Python Programming, Second Edition (2006)","if an item is a member (or not) of a set: >>> 'k' in s",simpleif,274 "Core Python Programming, Second Edition (2006)",if statement is:,simpleif,292 "Core Python Programming, Second Edition (2006)","if expression: expr_true_suite",simpleif,292 "Core Python Programming, Second Edition (2006)","if not warn and (system_load >= 10): print ""WARNING: losing resources""",simpleif,292 "Core Python Programming, Second Edition (2006)","if balance > 0.00: if balance - amt > min_bal and atm_cashout():",simpleif,294 "Core Python Programming, Second Edition (2006)","if balance > 0.00: if balance - amt > min_bal and atm_cashout():",simpleif,294 "Core Python Programming, Second Edition (2006)","if expression1: expr1_true_suite",simpleif,295 "Core Python Programming, Second Edition (2006)","if expression2: expr2_true_suite",simpleif,295 "Core Python Programming, Second Edition (2006)","if user.cmd == 'create': action = ""create item""",simpleif,295 "Core Python Programming, Second Edition (2006)","if user.cmd == 'delete': action = 'delete item'",simpleif,295 "Core Python Programming, Second Edition (2006)","if x < y: ... smaller = x",simpleif,297 "Core Python Programming, Second Edition (2006)",if certain criteria are met (or not):,simpleif,314 "Core Python Programming, Second Edition (2006)","if not eachURL.startswith('http://'): allURLs.remove(eachURL) # YIKES!!",simpleif,315 "Core Python Programming, Second Edition (2006)",if statement:,simpleif,316 "Core Python Programming, Second Edition (2006)","if linelen > longest: longest = linelen",simpleif,321 "Core Python Programming, Second Edition (2006)","if linelen > longest: longest = linelen",simpleif,321 "Core Python Programming, Second Edition (2006)","if linelen > longest: longest = linelen",simpleif,321 "Core Python Programming, Second Edition (2006)","if x > 0: # statement B",simpleif,324 "Core Python Programming, Second Edition (2006)","if x < 0: # statement C",simpleif,324 "Core Python Programming, Second Edition (2006)","if os.path.isdir(tmpdir): 6 break",simpleif,348 "Core Python Programming, Second Edition (2006)","if tmpdir: 12 os.chdir(tmpdir)",simpleif,348 "Core Python Programming, Second Edition (2006)",if both exceptions are managed by the same handler:,simpleif,382 "Core Python Programming, Second Edition (2006)","if written as a function. It would probably look something like this: def assert(expr, args=None):",simpleif,397 "Core Python Programming, Second Edition (2006)","if __debug__ and not expr: raise AssertionError, args",simpleif,397 "Core Python Programming, Second Edition (2006)","if isinstance(args, IOError): 13 myargs = []",simpleif,403 "Core Python Programming, Second Edition (2006)","if newarg: 19 myargs.append(newarg)",simpleif,403 "Core Python Programming, Second Edition (2006)","if os.access(file, permd[eachPerm]): 35 perms += eachPerm",simpleif,404 "Core Python Programming, Second Edition (2006)","if isinstance(args, IOError): 40 myargs = []",simpleif,404 "Core Python Programming, Second Edition (2006)","if the arguments are not given in the correct order: >>> def taxMe2(rate=0.0825, cost):",simpleif,437 "Core Python Programming, Second Edition (2006)","if not eachLine.strip(): 8 continue",simpleif,438 "Core Python Programming, Second Edition (2006)","if bool_func(eachItem): filtered_seq.append(eachItem)",simpleif,449 "Core Python Programming, Second Edition (2006)","if clo: 21 print ""f3 closure vars:"", [str(c) for c in clo]",simpleif,465 "Core Python Programming, Second Edition (2006)","if clo: 28 print ""f2 closure vars:"", [str(c) for c in clo]",simpleif,465 "Core Python Programming, Second Edition (2006)","if clo: 35 print ""f1 closure vars:"", [str(c) for c in clo]",simpleif,465 "Core Python Programming, Second Edition (2006)","if we ran into this problem interactively: >>> import sys",simpleif,484 "Core Python Programming, Second Edition (2006)","if cli4vof() is called, it will not have the omh4cli name loaded yet:",simpleif,506 "Core Python Programming, Second Edition (2006)","if the class attribute is mutable: >>> class Foo(object):",simpleif,542 "Core Python Programming, Second Edition (2006)","if you want to): class TestStaticMethod:",simpleif,546 "Core Python Programming, Second Edition (2006)","if isinstance(other, NumStr): 16 return self.__class__(self.__num + \",simpleif,581 "Core Python Programming, Second Edition (2006)","if isinstance(num, int): 25 return self.__class__(self.__num * num",simpleif,582 "Core Python Programming, Second Edition (2006)","if cmpres < 0: return -1",simpleif,585 "Core Python Programming, Second Edition (2006)","if cmpres > 0: return 1",simpleif,585 "Core Python Programming, Second Edition (2006)","if self.name not in FileDescr.saved: 14 raise AttributeError, \",simpleif,602 "Core Python Programming, Second Edition (2006)","if isinstance(data, int): print 'you entered an integer'",simpleif,612 "Core Python Programming, Second Edition (2006)","if isinstance(data, str): print 'you entered a string'",simpleif,612 "Core Python Programming, Second Edition (2006)","if individual operators had been part of the implementation: >>> from operator import * # import all operators",simpleif,612 "Core Python Programming, Second Edition (2006)",if the keys() method were (re)written as:,simpleif,621 "Core Python Programming, Second Edition (2006)","if dtype == 'n': 33 start = input('Starting value? ')",simpleif,638 "Core Python Programming, Second Edition (2006)","if ltype == 'f': 44 exec_str = exec_dict['f'] % (var, seq, var)",simpleif,638 "Core Python Programming, Second Edition (2006)","if ltype == 'w': 47 if dtype == 's':",simpleif,638 "Core Python Programming, Second Edition (2006)","if dtype == 'n': 53 exec_str = exec_dict['n'] % \",simpleif,638 "Core Python Programming, Second Edition (2006)","if foo(): 13 print 'PASSED'",simpleif,642 "Core Python Programming, Second Edition (2006)","if isinstance(obj, type(foo)): 21 if hasattr(obj, '__doc__'):",simpleif,642 "Core Python Programming, Second Edition (2006)","if hasattr(obj, 'tester'): 24 print 'Function ""%s"" has a tester... execut",simpleif,642 "Core Python Programming, Second Edition (2006)","if argc < 3: 12 usage()",simpleif,657 "Core Python Programming, Second Edition (2006)","if old_exit is not None and callable(old_exit): old_exit()",simpleif,657 "Core Python Programming, Second Edition (2006)","if not data: 23 break",simpleif,710 "Core Python Programming, Second Edition (2006)","if data: 12 print '...sending %s...' % data",simpleif,726 "Core Python Programming, Second Edition (2006)","if line: 64 lower = line.lower()",simpleif,748 "Core Python Programming, Second Edition (2006)","if not lastBlank or (lastBlank and line): 73 print ' %s' % line",simpleif,748 "Core Python Programming, Second Edition (2006)",if line:,simpleif,748 "Core Python Programming, Second Edition (2006)","if initdir: 56 self.cwd.set(os.curdir)",simpleif,814 "Core Python Programming, Second Edition (2006)","if not check: 67 check = os.curdir",simpleif,814 "Core Python Programming, Second Edition (2006)","if not os.path.exists(tdir): 77 error = tdir + ': no such file'",simpleif,815 "Core Python Programming, Second Edition (2006)","if not os.path.isdir(tdir): 79 error = tdir + ': not a directory'",simpleif,815 "Core Python Programming, Second Edition (2006)","if error: 82 self.cwd.set(error)",simpleif,815 "Core Python Programming, Second Edition (2006)","if path[-1] == '/': 25 path += deffile",simpleif,841 "Core Python Programming, Second Edition (2006)","if eachLink not in self.q: 88 self.q.append(eachLink)",simpleif,843 "Core Python Programming, Second Edition (2006)","if form.has_key('person'): 44 who = form['person'].value",simpleif,859 "Core Python Programming, Second Edition (2006)","if form.has_key('howmany'): 49 howmany = form['howmany'].value",simpleif,859 "Core Python Programming, Second Edition (2006)","if form.has_key('action'): 54 doResults(who, howmany)",simpleif,859 "Core Python Programming, Second Edition (2006)","if form.has_key('person'): 62 who = capwords(form['person'].value)",simpleif,863 "Core Python Programming, Second Edition (2006)","if form.has_key('howmany'): 67 howmany = form['howmany'].value",simpleif,863 "Core Python Programming, Second Edition (2006)","if not error: 76 if form.has_key('action') and \",simpleif,864 "Core Python Programming, Second Edition (2006)","if environ.has_key('HTTP_COOKIE'): 39 for eachCookie in map(strip, \",simpleif,877 "Core Python Programming, Second Edition (2006)","if self.cookies['info'] != '': 54 self.who, langStr, self.fn = \",simpleif,877 "Core Python Programming, Second Edition (2006)","if eachLang in self.langs: 66 langStr += AdvCGI.langItem % \",simpleif,878 "Core Python Programming, Second Edition (2006)","if form.has_key('lang'): 169 langdata = form['lang']",simpleif,879 "Core Python Programming, Second Edition (2006)","if form.has_key('upfile'): 179 upfile = form[""upfile""]",simpleif,880 "Core Python Programming, Second Edition (2006)","if upfile.file: 182 self.fp = upfile.file",simpleif,880 "Core Python Programming, Second Edition (2006)","if not self.error: 190 self.doResults()",simpleif,880 "Core Python Programming, Second Edition (2006)","if db == 'sqlite': 25 try:",simpleif,911 "Core Python Programming, Second Edition (2006)","if db == 'sqlite': 107 cur.executemany(""INSERT INTO users VALUES(?, ?, ?)"",",simpleif,912 "Core Python Programming, Second Edition (2006)","if db == 'gadfly': 110 for who, uid in randName():",simpleif,912 "Core Python Programming, Second Edition (2006)","if db == 'mysql': 114 cur.executemany(""INSERT INTO users VALUES(%s, %s, %s)"",",simpleif,912 "Core Python Programming, Second Edition (2006)","if not cxn: 144 print 'ERROR: %r not supported, exiting' % db",simpleif,913 "Core Python Programming, Second Edition (2006)",if you run this script:,simpleif,925 "Core Python Programming, Second Edition (2006)",if N/A):,simpleif,955 "Core Python Programming, Second Edition (2006)","if __name__=='__main__': 31 Tk().withdraw()",simpleif,959 "Core Python Programming, Second Edition (2006)","if __name__=='__main__': 31 Tk().withdraw()",simpleif,962 "Core Python Programming, Second Edition (2006)","if __name__=='__main__': 33 Tk().withdraw()",simpleif,963 "Core Python Programming, Second Edition (2006)","if __name__=='__main__': 33 Tk().withdraw()",simpleif,965 "Core Python Programming, Second Edition (2006)","if __name__=='__main__': 50 Tk().withdraw()",simpleif,968 "Core Python Programming, Second Edition (2006)","if i % 2 == 0: print i",simpleif,986 "Core Python Programming, Second Edition (2006)","if len(iden) > 0: if iden[0] not in alphas:",simpleif,988 "Core Python Programming, Second Edition (2006)","if len(iden) > 1: for eachChar in iden[1:]:",simpleif,988 "Core Python Programming, Second Edition (2006)","if eachChar not in alnums: print ""Error: others must be alnum""",simpleif,988 "Core Python Programming, Second Edition (2006)","if iden not in keyword.kwlist: print 'ok'",simpleif,988 "Core Python Programming, Second Edition (2006)","if i == num: break",simpleif,992 "Core Python Programming, Second Edition (2006)","aTuple = ('robots', 77, 93, 'try')",simpleTuple,39 "Core Python Programming, Second Edition (2006)","x, y, z) = (1, 2, 'a string')",simpleTuple,70 "Core Python Programming, Second Edition (2006)","names = ('Faye', 'Leanna', 'Daylen')",simpleTuple,160 "Core Python Programming, Second Edition (2006)","aTuple = (123, 'abc', 4.56, ['inner', 'tuple'], 7-9j)",simpleTuple,231 "Core Python Programming, Second Edition (2006)","anotherTuple = (None, 'something to see here')",simpleTuple,231 "Core Python Programming, Second Edition (2006)","emptiestPossibleTuple = (None,)",simpleTuple,231 "Core Python Programming, Second Edition (2006)","tup1 = (12, 34.56)",simpleTuple,232 "Core Python Programming, Second Edition (2006)","tup2 = ('abc', 'xyz')",simpleTuple,232 "Core Python Programming, Second Edition (2006)","t = (['xyz', 123], 23, -103.4)",simpleTuple,233 "Core Python Programming, Second Edition (2006)","2, 4) == (3, -1)",simpleTuple,234 "Core Python Programming, Second Edition (2006)","2, 4) == (2, 4)",simpleTuple,234 "Core Python Programming, Second Edition (2006)","t = ('third', 'fourth')",simpleTuple,235 "Core Python Programming, Second Edition (2006)","t = (['xyz', 123], 23, -103.4)",simpleTuple,236 "Core Python Programming, Second Edition (2006)","albums = ('Poe', 'Gaudi', 'Freud', 'Poe2')",simpleTuple,306 "Core Python Programming, Second Edition (2006)","years = (1976, 1987, 1990, 2003)",simpleTuple,306 "Core Python Programming, Second Edition (2006)","myTuple = (123, 'xyz', 45.67)",simpleTuple,313 "Core Python Programming, Second Edition (2006)","x_product_pairs = ((i, j) for i in rows for j in cols())",simpleTuple,320 "Core Python Programming, Second Edition (2006)","pathname, basename) == ('/tmp/example', 'filetest.txt')",simpleTuple,349 "Core Python Programming, Second Edition (2006)","filename, extension) == ('filetest', '.txt')",simpleTuple,349 "Core Python Programming, Second Edition (2006)","pathname, basename) == ('c:\\windows\\temp\\example', 'filetest.txt')",simpleTuple,350 "Core Python Programming, Second Edition (2006)","filename, extension) == ('filetest', '.txt')",simpleTuple,350 "Core Python Programming, Second Edition (2006)","7 myseq = (123, 45.67, -6.2e8, 999999999L)",simpleTuple,434 "Core Python Programming, Second Edition (2006)","dictVarArgs('one', d=10, e='zoo', men=('freud', 'gaudi'))",simpleTuple,442 "Core Python Programming, Second Edition (2006)","aTuple = (6, 7, 8)",simpleTuple,443 "Core Python Programming, Second Edition (2006)","opvec = (add, sub, mul, div)",simpleTuple,612 "Core Python Programming, Second Edition (2006)","8 doms = ( 'com', 'edu', 'net', 'org', 'gov' )",simpleTuple,689 "Core Python Programming, Second Edition (2006)","9 ADDR = (HOST, PORT)",simpleTuple,709 "Core Python Programming, Second Edition (2006)","8 ADDR = (HOST, PORT)",simpleTuple,711 "Core Python Programming, Second Edition (2006)","9 ADDR = (HOST, PORT)",simpleTuple,714 "Core Python Programming, Second Edition (2006)","8 ADDR = (HOST, PORT)",simpleTuple,715 "Core Python Programming, Second Edition (2006)","9 ADDR = (HOST, PORT)",simpleTuple,720 "Core Python Programming, Second Edition (2006)","8 ADDR = (HOST, PORT)",simpleTuple,722 "Core Python Programming, Second Edition (2006)","20 args=(i, loops[i]))",simpleTuple,785 "Core Python Programming, Second Edition (2006)","6 loops = (4, 2)",simpleTuple,788 "Core Python Programming, Second Edition (2006)","18 font=('Helvetica', 12, 'bold'))",simpleTuple,814 "Core Python Programming, Second Edition (2006)","8 size=(200, 140))",simpleTuple,824 "Core Python Programming, Second Edition (2006)","25 choices=('dog', 'cat', 'hamster','python'))",simpleTuple,824 "Core Python Programming, Second Edition (2006)","91 NAMES = ( 92 ('aaron', 8312), ('angela', 7603), ('dave', 7306)",simpleTuple,912 "Core Python Programming, Second Edition (2006)","8 FIELDS = ('login', 'uid', 'prid')",simpleTuple,918 "Core Python Programming, Second Edition (2006)","10 FIELDS = ('login', 'uid', 'prid')",simpleTuple,920 "Core Python Programming, Second Edition (2006)","retval = (PyObject*)Py_BuildValue(""i"", res)",simpleTuple,939 "Core Python Programming, Second Edition (2006)","6 ticks = ('YHOO', 'GOOG', 'EBAY', 'AMZN')",simpleTuple,955 "Core Python Programming, Second Edition (2006)","11 TICKS = ('YHOO', 'GOOG', 'EBAY', 'AMZN')",simpleTuple,968 "Core Python Programming, Second Edition (2006)","12 COLS = ('TICKER', 'PRICE', 'CHG', '%AGE')",simpleTuple,968 "Core Python Programming, Second Edition (2006)","38 sh.Cells(row, 2).Value = ('%.2f' % round(float(price), 2))",simpleTuple,968 "Core Python Programming, Second Edition (2006)","aList = [1, 2, 3, 4]",simpleList,39 "Core Python Programming, Second Edition (2006)","aList = [3.14e10, '2nd elmt of a list', 8.82-4.371j]",simpleList,68 "Core Python Programming, Second Edition (2006)","aList = [123, 'xyz']",simpleList,69 "Core Python Programming, Second Edition (2006)",aList += [45.6e7],simpleList,69 "Core Python Programming, Second Edition (2006)","myList = [123, x, 'xyz']",simpleList,82 "Core Python Programming, Second Edition (2006)","foolist = [123, 'xba', 342.23, 'abc']",simpleList,98 "Core Python Programming, Second Edition (2006)","3, 'abc'] == ['abc', 3]",simpleList,100 "Core Python Programming, Second Edition (2006)","3, 'abc'] == [3, 'abc']",simpleList,100 "Core Python Programming, Second Edition (2006)","a = [ 5, 'hat', -9.3]",simpleList,102 "Core Python Programming, Second Edition (2006)","aList = ['ammonia', 83, 85, 'lady']",simpleList,116 "Core Python Programming, Second Edition (2006)","anotherList = [None, 'something to see here']",simpleList,209 "Core Python Programming, Second Edition (2006)",aListThatStartedEmpty = [],simpleList,209 "Core Python Programming, Second Edition (2006)","list1 = ['abc', 123]",simpleList,211 "Core Python Programming, Second Edition (2006)","list2 = ['xyz', 789]",simpleList,211 "Core Python Programming, Second Edition (2006)","list3 = ['abc', 123]",simpleList,211 "Core Python Programming, Second Edition (2006)","num_list = [43, -1.23, -2, 6.19e5]",simpleList,211 "Core Python Programming, Second Edition (2006)","str_list = ['jack', 'jumped', 'over', 'candlestick']",simpleList,211 "Core Python Programming, Second Edition (2006)","num_list[2:4] = [16.0, -49]",simpleList,212 "Core Python Programming, Second Edition (2006)","num_list[0] = [65535L, 2e30, 76.45-1.3j]",simpleList,212 "Core Python Programming, Second Edition (2006)","num_list = [43, -1.23, -2, 6.19e5]",simpleList,213 "Core Python Programming, Second Edition (2006)","str_list = ['jack', 'jumped', 'over', 'candlestick']",simpleList,213 "Core Python Programming, Second Edition (2006)","list1, list2 = [123, 'xyz'], [456, 'abc']",simpleList,216 "Core Python Programming, Second Edition (2006)","s = ['They', 'stamp', 'them', 'when', ""they're"", 'small']",simpleList,218 "Core Python Programming, Second Edition (2006)","albums = ['tales', 'robot', 'pyramid']",simpleList,218 "Core Python Programming, Second Edition (2006)","fn = ['ian', 'stuart', 'david']",simpleList,218 "Core Python Programming, Second Edition (2006)","ln = ['bairnson', 'elliott', 'paton']",simpleList,218 "Core Python Programming, Second Edition (2006)","a = [6, 4, 5]",simpleList,218 "Core Python Programming, Second Edition (2006)","a = [6., 4., 5.]",simpleList,219 "Core Python Programming, Second Edition (2006)","aList = ['tao', 93, 99, 'time']",simpleList,219 "Core Python Programming, Second Edition (2006)",music_media = [45],simpleList,221 "Core Python Programming, Second Edition (2006)",motd = [],simpleList,223 "Core Python Programming, Second Edition (2006)",3 stack = [],simpleList,224 "Core Python Programming, Second Edition (2006)",3 queue = [],simpleList,228 "Core Python Programming, Second Edition (2006)","t[0][1] = ['abc', 'def']",simpleList,236 "Core Python Programming, Second Edition (2006)","person = ['name', ('savings', 100.00)]",simpleList,241 "Core Python Programming, Second Edition (2006)","nameList = ['Walter', ""Nicole"", 'Steven', 'Henry']",simpleList,302 "Core Python Programming, Second Edition (2006)","nameList = ['Cathy', ""Terry"", 'Joe', 'Heather', 'Lucy']",simpleList,302 "Core Python Programming, Second Edition (2006)","seq = [11, 10, 9, 9, 10, 10, 9, 8, 23, 9, 7, 18, 12, 11, 12]",simpleList,317 "Core Python Programming, Second Edition (2006)","rows = [1, 2, 3, 17]",simpleList,320 "Core Python Programming, Second Edition (2006)",aList = [],simpleList,370 "Core Python Programming, Second Edition (2006)","simple enough such that we could have just called randint() twice to get our operands, i.e., nums = [randint (1,10), randint(1,10)]",simpleList,423 "Core Python Programming, Second Edition (2006)",filtered_seq = [],simpleList,449 "Core Python Programming, Second Edition (2006)",allNums = [],simpleList,450 "Core Python Programming, Second Edition (2006)",allNums = [],simpleList,451 "Core Python Programming, Second Edition (2006)",allNums = [],simpleList,451 "Core Python Programming, Second Edition (2006)",mapped_seq = [],simpleList,452 "Core Python Programming, Second Edition (2006)",count = [start_at],simpleList,463 "Core Python Programming, Second Edition (2006)",12 retval = [],simpleList,579 "Core Python Programming, Second Edition (2006)",NumStr1 = [n1 :: s1] and NumStr2 = [n2 :: s2],simpleList,581 "Core Python Programming, Second Edition (2006)","repeating or concatenating the strings, i.e., NumStr1 * NumStr2 = [n1 * n :: s1 * n]",simpleList,581 "Core Python Programming, Second Edition (2006)",when NumStr = [0 :: ''],simpleList,581 "Core Python Programming, Second Edition (2006)",7 saved = [],simpleList,602 "Core Python Programming, Second Edition (2006)","vec1 = [12, 24]",simpleList,612 "Core Python Programming, Second Edition (2006)","vec2 = [2, 3, 4]",simpleList,612 "Core Python Programming, Second Edition (2006)","myList = [932, 'grail', 3.0, 'arrrghhh']",simpleList,640 "Core Python Programming, Second Edition (2006)",vals = [0] + vals + [1],simpleList,747 "Core Python Programming, Second Edition (2006)",vals = [start] + vals + [stop],simpleList,749 "Core Python Programming, Second Edition (2006)",vals = [0] + vals + [1],simpleList,749 "Core Python Programming, Second Edition (2006)","13 origBody = ['xxx', 'yyy', 'zzz']",simpleList,760 "Core Python Programming, Second Edition (2006)","6 loops = [4,2]",simpleList,780 "Core Python Programming, Second Edition (2006)",16 locks = [],simpleList,780 "Core Python Programming, Second Edition (2006)","6 loops = [4,2]",simpleList,785 "Core Python Programming, Second Edition (2006)",15 threads = [],simpleList,785 "Core Python Programming, Second Edition (2006)","6 loops = [4,2]",simpleList,787 "Core Python Programming, Second Edition (2006)",25 threads = [],simpleList,787 "Core Python Programming, Second Edition (2006)",25 threads = [],simpleList,789 "Core Python Programming, Second Edition (2006)","21 funcs = [fib, fac, sum]",simpleList,791 "Core Python Programming, Second Edition (2006)",36 threads = [],simpleList,791 "Core Python Programming, Second Edition (2006)","28 funcs = [writer, reader]",simpleList,794 "Core Python Programming, Second Edition (2006)",35 threads = [],simpleList,794 "Core Python Programming, Second Edition (2006)",59 self.langs = ['Python'],simpleList,878 "Core Python Programming, Second Edition (2006)",167 self.langs = [],simpleList,879 "Core Python Programming, Second Edition (2006)","Extension('Extest', sources=['Extest2.c']",simpleList,942 "Core Python Programming, Second Edition (2006)","setup('Extest', ext_modules=[...]",simpleList,942 "Core Python Programming, Second Edition (2006)","18 body = [""Line %d"" % i for i in RANGE]",simpleList,965 "Core Python Programming, Second Edition (2006)",for key in aDict:,forsimple,40 "Core Python Programming, Second Edition (2006)",for eachNum in range(3):,forsimple,45 "Core Python Programming, Second Edition (2006)",for c in foo:,forsimple,45 "Core Python Programming, Second Edition (2006)",for i in range(len(foo)):,forsimple,45 "Core Python Programming, Second Edition (2006)","for i, ch in enumerate(foo):",forsimple,46 "Core Python Programming, Second Edition (2006)",for i in squared:,forsimple,47 "Core Python Programming, Second Edition (2006)",for i in sqdEvens:,forsimple,47 "Core Python Programming, Second Edition (2006)",for eachLine in fobj:,forsimple,48 "Core Python Programming, Second Edition (2006)",for eachLine in fobj:,forsimple,87 "Core Python Programming, Second Edition (2006)","for people who aren't used to floor division. One of van Rossum's use cases is featured in his ""What's New in Python 2.2"" talk:",forsimple,134 "Core Python Programming, Second Edition (2006)",for eachNum in range(10):,forsimple,142 "Core Python Programming, Second Edition (2006)","for i in range(-1, -len(s), -1):",forsimple,164 "Core Python Programming, Second Edition (2006)",for otherChar in myInput[1:]:,forsimple,174 "Core Python Programming, Second Edition (2006)",for otherChar in myInput[1:]:,forsimple,175 "Core Python Programming, Second Edition (2006)",for otherChar in myInput[1:]:,forsimple,176 "Core Python Programming, Second Edition (2006)","for i, t in enumerate(s):",forsimple,186 "Core Python Programming, Second Edition (2006)",for t in reversed(s):,forsimple,218 "Core Python Programming, Second Edition (2006)","for i, album in enumerate(albums):",forsimple,218 "Core Python Programming, Second Edition (2006)","for i, j in zip(fn, ln):",forsimple,218 "Core Python Programming, Second Edition (2006)","for lists, parentheses for tuples, etc., defaults to tuples, as indicated in these short examples:",forsimple,236 "Core Python Programming, Second Edition (2006)",for key in dict2.keys():,forsimple,255 "Core Python Programming, Second Edition (2006)",for key in dict2:,forsimple,255 "Core Python Programming, Second Edition (2006)",for eachKey in dict2.keys():,forsimple,266 "Core Python Programming, Second Edition (2006)",for eachKey in sorted(dict2):,forsimple,266 "Core Python Programming, Second Edition (2006)",for i in s:,forsimple,274 "Core Python Programming, Second Edition (2006)",for i in range(5):,forsimple,280 "Core Python Programming, Second Edition (2006)",for iter_var in iterable:,forsimple,301 "Core Python Programming, Second Edition (2006)",for eachName in nameList:,forsimple,302 "Core Python Programming, Second Edition (2006)",for nameIndex in range(len(nameList)):,forsimple,302 "Core Python Programming, Second Edition (2006)","for i, eachLee in enumerate(nameList):",forsimple,303 "Core Python Programming, Second Edition (2006)","for eachVal in range(2, 19, 3):",forsimple,304 "Core Python Programming, Second Edition (2006)","for count in range(2, 5):",forsimple,305 "Core Python Programming, Second Edition (2006)",for album in sorted(albums):,forsimple,306 "Core Python Programming, Second Edition (2006)",for album in reversed(albums):,forsimple,306 "Core Python Programming, Second Edition (2006)","for i, album in enumerate(albums):",forsimple,306 "Core Python Programming, Second Edition (2006)","for album, yr in zip(albums, years):",forsimple,306 "Core Python Programming, Second Edition (2006)","for eachNum in range(10, 21):",forsimple,310 "Core Python Programming, Second Edition (2006)",for i in seq:,forsimple,313 "Core Python Programming, Second Edition (2006)","for eachKey in myDict as shown here:",forsimple,314 "Core Python Programming, Second Edition (2006)",for eachLegend in legends:,forsimple,314 "Core Python Programming, Second Edition (2006)",for eachLine in myFile:,forsimple,314 "Core Python Programming, Second Edition (2006)",for eachLine in myFile:,forsimple,314 "Core Python Programming, Second Edition (2006)",for eachURL in allURLs:,forsimple,315 "Core Python Programming, Second Edition (2006)",for eachKey in myDict:,forsimple,315 "Core Python Programming, Second Edition (2006)",for pair in x_product_pairs:,forsimple,320 "Core Python Programming, Second Edition (2006)",for line in allLines:,forsimple,321 "Core Python Programming, Second Edition (2006)",for line in allLines:,forsimple,321 "Core Python Programming, Second Edition (2006)",for eachLine in f:,forsimple,335 "Core Python Programming, Second Edition (2006)",for eachLine in allLines:,forsimple,336 "Core Python Programming, Second Edition (2006)",for eachLine in f:,forsimple,337 "Core Python Programming, Second Edition (2006)",for eachLine in fobj:,forsimple,348 "Core Python Programming, Second Edition (2006)",for eachLine in fobj:,forsimple,351 "Core Python Programming, Second Edition (2006)",for eachLine in f:,forsimple,390 "Core Python Programming, Second Edition (2006)",for eachItem in exc_tuple:,forsimple,411 "Core Python Programming, Second Edition (2006)","for both, i.e., there is no naming conflict in this snippet of code:",forsimple,427 "Core Python Programming, Second Edition (2006)",for i in range(2):,forsimple,432 "Core Python Programming, Second Edition (2006)",for eachLine in lines:,forsimple,438 "Core Python Programming, Second Edition (2006)",for eachXtrArg in theRest:,forsimple,441 "Core Python Programming, Second Edition (2006)",for eachXtrArg in theRest.keys():,forsimple,441 "Core Python Programming, Second Edition (2006)",for eachNKW in nkw:,forsimple,442 "Core Python Programming, Second Edition (2006)",for eachKW in kw.keys():,forsimple,442 "Core Python Programming, Second Edition (2006)",for eachItem in seq:,forsimple,449 "Core Python Programming, Second Edition (2006)",for eachNum in range(9):,forsimple,450 "Core Python Programming, Second Edition (2006)",for eachNum in range(9):,forsimple,451 "Core Python Programming, Second Edition (2006)",for eachNum in range(9):,forsimple,451 "Core Python Programming, Second Edition (2006)",for eachItem in seq:,forsimple,452 "Core Python Programming, Second Edition (2006)",for item in lseq:,forsimple,454 "Core Python Programming, Second Edition (2006)",for eachNum in allNums:,forsimple,455 "Core Python Programming, Second Edition (2006)",for eachItem in simpleGen():,forsimple,474 "Core Python Programming, Second Edition (2006)","for item in randGen(['rock', 'paper', 'scissors']):",forsimple,474 "Core Python Programming, Second Edition (2006)",for eachNum in range(5):,forsimple,477 "Core Python Programming, Second Edition (2006)","for eachNum in range(n, 5):",forsimple,477 "Core Python Programming, Second Edition (2006)","for eachNum in range(n, 5):",forsimple,477 "Core Python Programming, Second Edition (2006)",for eachItem in range(howmany):,forsimple,579 "Core Python Programming, Second Edition (2006)","for j in range(1,5):",forsimple,580 "Core Python Programming, Second Edition (2006)",for eachLine in f:,forsimple,594 "Core Python Programming, Second Edition (2006)","for your attribute, as shown here in this next example:",forsimple,605 "Core Python Programming, Second Edition (2006)",for eachOp in opvec:,forsimple,612 "Core Python Programming, Second Edition (2006)","for built-in methods as it does for BIFsnote how we have to provide a built-in type (object or reference) in order to access a BIM:",forsimple,627 "Core Python Programming, Second Edition (2006)",for eachNum in range(req):,forsimple,633 "Core Python Programming, Second Edition (2006)",for eachAttr in dir():,forsimple,642 "Core Python Programming, Second Edition (2006)","for import2.py, changed in the same manner:",forsimple,645 "Core Python Programming, Second Edition (2006)",for eachLine in data:,forsimple,654 "Core Python Programming, Second Edition (2006)",for eachLine in f.readlines():,forsimple,686 "Core Python Programming, Second Edition (2006)",for eachLine in f.readlines():,forsimple,687 "Core Python Programming, Second Edition (2006)","for i in range(randint(5, 10)):",forsimple,689 "Core Python Programming, Second Edition (2006)",for j in range(shorter):,forsimple,689 "Core Python Programming, Second Edition (2006)",for j in range(longer):,forsimple,689 "Core Python Programming, Second Edition (2006)",for eachLine in data:,forsimple,746 "Core Python Programming, Second Edition (2006)",for j in range(2*N+1):,forsimple,747 "Core Python Programming, Second Edition (2006)",for line in lines:,forsimple,748 "Core Python Programming, Second Edition (2006)",for j in range(2*N+1):,forsimple,749 "Core Python Programming, Second Edition (2006)",for eachLine in msg:,forsimple,758 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,780 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,780 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,785 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,785 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,785 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,787 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,787 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,787 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,789 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,789 "Core Python Programming, Second Edition (2006)",for i in nloops:,forsimple,789 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,791 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,791 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,791 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,791 "Core Python Programming, Second Edition (2006)",for i in range(loops):,forsimple,794 "Core Python Programming, Second Edition (2006)",for i in range(loops):,forsimple,794 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,794 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,794 "Core Python Programming, Second Edition (2006)",for i in nfuncs:,forsimple,794 "Core Python Programming, Second Edition (2006)",for eachSign in SIGNS:,forsimple,812 "Core Python Programming, Second Edition (2006)",for eachFile in dirlist:,forsimple,815 "Core Python Programming, Second Edition (2006)",for eachLang in AdvCGI.langSet:,forsimple,878 "Core Python Programming, Second Edition (2006)",for eachCookie in self.cookies.keys():,forsimple,878 "Core Python Programming, Second Edition (2006)",for eachLang in self.langs:,forsimple,879 "Core Python Programming, Second Edition (2006)",for eachLang in langdata:,forsimple,879 "Core Python Programming, Second Edition (2006)",for data in cur.fetchall():,forsimple,907 "Core Python Programming, Second Edition (2006)",for data in cur.fetchall():,forsimple,907 "Core Python Programming, Second Edition (2006)",for i in rows:,forsimple,908 "Core Python Programming, Second Edition (2006)",for eachUser in cur.fetchall():,forsimple,909 "Core Python Programming, Second Edition (2006)",for data in cur.fetchall():,forsimple,912 "Core Python Programming, Second Edition (2006)",for data in res.fetchall():,forsimple,919 "Core Python Programming, Second Edition (2006)","for who, uid in randName():",forsimple,921 "Core Python Programming, Second Edition (2006)","for i, user in enumerate(users):",forsimple,921 "Core Python Programming, Second Edition (2006)","for i, user in enumerate(users):",forsimple,921 "Core Python Programming, Second Edition (2006)",for usr in self.users.select():,forsimple,921 "Core Python Programming, Second Edition (2006)",for row in u:,forsimple,953 "Core Python Programming, Second Edition (2006)",for row in csv.reader(u):,forsimple,953 "Core Python Programming, Second Edition (2006)",for row in u:,forsimple,955 "Core Python Programming, Second Edition (2006)",for i in RANGE:,forsimple,959 "Core Python Programming, Second Edition (2006)",for i in RANGE:,forsimple,962 "Core Python Programming, Second Edition (2006)",for i in RANGE:,forsimple,963 "Core Python Programming, Second Edition (2006)",for i in range(4):,forsimple,968 "Core Python Programming, Second Edition (2006)",for data in u:,forsimple,968 "Core Python Programming, Second Edition (2006)",for eachChar in s:,forsimple,982 "Core Python Programming, Second Edition (2006)",for i in range(len(s)):,forsimple,982 "Core Python Programming, Second Edition (2006)","for i, x in enumerate(s):",forsimple,983 "Core Python Programming, Second Edition (2006)",for i in range(5):,forsimple,983 "Core Python Programming, Second Edition (2006)","for i in range(0, 22, 2):",forsimple,986 "Core Python Programming, Second Edition (2006)",for i in range(22):,forsimple,986 "Core Python Programming, Second Edition (2006)","for i in range(1, 20, 2):",forsimple,986 "Core Python Programming, Second Edition (2006)",for i in range(20):,forsimple,986 "Core Python Programming, Second Edition (2006)",for i in range(len(list1)):,forsimple,989 "Core Python Programming, Second Edition (2006)","for i, x in enumerate(list1):",forsimple,989 "Core Python Programming, Second Edition (2006)",for eachLine in f:,forsimple,992 "Core Python Programming, Second Edition (2006)",for loop in stock.py with the following:,forsimple,1008 "Core Python Programming, Second Edition (2006)","for tick, price, chg, per in csv.reader(f):",forsimple,1008 "Core Python Programming, Second Edition (2006)",counter = counter + 1,assignwithSum,35 "Core Python Programming, Second Edition (2006)","and -- are also unary operators, Python will interpret --n as -(-n) == n, and the same is true for ++n.",assignwithSum,35 "Core Python Programming, Second Edition (2006)",y = (x = x + 1) # assignments not expressions!,assignwithSum,68 "Core Python Programming, Second Edition (2006)",y = (x = x + 1),assignwithSum,68 "Core Python Programming, Second Edition (2006)",y = x = x + 1,assignwithSum,68 "Core Python Programming, Second Edition (2006)",x = x + 1,assignwithSum,69 "Core Python Programming, Second Edition (2006)",objects will have the same effect as A = A + B (with a new object allocated) except that A is only,assignwithSum,69 "Core Python Programming, Second Edition (2006)",foo2 = 1.3 + 3.0,assignwithSum,101 "Core Python Programming, Second Edition (2006)",elif type(num) == type(0+0j):,assignwithSum,110 "Core Python Programming, Second Edition (2006)",i = i + 1,assignwithSum,115 "Core Python Programming, Second Edition (2006)",i = i + 1,assignwithSum,115 "Core Python Programming, Second Edition (2006)",aList[2] = aList[2] + 1,assignwithSum,116 "Core Python Programming, Second Edition (2006)",aComplex = 1.23+4.56J,assignwithSum,123 "Core Python Programming, Second Edition (2006)",aString = aString[:6] + 'Python!',assignwithSum,169 "Core Python Programming, Second Edition (2006)",aString = aString[:3] + aString[4:],assignwithSum,169 "Core Python Programming, Second Edition (2006)",5 alphas = string.letters + '_',assignwithSum,174 "Core Python Programming, Second Edition (2006)",alphnums = alphas + nums,assignwithSum,176 "Core Python Programming, Second Edition (2006)",s = s + 'def',assignwithSum,194 "Core Python Programming, Second Edition (2006)",list3 = list2 + [789],assignwithSum,216 "Core Python Programming, Second Edition (2006)",tup3 = tup1 + tup2,assignwithSum,232 "Core Python Programming, Second Edition (2006)","t = t + ('free', 'easy')",assignwithSum,233 "Core Python Programming, Second Edition (2006)",s = s + ' second',assignwithSum,235 "Core Python Programming, Second Edition (2006)","t = t + ('fifth', 'sixth')",assignwithSum,235 "Core Python Programming, Second Edition (2006)","10 fac_list = range(1, num_num+1)",assignwithSum,248 "Core Python Programming, Second Edition (2006)",23 i = i + 1,assignwithSum,248 "Core Python Programming, Second Edition (2006)",v = s + t,assignwithSum,278 "Core Python Programming, Second Edition (2006)",10 op = choice('+-'),assignwithSum,422 "Core Python Programming, Second Edition (2006)","a = lambda x, y=2: x + y",assignwithSum,447 "Core Python Programming, Second Edition (2006)",bar = lambda :x+y,assignwithSum,468 "Core Python Programming, Second Edition (2006)",bar = lambda y=y: x+y,assignwithSum,469 "Core Python Programming, Second Edition (2006)",bar = lambda y=y: x+y,assignwithSum,469 "Core Python Programming, Second Edition (2006)",bar = lambda z:x+z,assignwithSum,469 "Core Python Programming, Second Edition (2006)",bar = lambda :x+y,assignwithSum,470 "Core Python Programming, Second Edition (2006)",C.foo = C.foo + 1,assignwithSum,525 "Core Python Programming, Second Edition (2006)",x = 3+0.14j,assignwithSum,539 "Core Python Programming, Second Edition (2006)",foo.x = Foo.x + 0.2,assignwithSum,541 "Core Python Programming, Second Edition (2006)","obj. For example, __iadd__(self, obj) is called for self = self + obj.",assignwithSum,571 "Core Python Programming, Second Edition (2006)",wrappedComplex = WrapMe(3.5+4.2j),assignwithSum,588 "Core Python Programming, Second Edition (2006)","eval_code = compile('100 + 200', '', 'eval')",assignwithSum,633 "Core Python Programming, Second Edition (2006)",counter = counter + 1,assignwithSum,639 "Core Python Programming, Second Edition (2006)",eachIndex = eachIndex + 1,assignwithSum,640 "Core Python Programming, Second Edition (2006)",29 recvBody = msg[sep+1:],assignwithSum,760 "Core Python Programming, Second Edition (2006)",21 path = parsedurl[1] + parsedurl[2],assignwithSum,841 "Core Python Programming, Second Edition (2006)",name=Georgina+Garcia&hmdir=%7eggarcia',assignwithSum,844 "Core Python Programming, Second Edition (2006)",26 friends = friends + fradio % \,assignwithSum,859 "Core Python Programming, Second Edition (2006)",40 friends = friends + fradio % \,assignwithSum,863 "Core Python Programming, Second Edition (2006)",53 newurl = url + '?action=reedit&person=%s&howmany=%s'%\,assignwithSum,863 "Core Python Programming, Second Edition (2006)",116 langlist = langlist + '<LI>%s<BR>' % eachLang,assignwithSum,879 "Core Python Programming, Second Edition (2006)",20 top.visible = 1 # or True for Jython 2.2+,assignwithSum,973 "Core Python Programming, Second Edition (2006)",alphas = string.letters + '_',assignwithSum,988 "Core Python Programming, Second Edition (2006)",alnums = alphas + string.digits,assignwithSum,988 "Core Python Programming, Second Edition (2006)",directories given to the set path or PATH= directive. Adding the full path to where your Python interpreter,simpleAssign,10 "Core Python Programming, Second Edition (2006)",http://codeplex.com/Wiki/View.aspx?ProjectName=IronPython,simpleAssign,23 "Core Python Programming, Second Edition (2006)",user = raw_input('Enter login name: '),simpleAssign,30 "Core Python Programming, Second Edition (2006)",num = raw_input('Now enter a number: '),simpleAssign,30 "Core Python Programming, Second Edition (2006)",2 == 4,simpleAssign,33 "Core Python Programming, Second Edition (2006)",6.2 <= 6,simpleAssign,33 "Core Python Programming, Second Edition (2006)",6.2 <= 6.2,simpleAssign,33 "Core Python Programming, Second Edition (2006)",6.2 <= 6.20001,simpleAssign,33 "Core Python Programming, Second Edition (2006)","Python currently supports two ""not equal"" comparison operators, != and <>. These are the C-style and",simpleAssign,34 "Core Python Programming, Second Edition (2006)",2 < 4 and 2 == 4,simpleAssign,34 "Core Python Programming, Second Edition (2006)",not 6.2 <= 6,simpleAssign,34 "Core Python Programming, Second Edition (2006)",counter = 0,simpleAssign,35 "Core Python Programming, Second Edition (2006)",miles = 1000.0,simpleAssign,35 "Core Python Programming, Second Edition (2006)",kilometers = 1.609 * miles,simpleAssign,35 "Core Python Programming, Second Edition (2006)",n = n * 10,simpleAssign,35 "Core Python Programming, Second Edition (2006)",n *= 10,simpleAssign,35 "Core Python Programming, Second Edition (2006)",aList[1] = 5,simpleAssign,39 "Core Python Programming, Second Edition (2006)",aTuple[1] = 5,simpleAssign,39 "Core Python Programming, Second Edition (2006)",aDict['port'] = 80 # add to dict,simpleAssign,40 "Core Python Programming, Second Edition (2006)",counter = 0,simpleAssign,43 "Core Python Programming, Second Edition (2006)",filename = raw_input('Enter file name: '),simpleAssign,48 "Core Python Programming, Second Edition (2006)",version = 0.1 # class (data) attribute,simpleAssign,53 "Core Python Programming, Second Edition (2006)",foo1 = FooClass(),simpleAssign,54 "Core Python Programming, Second Edition (2006)",foo2 = FooClass('Jane Smith'),simpleAssign,54 "Core Python Programming, Second Edition (2006)","Open file fn with mode ('r' = read, 'w' = write)",simpleAssign,58 "Core Python Programming, Second Edition (2006)",if (weather_is_hot == 1) and \,simpleAssign,65 "Core Python Programming, Second Edition (2006)",shark_warnings == 0):,simpleAssign,65 "Core Python Programming, Second Edition (2006)",x = 1,simpleAssign,68 "Core Python Programming, Second Edition (2006)",m = 12,simpleAssign,69 "Core Python Programming, Second Edition (2006)",m %= 7,simpleAssign,69 "Core Python Programming, Second Edition (2006)",m **= 2,simpleAssign,69 "Core Python Programming, Second Edition (2006)",x = y = z = 1,simpleAssign,69 "Core Python Programming, Second Edition (2006)","x, y, z = 1, 2, 'a string'",simpleAssign,70 "Core Python Programming, Second Edition (2006)",tmp = x;,simpleAssign,70 "Core Python Programming, Second Edition (2006)",x = y;,simpleAssign,70 "Core Python Programming, Second Edition (2006)",y = tmp;,simpleAssign,70 "Core Python Programming, Second Edition (2006)","x, y = 1, 2",simpleAssign,70 "Core Python Programming, Second Edition (2006)","x, y = y, x",simpleAssign,70 "Core Python Programming, Second Edition (2006)",x = 4,simpleAssign,80 "Core Python Programming, Second Edition (2006)",x = 3.14,simpleAssign,81 "Core Python Programming, Second Edition (2006)",y = x,simpleAssign,81 "Core Python Programming, Second Edition (2006)",The statement x = 3.14 allocates a floating point number (float) object and assigns a reference x to it. x,simpleAssign,81 "Core Python Programming, Second Edition (2006)","is the first reference, hence setting that object's refcount to one. The statement y = x creates an alias y,",simpleAssign,81 "Core Python Programming, Second Edition (2006)",x = 3.14,simpleAssign,82 "Core Python Programming, Second Edition (2006)",y = x,simpleAssign,82 "Core Python Programming, Second Edition (2006)",bar = foo,simpleAssign,82 "Core Python Programming, Second Edition (2006)",foo = 123,simpleAssign,82 "Core Python Programming, Second Edition (2006)",x = 123,simpleAssign,82 "Core Python Programming, Second Edition (2006)",6 ls = os.linesep,simpleAssign,84 "Core Python Programming, Second Edition (2006)",6 fname = raw_input('Enter filename: '),simpleAssign,87 "Core Python Programming, Second Edition (2006)","Given the assignment x, y, z = 1, 2, 3, what do x, y, and z contain?",simpleAssign,90 "Core Python Programming, Second Edition (2006)","What do x, y, and z contain after executing: z, x, y = y, z, x?",simpleAssign,90 "Core Python Programming, Second Edition (2006)",expr1 <= expr2 expr1 is less than or equal to expr2,simpleAssign,99 "Core Python Programming, Second Edition (2006)",expr1 >= expr2 expr1 is greater than or equal to expr2,simpleAssign,99 "Core Python Programming, Second Edition (2006)",expr1 == expr2 expr1 is equal to expr2,simpleAssign,99 "Core Python Programming, Second Edition (2006)",expr1 != expr2 expr1 is not equal to expr2 (C-style),simpleAssign,99 "Core Python Programming, Second Edition (2006)","a] This ""not equal"" sign will be phased out in future version of Python. Use != instead.",simpleAssign,99 "Core Python Programming, Second Edition (2006)",2 == 2,simpleAssign,99 "Core Python Programming, Second Edition (2006)",2.46 <= 8.33,simpleAssign,99 "Core Python Programming, Second Edition (2006)",5+4j >= 2-3j,simpleAssign,99 "Core Python Programming, Second Edition (2006)",4 > 3 == 3 # same as ( 4 > 3 ) and ( 3 == 3 ),simpleAssign,100 "Core Python Programming, Second Edition (2006)",4 < 3 < 5 != 2 < 7,simpleAssign,100 "Core Python Programming, Second Edition (2006)",foo1 = foo2 = 4.3,simpleAssign,100 "Core Python Programming, Second Edition (2006)",foo1 = 4.3,simpleAssign,101 "Core Python Programming, Second Edition (2006)",foo2 = foo1,simpleAssign,101 "Core Python Programming, Second Edition (2006)","one variable. When foo2 = foo1 occurs, foo2 is directed to the same object as foo1 since Python deals",simpleAssign,101 "Core Python Programming, Second Edition (2006)",foo1 = 4.3,simpleAssign,101 "Core Python Programming, Second Edition (2006)",id(a) == id(b),simpleAssign,102 "Core Python Programming, Second Edition (2006)",b = a,simpleAssign,102 "Core Python Programming, Second Edition (2006)",b = 2.5e-5,simpleAssign,102 "Core Python Programming, Second Edition (2006)",a = 1,simpleAssign,103 "Core Python Programming, Second Edition (2006)",b = 1,simpleAssign,103 "Core Python Programming, Second Edition (2006)",c = 1.0,simpleAssign,103 "Core Python Programming, Second Edition (2006)",d = 1.0,simpleAssign,103 "Core Python Programming, Second Edition (2006)","to create a new integer object rather than an alias, as in b = a.",simpleAssign,103 "Core Python Programming, Second Edition (2006)","x, y = 3.1415926536, -1024",simpleAssign,104 "Core Python Programming, Second Edition (2006)",i == 0 if obj1 == obj2,simpleAssign,105 "Core Python Programming, Second Edition (2006)",foo = Foo(),simpleAssign,108 "Core Python Programming, Second Edition (2006)",bar = Bar(),simpleAssign,108 "Core Python Programming, Second Edition (2006)",elif type(num) == type(0L):,simpleAssign,110 "Core Python Programming, Second Edition (2006)",elif type(num) == type(0.0):,simpleAssign,110 "Core Python Programming, Second Edition (2006)",if type(num) == type(0)...,simpleAssign,110 "Core Python Programming, Second Edition (2006)",if type(num) == types.IntType...,simpleAssign,110 "Core Python Programming, Second Edition (2006)",i = 0,simpleAssign,115 "Core Python Programming, Second Edition (2006)",i = 0,simpleAssign,115 "Core Python Programming, Second Edition (2006)",a = 10,simpleAssign,121 "Core Python Programming, Second Edition (2006)",b = 10,simpleAssign,121 "Core Python Programming, Second Edition (2006)",c = 100,simpleAssign,121 "Core Python Programming, Second Edition (2006)",d = 100,simpleAssign,121 "Core Python Programming, Second Edition (2006)",e = 10.0,simpleAssign,121 "Core Python Programming, Second Edition (2006)",f = 10.0,simpleAssign,121 "Core Python Programming, Second Edition (2006)",anInt = 1,simpleAssign,123 "Core Python Programming, Second Edition (2006)",aFloat = 3.1415926535897932384626433832795,simpleAssign,123 "Core Python Programming, Second Edition (2006)",aFloat = 2.718281828,simpleAssign,123 "Core Python Programming, Second Edition (2006)",aLong = 999999999l,simpleAssign,126 "Core Python Programming, Second Edition (2006)",5.2 == 5.2,simpleAssign,133 "Core Python Programming, Second Edition (2006)",719 >= 833,simpleAssign,133 "Core Python Programming, Second Edition (2006)",5+4e >= 2-3e,simpleAssign,133 "Core Python Programming, Second Edition (2006)",77 > 66 == 66 # same as ( 77 > 66 )and ( 66 == 66 ),simpleAssign,133 "Core Python Programming, Second Edition (2006)",0. < -90.4 < 55.3e2 != 3 < 181,simpleAssign,133 "Core Python Programming, Second Edition (2006)",rate = distance / totalTime,simpleAssign,134 "Core Python Programming, Second Edition (2006)","to cast both to floats, i.e., rate = float(distance) / float(totalTime). With the upcoming change to",simpleAssign,134 "Core Python Programming, Second Edition (2006)","int(obj, base=10)",simpleAssign,140 "Core Python Programming, Second Edition (2006)","long(obj, base=10)",simpleAssign,140 "Core Python Programming, Second Edition (2006)","complex(str) or complex(real, imag=0.0) Returns complex number representation of str, or builds",simpleAssign,140 "Core Python Programming, Second Edition (2006)","The round() built-in function has a syntax of round(flt,ndig=0). It normally rounds a floating point",simpleAssign,142 "Core Python Programming, Second Edition (2006)","pow(num1, num2, mod=1) Raises num1 to num2 power, quantity modulo mod if provided",simpleAssign,144 "Core Python Programming, Second Edition (2006)","round(flt, ndig=0)",simpleAssign,144 "Core Python Programming, Second Edition (2006)",Takes ASCII value num and returns ASCII character as string; 0 <= num <= 255 only,simpleAssign,145 "Core Python Programming, Second Edition (2006)",foo = 42,simpleAssign,147 "Core Python Programming, Second Edition (2006)",bar = foo < 100,simpleAssign,147 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,148 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,148 "Core Python Programming, Second Edition (2006)","True, False = False, True",simpleAssign,148 "Core Python Programming, Second Edition (2006)",dec = Decimal(.1),simpleAssign,149 "Core Python Programming, Second Edition (2006)",dec = Decimal('.1'),simpleAssign,149 "Core Python Programming, Second Edition (2006)",other = _convert_other(other),simpleAssign,149 "Core Python Programming, Second Edition (2006)","Generate a list of a random number (1 < N <= 100) of random numbers (0 <= n <= 231-1). Then randomly select a set of these numbers (1 <= N <= 100), sort them, and",simpleAssign,156 "Core Python Programming, Second Edition (2006)","section), this gives an index with the range 0 <= index <= len (sequence)-1.",simpleAssign,160 "Core Python Programming, Second Edition (2006)","sequence), i.e., -len(sequence) <= index <= -1. The difference between the positive and negative",simpleAssign,160 "Core Python Programming, Second Edition (2006)","max(iter, key=None) or max(arg0, arg1..., key=None)[b] Returns ""largest"" element in iter or returns",simpleAssign,166 "Core Python Programming, Second Edition (2006)","min(iter, key=None) or min(arg0, arg1.... key=None)",simpleAssign,166 "Core Python Programming, Second Edition (2006)","sorted(iter, func=None, key=None, reverse=False)[c]",simpleAssign,166 "Core Python Programming, Second Edition (2006)","sum(seq, init=0)[a]",simpleAssign,166 "Core Python Programming, Second Edition (2006)",s = str(range(4)) # turn list to string,simpleAssign,168 "Core Python Programming, Second Edition (2006)",str2 != str3,simpleAssign,171 "Core Python Programming, Second Edition (2006)","final_index = len(aString) - 1 = 4 - 1",simpleAssign,172 "Core Python Programming, Second Edition (2006)","start:end], start <= x < end.",simpleAssign,172 "Core Python Programming, Second Edition (2006)",6 nums = string.digits,simpleAssign,174 "Core Python Programming, Second Edition (2006)",10 myInput = raw_input('Identifier to test? '),simpleAssign,174 "Core Python Programming, Second Edition (2006)",length = len(myString),simpleAssign,175 "Core Python Programming, Second Edition (2006)",f = urllib.urlopen('http://' # protocol,simpleAssign,177 "Core Python Programming, Second Edition (2006)",num = 123,simpleAssign,181 "Core Python Programming, Second Edition (2006)",MM/DD/YY = 02/15/67',simpleAssign,182 "Core Python Programming, Second Edition (2006)",s = Template('There are ${howmany} ${lang} Quotation Symbols'),simpleAssign,182 "Core Python Programming, Second Edition (2006)","print s.substitute(lang='Python', howmany=3)",simpleAssign,182 "Core Python Programming, Second Edition (2006)",val = mapping[named],simpleAssign,183 "Core Python Programming, Second Edition (2006)","m = re.search('\\[rtfvn]', r'Hello World!\n')",simpleAssign,184 "Core Python Programming, Second Edition (2006)","m = re.search(r'\\[rtfvn]', r'Hello World!\n')",simpleAssign,184 "Core Python Programming, Second Edition (2006)","user_input = raw_input(""Enter your name: "")",simpleAssign,186 "Core Python Programming, Second Edition (2006)","string.count(str, beg= 0, end=len(string))",simpleAssign,188 "Core Python Programming, Second Edition (2006)","string.endswith(obj, beg=0, end=len(string))[b],",simpleAssign,188 "Core Python Programming, Second Edition (2006)",string.expandtabs(tabsize=8),simpleAssign,188 "Core Python Programming, Second Edition (2006)","string.find(str, beg=0end=len(string))",simpleAssign,188 "Core Python Programming, Second Edition (2006)","string.index(str, beg=0, end=len(string))",simpleAssign,188 "Core Python Programming, Second Edition (2006)","not found, string_pre_str == string",simpleAssign,189 "Core Python Programming, Second Edition (2006)","string.replace(str1, str2, num=string.count",simpleAssign,189 "Core Python Programming, Second Edition (2006)","string.rfind(str, beg=0, end=len(string))",simpleAssign,189 "Core Python Programming, Second Edition (2006)","string.rindex( str, beg=0, end=len(string))",simpleAssign,189 "Core Python Programming, Second Edition (2006)","string.split(str="""", num=string.count(str))",simpleAssign,190 "Core Python Programming, Second Edition (2006)","string.splitlines(num=string.count('\n'))[b],[c] Splits string at all (or num) NEWLINEs and returns",simpleAssign,190 "Core Python Programming, Second Edition (2006)","string.startswith(obj, beg=0, end=len(string))",simpleAssign,190 "Core Python Programming, Second Edition (2006)",FORM><INPUT TYPE=button VALUE=Back,simpleAssign,194 "Core Python Programming, Second Edition (2006)","9 hello_out = u""Hello world\n""",simpleAssign,200 "Core Python Programming, Second Edition (2006)",10 bytes_out = hello_out.encode(CODEC),simpleAssign,200 "Core Python Programming, Second Edition (2006)",18 hello_in = bytes_in.decode(CODEC),simpleAssign,200 "Core Python Programming, Second Edition (2006)",list2 > list3 and list1 == list3,simpleAssign,211 "Core Python Programming, Second Edition (2006)",resulting in list1 < list2 and list2 >= list3. Tuple comparisons are performed in the same manner as,simpleAssign,211 "Core Python Programming, Second Edition (2006)",hr *= 30,simpleAssign,214 "Core Python Programming, Second Edition (2006)",i for i in range(8) if i % 2 == 0 ],simpleAssign,214 "Core Python Programming, Second Edition (2006)",aTuple = tuple(aList),simpleAssign,219 "Core Python Programming, Second Edition (2006)",aList == aTuple,simpleAssign,219 "Core Python Programming, Second Edition (2006)",anotherList = list(aTuple),simpleAssign,219 "Core Python Programming, Second Edition (2006)",aList == anotherList,simpleAssign,219 "Core Python Programming, Second Edition (2006)","list.index(obj, i=0, j=len(list))",simpleAssign,220 "Core Python Programming, Second Edition (2006)",Returns lowest index k where list[k]==obj and,simpleAssign,220 "Core Python Programming, Second Edition (2006)",i<= k<j; otherwise ValueError raised,simpleAssign,220 "Core Python Programming, Second Edition (2006)","list.sort(func=None, key=None, reverse=False)[b] Sorts list members with optional comparison",simpleAssign,221 "Core Python Programming, Second Edition (2006)",9 if len(stack) == 0:,simpleAssign,224 "Core Python Programming, Second Edition (2006)",9 if len(queue) == 0:,simpleAssign,228 "Core Python Programming, Second Edition (2006)","aTuple = aTuple[0], aTuple[1], aTuple[-1]",simpleAssign,232 "Core Python Programming, Second Edition (2006)","x, y = 1, 2",simpleAssign,236 "Core Python Programming, Second Edition (2006)",hubby = person[:] # slice copy,simpleAssign,240 "Core Python Programming, Second Edition (2006)",wifey = list(person) # fac func copy,simpleAssign,240 "Core Python Programming, Second Edition (2006)",hubby[1][1] = 50.00,simpleAssign,240 "Core Python Programming, Second Edition (2006)",hubby = person,simpleAssign,241 "Core Python Programming, Second Edition (2006)",wifey = copy.deepcopy(person),simpleAssign,241 "Core Python Programming, Second Edition (2006)",hubby[1][1] = 50.00,simpleAssign,241 "Core Python Programming, Second Edition (2006)",newPerson = copy.deepcopy(person),simpleAssign,241 "Core Python Programming, Second Edition (2006)",4 num_str = raw_input('Enter a number: '),simpleAssign,248 "Core Python Programming, Second Edition (2006)",7 num_num = int(num_str),simpleAssign,248 "Core Python Programming, Second Edition (2006)",14 i = 0,simpleAssign,248 "Core Python Programming, Second Edition (2006)",20 if num_num % fac_list[i] == 0:,simpleAssign,248 "Core Python Programming, Second Edition (2006)","fdict = dict((['x', 1], ['y', 2]))",simpleAssign,254 "Core Python Programming, Second Edition (2006)","key=name, value=earth",simpleAssign,255 "Core Python Programming, Second Edition (2006)","key=port, value=80",simpleAssign,255 "Core Python Programming, Second Edition (2006)","key=name, value=earth",simpleAssign,255 "Core Python Programming, Second Edition (2006)","key=port, value=80",simpleAssign,255 "Core Python Programming, Second Edition (2006)",dict3['1'] = 3.14159,simpleAssign,256 "Core Python Programming, Second Edition (2006)",dict2['port'] = 6969 # update existing entry,simpleAssign,256 "Core Python Programming, Second Edition (2006)",d[k] = v # set value 'v' in dictionary with key 'k',simpleAssign,258 "Core Python Programming, Second Edition (2006)",dict1['port'] = 8080,simpleAssign,260 "Core Python Programming, Second Edition (2006)",dict1['port'] = 80,simpleAssign,260 "Core Python Programming, Second Edition (2006)",cdict['oranges'] = 0,simpleAssign,261 "Core Python Programming, Second Edition (2006)",ddict['apples'] = 0,simpleAssign,261 "Core Python Programming, Second Edition (2006)","dict(x=1, y=2)",simpleAssign,263 "Core Python Programming, Second Edition (2006)","dict8 = dict(x=1, y=2)",simpleAssign,263 "Core Python Programming, Second Edition (2006)",dict9 = dict(**dict8),simpleAssign,263 "Core Python Programming, Second Edition (2006)",dict9 = dict8.copy(),simpleAssign,263 "Core Python Programming, Second Edition (2006)","c] (seq, val=None)",simpleAssign,265 "Core Python Programming, Second Edition (2006)","dict.get(key, default=None)",simpleAssign,265 "Core Python Programming, Second Edition (2006)","dict.setdefault (key, default=None)",simpleAssign,265 "Core Python Programming, Second Edition (2006)","e] Similar to get(), but sets dict[key]=default if key is not",simpleAssign,265 "Core Python Programming, Second Edition (2006)",dict4 = dict2.copy(),simpleAssign,267 "Core Python Programming, Second Edition (2006)",dict1['foo'] = 123,simpleAssign,269 "Core Python Programming, Second Edition (2006)",34 done = False,simpleAssign,270 "Core Python Programming, Second Edition (2006)",37 chosen = False,simpleAssign,270 "Core Python Programming, Second Edition (2006)","40 choice = raw_input(prompt).strip()[0].lower()",simpleAssign,271 "Core Python Programming, Second Edition (2006)",47 chosen = True,simpleAssign,271 "Core Python Programming, Second Edition (2006)",49 if choice == 'q': done = True,simpleAssign,271 "Core Python Programming, Second Edition (2006)","cid:135) = in",simpleAssign,273 "Core Python Programming, Second Edition (2006)",s = set('cheeseshop'),simpleAssign,274 "Core Python Programming, Second Edition (2006)",t = frozenset('bookshop'),simpleAssign,274 "Core Python Programming, Second Edition (2006)",len(s) == len(t),simpleAssign,274 "Core Python Programming, Second Edition (2006)",s == t,simpleAssign,274 "Core Python Programming, Second Edition (2006)",s -= set('pypi'),simpleAssign,275 "Core Python Programming, Second Edition (2006)",s = set('cheeseshop'),simpleAssign,276 "Core Python Programming, Second Edition (2006)",t = frozenset('bookshop'),simpleAssign,276 "Core Python Programming, Second Edition (2006)","n improper) subset of the other, e.g., both expressions s <= t and s >= t are true, or (s <= t and s >= t) is TRue. Equality (or inequality) is independent of set type or ordering of members when the sets",simpleAssign,276 "Core Python Programming, Second Edition (2006)",s == t,simpleAssign,276 "Core Python Programming, Second Edition (2006)",s != t,simpleAssign,276 "Core Python Programming, Second Edition (2006)",u = frozenset(s),simpleAssign,276 "Core Python Programming, Second Edition (2006)",s == u,simpleAssign,276 "Core Python Programming, Second Edition (2006)",set('posh') == set('shop'),simpleAssign,276 "Core Python Programming, Second Edition (2006)",set('bookshop') >= set('shop'),simpleAssign,277 "Core Python Programming, Second Edition (2006)",v = s | t,simpleAssign,278 "Core Python Programming, Second Edition (2006)",s = set('cheeseshop'),simpleAssign,278 "Core Python Programming, Second Edition (2006)",u = frozenset(s),simpleAssign,278 "Core Python Programming, Second Edition (2006)",s |= set('pypi'),simpleAssign,278 "Core Python Programming, Second Edition (2006)",s = set(u),simpleAssign,278 "Core Python Programming, Second Edition (2006)",s &= set('shop'),simpleAssign,279 "Core Python Programming, Second Edition (2006)",s = set(u),simpleAssign,279 "Core Python Programming, Second Edition (2006)",s -= set('shop'),simpleAssign,279 "Core Python Programming, Second Edition (2006)",s = set(u),simpleAssign,279 "Core Python Programming, Second Edition (2006)",t = frozenset('bookshop'),simpleAssign,279 "Core Python Programming, Second Edition (2006)",s ^= t,simpleAssign,279 "Core Python Programming, Second Edition (2006)",s = set(u),simpleAssign,280 "Core Python Programming, Second Edition (2006)",s == t,simpleAssign,283 "Core Python Programming, Second Edition (2006)",s != t,simpleAssign,283 "Core Python Programming, Second Edition (2006)",s <= t,simpleAssign,283 "Core Python Programming, Second Edition (2006)",s >= t,simpleAssign,283 "Core Python Programming, Second Edition (2006)",Strict) subset test; s != t and all,simpleAssign,283 "Core Python Programming, Second Edition (2006)",Strict) superset test: s != t and all,simpleAssign,283 "Core Python Programming, Second Edition (2006)",s |= t,simpleAssign,284 "Core Python Programming, Second Edition (2006)",s &= t,simpleAssign,284 "Core Python Programming, Second Edition (2006)",s -= t,simpleAssign,284 "Core Python Programming, Second Edition (2006)",s.symmetric_ difference_ update(t) s ^= t,simpleAssign,284 "Core Python Programming, Second Edition (2006)","abcdef', then tr() would output'mnodef'. Note that len(srcstr) == len(dststr).",simpleAssign,288 "Core Python Programming, Second Edition (2006)","abcdefghi', then tr() would output 'mnoghi'. Note now that len(srcstr) >= len",simpleAssign,289 "Core Python Programming, Second Edition (2006)",id = user.id,simpleAssign,293 "Core Python Programming, Second Edition (2006)",valid = True,simpleAssign,293 "Core Python Programming, Second Edition (2006)",valid = False,simpleAssign,293 "Core Python Programming, Second Edition (2006)",if (((balance - amt) > min_bal) && (atm_cashout() == 1)),simpleAssign,293 "Core Python Programming, Second Edition (2006)","action = msgs.get(user.cmd, default)",simpleAssign,296 "Core Python Programming, Second Edition (2006)","x, y = 4, 3",simpleAssign,297 "Core Python Programming, Second Edition (2006)",smaller = y,simpleAssign,297 "Core Python Programming, Second Edition (2006)",smaller = x if x < y else y,simpleAssign,297 "Core Python Programming, Second Edition (2006)",count = 0,simpleAssign,299 "Core Python Programming, Second Edition (2006)",count = 0,simpleAssign,299 "Core Python Programming, Second Edition (2006)","handle, indata = wait_for_client_connect()",simpleAssign,300 "Core Python Programming, Second Edition (2006)",outdata = process_request(indata),simpleAssign,300 "Core Python Programming, Second Edition (2006)","will then return a list where for any k, start <= k < end and k iterates from start to end in",simpleAssign,304 "Core Python Programming, Second Edition (2006)",count = num / 2,simpleAssign,307 "Core Python Programming, Second Edition (2006)",valid = False,simpleAssign,308 "Core Python Programming, Second Edition (2006)",count = 3,simpleAssign,308 "Core Python Programming, Second Edition (2006)",4 count = num / 2,simpleAssign,310 "Core Python Programming, Second Edition (2006)",i = iter(myTuple),simpleAssign,313 "Core Python Programming, Second Edition (2006)",fetch = iter(seq),simpleAssign,313 "Core Python Programming, Second Edition (2006)",longest = 0,simpleAssign,321 "Core Python Programming, Second Edition (2006)",longest = 0,simpleAssign,321 "Core Python Programming, Second Edition (2006)",allLines = f.readlines(),simpleAssign,321 "Core Python Programming, Second Edition (2006)",linelen = len(line.strip()),simpleAssign,321 "Core Python Programming, Second Edition (2006)",longest = 0,simpleAssign,321 "Core Python Programming, Second Edition (2006)",linelen = len(line),simpleAssign,321 "Core Python Programming, Second Edition (2006)",longest = max(len(x.strip()) for x in f),simpleAssign,322 "Core Python Programming, Second Edition (2006)",Which of the statements above will be executed if x = = 0?,simpleAssign,324 "Core Python Programming, Second Edition (2006)","input is f == 2, t == 26, and i == 4, the program would output: 2, 6, 10, 14, 18, 22,",simpleAssign,324 "Core Python Programming, Second Edition (2006)",that number. A shorthand for N factorial is N! where N! == factorial(N) == 1 * 2 * 3,simpleAssign,325 "Core Python Programming, Second Edition (2006)","N-2) * (N-1) * N. So 4! == 1 * 2 * 3 * 4. Write a routine such that given N, the",simpleAssign,325 "Core Python Programming, Second Edition (2006)",filename = raw_input('Enter file name: '),simpleAssign,336 "Core Python Programming, Second Edition (2006)",allLines = f.readlines(),simpleAssign,336 "Core Python Programming, Second Edition (2006)",filename = raw_input('Enter file name: '),simpleAssign,337 "Core Python Programming, Second Edition (2006)",filename = raw_input('Enter file name: '),simpleAssign,338 "Core Python Programming, Second Edition (2006)",file.readlines(sizhint=0),simpleAssign,339 "Core Python Programming, Second Edition (2006)","file.seek(off, whence=0)",simpleAssign,339 "Core Python Programming, Second Edition (2006)","Moves to a location within file, off bytes offset from whence (0 == beginning of file, 1 == current location, or 2 == end of file)",simpleAssign,339 "Core Python Programming, Second Edition (2006)","file.truncate(size=file.tell()) Truncates file to at most size bytes, the default being the current",simpleAssign,340 "Core Python Programming, Second Edition (2006)",13 cwd = os.getcwd(),simpleAssign,348 "Core Python Programming, Second Edition (2006)",20 cwd = os.getcwd(),simpleAssign,348 "Core Python Programming, Second Edition (2006)","39 path = os.path.join(cwd, os.listdir (cwd)[0])",simpleAssign,348 "Core Python Programming, Second Edition (2006)",cwd = os.getcwd(),simpleAssign,350 "Core Python Programming, Second Edition (2006)",cwd = os.getcwd(),simpleAssign,350 "Core Python Programming, Second Edition (2006)","path = os.path.join(cwd, os.listdir(cwd)[0])",simpleAssign,351 "Core Python Programming, Second Edition (2006)",myInst = myClass(),simpleAssign,370 "Core Python Programming, Second Edition (2006)",retval = None,simpleAssign,375 "Core Python Programming, Second Edition (2006)",6 retval = float(obj),simpleAssign,382 "Core Python Programming, Second Edition (2006)",8 retval = str(diag),simpleAssign,382 "Core Python Programming, Second Edition (2006)","11 def updArgs(args, newarg=None):",simpleAssign,403 "Core Python Programming, Second Edition (2006)",16 myargs = list(args),simpleAssign,403 "Core Python Programming, Second Edition (2006)",24 if args[0] == errno.EACCES and \,simpleAssign,404 "Core Python Programming, Second Edition (2006)",29 pkeys = permd.keys(),simpleAssign,404 "Core Python Programming, Second Edition (2006)",43 myargs = list(args),simpleAssign,404 "Core Python Programming, Second Edition (2006)",51 myargs = args,simpleAssign,404 "Core Python Programming, Second Edition (2006)",exc_tuple = sys.exc_info(),simpleAssign,411 "Core Python Programming, Second Edition (2006)",d) >>> x = 4 % 0,simpleAssign,414 "Core Python Programming, Second Edition (2006)",i = math.sqrt(-1),simpleAssign,414 "Core Python Programming, Second Edition (2006)",res = hello(),simpleAssign,417 "Core Python Programming, Second Edition (2006)",aTuple = bar(),simpleAssign,418 "Core Python Programming, Second Edition (2006)","x, y, z = bar()",simpleAssign,418 "Core Python Programming, Second Edition (2006)","a, b, c) = bar()",simpleAssign,418 "Core Python Programming, Second Edition (2006)",Keyword calls to foo(): foo(x=42) foo(x='bar') foo(x=y),simpleAssign,420 "Core Python Programming, Second Edition (2006)","net_conn(port=8080, host='chino')",simpleAssign,420 "Core Python Programming, Second Edition (2006)",7 MAXTRIES = 2,simpleAssign,422 "Core Python Programming, Second Edition (2006)",12 nums.sort(reverse=True),simpleAssign,422 "Core Python Programming, Second Edition (2006)",13 ans = ops[op](*nums),simpleAssign,422 "Core Python Programming, Second Edition (2006)",15 oops = 0,simpleAssign,422 "Core Python Programming, Second Edition (2006)",7 - 2 = 5,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 6 = 42,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 3 = 20,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 3 = 22,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 3 = 23,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 3 = 21,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 * 3 = 21,simpleAssign,424 "Core Python Programming, Second Edition (2006)",7 - 5 = 2,simpleAssign,424 "Core Python Programming, Second Edition (2006)",bar.version = 0.1,simpleAssign,427 "Core Python Programming, Second Edition (2006)",version'] = 0.1. The reason for this is,simpleAssign,427 "Core Python Programming, Second Edition (2006)",staticFoo = staticmethod(staticFoo),simpleAssign,429 "Core Python Programming, Second Edition (2006)","method, but note how ""sloppy"" it looks with def staticFoo() followed by staticFoo = staticmethod",simpleAssign,429 "Core Python Programming, Second Edition (2006)",func = deco2(deco1(func)),simpleAssign,430 "Core Python Programming, Second Edition (2006)",Function composition in math is defined like this: (g · f)(x) = g(f(x)). For consistency in Python:,simpleAssign,430 "Core Python Programming, Second Edition (2006)",is the same as foo = g(f(foo)).,simpleAssign,430 "Core Python Programming, Second Edition (2006)",foo = deco(foo),simpleAssign,430 "Core Python Programming, Second Edition (2006)",foo = decomaker(deco_args)(foo),simpleAssign,430 "Core Python Programming, Second Edition (2006)",func = deco1(deco_arg)(deco2(func)),simpleAssign,431 "Core Python Programming, Second Edition (2006)",bar = foo,simpleAssign,433 "Core Python Programming, Second Edition (2006)","net_conn(port=8080, host='chino')",simpleAssign,437 "Core Python Programming, Second Edition (2006)","net_conn(port=81, host='chino') # use stype def arg",simpleAssign,437 "Core Python Programming, Second Edition (2006)",14 lines = f.readlines(),simpleAssign,438 "Core Python Programming, Second Edition (2006)",21 process=firstLast):,simpleAssign,438 "Core Python Programming, Second Edition (2006)",25 retval = None,simpleAssign,438 "Core Python Programming, Second Edition (2006)","dictVarArgs(arg2='tales', c=123, d='poe', arg1='mystery')",simpleAssign,442 "Core Python Programming, Second Edition (2006)","newfoo('wolf', 3, 'projects', freud=90, gamble=96)",simpleAssign,442 "Core Python Programming, Second Edition (2006)","newfoo(10, 20, 30, 40, foo=50, bar=60)",simpleAssign,442 "Core Python Programming, Second Edition (2006)","newfoo(1, 2, 3, x=4, y=5, *aTuple, **aDict)",simpleAssign,443 "Core Python Programming, Second Edition (2006)",25 print '%s(%s) = FAILED:' % \,simpleAssign,444 "Core Python Programming, Second Edition (2006)",int(1234) = 1234,simpleAssign,444 "Core Python Programming, Second Edition (2006)",int(12.34) = 12,simpleAssign,444 "Core Python Programming, Second Edition (2006)",int('1234') = 1234,simpleAssign,445 "Core Python Programming, Second Edition (2006)",int('12.34') = FAILED: invalid literal for int(): 12.34,simpleAssign,445 "Core Python Programming, Second Edition (2006)",long(1234) = 1234L,simpleAssign,445 "Core Python Programming, Second Edition (2006)",long(12.34) = 12L,simpleAssign,445 "Core Python Programming, Second Edition (2006)",long('1234') = 1234L,simpleAssign,445 "Core Python Programming, Second Edition (2006)",long('12.34') = FAILED: invalid literal for long(): 12.34,simpleAssign,445 "Core Python Programming, Second Edition (2006)",float(1234) = 1234.0,simpleAssign,445 "Core Python Programming, Second Edition (2006)",float(12.34) = 12.34,simpleAssign,445 "Core Python Programming, Second Edition (2006)",float('1234') = 1234.0,simpleAssign,445 "Core Python Programming, Second Edition (2006)",float('12.34') = 12.34,simpleAssign,445 "Core Python Programming, Second Edition (2006)",true = lambda :True,simpleAssign,447 "Core Python Programming, Second Edition (2006)",b = lambda *z: z,simpleAssign,448 "Core Python Programming, Second Edition (2006)",lseq = list(seq) # convert to list,simpleAssign,454 "Core Python Programming, Second Edition (2006)",res = lseq.pop(0) # no,simpleAssign,454 "Core Python Programming, Second Edition (2006)",res = init # yes,simpleAssign,454 "Core Python Programming, Second Edition (2006)","res = bin_func(res, item) # apply function",simpleAssign,454 "Core Python Programming, Second Edition (2006)","allNums = range(5) # [0, 1, 2, 3, 4]",simpleAssign,455 "Core Python Programming, Second Edition (2006)",total = 0,simpleAssign,455 "Core Python Programming, Second Edition (2006)","total = mySum(total, eachNum)",simpleAssign,455 "Core Python Programming, Second Edition (2006)","add1 = partial(add, 1) # add1(x) == add(1, x)",simpleAssign,456 "Core Python Programming, Second Edition (2006)","mul100 = partial(mul, 100) # mul100(x) == mul(100, x)",simpleAssign,456 "Core Python Programming, Second Edition (2006)","baseTwo = partial(int, base=2)",simpleAssign,457 "Core Python Programming, Second Edition (2006)","If you create the partial function without the base keyword, e.g., baseTwoBAD = partial(int, 2), it would",simpleAssign,457 "Core Python Programming, Second Edition (2006)","left of the runtime arguments, meaning that baseTwoBAD(x) == int(2, x). If you call it, it would pass in 2",simpleAssign,457 "Core Python Programming, Second Edition (2006)","baseTwoBAD = partial(int, 2)",simpleAssign,457 "Core Python Programming, Second Edition (2006)","always come after the formal arguments, so baseTwo(x) == int(x, base=2).",simpleAssign,457 "Core Python Programming, Second Edition (2006)",6 root = Tkinter.Tk(),simpleAssign,458 "Core Python Programming, Second Edition (2006)","7 MyButton = partial(Tkinter.Button, root,",simpleAssign,458 "Core Python Programming, Second Edition (2006)",9 b1 = MyButton(text='Button 1'),simpleAssign,458 "Core Python Programming, Second Edition (2006)",10 b2 = MyButton(text='Button 2'),simpleAssign,458 "Core Python Programming, Second Edition (2006)","11 qb = MyButton(text='QUIT', bg='red',",simpleAssign,458 "Core Python Programming, Second Edition (2006)",12 command=root.quit),simpleAssign,458 "Core Python Programming, Second Edition (2006)","15 qb.pack(fill=Tkinter.X, expand=True)",simpleAssign,458 "Core Python Programming, Second Edition (2006)","b1 = Tkinter.Button(root, fg='white', bg='blue', text='Button 1')",simpleAssign,458 "Core Python Programming, Second Edition (2006)","b2 = Tkinter.Button(root, fg='white', bg='blue', text='Button 2')",simpleAssign,458 "Core Python Programming, Second Edition (2006)","qb = Tkinter.Button(root, fg='white', text='QUIT', bg='red',",simpleAssign,458 "Core Python Programming, Second Edition (2006)",command=root.quit),simpleAssign,458 "Core Python Programming, Second Edition (2006)",bar = 200,simpleAssign,461 "Core Python Programming, Second Edition (2006)",bar = 100,simpleAssign,461 "Core Python Programming, Second Edition (2006)",m = 3,simpleAssign,462 "Core Python Programming, Second Edition (2006)",n = 4,simpleAssign,462 "Core Python Programming, Second Edition (2006)",count = counter(5),simpleAssign,463 "Core Python Programming, Second Edition (2006)",count2 = counter(100),simpleAssign,464 "Core Python Programming, Second Edition (2006)",int 'w' id=0x2003788 val=1>,simpleAssign,464 "Core Python Programming, Second Edition (2006)",int 'x' id=0x200377c val=2>,simpleAssign,464 "Core Python Programming, Second Edition (2006)",int 'y' id=0x2003770 val=3>,simpleAssign,464 "Core Python Programming, Second Edition (2006)",int 'z' id=0x2003764 val=4>,simpleAssign,464 "Core Python Programming, Second Edition (2006)",4 w = x = y = z = 1,simpleAssign,464 "Core Python Programming, Second Edition (2006)",7 x = y = z = 2,simpleAssign,464 "Core Python Programming, Second Edition (2006)",10 y = z = 3,simpleAssign,464 "Core Python Programming, Second Edition (2006)",13 z = 4,simpleAssign,464 "Core Python Programming, Second Edition (2006)",19 clo = f3.func_closure,simpleAssign,465 "Core Python Programming, Second Edition (2006)",26 clo = f2.func_closure,simpleAssign,465 "Core Python Programming, Second Edition (2006)",33 clo = f1.func_closure,simpleAssign,465 "Core Python Programming, Second Edition (2006)",20 now = time(),simpleAssign,466 "Core Python Programming, Second Edition (2006)",x = 10,simpleAssign,468 "Core Python Programming, Second Edition (2006)",y = 5,simpleAssign,468 "Core Python Programming, Second Edition (2006)",x = 10,simpleAssign,469 "Core Python Programming, Second Edition (2006)",y = 5,simpleAssign,469 "Core Python Programming, Second Edition (2006)",y = 8,simpleAssign,469 "Core Python Programming, Second Edition (2006)",x = 10,simpleAssign,469 "Core Python Programming, Second Edition (2006)",y = 5,simpleAssign,469 "Core Python Programming, Second Edition (2006)",y = 8,simpleAssign,469 "Core Python Programming, Second Edition (2006)",x = 10,simpleAssign,470 "Core Python Programming, Second Edition (2006)",y = 5,simpleAssign,470 "Core Python Programming, Second Edition (2006)",y = 8,simpleAssign,470 "Core Python Programming, Second Edition (2006)","2 j, k = 1, 2",simpleAssign,470 "Core Python Programming, Second Edition (2006)","6 j, k = 3, 4",simpleAssign,470 "Core Python Programming, Second Edition (2006)",8 k = 5,simpleAssign,470 "Core Python Programming, Second Edition (2006)",12 j = 6,simpleAssign,470 "Core Python Programming, Second Edition (2006)",17 k = 7,simpleAssign,471 "Core Python Programming, Second Edition (2006)",21 j = 8,simpleAssign,471 "Core Python Programming, Second Edition (2006)","factorial(N) = N! = N * (N-1)!",simpleAssign,472 "Core Python Programming, Second Edition (2006)","We can now see that factorial is recursive because factorial(N) = N * factorial(N-1). In other words,",simpleAssign,472 "Core Python Programming, Second Edition (2006)",if n == 0 or n == 1: # 0! = 1! = 1,simpleAssign,472 "Core Python Programming, Second Edition (2006)",myG = simpleGen(),simpleAssign,474 "Core Python Programming, Second Edition (2006)",count = start_at,simpleAssign,475 "Core Python Programming, Second Edition (2006)",count = counter(5),simpleAssign,475 "Core Python Programming, Second Edition (2006)","files = filter(lambda x: x and x[0] != '.', os.",simpleAssign,479 "Core Python Programming, Second Edition (2006)",bar = 200,simpleAssign,486 "Core Python Programming, Second Edition (2006)",bar = 100,simpleAssign,487 "Core Python Programming, Second Edition (2006)",foo.version = 0.2,simpleAssign,487 "Core Python Programming, Second Edition (2006)",bag = MyUltimatePythonStorageDevice(),simpleAssign,487 "Core Python Programming, Second Edition (2006)",bag.x = 100,simpleAssign,487 "Core Python Programming, Second Edition (2006)",bag.y = 200,simpleAssign,487 "Core Python Programming, Second Edition (2006)",bag.version = 0.1,simpleAssign,487 "Core Python Programming, Second Edition (2006)",bag.completed = False,simpleAssign,487 "Core Python Programming, Second Edition (2006)",short = longmodulename,simpleAssign,491 "Core Python Programming, Second Edition (2006)",foo = 123,simpleAssign,493 "Core Python Programming, Second Edition (2006)",imptee.foo = 123,simpleAssign,494 "Core Python Programming, Second Edition (2006)",sys = __import__('sys'),simpleAssign,497 "Core Python Programming, Second Edition (2006)",anInt = 42,simpleAssign,497 "Core Python Programming, Second Edition (2006)","example, calling newname=importAs ('mymodule') will import the module mymodule, but",simpleAssign,509 "Core Python Programming, Second Edition (2006)",myFirstObject = MyNewObjectType(),simpleAssign,513 "Core Python Programming, Second Edition (2006)",mathObj = MyData(),simpleAssign,513 "Core Python Programming, Second Edition (2006)",mathObj.x = 4,simpleAssign,513 "Core Python Programming, Second Edition (2006)",mathObj.y = 5,simpleAssign,513 "Core Python Programming, Second Edition (2006)",myObj = MyDataWithMethod() # create the instance,simpleAssign,514 "Core Python Programming, Second Edition (2006)","john = AddrBookEntry('John Doe', '408-555-1212')",simpleAssign,515 "Core Python Programming, Second Edition (2006)","jane = AddrBookEntry('Jane Doe', '650-555-1212')",simpleAssign,515 "Core Python Programming, Second Edition (2006)","john = EmplAddrBookEntry('John Doe', '408-555-1212',",simpleAssign,517 "Core Python Programming, Second Edition (2006)",foo = 100,simpleAssign,524 "Core Python Programming, Second Edition (2006)",mc = MyClass(),simpleAssign,525 "Core Python Programming, Second Edition (2006)",stype = type('What is your quest?'),simpleAssign,528 "Core Python Programming, Second Edition (2006)",mc = MyClass() # instantiate class,simpleAssign,530 "Core Python Programming, Second Edition (2006)",mc = MyClass(),simpleAssign,530 "Core Python Programming, Second Edition (2006)",c1 = C() # instantiation,simpleAssign,532 "Core Python Programming, Second Edition (2006)",c2 = c1 # create additional alias,simpleAssign,532 "Core Python Programming, Second Edition (2006)",c3 = c1 # create a third alias,simpleAssign,532 "Core Python Programming, Second Edition (2006)",count = 0 # count is class attr,simpleAssign,533 "Core Python Programming, Second Edition (2006)",InstCt.count -= 1,simpleAssign,533 "Core Python Programming, Second Edition (2006)",a = InstTrack(),simpleAssign,533 "Core Python Programming, Second Edition (2006)",b = InstTrack(),simpleAssign,534 "Core Python Programming, Second Edition (2006)","4 def __init__(self, rt, sales=0.085, rm=0.1):",simpleAssign,536 "Core Python Programming, Second Edition (2006)",6 sales tax == 8.5% and room tax == 10%''',simpleAssign,536 "Core Python Programming, Second Edition (2006)",7 self.salesTax = sales,simpleAssign,536 "Core Python Programming, Second Edition (2006)",8 self.roomTax = rm,simpleAssign,536 "Core Python Programming, Second Edition (2006)",9 self.roomRate = rt,simpleAssign,536 "Core Python Programming, Second Edition (2006)","11 def calcTotal(self, days=1):",simpleAssign,536 "Core Python Programming, Second Edition (2006)",13 daily = round((self.roomRate *,simpleAssign,536 "Core Python Programming, Second Edition (2006)",sfo = HotelRoomCalc(299) # new instance,simpleAssign,536 "Core Python Programming, Second Edition (2006)","sea = HotelRoomCalc(189, 0.086, 0.058) # new instance",simpleAssign,536 "Core Python Programming, Second Edition (2006)","wasWkDay = HotelRoomCalc(169, 0.045, 0.02) # new instance",simpleAssign,536 "Core Python Programming, Second Edition (2006)","wasWkEnd = HotelRoomCalc(119, 0.045, 0.02) # new instance",simpleAssign,537 "Core Python Programming, Second Edition (2006)",mc = MyClass(),simpleAssign,537 "Core Python Programming, Second Edition (2006)",mc = MyClass(),simpleAssign,537 "Core Python Programming, Second Edition (2006)",mc = MyClass(),simpleAssign,537 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,537 "Core Python Programming, Second Edition (2006)",c = C() # create instance,simpleAssign,538 "Core Python Programming, Second Edition (2006)",c.foo = 1,simpleAssign,538 "Core Python Programming, Second Edition (2006)",version = 1.2 # static member,simpleAssign,540 "Core Python Programming, Second Edition (2006)",c = C() # instantiation,simpleAssign,540 "Core Python Programming, Second Edition (2006)",x = 1.5,simpleAssign,541 "Core Python Programming, Second Edition (2006)",foo = Foo(),simpleAssign,541 "Core Python Programming, Second Edition (2006)",foo.x = 1.7 # try to update class attr,simpleAssign,541 "Core Python Programming, Second Edition (2006)",foo = Foo(),simpleAssign,542 "Core Python Programming, Second Edition (2006)",spam = 100 # class attribute,simpleAssign,542 "Core Python Programming, Second Edition (2006)",c1 = C() # create an instance,simpleAssign,542 "Core Python Programming, Second Edition (2006)",c2 = C() # create another instance,simpleAssign,542 "Core Python Programming, Second Edition (2006)",foo = staticmethod(foo),simpleAssign,546 "Core Python Programming, Second Edition (2006)",foo = classmethod(foo),simpleAssign,546 "Core Python Programming, Second Edition (2006)",tsm = TestStaticMethod(),simpleAssign,546 "Core Python Programming, Second Edition (2006)",tcm = TestClassMethod(),simpleAssign,547 "Core Python Programming, Second Edition (2006)","Now, seeing code like foo = staticmethod(foo) can irritate some programmers. There is something",simpleAssign,547 "Core Python Programming, Second Edition (2006)",p = Parent() # instance of parent,simpleAssign,550 "Core Python Programming, Second Edition (2006)",c = Child() # instance of child,simpleAssign,550 "Core Python Programming, Second Edition (2006)",c = C() # instantiate child,simpleAssign,551 "Core Python Programming, Second Edition (2006)",p = P() # parent instance,simpleAssign,551 "Core Python Programming, Second Edition (2006)",c = C() # child instance,simpleAssign,551 "Core Python Programming, Second Edition (2006)",p = P(),simpleAssign,552 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,553 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,553 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,554 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,554 "Core Python Programming, Second Edition (2006)","d = SortedKeyDict((('zheng-cai', 67), ('hui-jun', 68),",simpleAssign,556 "Core Python Programming, Second Edition (2006)",gc = GC(),simpleAssign,559 "Core Python Programming, Second Edition (2006)",gc = GC(),simpleAssign,559 "Core Python Programming, Second Edition (2006)",d = D(),simpleAssign,560 "Core Python Programming, Second Edition (2006)",c1 = C1(),simpleAssign,562 "Core Python Programming, Second Edition (2006)",c2 = C2(),simpleAssign,562 "Core Python Programming, Second Edition (2006)",myInst = myClass(),simpleAssign,564 "Core Python Programming, Second Edition (2006)",c = C(),simpleAssign,565 "Core Python Programming, Second Edition (2006)",c.foo = 100,simpleAssign,566 "Core Python Programming, Second Edition (2006)",dir(obj=None),simpleAssign,566 "Core Python Programming, Second Edition (2006)","super(type, obj=None)[a]",simpleAssign,566 "Core Python Programming, Second Edition (2006)",vars(obj=None),simpleAssign,566 "Core Python Programming, Second Edition (2006)",attr = val,simpleAssign,566 "Core Python Programming, Second Edition (2006)",less than/less than or equal to; < and <= operators,simpleAssign,568 "Core Python Programming, Second Edition (2006)","C.__gt__(self, obj) and C.__ge__(self, obj) greater than/greater than or equal to; > and >= operators",simpleAssign,568 "Core Python Programming, Second Edition (2006)","C.__eq__(self, obj) and C.__ne__(self, obj) equal/not equal to; ==,!= and <> operators",simpleAssign,568 "Core Python Programming, Second Edition (2006)","place of the asterisk implies a combination left-hand operation plus an assignment, as in self = self OP",simpleAssign,571 "Core Python Programming, Second Edition (2006)",rfm = RoundFloatManual(42),simpleAssign,572 "Core Python Programming, Second Edition (2006)",rfm = RoundFloatManual(4.2),simpleAssign,572 "Core Python Programming, Second Edition (2006)",rfm = RoundFloatManual(5.590464),simpleAssign,572 "Core Python Programming, Second Edition (2006)",rfm = RoundFloatManual(5.5964),simpleAssign,572 "Core Python Programming, Second Edition (2006)",__repr__ = __str__,simpleAssign,573 "Core Python Programming, Second Edition (2006)",rfm = RoundFloatManual(5.5964),simpleAssign,573 "Core Python Programming, Second Edition (2006)","7 self.value = round(val, 2)",simpleAssign,574 "Core Python Programming, Second Edition (2006)",12 __repr__ = __str__,simpleAssign,574 "Core Python Programming, Second Edition (2006)","mon = Time60(10, 30)",simpleAssign,574 "Core Python Programming, Second Edition (2006)","tue = Time60(11, 15)",simpleAssign,574 "Core Python Programming, Second Edition (2006)","mon = Time60(10, 30)",simpleAssign,575 "Core Python Programming, Second Edition (2006)","tue = Time60(11, 15)",simpleAssign,575 "Core Python Programming, Second Edition (2006)",__repr__ = __str__,simpleAssign,576 "Core Python Programming, Second Edition (2006)","mon = Time60(10, 30)",simpleAssign,576 "Core Python Programming, Second Edition (2006)","tue = Time60(11, 15)",simpleAssign,576 "Core Python Programming, Second Edition (2006)",8 self.hr = hr,simpleAssign,577 "Core Python Programming, Second Edition (2006)",9 self.min = min,simpleAssign,577 "Core Python Programming, Second Edition (2006)",15 __repr__ = __str__,simpleAssign,577 "Core Python Programming, Second Edition (2006)",7 self.data = seq,simpleAssign,577 "Core Python Programming, Second Edition (2006)","wed = Time60(12, 5)",simpleAssign,578 "Core Python Programming, Second Edition (2006)","thu = Time60(10, 30)",simpleAssign,578 "Core Python Programming, Second Edition (2006)","fri = Time60(8, 45)",simpleAssign,578 "Core Python Programming, Second Edition (2006)","4 def __init__(self, data, safe=False):",simpleAssign,579 "Core Python Programming, Second Edition (2006)",5 self.safe = safe,simpleAssign,579 "Core Python Programming, Second Edition (2006)",6 self.iter = iter(data),simpleAssign,579 "Core Python Programming, Second Edition (2006)","11 def next(self, howmany=1):",simpleAssign,579 "Core Python Programming, Second Edition (2006)",a = AnyIter(range(10)),simpleAssign,580 "Core Python Programming, Second Edition (2006)",i = iter(a),simpleAssign,580 "Core Python Programming, Second Edition (2006)",i = iter(a),simpleAssign,580 "Core Python Programming, Second Edition (2006)","a = AnyIter(range(10), True)",simpleAssign,580 "Core Python Programming, Second Edition (2006)",i = iter(a),simpleAssign,580 "Core Python Programming, Second Edition (2006)","the empty string should be used, i.e., n=0 and s='', as defaults.",simpleAssign,580 "Core Python Programming, Second Edition (2006)","i.e., n1 > n2 and s1 < s2, n1 == n2 and s1 > s2, etc.). We use the normal numeric and lexicographic",simpleAssign,581 "Core Python Programming, Second Edition (2006)","5 def __init__(self, num=0, string=''):",simpleAssign,581 "Core Python Programming, Second Edition (2006)",6 self.__num = num,simpleAssign,581 "Core Python Programming, Second Edition (2006)",7 self.__string = string,simpleAssign,581 "Core Python Programming, Second Edition (2006)",12 __repr__ = __str__,simpleAssign,581 "Core Python Programming, Second Edition (2006)","a = NumStr(3, 'foo')",simpleAssign,582 "Core Python Programming, Second Edition (2006)","b = NumStr(3, 'goo')",simpleAssign,582 "Core Python Programming, Second Edition (2006)","c = NumStr(2, 'foo')",simpleAssign,582 "Core Python Programming, Second Edition (2006)",d = NumStr(),simpleAssign,582 "Core Python Programming, Second Edition (2006)",e = NumStr(string='boo'),simpleAssign,582 "Core Python Programming, Second Edition (2006)",f = NumStr(1),simpleAssign,582 "Core Python Programming, Second Edition (2006)",a == a,simpleAssign,582 "Core Python Programming, Second Edition (2006)","wrappedList = WrapMe([123, 'foo', 45.67])",simpleAssign,589 "Core Python Programming, Second Edition (2006)",realList = wrappedList.get(),simpleAssign,590 "Core Python Programming, Second Edition (2006)",8 self.__data = obj,simpleAssign,591 "Core Python Programming, Second Edition (2006)",9 self.__ctime = self.__mtime = \,simpleAssign,591 "Core Python Programming, Second Edition (2006)",10 self.__atime = time(),simpleAssign,591 "Core Python Programming, Second Edition (2006)",13 self.__atime = time(),simpleAssign,591 "Core Python Programming, Second Edition (2006)",28 self.__data = obj,simpleAssign,591 "Core Python Programming, Second Edition (2006)",29 self.__mtime = self.__atime = time(),simpleAssign,591 "Core Python Programming, Second Edition (2006)",32 self.__atime = time(),simpleAssign,591 "Core Python Programming, Second Edition (2006)",36 self.__atime = time(),simpleAssign,591 "Core Python Programming, Second Edition (2006)",40 self.__atime = time(),simpleAssign,592 "Core Python Programming, Second Edition (2006)",timeWrappedObj = TimedWrapMe(932),simpleAssign,592 "Core Python Programming, Second Edition (2006)","f = CapOpen('/tmp/xxx', 'w')",simpleAssign,593 "Core Python Programming, Second Edition (2006)","f = CapOpen('/tmp/xxx', 'r')",simpleAssign,594 "Core Python Programming, Second Edition (2006)",if type(obj) == type(0)...,simpleAssign,596 "Core Python Programming, Second Edition (2006)",if type(obj) == types.IntType...,simpleAssign,596 "Core Python Programming, Second Edition (2006)",c = SlottedClass(),simpleAssign,596 "Core Python Programming, Second Edition (2006)",c.foo = 42,simpleAssign,596 "Core Python Programming, Second Edition (2006)","def __get__(self, obj, typ=None)",simpleAssign,598 "Core Python Programming, Second Edition (2006)",foo = DevNull1(),simpleAssign,599 "Core Python Programming, Second Edition (2006)",c1 = C1(),simpleAssign,599 "Core Python Programming, Second Edition (2006)",foo = DevNull2(),simpleAssign,600 "Core Python Programming, Second Edition (2006)",c2 = C2(),simpleAssign,600 "Core Python Programming, Second Edition (2006)",x = c2.foo,simpleAssign,600 "Core Python Programming, Second Edition (2006)",foo = DevNull3('foo'),simpleAssign,600 "Core Python Programming, Second Edition (2006)",c3 = C3(),simpleAssign,600 "Core Python Programming, Second Edition (2006)",x = c3.foo,simpleAssign,600 "Core Python Programming, Second Edition (2006)",x = c3.foo,simpleAssign,600 "Core Python Programming, Second Edition (2006)",bar = FooFoo(),simpleAssign,601 "Core Python Programming, Second Edition (2006)",bar.foo = barBar,simpleAssign,601 "Core Python Programming, Second Edition (2006)","9 def __init__(self, name=None):",simpleAssign,602 "Core Python Programming, Second Edition (2006)",10 self.name = name,simpleAssign,602 "Core Python Programming, Second Edition (2006)","12 def __get__(self, obj, typ=None):",simpleAssign,602 "Core Python Programming, Second Edition (2006)",foo = FileDescr('foo'),simpleAssign,603 "Core Python Programming, Second Edition (2006)",bar = FileDescr('bar'),simpleAssign,603 "Core Python Programming, Second Edition (2006)",fvc = MyFileVarClass(),simpleAssign,603 "Core Python Programming, Second Edition (2006)",fvc.foo = 42,simpleAssign,603 "Core Python Programming, Second Edition (2006)",fvc.foo = __builtins__,simpleAssign,603 "Core Python Programming, Second Edition (2006)",x = property(get_x),simpleAssign,604 "Core Python Programming, Second Edition (2006)",inst = ProtectAndHideX('foo'),simpleAssign,605 "Core Python Programming, Second Edition (2006)",inst = ProtectAndHideX(10),simpleAssign,605 "Core Python Programming, Second Edition (2006)",inst.x = 10,simpleAssign,605 "Core Python Programming, Second Edition (2006)",inst.x = 20,simpleAssign,605 "Core Python Programming, Second Edition (2006)","x = property(get_x, set_x)",simpleAssign,605 "Core Python Programming, Second Edition (2006)",inst = HideX(20),simpleAssign,605 "Core Python Programming, Second Edition (2006)",inst.x = 30,simpleAssign,605 "Core Python Programming, Second Edition (2006)","pi = property(get_pi, doc='Constant ""pi""')",simpleAssign,606 "Core Python Programming, Second Edition (2006)",inst = PI(),simpleAssign,606 "Core Python Programming, Second Edition (2006)",inst.set_x(40) # can we require inst.x = 40?,simpleAssign,606 "Core Python Programming, Second Edition (2006)",longer use inst.set_x(40) to set the attribute ... they have to use init.x = 40. We also use a function,simpleAssign,607 "Core Python Programming, Second Edition (2006)",following assignment after the x() function declaration with x = property(**x()).,simpleAssign,607 "Core Python Programming, Second Edition (2006)","can do some trickery here... if you define a classic class and set __metaclass__ = type, you have",simpleAssign,608 "Core Python Programming, Second Edition (2006)",f = Foo(),simpleAssign,609 "Core Python Programming, Second Edition (2006)",stacklevel=3),simpleAssign,610 "Core Python Programming, Second Edition (2006)",18 stacklevel=3),simpleAssign,610 "Core Python Programming, Second Edition (2006)",23 __metaclass__ = ReqStrSugRepr,simpleAssign,610 "Core Python Programming, Second Edition (2006)",35 __metaclass__ = ReqStrSugRepr,simpleAssign,610 "Core Python Programming, Second Edition (2006)",44 __metaclass__ = ReqStrSugRepr,simpleAssign,611 "Core Python Programming, Second Edition (2006)","add(12, 2) = 14",simpleAssign,613 "Core Python Programming, Second Edition (2006)","add(12, 3) = 15",simpleAssign,613 "Core Python Programming, Second Edition (2006)","add(12, 4) = 16",simpleAssign,613 "Core Python Programming, Second Edition (2006)","add(24, 2) = 26",simpleAssign,613 "Core Python Programming, Second Edition (2006)","add(24, 3) = 27",simpleAssign,613 "Core Python Programming, Second Edition (2006)","add(24, 4) = 28",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(12, 2) = 10",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(12, 3) = 9",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(12, 4) = 8",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(24, 2) = 22",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(24, 3) = 21",simpleAssign,613 "Core Python Programming, Second Edition (2006)","sub(24, 4) = 20",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(12, 2) = 24",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(12, 3) = 36",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(12, 4) = 48",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(24, 2) = 48",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(24, 3) = 72",simpleAssign,613 "Core Python Programming, Second Edition (2006)","mul(24, 4) = 96",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(12, 2) = 6",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(12, 3) = 4",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(12, 4) = 3",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(24, 2) = 12",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(24, 3) = 8",simpleAssign,613 "Core Python Programming, Second Edition (2006)","div(24, 4) = 6",simpleAssign,613 "Core Python Programming, Second Edition (2006)","4 def __init__(self, value=0.0) : # constructor",simpleAssign,616 "Core Python Programming, Second Edition (2006)",5 self.value = float(value),simpleAssign,616 "Core Python Programming, Second Edition (2006)","7 def update(self, value=None): # allow updates",simpleAssign,616 "Core Python Programming, Second Edition (2006)",cash = moneyfmt.MoneyFmt(123.45),simpleAssign,616 "Core Python Programming, Second Edition (2006)","wed = Time60(12, 5)",simpleAssign,621 "Core Python Programming, Second Edition (2006)","thu = Time60(10, 30)",simpleAssign,622 "Core Python Programming, Second Edition (2006)","fri = Time60(8, 45)",simpleAssign,622 "Core Python Programming, Second Edition (2006)",X = property (**x()).,simpleAssign,622 "Core Python Programming, Second Edition (2006)",lambdaFunc = lambda x: x * 2,simpleAssign,626 "Core Python Programming, Second Edition (2006)",c = C() # instantiation,simpleAssign,628 "Core Python Programming, Second Edition (2006)",c1 = C() # invoking class to instantiate c1,simpleAssign,629 "Core Python Programming, Second Edition (2006)","c2 = C('The number of the counting shall be', 3)",simpleAssign,629 "Core Python Programming, Second Edition (2006)",c = C() # instantiation,simpleAssign,629 "Core Python Programming, Second Edition (2006)","eval(obj, globals=globals(), locals=locals()) Evaluates obj, which is either an expression compiled",simpleAssign,632 "Core Python Programming, Second Edition (2006)","single_code = compile('print""Hello world!""', '', 'single')",simpleAssign,633 "Core Python Programming, Second Edition (2006)","exec_code = compile(""""""",simpleAssign,633 "Core Python Programming, Second Edition (2006)",req = input('Count how many numbers? '),simpleAssign,633 "Core Python Programming, Second Edition (2006)",x = 0,simpleAssign,635 "Core Python Programming, Second Edition (2006)",aString = raw_input('Enter a list: '),simpleAssign,636 "Core Python Programming, Second Edition (2006)",aList = input('Enter a list: '),simpleAssign,637 "Core Python Programming, Second Edition (2006)",12 %s = 0,simpleAssign,637 "Core Python Programming, Second Edition (2006)",29 ltype = raw_input('Loop type? (For/While) '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",30 dtype = raw_input('Data type? (Number/Seq) '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",34 stop = input('Ending value (non-inclusive)? '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",35 step = input('Stepping value? '),simpleAssign,638 "Core Python Programming, Second Edition (2006)","36 seq = str(range(start, stop, step))",simpleAssign,638 "Core Python Programming, Second Edition (2006)",39 seq = raw_input('Enter sequence: '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",41 var = raw_input('Iterative variable name? '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",48 svar = raw_input('Enter sequence name? '),simpleAssign,638 "Core Python Programming, Second Edition (2006)",49 exec_str = exec_dict['s'] % \,simpleAssign,638 "Core Python Programming, Second Edition (2006)",counter = 0,simpleAssign,639 "Core Python Programming, Second Edition (2006)",eachIndex = 0,simpleAssign,640 "Core Python Programming, Second Edition (2006)",19 obj = eval(eachAttr),simpleAssign,642 "Core Python Programming, Second Edition (2006)","execfile(filename, globals=globals(), locals=locals())",simpleAssign,646 "Core Python Programming, Second Edition (2006)",result = os.system('cat /etc/motd'),simpleAssign,650 "Core Python Programming, Second Edition (2006)",result = os.system('uname -a'),simpleAssign,650 "Core Python Programming, Second Edition (2006)",result = os.system('dir'),simpleAssign,650 "Core Python Programming, Second Edition (2006)","ret = os.fork() # spawn 2 processes, both return",simpleAssign,651 "Core Python Programming, Second Edition (2006)",if ret == 0: # child returns with PID of 0,simpleAssign,651 "Core Python Programming, Second Edition (2006)",ret = os.fork(),simpleAssign,652 "Core Python Programming, Second Edition (2006)",if ret == 0: # child code,simpleAssign,652 "Core Python Programming, Second Edition (2006)","res = call(('cat', '/etc/motd'))",simpleAssign,653 "Core Python Programming, Second Edition (2006)","res = call(('dir', r'c:\windows\temp'), shell=True)",simpleAssign,653 "Core Python Programming, Second Edition (2006)",sys.exit(status=0),simpleAssign,656 "Core Python Programming, Second Edition (2006)",10 argc = len(sys.argv),simpleAssign,657 "Core Python Programming, Second Edition (2006)","prev_exit_func = getattr(sys, 'exitfunc', None)",simpleAssign,657 "Core Python Programming, Second Edition (2006)",sys.exitfunc = my_exit_func,simpleAssign,657 "Core Python Programming, Second Edition (2006)",prev_exit_func = None,simpleAssign,658 "Core Python Programming, Second Edition (2006)","compile(pattern, flags=0)",simpleAssign,676 "Core Python Programming, Second Edition (2006)","match(pattern, string, flags=0)",simpleAssign,677 "Core Python Programming, Second Edition (2006)","search(pattern, string, flags=0)",simpleAssign,677 "Core Python Programming, Second Edition (2006)","split(pattern, string, max=0)",simpleAssign,677 "Core Python Programming, Second Edition (2006)","sub(pattern, repl, string, max=0)",simpleAssign,677 "Core Python Programming, Second Edition (2006)",group(num=0),simpleAssign,677 "Core Python Programming, Second Edition (2006)","m = re.match('foo', 'foo') # pattern matches string",simpleAssign,679 "Core Python Programming, Second Edition (2006)","m = re.match('foo', 'bar')# pattern does not match string",simpleAssign,679 "Core Python Programming, Second Edition (2006)","m = re.match('foo', 'food on the table') # match succeeds",simpleAssign,679 "Core Python Programming, Second Edition (2006)","m = re.match('foo', 'seafood') # no match",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.search('foo', 'seafood') # use search() instead",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.match(bt, 'bat') # 'bat' is a match",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.match(bt, 'blt') # no match for 'blt'",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.match(bt, 'He bit me!') # does not match string",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.search(bt, 'He bit me!') # found 'bit' via search",simpleAssign,680 "Core Python Programming, Second Edition (2006)","m = re.match(anyend, 'bend') # dot matches 'b'",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match(anyend, 'end') # no char to match",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match(anyend, '\nend') # any char except \n",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.search('.end', 'The end.') # matches ' ' in search",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match(pi_patt, '3.14') # exact match",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match(patt314, '3014') # dot matches '0'",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match(patt314, '3.14') # dot matches '.'",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match('[cr][23][dp][o2]', 'c3po') # matches 'c3po'",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match('[cr][23][dp][o2]', 'c2do') # matches 'c2do'",simpleAssign,681 "Core Python Programming, Second Edition (2006)","m = re.match('r2d2|c3po', 'c2do') # does not match 'c2do'",simpleAssign,682 "Core Python Programming, Second Edition (2006)","m = re.match('r2d2|c3po', 'r2d2') # matches 'r2d2'",simpleAssign,682 "Core Python Programming, Second Edition (2006)","m = re.match('\w\w\w-\d\d\d', 'abc-123')",simpleAssign,682 "Core Python Programming, Second Edition (2006)","m = re.match('\w\w\w-\d\d\d', 'abc-xyz')",simpleAssign,682 "Core Python Programming, Second Edition (2006)","m = re.match('(\w\w\w)-(\d\d\d)', 'abc-123')",simpleAssign,683 "Core Python Programming, Second Edition (2006)","m = re.match('ab', 'ab') # no subgroups",simpleAssign,683 "Core Python Programming, Second Edition (2006)","m = re.match('(ab)', 'ab') # one subgroup",simpleAssign,683 "Core Python Programming, Second Edition (2006)","m = re.match('(a)(b)', 'ab') # two subgroups",simpleAssign,683 "Core Python Programming, Second Edition (2006)","m = re.match('(a(b))', 'ab') # two subgroups",simpleAssign,683 "Core Python Programming, Second Edition (2006)","m = re.search('^The', 'The end.') # match",simpleAssign,684 "Core Python Programming, Second Edition (2006)","m = re.search('^The', 'end. The') # not at beginning",simpleAssign,684 "Core Python Programming, Second Edition (2006)","m = re.search(r'\bthe', 'bite the dog') # at a boundary",simpleAssign,684 "Core Python Programming, Second Edition (2006)","m = re.search(r'\bthe', 'bitethe dog') # no boundary",simpleAssign,684 "Core Python Programming, Second Edition (2006)","m = re.search(r'\Bthe', 'bitethe dog') # no boundary",simpleAssign,684 "Core Python Programming, Second Edition (2006)","m = re.match('\bblow', 'blow') # backspace, no match",simpleAssign,688 "Core Python Programming, Second Edition (2006)","m = re.match('\\bblow', 'blow') # escaped \, now it works",simpleAssign,688 "Core Python Programming, Second Edition (2006)","m = re.match(r'\bblow', 'blow') # use raw string instead",simpleAssign,688 "Core Python Programming, Second Edition (2006)","11 dtint = randint(0, maxint-1) # pick date",simpleAssign,689 "Core Python Programming, Second Edition (2006)",12 dtstr = ctime(dtint) # date string,simpleAssign,689 "Core Python Programming, Second Edition (2006)","14 shorter = randint(4, 7) # login shorter",simpleAssign,689 "Core Python Programming, Second Edition (2006)","19 longer = randint(shorter, 12) # domain longer",simpleAssign,689 "Core Python Programming, Second Edition (2006)","m = re.match(patt, data)",simpleAssign,691 "Core Python Programming, Second Edition (2006)","m = re.match(patt, data)",simpleAssign,692 "Core Python Programming, Second Edition (2006)","m = re.match(patt, data)",simpleAssign,692 "Core Python Programming, Second Edition (2006)","m = re.search(patt, data)",simpleAssign,694 "Core Python Programming, Second Edition (2006)","socket(socket_family, socket_type, protocol=0)",simpleAssign,706 "Core Python Programming, Second Edition (2006)","tcpSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)",simpleAssign,706 "Core Python Programming, Second Edition (2006)","udpSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)",simpleAssign,706 "Core Python Programming, Second Edition (2006)","tcpSock = socket(AF_INET, SOCK_STREAM)",simpleAssign,706 "Core Python Programming, Second Edition (2006)",ss = socket() # create server socket,simpleAssign,708 "Core Python Programming, Second Edition (2006)",cs = ss.accept() # accept client connection,simpleAssign,708 "Core Python Programming, Second Edition (2006)",7 PORT = 21567,simpleAssign,709 "Core Python Programming, Second Edition (2006)",8 BUFSIZ = 1024,simpleAssign,709 "Core Python Programming, Second Edition (2006)","11 tcpSerSock = socket(AF_INET, SOCK_STREAM)",simpleAssign,709 "Core Python Programming, Second Edition (2006)","17 tcpCliSock, addr = tcpSerSock.accept()",simpleAssign,709 "Core Python Programming, Second Edition (2006)",21 data = tcpCliSock.recv(BUFSIZ),simpleAssign,709 "Core Python Programming, Second Edition (2006)",cs = socket() # create client socket,simpleAssign,710 "Core Python Programming, Second Edition (2006)",6 PORT = 21567,simpleAssign,711 "Core Python Programming, Second Edition (2006)",7 BUFSIZ = 1024,simpleAssign,711 "Core Python Programming, Second Edition (2006)","10 tcpCliSock = socket(AF_INET, SOCK_STREAM)",simpleAssign,711 "Core Python Programming, Second Edition (2006)",ss = socket() # create server socket,simpleAssign,713 "Core Python Programming, Second Edition (2006)",cs = ss.recvfrom()/ss.sendto()# dialog (receive/send),simpleAssign,713 "Core Python Programming, Second Edition (2006)",7 PORT = 21567,simpleAssign,714 "Core Python Programming, Second Edition (2006)",8 BUFSIZ = 1024,simpleAssign,714 "Core Python Programming, Second Edition (2006)","11 udpSerSock = socket(AF_INET, SOCK_DGRAM)",simpleAssign,714 "Core Python Programming, Second Edition (2006)","16 data, addr = udpSerSock.recvfrom(BUFSIZ)",simpleAssign,714 "Core Python Programming, Second Edition (2006)",cs = socket() # create client socket,simpleAssign,715 "Core Python Programming, Second Edition (2006)",6 PORT = 21567,simpleAssign,715 "Core Python Programming, Second Edition (2006)",7 BUFSIZ = 1024,simpleAssign,715 "Core Python Programming, Second Edition (2006)","10 udpCliSock = socket(AF_INET, SOCK_DGRAM)",simpleAssign,715 "Core Python Programming, Second Edition (2006)","Socket types (TCP = stream, UDP = datagram)",simpleAssign,717 "Core Python Programming, Second Edition (2006)",8 PORT = 21567,simpleAssign,720 "Core Python Programming, Second Edition (2006)","17 tcpServ = TCP(ADDR, MyRequestHandler)",simpleAssign,720 "Core Python Programming, Second Edition (2006)",6 PORT = 21567,simpleAssign,722 "Core Python Programming, Second Edition (2006)",7 BUFSIZ = 1024,simpleAssign,722 "Core Python Programming, Second Edition (2006)",6 PORT = 21567,simpleAssign,725 "Core Python Programming, Second Edition (2006)",10 clnt = self.clnt = self.transport.getPeer().host,simpleAssign,725 "Core Python Programming, Second Edition (2006)",16 factory = protocol.Factory(),simpleAssign,725 "Core Python Programming, Second Edition (2006)",17 factory.protocol = TSServProtocol,simpleAssign,725 "Core Python Programming, Second Edition (2006)",6 PORT = 21567,simpleAssign,726 "Core Python Programming, Second Edition (2006)",10 data = raw_input('> '),simpleAssign,726 "Core Python Programming, Second Edition (2006)",25 protocol = TSClntProtocol,simpleAssign,726 "Core Python Programming, Second Edition (2006)",26 clientConnectionLost = clientConnectionFailed = \,simpleAssign,726 "Core Python Programming, Second Edition (2006)",f= FTP('ftp.python.org'),simpleAssign,737 "Core Python Programming, Second Edition (2006)","retrbinary (cmd, cb [ , bs =8192[ ,ra ]] )",simpleAssign,738 "Core Python Programming, Second Edition (2006)","storbinary (cmd, f [ , bs= 8192] )",simpleAssign,738 "Core Python Programming, Second Edition (2006)",f = FTP('ftp.python.org'),simpleAssign,738 "Core Python Programming, Second Edition (2006)","user:passwd@host/path?attr1=val1&attr2=val2..."".",simpleAssign,741 "Core Python Programming, Second Edition (2006)",n = NNTP('your.nntp.server'),simpleAssign,745 "Core Python Programming, Second Edition (2006)","r,c,f,l,g = n.group('comp.lang.python')",simpleAssign,745 "Core Python Programming, Second Edition (2006)","group name, all of which are strings (name == group)",simpleAssign,745 "Core Python Programming, Second Edition (2006)",n = NNTP('your.nntp.server'),simpleAssign,746 "Core Python Programming, Second Edition (2006)","rsp, ct, fst, lst, grp = n.group('comp.lang.python')",simpleAssign,746 "Core Python Programming, Second Edition (2006)","rsp, anum, mid, data = n.article('110457')",simpleAssign,746 "Core Python Programming, Second Edition (2006)",First (<= 20) meaningful lines:,simpleAssign,747 "Core Python Programming, Second Edition (2006)",vals = sorted( random.random() for _ in range(2*N) ),simpleAssign,747 "Core Python Programming, Second Edition (2006)",14 n = nntplib.NNTP(HOST),simpleAssign,747 "Core Python Programming, Second Edition (2006)","15 #, user=USER, password=PASS)",simpleAssign,747 "Core Python Programming, Second Edition (2006)","43 rsp, frm = n.xhdr('from', rng)",simpleAssign,748 "Core Python Programming, Second Edition (2006)","44 rsp, sub = n.xhdr('subject', rng)",simpleAssign,748 "Core Python Programming, Second Edition (2006)","45 rsp, dat = n.xhdr('date', rng)",simpleAssign,748 "Core Python Programming, Second Edition (2006)","53 rsp, anum, mid, data = n.body(lst)",simpleAssign,748 "Core Python Programming, Second Edition (2006)",58 print '*** First (<= 20) meaningful lines:\n',simpleAssign,748 "Core Python Programming, Second Edition (2006)",59 count = 0,simpleAssign,748 "Core Python Programming, Second Edition (2006)",61 lastBlank = True,simpleAssign,748 "Core Python Programming, Second Edition (2006)",76 lastBlank = False,simpleAssign,749 "Core Python Programming, Second Edition (2006)",78 lastBlank = True,simpleAssign,749 "Core Python Programming, Second Edition (2006)",79 if count == 20:,simpleAssign,749 "Core Python Programming, Second Edition (2006)",d = stop - start,simpleAssign,749 "Core Python Programming, Second Edition (2006)",P = partition(),simpleAssign,749 "Core Python Programming, Second Edition (2006)",vals = sorted( random.random() for _ in range(2*N) ),simpleAssign,749 "Core Python Programming, Second Edition (2006)",n = SMTP('smtp.yourdomain.com'),simpleAssign,754 "Core Python Programming, Second Edition (2006)",s = smtp('smtp.python.is.cool'),simpleAssign,755 "Core Python Programming, Second Edition (2006)",send: 'mail FROM:<wesley@python.is.cool> size=108\r\n',simpleAssign,755 "Core Python Programming, Second Edition (2006)",reply: '250 ok ; id=2005122623583701300or7hhe\r\n',simpleAssign,755 "Core Python Programming, Second Edition (2006)",reply: retcode (250); Msg: ok ; id=2005122623583701300or7hhe,simpleAssign,755 "Core Python Programming, Second Edition (2006)","data: (250, 'ok ; id=2005122623583701300or7hhe')",simpleAssign,756 "Core Python Programming, Second Edition (2006)",p = POP3('pop.python.is.cool'),simpleAssign,757 "Core Python Programming, Second Edition (2006)",p = POP3('pop.python.is.cool'),simpleAssign,758 "Core Python Programming, Second Edition (2006)","rsp, msg, siz = p.retr(102)",simpleAssign,758 "Core Python Programming, Second Edition (2006)",16 sendSvr = SMTP(SMTPSVR),simpleAssign,760 "Core Python Programming, Second Edition (2006)","17 errs = sendSvr.sendmail('wesley@python.is.cool',",simpleAssign,760 "Core Python Programming, Second Edition (2006)","20 assert len(errs) == 0, errs",simpleAssign,760 "Core Python Programming, Second Edition (2006)",23 recvSvr = POP3(POP3SVR),simpleAssign,760 "Core Python Programming, Second Edition (2006)","26 rsp, msg, siz = recvSvr.retr(recvSvr.stat()[0])",simpleAssign,760 "Core Python Programming, Second Edition (2006)",28 sep = msg.index(''),simpleAssign,760 "Core Python Programming, Second Edition (2006)",30 assert origBody == recvBody # assert identical,simpleAssign,760 "Core Python Programming, Second Edition (2006)",acquire(wait=None),simpleAssign,778 "Core Python Programming, Second Edition (2006)",17 nloops = range(len(loops)),simpleAssign,780 "Core Python Programming, Second Edition (2006)",20 lock = thread.allocate_lock(),simpleAssign,780 "Core Python Programming, Second Edition (2006)",join(timeout = None) Suspend until the started thread terminates; blocks unless timeout (in seconds),simpleAssign,784 "Core Python Programming, Second Edition (2006)",16 nloops = range(len(loops)),simpleAssign,785 "Core Python Programming, Second Edition (2006)","19 t = threading.Thread(target=loop,",simpleAssign,785 "Core Python Programming, Second Edition (2006)",11 self.name = name,simpleAssign,787 "Core Python Programming, Second Edition (2006)",12 self.func = func,simpleAssign,787 "Core Python Programming, Second Edition (2006)",13 self.args = args,simpleAssign,787 "Core Python Programming, Second Edition (2006)",26 nloops = range(len(loops)),simpleAssign,787 "Core Python Programming, Second Edition (2006)",29 t = threading.Thread(,simpleAssign,787 "Core Python Programming, Second Edition (2006)","30 target=ThreadFunc(loop, (i, loops[i]),",simpleAssign,787 "Core Python Programming, Second Edition (2006)",11 self.name = name,simpleAssign,788 "Core Python Programming, Second Edition (2006)",12 self.func = func,simpleAssign,788 "Core Python Programming, Second Edition (2006)",13 self.args = args,simpleAssign,788 "Core Python Programming, Second Edition (2006)",26 nloops = range(len(loops)),simpleAssign,789 "Core Python Programming, Second Edition (2006)",9 self.name = name,simpleAssign,790 "Core Python Programming, Second Edition (2006)",10 self.func = func,simpleAssign,790 "Core Python Programming, Second Edition (2006)",11 self.args = args,simpleAssign,790 "Core Python Programming, Second Edition (2006)","19 self.res = apply(self.func, self.args)",simpleAssign,790 "Core Python Programming, Second Edition (2006)",22 n = 12,simpleAssign,791 "Core Python Programming, Second Edition (2006)",25 nfuncs = range(len(funcs)),simpleAssign,791 "Core Python Programming, Second Edition (2006)","put(item, block=0) Puts item in queue, if block given (not 0), block until room is available",simpleAssign,793 "Core Python Programming, Second Edition (2006)",get(block=0),simpleAssign,793 "Core Python Programming, Second Edition (2006)",14 val = queue.get(1),simpleAssign,793 "Core Python Programming, Second Edition (2006)",29 nfuncs = range(len(funcs)),simpleAssign,794 "Core Python Programming, Second Edition (2006)","32 nloops = randint(2, 5)",simpleAssign,794 "Core Python Programming, Second Edition (2006)",33 q = Queue(32),simpleAssign,794 "Core Python Programming, Second Edition (2006)","top = Tkinter.Tk() # or just Tk() with ""from Tkinter import *""",simpleAssign,802 "Core Python Programming, Second Edition (2006)",top = Tkinter.Tk(),simpleAssign,804 "Core Python Programming, Second Edition (2006)",5 top = Tkinter.Tk(),simpleAssign,806 "Core Python Programming, Second Edition (2006)","6 label = Tkinter.Label(top, text='Hello World!')",simpleAssign,806 "Core Python Programming, Second Edition (2006)",5 top = Tkinter.Tk(),simpleAssign,807 "Core Python Programming, Second Edition (2006)","6 quit = Tkinter.Button(top, text='Hello World!',",simpleAssign,807 "Core Python Programming, Second Edition (2006)",7 command=top.quit),simpleAssign,807 "Core Python Programming, Second Edition (2006)",4 top = Tkinter.Tk(),simpleAssign,808 "Core Python Programming, Second Edition (2006)","6 hello = Tkinter.Label(top, text='Hello World!')",simpleAssign,808 "Core Python Programming, Second Edition (2006)","9 quit = Tkinter.Button(top, text='QUIT',",simpleAssign,808 "Core Python Programming, Second Edition (2006)","10 command=top.quit, bg='red', fg='white')",simpleAssign,808 "Core Python Programming, Second Edition (2006)","11 quit.pack(fill=Tkinter.X, expand=1)",simpleAssign,808 "Core Python Programming, Second Edition (2006)",5 def resize(ev=None):,simpleAssign,809 "Core Python Programming, Second Edition (2006)",9 top = Tk(),simpleAssign,809 "Core Python Programming, Second Edition (2006)","12 label = Label(top, text='Hello World!',",simpleAssign,809 "Core Python Programming, Second Edition (2006)","14 label.pack(fill=Y, expand=1)",simpleAssign,809 "Core Python Programming, Second Edition (2006)","16 scale = Scale(top, from_=10, to=40,",simpleAssign,809 "Core Python Programming, Second Edition (2006)","17 orient=HORIZONTAL, command=resize)",simpleAssign,809 "Core Python Programming, Second Edition (2006)","19 scale.pack(fill=X, expand=1)",simpleAssign,809 "Core Python Programming, Second Edition (2006)","21 quit = Button(top, text='QUIT',",simpleAssign,809 "Core Python Programming, Second Edition (2006)","22 command=top.quit, activeforeground='white',",simpleAssign,809 "Core Python Programming, Second Edition (2006)","20 critCB = lambda: showerror('Error', 'Error Button Pressed!')",simpleAssign,811 "Core Python Programming, Second Edition (2006)","21 warnCB = lambda: showwarning('Warning',",simpleAssign,811 "Core Python Programming, Second Edition (2006)","23 infoCB = lambda: showinfo('Info', 'Info Button Pressed!')",simpleAssign,811 "Core Python Programming, Second Edition (2006)",25 top = Tk(),simpleAssign,811 "Core Python Programming, Second Edition (2006)","27 Button(top, text='QUIT', command=top.quit,",simpleAssign,811 "Core Python Programming, Second Edition (2006)","30 MyButton = pto(Button, top)",simpleAssign,812 "Core Python Programming, Second Edition (2006)","31 CritButton = pto(MyButton, command=critCB, bg='white', fg='red')",simpleAssign,812 "Core Python Programming, Second Edition (2006)","32 WarnButton = pto(MyButton, command=warnCB, bg='goldenrod1')",simpleAssign,812 "Core Python Programming, Second Edition (2006)","33 ReguButton = pto(MyButton, command=infoCB, bg='white')",simpleAssign,812 "Core Python Programming, Second Edition (2006)",36 signType = SIGNS[eachSign],simpleAssign,812 "Core Python Programming, Second Edition (2006)","37 cmd = '%sButton(text=%r%s).pack(fill=X, expand=True)' % (",simpleAssign,812 "Core Python Programming, Second Edition (2006)",39 '.upper()' if signType == CRIT else '.title()'),simpleAssign,812 "Core Python Programming, Second Edition (2006)","9 def __init__(self, initdir=None):",simpleAssign,813 "Core Python Programming, Second Edition (2006)",10 self.top = Tk(),simpleAssign,813 "Core Python Programming, Second Edition (2006)","11 self.label = Label(self.top,",simpleAssign,813 "Core Python Programming, Second Edition (2006)",15 self.cwd = StringVar(self.top),simpleAssign,814 "Core Python Programming, Second Edition (2006)","17 self.dirl = Label(self.top, fg='blue',",simpleAssign,814 "Core Python Programming, Second Edition (2006)",21 self.dirfm = Frame(self.top),simpleAssign,814 "Core Python Programming, Second Edition (2006)",22 self.dirsb = Scrollbar(self.dirfm),simpleAssign,814 "Core Python Programming, Second Edition (2006)","23 self.dirsb.pack(side=RIGHT, fill=Y)",simpleAssign,814 "Core Python Programming, Second Edition (2006)","24 self.dirs = Listbox(self.dirfm, height=15,",simpleAssign,814 "Core Python Programming, Second Edition (2006)","25 width=50, yscrollcommand=self.dirsb.set)",simpleAssign,814 "Core Python Programming, Second Edition (2006)",27 self.dirsb.config(command=self.dirs.yview),simpleAssign,814 "Core Python Programming, Second Edition (2006)","28 self.dirs.pack(side=LEFT, fill=BOTH)",simpleAssign,814 "Core Python Programming, Second Edition (2006)","31 self.dirn = Entry(self.top, width=50,",simpleAssign,814 "Core Python Programming, Second Edition (2006)",32 textvariable=self.cwd),simpleAssign,814 "Core Python Programming, Second Edition (2006)",36 self.bfm = Frame(self.top),simpleAssign,814 "Core Python Programming, Second Edition (2006)","37 self.clr = Button(self.bfm, text='Clear',",simpleAssign,814 "Core Python Programming, Second Edition (2006)","38 command=self.clrDir,",simpleAssign,814 "Core Python Programming, Second Edition (2006)","41 self.ls = Button(self.bfm,",simpleAssign,814 "Core Python Programming, Second Edition (2006)","43 command=self.doLS,",simpleAssign,814 "Core Python Programming, Second Edition (2006)","46 self.quit = Button(self.bfm, text='Quit',",simpleAssign,814 "Core Python Programming, Second Edition (2006)","47 command=self.top.quit,",simpleAssign,814 "Core Python Programming, Second Edition (2006)",50 self.clr.pack(side=LEFT),simpleAssign,814 "Core Python Programming, Second Edition (2006)",51 self.ls.pack(side=LEFT),simpleAssign,814 "Core Python Programming, Second Edition (2006)",52 self.quit.pack(side=LEFT),simpleAssign,814 "Core Python Programming, Second Edition (2006)","59 def clrDir(self, ev=None):",simpleAssign,814 "Core Python Programming, Second Edition (2006)","62 def setDirAndGo(self, ev=None):",simpleAssign,814 "Core Python Programming, Second Edition (2006)",63 self.last = self.cwd.get(),simpleAssign,814 "Core Python Programming, Second Edition (2006)",65 check = self.dirs.get(self.dirs.curselection()),simpleAssign,814 "Core Python Programming, Second Edition (2006)","71 def doLS(self, ev=None):",simpleAssign,815 "Core Python Programming, Second Edition (2006)",73 tdir = self.cwd.get(),simpleAssign,815 "Core Python Programming, Second Edition (2006)",74 if not tdir: tdir = os.curdir,simpleAssign,815 "Core Python Programming, Second Edition (2006)",87 self.last = os.curdir,simpleAssign,815 "Core Python Programming, Second Edition (2006)",97 dirlist = os.listdir(tdir),simpleAssign,815 "Core Python Programming, Second Edition (2006)",100 self.dirl.config(text=os.getcwd()),simpleAssign,815 "Core Python Programming, Second Edition (2006)",111 d = DirList(os.curdir),simpleAssign,815 "Core Python Programming, Second Edition (2006)",6 top = Tk(),simpleAssign,822 "Core Python Programming, Second Edition (2006)","9 lb = Label(top,",simpleAssign,822 "Core Python Programming, Second Edition (2006)","13 ct = Control(top, label='Number:',",simpleAssign,822 "Core Python Programming, Second Edition (2006)","14 integer=True, max=12, min=2, value=2, step=2)",simpleAssign,822 "Core Python Programming, Second Edition (2006)","18 cb = ComboBox(top, label='Type:', editable=True)",simpleAssign,822 "Core Python Programming, Second Edition (2006)","23 qb = Button(top, text='QUIT',",simpleAssign,822 "Core Python Programming, Second Edition (2006)","24 command=top.quit, bg='red', fg='white')",simpleAssign,822 "Core Python Programming, Second Edition (2006)",6 top = initialise(),simpleAssign,823 "Core Python Programming, Second Edition (2006)","8 lb = Label(top,",simpleAssign,823 "Core Python Programming, Second Edition (2006)","12 ct = Counter(top, labelpos=W, label_text='Number:',",simpleAssign,823 "Core Python Programming, Second Edition (2006)","13 datatype='integer', entryfield_value=2,",simpleAssign,823 "Core Python Programming, Second Edition (2006)","18 cb = ComboBox(top, labelpos=W, label_text='Type:')",simpleAssign,823 "Core Python Programming, Second Edition (2006)","23 qb = Button(top, text='QUIT',",simpleAssign,823 "Core Python Programming, Second Edition (2006)","24 command=top.quit, bg='red', fg='white')",simpleAssign,823 "Core Python Programming, Second Edition (2006)","6 def __init__(self, parent=None, id=-1, title=''):",simpleAssign,824 "Core Python Programming, Second Edition (2006)",9 top = wx.Panel(self),simpleAssign,824 "Core Python Programming, Second Edition (2006)",10 sizer = wx.BoxSizer(wx.VERTICAL),simpleAssign,824 "Core Python Programming, Second Edition (2006)","11 font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD)",simpleAssign,824 "Core Python Programming, Second Edition (2006)","12 lb = wx.StaticText(top, -1,",simpleAssign,824 "Core Python Programming, Second Edition (2006)","16 c1 = wx.StaticText(top, -1, 'Number:')",simpleAssign,824 "Core Python Programming, Second Edition (2006)","18 ct = wx.SpinCtrl(top, -1, '2', min=2, max=12)",simpleAssign,824 "Core Python Programming, Second Edition (2006)","22 c2 = wx.StaticText(top, -1, 'Type:')",simpleAssign,824 "Core Python Programming, Second Edition (2006)","24 cb = wx.ComboBox(top, -1, '',",simpleAssign,824 "Core Python Programming, Second Edition (2006)","29 qb = wx.Button(top, -1, ""QUIT"")",simpleAssign,824 "Core Python Programming, Second Edition (2006)","41 frame = MyFrame(title=""wxWidgets"")",simpleAssign,824 "Core Python Programming, Second Edition (2006)",47 app = MyApp(),simpleAssign,824 "Core Python Programming, Second Edition (2006)",10 top = gtk.Window(gtk.WINDOW_TOPLEVEL),simpleAssign,825 "Core Python Programming, Second Edition (2006)","13 box = gtk.VBox(False, 0)",simpleAssign,825 "Core Python Programming, Second Edition (2006)",14 lb = gtk.Label(,simpleAssign,825 "Core Python Programming, Second Edition (2006)","18 sb = gtk.HBox(False, 0)",simpleAssign,826 "Core Python Programming, Second Edition (2006)","19 adj = gtk.Adjustment(2, 2, 12, 2, 4, 0)",simpleAssign,826 "Core Python Programming, Second Edition (2006)",20 sl = gtk.Label('Number:'),simpleAssign,826 "Core Python Programming, Second Edition (2006)","24 ct = gtk.SpinButton(adj, 0, 0)",simpleAssign,826 "Core Python Programming, Second Edition (2006)","28 cb = gtk.HBox(False, 0)",simpleAssign,826 "Core Python Programming, Second Edition (2006)",29 c2 = gtk.Label('Type:'),simpleAssign,826 "Core Python Programming, Second Edition (2006)",31 ce = gtk.combo_box_entry_new_text(),simpleAssign,826 "Core Python Programming, Second Edition (2006)","37 qb = gtk.Button("""")",simpleAssign,826 "Core Python Programming, Second Edition (2006)",38 red = gtk.gdk.color_parse('red'),simpleAssign,826 "Core Python Programming, Second Edition (2006)",39 sty = qb.get_style(),simpleAssign,826 "Core Python Programming, Second Edition (2006)",42 sty.bg[st] = red,simpleAssign,826 "Core Python Programming, Second Edition (2006)",44 ql = qb.child,simpleAssign,826 "Core Python Programming, Second Edition (2006)",53 animal = GTKapp(),simpleAssign,826 "Core Python Programming, Second Edition (2006)","Ampersand ( & ) delimited set of ""key=value"" pairs",simpleAssign,836 "Core Python Programming, Second Edition (2006)","urlparse(urlstr, defProtSch=None, allowFrag=None)",simpleAssign,837 "Core Python Programming, Second Edition (2006)","urljoin(baseurl, newurl, allowFrag=None)",simpleAssign,838 "Core Python Programming, Second Edition (2006)","urlparse(urlstr, defProtSch=None, allowFrag=None) Parses urlstr into separate components, using",simpleAssign,838 "Core Python Programming, Second Edition (2006)","urljoin(baseurl,newurl,allowFrag=None)",simpleAssign,839 "Core Python Programming, Second Edition (2006)","urlretrieve(urlstr, localfile=None, downloadSta-",simpleAssign,841 "Core Python Programming, Second Edition (2006)",tusHook=None),simpleAssign,841 "Core Python Programming, Second Edition (2006)",16 self.url = url,simpleAssign,841 "Core Python Programming, Second Edition (2006)",17 self.file = self.filename(url),simpleAssign,841 "Core Python Programming, Second Edition (2006)","20 parsedurl = urlparse(url, 'http:', 0) ## parse path",simpleAssign,841 "Core Python Programming, Second Edition (2006)",22 ext = splitext(path),simpleAssign,841 "Core Python Programming, Second Edition (2006)",28 ldir = dirname(path) # local directory,simpleAssign,842 "Core Python Programming, Second Edition (2006)","30 ldir = replace(ldir, '/', sep)",simpleAssign,842 "Core Python Programming, Second Edition (2006)",105 url = raw_input('Enter starting URL: '),simpleAssign,843 "Core Python Programming, Second Edition (2006)",number = 6,simpleAssign,843 "Core Python Programming, Second Edition (2006)",http://www/~foo/cgi-bin/s.py?name=joe mama&num=6',simpleAssign,844 "Core Python Programming, Second Edition (2006)","be included as part of a query in a CGI request URL string. The pairs are in ""key=value"" format and are",simpleAssign,844 "Core Python Programming, Second Edition (2006)","urlretrieve(urlstr, localfile=None,",simpleAssign,845 "Core Python Programming, Second Edition (2006)",downloadStatusHook=None),simpleAssign,845 "Core Python Programming, Second Edition (2006)",11 hdlr = urllib2.HTTPBasicAuthHandler(),simpleAssign,846 "Core Python Programming, Second Edition (2006)",13 opener = urllib2.build_opener(hdlr),simpleAssign,846 "Core Python Programming, Second Edition (2006)",19 req = urllib2.Request(url),simpleAssign,846 "Core Python Programming, Second Edition (2006)","20 b64str = encodestring('%s:%s' % (LOGIN, PASSWD))[:-1]",simpleAssign,846 "Core Python Programming, Second Edition (2006)",26 url = eval('%s_version')(URL),simpleAssign,846 "Core Python Programming, Second Edition (2006)","7 <INPUT TYPE=text NAME=person VALUE=""NEW USER"" SIZE=15>",simpleAssign,855 "Core Python Programming, Second Edition (2006)","9 <INPUT TYPE=radio NAME=howmany VALUE=""0"" CHECKED> 0",simpleAssign,855 "Core Python Programming, Second Edition (2006)","10 <INPUT TYPE=radio NAME=howmany VALUE=""10""> 10",simpleAssign,855 "Core Python Programming, Second Edition (2006)","11 <INPUT TYPE=radio NAME=howmany VALUE=""25""> 25",simpleAssign,855 "Core Python Programming, Second Edition (2006)","12 <INPUT TYPE=radio NAME=howmany VALUE=""50""> 50",simpleAssign,855 "Core Python Programming, Second Edition (2006)","13 <INPUT TYPE=radio NAME=howmany VALUE=""100""> 100",simpleAssign,855 "Core Python Programming, Second Edition (2006)",14 <P><INPUT TYPE=submit></FORM></BODY></HTML>,simpleAssign,855 "Core Python Programming, Second Edition (2006)",14 form = cgi.FieldStorage(),simpleAssign,857 "Core Python Programming, Second Edition (2006)",15 who = form['person'].value,simpleAssign,857 "Core Python Programming, Second Edition (2006)",16 howmany = form['howmany'].value,simpleAssign,857 "Core Python Programming, Second Edition (2006)",12 <INPUT TYPE=hidden NAME=action VALUE=edit>,simpleAssign,859 "Core Python Programming, Second Edition (2006)","13 <INPUT TYPE=text NAME=person VALUE=""NEW USER"" SIZE=15>",simpleAssign,859 "Core Python Programming, Second Edition (2006)",16 <P><INPUT TYPE=submit></FORM></BODY></HTML>''',simpleAssign,859 "Core Python Programming, Second Edition (2006)","18 fradio = '<INPUT TYPE=radio NAME=howmany VALUE=""%s"" %s> %s\n'",simpleAssign,859 "Core Python Programming, Second Edition (2006)",24 if i == 0:,simpleAssign,859 "Core Python Programming, Second Edition (2006)",42 form = cgi.FieldStorage(),simpleAssign,859 "Core Python Programming, Second Edition (2006)",51 howmany = 0,simpleAssign,859 "Core Python Programming, Second Edition (2006)",14 <FORM><INPUT TYPE=button VALUE=Back,simpleAssign,863 "Core Python Programming, Second Edition (2006)",26 <INPUT TYPE=hidden NAME=action VALUE=edit>,simpleAssign,863 "Core Python Programming, Second Edition (2006)","27 <INPUT TYPE=text NAME=person VALUE=""%s"" SIZE=15>",simpleAssign,863 "Core Python Programming, Second Edition (2006)",30 <P><INPUT TYPE=submit></FORM></BODY></HTML>''',simpleAssign,863 "Core Python Programming, Second Edition (2006)","32 fradio = '<INPUT TYPE=radio NAME=howmany VALUE=""%s"" %s> %s\n'",simpleAssign,863 "Core Python Programming, Second Edition (2006)",38 if str(i) == howmany:,simpleAssign,863 "Core Python Programming, Second Edition (2006)",59 form = cgi.FieldStorage(),simpleAssign,863 "Core Python Programming, Second Edition (2006)",73 howmany = 0,simpleAssign,864 "Core Python Programming, Second Edition (2006)","UNICODE_HELLO = u""""""",simpleAssign,868 "Core Python Programming, Second Edition (2006)",print 'Content-type: text/html; charset=UTF-8\r',simpleAssign,868 "Core Python Programming, Second Edition (2006)",4 UNICODE_HELLO = u''',simpleAssign,869 "Core Python Programming, Second Edition (2006)",INPUT type=file name=...>,simpleAssign,870 "Core Python Programming, Second Edition (2006)","come in ""key=value"" pairs. All your application needs to do to access the data values is to split the",simpleAssign,871 "Core Python Programming, Second Edition (2006)","17 <FORM METHOD=post ACTION=""%s"" ENCTYPE=""multipart/form-data"">",simpleAssign,877 "Core Python Programming, Second Edition (2006)","21 <INPUT NAME=cookie value=""%s""> (<I>optional</I>)</H3>",simpleAssign,877 "Core Python Programming, Second Edition (2006)","23 <INPUT NAME=person VALUE=""%s""> (<I>required</I>)</H3>",simpleAssign,877 "Core Python Programming, Second Edition (2006)","28 <INPUT TYPE=file NAME=upfile VALUE=""%s"" SIZE=45>",simpleAssign,877 "Core Python Programming, Second Edition (2006)",29 <P><INPUT TYPE=submit>,simpleAssign,877 "Core Python Programming, Second Edition (2006)","35 '<INPUT TYPE=checkbox NAME=lang VALUE=""%s""%s> %s\n'",simpleAssign,877 "Core Python Programming, Second Edition (2006)",43 tag = eachCookie[3:7],simpleAssign,877 "Core Python Programming, Second Edition (2006)",51 self.cookies['info'] = self.cookies['user'] = '',simpleAssign,877 "Core Python Programming, Second Edition (2006)","56 self.langs = split(langStr, ',')",simpleAssign,878 "Core Python Programming, Second Edition (2006)",58 self.who = self.fn = ' ',simpleAssign,878 "Core Python Programming, Second Edition (2006)",77 userCook = cookStatus = self.cookies['user'],simpleAssign,878 "Core Python Programming, Second Edition (2006)",86 <FORM><INPUT TYPE=button VALUE=Back,simpleAssign,878 "Core Python Programming, Second Edition (2006)",113 MAXBYTES = 1024,simpleAssign,879 "Core Python Programming, Second Edition (2006)",170 if type(langdata) == type([]):,simpleAssign,879 "Core Python Programming, Second Edition (2006)",180 self.fn = upfile.filename or '',simpleAssign,880 "Core Python Programming, Second Edition (2006)",184 self.fp = StringIO('(no data)'),simpleAssign,880 "Core Python Programming, Second Edition (2006)",186 self.fp = StringIO('(no file)'),simpleAssign,880 "Core Python Programming, Second Edition (2006)",195 page = AdvCGI(),simpleAssign,880 "Core Python Programming, Second Edition (2006)",form = cgi.FieldStorage(),simpleAssign,891 "Core Python Programming, Second Edition (2006)","howmany = form.get('who', '(no name submitted)')",simpleAssign,891 "Core Python Programming, Second Edition (2006)",UPDATE users SET prid=4 WHERE prid=2;,simpleAssign,896 "Core Python Programming, Second Edition (2006)",UPDATE users SET prid=1 WHERE uid=311;,simpleAssign,896 "Core Python Programming, Second Edition (2006)",fetchmany ([ size=cursor.arraysize]) Fetch next size rows of query result,simpleAssign,903 "Core Python Programming, Second Edition (2006)",cxn = MySQLdb.connect(user='root'),simpleAssign,906 "Core Python Programming, Second Edition (2006)",cxn = MySQLdb.connect(db='test'),simpleAssign,906 "Core Python Programming, Second Edition (2006)",cur = cxn.cursor(),simpleAssign,906 "Core Python Programming, Second Edition (2006)","cur.execute(""UPDATE users SET uid=7100 WHERE uid=7001"")",simpleAssign,907 "Core Python Programming, Second Edition (2006)",cxn = psycopg.connect(user='pgsql'),simpleAssign,908 "Core Python Programming, Second Edition (2006)",cxn = PgSQL.connect(user='pgsql'),simpleAssign,908 "Core Python Programming, Second Edition (2006)",cxn = pgdb.connect(user='pgsql'),simpleAssign,908 "Core Python Programming, Second Edition (2006)",cur = cxn.cursor(),simpleAssign,908 "Core Python Programming, Second Edition (2006)",rows = cur.fetchall(),simpleAssign,908 "Core Python Programming, Second Edition (2006)",pgsql=C*T*/pgsql}'),simpleAssign,908 "Core Python Programming, Second Edition (2006)",pgsql=C*T*/pgsql}'),simpleAssign,908 "Core Python Programming, Second Edition (2006)","None, '{pgsql=C*T*/pgsql}']",simpleAssign,909 "Core Python Programming, Second Edition (2006)","462', '', None, '{pgsql=C*T*/pgsql}']",simpleAssign,909 "Core Python Programming, Second Edition (2006)",cxn = sqlite3.connect('sqlite_test/test'),simpleAssign,909 "Core Python Programming, Second Edition (2006)",cur = cxn.cursor(),simpleAssign,909 "Core Python Programming, Second Edition (2006)",6 COLSIZ = 10,simpleAssign,910 "Core Python Programming, Second Edition (2006)",8 DB_EXC = None,simpleAssign,910 "Core Python Programming, Second Edition (2006)",89 drop = lambda cur: cur.execute('DROP TABLE users'),simpleAssign,912 "Core Python Programming, Second Edition (2006)",101 pick = list(NAMES),simpleAssign,912 "Core Python Programming, Second Edition (2006)","117 getRC = lambda cur: cur.rowcount if hasattr(cur,",simpleAssign,912 "Core Python Programming, Second Edition (2006)","120 fr = rrange(1,5)",simpleAssign,912 "Core Python Programming, Second Edition (2006)","121 to = rrange(1,5)",simpleAssign,912 "Core Python Programming, Second Edition (2006)","127 rm = rrange(1,5)",simpleAssign,912 "Core Python Programming, Second Edition (2006)",140 db = setup(),simpleAssign,913 "Core Python Programming, Second Edition (2006)","142 cxn = connect(db, 'test')",simpleAssign,913 "Core Python Programming, Second Edition (2006)","156 fr, to, num = update(cur)",simpleAssign,913 "Core Python Programming, Second Edition (2006)","162 rm, num = delete(cur)",simpleAssign,913 "Core Python Programming, Second Edition (2006)","getRC = lambda cur: (hasattr(cur, 'rowcount') \",simpleAssign,915 "Core Python Programming, Second Edition (2006)",10 COLSIZ = 10,simpleAssign,918 "Core Python Programming, Second Edition (2006)",16 MySQLdb = pool.manage(MySQLdb),simpleAssign,918 "Core Python Programming, Second Edition (2006)",18 eng = create_engine(url),simpleAssign,918 "Core Python Programming, Second Edition (2006)",60 users = self.users,simpleAssign,919 "Core Python Programming, Second Edition (2006)","61 fr = rrange(1,5)",simpleAssign,919 "Core Python Programming, Second Edition (2006)","62 to = rrange(1,5)",simpleAssign,919 "Core Python Programming, Second Edition (2006)",64 users.update(users.c.prid==fr).execute(prid=to).rowcount,simpleAssign,919 "Core Python Programming, Second Edition (2006)",67 users = self.users,simpleAssign,919 "Core Python Programming, Second Edition (2006)","68 rm = rrange(1,5)",simpleAssign,919 "Core Python Programming, Second Edition (2006)",70 users.delete(users.c.prid==rm).execute().rowcount,simpleAssign,919 "Core Python Programming, Second Edition (2006)",73 res = self.users.select().execute(),simpleAssign,919 "Core Python Programming, Second Edition (2006)","88 orm = MySQLAlchemy('mysql', DBNAME)",simpleAssign,919 "Core Python Programming, Second Edition (2006)","98 fr, to, num = orm.update()",simpleAssign,919 "Core Python Programming, Second Edition (2006)","104 rm, num = orm.delete()",simpleAssign,919 "Core Python Programming, Second Edition (2006)",9 COLSIZ = 10,simpleAssign,920 "Core Python Programming, Second Edition (2006)",19 cxn = connectionForURI(url),simpleAssign,920 "Core Python Programming, Second Edition (2006)",20 sqlhub.processConnection = cxn,simpleAssign,920 "Core Python Programming, Second Edition (2006)",21 #cxn.debug = True,simpleAssign,920 "Core Python Programming, Second Edition (2006)","37 cxn1 = sqlhub.processConnection= connectionForURI('mysql://root@localhost')",simpleAssign,920 "Core Python Programming, Second Edition (2006)",41 self.users = Users,simpleAssign,920 "Core Python Programming, Second Edition (2006)",42 self.cxn = cxn,simpleAssign,920 "Core Python Programming, Second Edition (2006)",45 Users = self.users,simpleAssign,921 "Core Python Programming, Second Edition (2006)","55 fr = rrange(1,5)",simpleAssign,921 "Core Python Programming, Second Edition (2006)","56 to = rrange(1,5)",simpleAssign,921 "Core Python Programming, Second Edition (2006)",57 users = self.users.selectBy(prid=fr),simpleAssign,921 "Core Python Programming, Second Edition (2006)",59 user.prid = to,simpleAssign,921 "Core Python Programming, Second Edition (2006)","63 rm = rrange(1,5)",simpleAssign,921 "Core Python Programming, Second Edition (2006)",64 users = self.users.selectBy(prid=rm),simpleAssign,921 "Core Python Programming, Second Edition (2006)",77 drop = lambda self: self.users.dropTable(),simpleAssign,921 "Core Python Programming, Second Edition (2006)",78 finish = lambda self: self.cxn.close(),simpleAssign,921 "Core Python Programming, Second Edition (2006)","82 orm = MySQLObject('mysql', DBNAME)",simpleAssign,921 "Core Python Programming, Second Edition (2006)","92 fr, to, num = orm.update()",simpleAssign,921 "Core Python Programming, Second Edition (2006)","98 rm, num = orm.delete()",simpleAssign,921 "Core Python Programming, Second Edition (2006)",drop = lambda self: self.users.drop(),simpleAssign,922 "Core Python Programming, Second Edition (2006)",7 if (n < 2) return(1); /* 0! == 1! == 1 */,simpleAssign,935 "Core Python Programming, Second Edition (2006)",8 return (n)*fac(n-1); /* n! == n*(n-1)! */,simpleAssign,935 "Core Python Programming, Second Edition (2006)","14 *p = s, /* fwd */",simpleAssign,935 "Core Python Programming, Second Edition (2006)",21 *q-- = t;,simpleAssign,935 "Core Python Programming, Second Edition (2006)",4! == 24,simpleAssign,936 "Core Python Programming, Second Edition (2006)",8! == 40320,simpleAssign,936 "Core Python Programming, Second Edition (2006)",12! == 479001600,simpleAssign,936 "Core Python Programming, Second Edition (2006)","res = PyArg_ParseTuple(args, ""i"", &num);",simpleAssign,939 "Core Python Programming, Second Edition (2006)",res = fac(num);,simpleAssign,939 "Core Python Programming, Second Edition (2006)",dupe_str=reverse(strdup(orig_str)));,simpleAssign,940 "Core Python Programming, Second Edition (2006)",4! == 24,simpleAssign,944 "Core Python Programming, Second Edition (2006)",8! == 40320,simpleAssign,944 "Core Python Programming, Second Edition (2006)",12! == 479001600,simpleAssign,944 "Core Python Programming, Second Edition (2006)","14 *p = s,",simpleAssign,945 "Core Python Programming, Second Edition (2006)",21 *q-- = t;,simpleAssign,945 "Core Python Programming, Second Edition (2006)",62 dupe_str=reverse(strdup(orig_str)));,simpleAssign,946 "Core Python Programming, Second Edition (2006)","75 ExtestMethods[] = 76 {",simpleAssign,946 "Core Python Programming, Second Edition (2006)",http://finance.yahoo.com/d/quotes.csv?s=GOOG&f=sl1d1t1c1ohgv&e=.csv,simpleAssign,953 "Core Python Programming, Second Edition (2006)",u = urlopen('http://quote.yahoo.com/d/,simpleAssign,953 "Core Python Programming, Second Edition (2006)",quotes.csv?s=YHOO&f=sl1d1t1c1ohgv'),simpleAssign,953 "Core Python Programming, Second Edition (2006)","For example, if we give the server a field request of f=sl1d1c1p2, we get a string like the following",simpleAssign,955 "Core Python Programming, Second Edition (2006)","The quote server will also allow you to specify multiple stock ticker symbols, as in s=YHOO,GOOG,EBAY,",simpleAssign,955 "Core Python Programming, Second Edition (2006)",7 URL = 'http://quote.yahoo.com/d/quotes.csv?s=%s&f=sl1c1p2',simpleAssign,955 "Core Python Programming, Second Edition (2006)","15 tick, price, chg, per = row.split(',')",simpleAssign,955 "Core Python Programming, Second Edition (2006)","Wiki/View.aspx?ProjectName=IronPython), an implementation of the Python language in C# for the .",simpleAssign,957 "Core Python Programming, Second Edition (2006)","8 warn = lambda app: showwarning(app, 'Exit?')",simpleAssign,959 "Core Python Programming, Second Edition (2006)","9 RANGE = range(3, 8)",simpleAssign,959 "Core Python Programming, Second Edition (2006)",13 xl = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,959 "Core Python Programming, Second Edition (2006)",14 ss = xl.Workbooks.Add(),simpleAssign,959 "Core Python Programming, Second Edition (2006)",15 sh = ss.ActiveSheet,simpleAssign,959 "Core Python Programming, Second Edition (2006)",16 xl.Visible = True,simpleAssign,959 "Core Python Programming, Second Edition (2006)",xl = win32com.client.Dispatch('%s.Application' % app),simpleAssign,960 "Core Python Programming, Second Edition (2006)","8 warn = lambda app: showwarning(app, 'Exit?')",simpleAssign,961 "Core Python Programming, Second Edition (2006)","9 RANGE = range(3, 8)",simpleAssign,961 "Core Python Programming, Second Edition (2006)",13 word = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,961 "Core Python Programming, Second Edition (2006)",14 doc = word.Documents.Add(),simpleAssign,961 "Core Python Programming, Second Edition (2006)",15 word.Visible = True,simpleAssign,961 "Core Python Programming, Second Edition (2006)","18 rng = doc.Range(0,0)",simpleAssign,961 "Core Python Programming, Second Edition (2006)","8 warn = lambda app: showwarning(app, 'Exit?')",simpleAssign,963 "Core Python Programming, Second Edition (2006)","9 RANGE = range(3, 8)",simpleAssign,963 "Core Python Programming, Second Edition (2006)",13 ppoint = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,963 "Core Python Programming, Second Edition (2006)",14 pres = ppoint.Presentations.Add(),simpleAssign,963 "Core Python Programming, Second Edition (2006)",15 ppoint.Visible = True,simpleAssign,963 "Core Python Programming, Second Edition (2006)","17 s1 = pres.Slides.Add(1, win32.constants.ppLayoutText)",simpleAssign,963 "Core Python Programming, Second Edition (2006)",19 s1a = s1.Shapes[0].TextFrame.TextRange,simpleAssign,963 "Core Python Programming, Second Edition (2006)",22 s1b = s1.Shapes[1].TextFrame.TextRange,simpleAssign,963 "Core Python Programming, Second Edition (2006)","8 warn = lambda app: showwarning(app, 'Exit?')",simpleAssign,965 "Core Python Programming, Second Edition (2006)","9 RANGE = range(3, 8)",simpleAssign,965 "Core Python Programming, Second Edition (2006)",13 olook = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,965 "Core Python Programming, Second Edition (2006)",15 mail = olook.CreateItem(win32.constants.olMailItem),simpleAssign,965 "Core Python Programming, Second Edition (2006)",16 recip = mail.Recipients.Add('you@127.0.0.1'),simpleAssign,965 "Core Python Programming, Second Edition (2006)",17 subj = mail.Subject = 'Python-to-%s Demo' % app,simpleAssign,965 "Core Python Programming, Second Edition (2006)","24 ns = olook.GetNamespace(""MAPI"")",simpleAssign,965 "Core Python Programming, Second Edition (2006)",25 obox = ns.GetDefaultFolder(win32.constants.olFolderOutbox),simpleAssign,965 "Core Python Programming, Second Edition (2006)","9 warn = lambda app: showwarning(app, 'Exit?')",simpleAssign,968 "Core Python Programming, Second Edition (2006)","10 RANGE = range(3, 8)",simpleAssign,968 "Core Python Programming, Second Edition (2006)",13 URL = 'http://quote.yahoo.com/d/quotes.csv?s=%s&f=sl1c1p2',simpleAssign,968 "Core Python Programming, Second Edition (2006)",17 xl = win32.gencache.EnsureDispatch('%s.Application' % app),simpleAssign,968 "Core Python Programming, Second Edition (2006)",18 ss = xl.Workbooks.Add(),simpleAssign,968 "Core Python Programming, Second Edition (2006)",19 sh = ss.ActiveSheet,simpleAssign,968 "Core Python Programming, Second Edition (2006)",20 xl.Visible = True,simpleAssign,968 "Core Python Programming, Second Edition (2006)","28 sh.Cells(5, i+1).Value = COLS[i]",simpleAssign,968 "Core Python Programming, Second Edition (2006)","30 sh.Range(sh.Cells(5, 1), sh.Cells(5, 4)).Font.Bold = True",simpleAssign,968 "Core Python Programming, Second Edition (2006)",32 row = 6,simpleAssign,968 "Core Python Programming, Second Edition (2006)","36 tick, price, chg, per = data.split(',')",simpleAssign,968 "Core Python Programming, Second Edition (2006)","37 sh.Cells(row, 1).Value = eval(tick)",simpleAssign,968 "Core Python Programming, Second Edition (2006)","39 sh.Cells(row, 3).Value = chg",simpleAssign,968 "Core Python Programming, Second Edition (2006)","40 sh.Cells(row, 4).Value = eval(per.rstrip())",simpleAssign,968 "Core Python Programming, Second Edition (2006)",13 JPanel box = new JPanel(new BorderLayout());,simpleAssign,972 "Core Python Programming, Second Edition (2006)","14 JLabel hello = new JLabel(""Hello World!"");",simpleAssign,972 "Core Python Programming, Second Edition (2006)","15 JButton quit = new JButton(""QUIT"");",simpleAssign,972 "Core Python Programming, Second Edition (2006)",17 ActionListener quitAction = new ActionListener() {,simpleAssign,972 "Core Python Programming, Second Edition (2006)",39 swhello app = new swhello();,simpleAssign,972 "Core Python Programming, Second Edition (2006)","10 top = swing.JFrame(""PySwing"")",simpleAssign,973 "Core Python Programming, Second Edition (2006)",11 box = swing.JPanel(),simpleAssign,973 "Core Python Programming, Second Edition (2006)","12 hello = swing.JLabel(""Hello World!"")",simpleAssign,973 "Core Python Programming, Second Edition (2006)","13 quit = swing.JButton(""QUIT"", actionPerformed=quit,",simpleAssign,973 "Core Python Programming, Second Edition (2006)","14 background=Color.red, foreground=Color.white)",simpleAssign,973 "Core Python Programming, Second Edition (2006)",i = 0,simpleAssign,982 "Core Python Programming, Second Edition (2006)",s = raw_input('enter a string: '),simpleAssign,982 "Core Python Programming, Second Edition (2006)",i = 0,simpleAssign,982 "Core Python Programming, Second Edition (2006)",slen = len(s),simpleAssign,982 "Core Python Programming, Second Edition (2006)",subtot = 0,simpleAssign,983 "Core Python Programming, Second Edition (2006)",type(a) == type(b) whether the value of type(a) is the same as the value of type,simpleAssign,985 "Core Python Programming, Second Edition (2006)",b)... == is a value compare,simpleAssign,985 "Core Python Programming, Second Edition (2006)",s = float(raw_input('enter length of one side: ')),simpleAssign,986 "Core Python Programming, Second Edition (2006)",r = float(raw_input('enter length of radius: ')),simpleAssign,986 "Core Python Programming, Second Edition (2006)",if i % 2 != 0:,simpleAssign,986 "Core Python Programming, Second Edition (2006)","When i % 2 == 0, it's even (divisible by 2), otherwise it's odd.",simpleAssign,987 "Core Python Programming, Second Edition (2006)",iden = raw_input('Identifier to check? '),simpleAssign,988 "Core Python Programming, Second Edition (2006)",keys = dict.keys(),simpleAssign,989 "Core Python Programming, Second Edition (2006)",d[list1[i]] = list2[i],simpleAssign,989 "Core Python Programming, Second Edition (2006)",d[x] = list2[i],simpleAssign,989 "Core Python Programming, Second Edition (2006)","d = dict(map(None, list1, list2))",simpleAssign,989 "Core Python Programming, Second Edition (2006)","d = dict(zip(list1, list2))",simpleAssign,989 "Core Python Programming, Second Edition (2006)",list1 = oldDict.values(),simpleAssign,990 "Core Python Programming, Second Edition (2006)",list2 = oldDict.keys(),simpleAssign,990 "Core Python Programming, Second Edition (2006)",count = int(math.sqrt(num)),simpleAssign,991 "Core Python Programming, Second Edition (2006)",i = 0,simpleAssign,992 "Core Python Programming, Second Edition (2006)",num = int(raw_input('enter number of lines: ')),simpleAssign,992 "Core Python Programming, Second Edition (2006)","string.count(str, beg=0, end=len(string))",simpleAssign,1021 "Core Python Programming, Second Edition (2006)","string.endswith(str, beg=0, end=len(string))",simpleAssign,1021 "Core Python Programming, Second Edition (2006)",string.expandtabs(tabsize=8),simpleAssign,1021 "Core Python Programming, Second Edition (2006)","string.find(str, beg=0 end=len(string))",simpleAssign,1021 "Core Python Programming, Second Edition (2006)","string.index(str, beg=0, end=len(string))",simpleAssign,1021 "Core Python Programming, Second Edition (2006)","string.replace(str1, str2, num=string.count",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","string.rfind(str, beg=0, end=len(string))",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","string.rindex(str, beg=0, end=len(string))",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","string.split(str="""", num=string.count(str))",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","string.splitlines(num=string.count('\n'))[b],[c]",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","string.startswith(str, beg=0, end=len(string))",simpleAssign,1022 "Core Python Programming, Second Edition (2006)","list.index(obj, i=0, j=len(list))",simpleAssign,1024 "Core Python Programming, Second Edition (2006)",Returns lowest index k where list[k] == obj and i,simpleAssign,1024 "Core Python Programming, Second Edition (2006)","list.sort(func=None, key=None, reverse=False) Sorts list members with optional comparison",simpleAssign,1024 "Core Python Programming, Second Edition (2006)","dict.fromkeys[c](seq, val=None)",simpleAssign,1025 "Core Python Programming, Second Edition (2006)","dict.get(key, default=None)[a]",simpleAssign,1025 "Core Python Programming, Second Edition (2006)","dict.setdefault(key, default=None)[e] Similar to get(), but sets dict[key]=default if key is not",simpleAssign,1025 "Core Python Programming, Second Edition (2006)",s == t,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",s != t,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",s <= t,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",s >= t,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",Strict) subset test; s !=t and all elements,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",Strict) superset test: s != t and all,simpleAssign,1027 "Core Python Programming, Second Edition (2006)",s |= t,simpleAssign,1028 "Core Python Programming, Second Edition (2006)",s &= t,simpleAssign,1028 "Core Python Programming, Second Edition (2006)",s -= t,simpleAssign,1028 "Core Python Programming, Second Edition (2006)",s.symmetric_difference_update(t) s ^= t,simpleAssign,1028 "Core Python Programming, Second Edition (2006)",file.readlines(sizhint=0),simpleAssign,1029 "Core Python Programming, Second Edition (2006)","file.seek(off, whence=0)",simpleAssign,1029 "Core Python Programming, Second Edition (2006)","Moves to a location within file, off bytes offset from whence (0 == beginning of file, 1 == current location, or 2 == end of file)",simpleAssign,1029 "Core Python Programming, Second Edition (2006)","file.truncate(size=file.tell()) Truncates file to at most size bytes, the default being the current",simpleAssign,1029 "Core Python Programming, Second Edition (2006)",Less than/less than or equal to; < and <= operators,simpleAssign,1036 "Core Python Programming, Second Edition (2006)","Greater than/greater than or equal to; > and >= operators",simpleAssign,1036 Programming in Python 3- a complete introduction to the Python language,"_grid = [[_background_char for column in range(_max_columns)] for row in range(_max_rows)]",listCompNested,207 Programming in Python 3- a complete introduction to the Python language,zip(),zip,124 Programming in Python 3- a complete introduction to the Python language,zip(),zip,124 Programming in Python 3- a complete introduction to the Python language,zip(),zip,124 Programming in Python 3- a complete introduction to the Python language,zip() function. The zip(),zip,140 Programming in Python 3- a complete introduction to the Python language,zip(),zip,140 Programming in Python 3- a complete introduction to the Python language,zip(),zip,141 Programming in Python 3- a complete introduction to the Python language,"zip() function returns 3-tuples, (-10, 0, 1)",zip,141 Programming in Python 3- a complete introduction to the Python language,zip(),zip,154 Programming in Python 3- a complete introduction to the Python language,zip(),zip,155 Programming in Python 3- a complete introduction to the Python language,"zip(arg_spec.args, args))",zip,358 Programming in Python 3- a complete introduction to the Python language,zip() returns an iterator and dictionary.items(),zip,359 Programming in Python 3- a complete introduction to the Python language,zip(),zip,597 Programming in Python 3- a complete introduction to the Python language,zip() (built-in),zip,625 Programming in Python 3- a complete introduction to the Python language,map(),map,392 Programming in Python 3- a complete introduction to the Python language,"map(lambda x: x ** 2, [1, 2, 3, 4]))",map,392 Programming in Python 3- a complete introduction to the Python language,map(),map,392 Programming in Python 3- a complete introduction to the Python language,map(),map,392 Programming in Python 3- a complete introduction to the Python language,"map(os.path.getsize, files))",map,393 Programming in Python 3- a complete introduction to the Python language,map(),map,393 Programming in Python 3- a complete introduction to the Python language,map() and filter(),map,394 Programming in Python 3- a complete introduction to the Python language,"map(), filter(), and functools.reduce()",map,394 Programming in Python 3- a complete introduction to the Python language,map() with a list comprehension and filter(),map,394 Programming in Python 3- a complete introduction to the Python language,"map(), filter(), or functools.reduce()",map,394 Programming in Python 3- a complete introduction to the Python language,map(),map,400 Programming in Python 3- a complete introduction to the Python language,map() function is more convenient.),map,534 Programming in Python 3- a complete introduction to the Python language,map(icon),map,574 Programming in Python 3- a complete introduction to the Python language,map(),map,574 Programming in Python 3- a complete introduction to the Python language,"map(""@"" + path + ""bookmark.xbm"")",map,585 Programming in Python 3- a complete introduction to the Python language,map(),map,585 Programming in Python 3- a complete introduction to the Python language,map(),map,597 Programming in Python 3- a complete introduction to the Python language,map() (built-in),map,611 Programming in Python 3- a complete introduction to the Python language,"def __bisect_left(self, value)",privatemethod,269 Programming in Python 3- a complete introduction to the Python language,"def __seek_to_index(self, index)",privatemethod,325 Programming in Python 3- a complete introduction to the Python language,"def __change_stock(self, identity, amount)",privatemethod,331 Programming in Python 3- a complete introduction to the Python language,"class FuzzyBool(float): def __new__(cls, value=0.0):",metaclass3,253 Programming in Python 3- a complete introduction to the Python language,"class Product(metaclass=AutoSlotProperties): def __init__(self, barcode, description): self.__barcode = barcode self.description = description def get_barcode(self): return self.__barcode def get_description(self): return self.__description def set_description(self, description): if description is None or len(description) < 3: self.__description = ""<Invalid Description>"" else: self.__description = description We must assign to the private __barcode property in the initializer since there is no setter for it; another consequence of this is that barcode is a read-only property. On the other hand, description is a readable/writable property. Here are some examples of interactive use: >>> product = Product(""101110110"", ""8mm Stapler"") >>> product.barcode, product.description ('101110110', '8mm Stapler') >>> product.description = ""8mm Stapler (long)"" >>> product.barcode, product.description ('101110110', '8mm Stapler (long)') If we attempt to assign to the bar code an AttributeError exception is raised with the error text “can’t set attribute”. If we look at the Product class’s attributes (e.g., using dir()), the only public ones to be found are barcode and description. The get_name() and set_name() methods are no longer there—they have been replaced with the name property. And the variables holding the bar code and description are also private (__bar- code and __description), and have been added as slots to minimize the class’s memory use. This is all done by the AutoSlotProperties metaclass which is im- plemented in a single method: class AutoSlotProperties(type): def __new__(mcl, classname, bases, dictionary):",metaclass3,390 Programming in Python 3- a complete introduction to the Python language,class Appliance(metaclass=abc.ABCMeta):,metaclassheader,381 Programming in Python 3- a complete introduction to the Python language,class TextFilter(metaclass=abc.ABCMeta):,metaclassheader,382 Programming in Python 3- a complete introduction to the Python language,class Undo(metaclass=abc.ABCMeta):,metaclassheader,383 Programming in Python 3- a complete introduction to the Python language,class Bad(metaclass=Meta.LoadableSaveable):,metaclassheader,389 Programming in Python 3- a complete introduction to the Python language,class Good(metaclass=Meta.LoadableSaveable):,metaclassheader,389 Programming in Python 3- a complete introduction to the Python language,super().__init__() at the start of a custom,superfunc,238 Programming in Python 3- a complete introduction to the Python language,"super().__init__(x, y)",superfunc,240 Programming in Python 3- a complete introduction to the Python language,super(). If we did not use super() we would have infinite recur-,superfunc,242 Programming in Python 3- a complete introduction to the Python language,super().__repr__())),superfunc,255 Programming in Python 3- a complete introduction to the Python language,super().__init__(dictionary),superfunc,273 Programming in Python 3- a complete introduction to the Python language,super().update(kwargs),superfunc,273 Programming in Python 3- a complete introduction to the Python language,super().__init__() call is used to initialize the SortedDict using the base class,superfunc,273 Programming in Python 3- a complete introduction to the Python language,super().update(dictionary),superfunc,274 Programming in Python 3- a complete introduction to the Python language,"super().__setitem__(key, value)",superfunc,274 Programming in Python 3- a complete introduction to the Python language,super().update(kwargs),superfunc,274 Programming in Python 3- a complete introduction to the Python language,super().__delitem__(key),superfunc,275 Programming in Python 3- a complete introduction to the Python language,super().clear(),superfunc,277 Programming in Python 3- a complete introduction to the Python language,super().__init__(),superfunc,319 Programming in Python 3- a complete introduction to the Python language,"super().__init__(model, price)",superfunc,382 Programming in Python 3- a complete introduction to the Python language,super().__init__(),superfunc,384 Programming in Python 3- a complete introduction to the Python language,super().undo(),superfunc,384 Programming in Python 3- a complete introduction to the Python language,super().load(),superfunc,386 Programming in Python 3- a complete introduction to the Python language,"super().__init__(classname, bases, dictionary)",superfunc,388 Programming in Python 3- a complete introduction to the Python language,super().__init__(),superfunc,445 Programming in Python 3- a complete introduction to the Python language,super().__init__(),superfunc,448 Programming in Python 3- a complete introduction to the Python language,super().__init__(parent),superfunc,569 Programming in Python 3- a complete introduction to the Python language,super().__init__(parent),superfunc,586 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,243 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,243 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,244 Programming in Python 3- a complete introduction to the Python language,"@radius.setter def",decaratorfunc,244 Programming in Python 3- a complete introduction to the Python language,"@staticmethod def",decaratorfunc,251 Programming in Python 3- a complete introduction to the Python language,"@classmethod before def",decaratorfunc,254 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,260 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,261 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,261 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,261 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,268 Programming in Python 3- a complete introduction to the Python language,"@classmethod def",decaratorfunc,274 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,288 Programming in Python 3- a complete introduction to the Python language,"@date.setter def",decaratorfunc,288 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,324 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,324 Programming in Python 3- a complete introduction to the Python language,"@positive_result def",decaratorfunc,354 Programming in Python 3- a complete introduction to the Python language,"@functools.wraps(function) def",decaratorfunc,354 Programming in Python 3- a complete introduction to the Python language,"@bounded(0, 100) def",decaratorfunc,355 Programming in Python 3- a complete introduction to the Python language,"@functools.wraps(function) def",decaratorfunc,355 Programming in Python 3- a complete introduction to the Python language,"@logged def",decaratorfunc,355 Programming in Python 3- a complete introduction to the Python language,"@functools.wraps(function) def",decaratorfunc,356 Programming in Python 3- a complete introduction to the Python language,"@functools.wraps(function) def",decaratorfunc,358 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,362 Programming in Python 3- a complete introduction to the Python language,"@Property def",decaratorfunc,373 Programming in Python 3- a complete introduction to the Python language,"@Property def",decaratorfunc,373 Programming in Python 3- a complete introduction to the Python language,"@extension.setter def",decaratorfunc,373 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractmethod def",decaratorfunc,381 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,381 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractproperty def",decaratorfunc,382 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractmethod def",decaratorfunc,382 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,382 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,383 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractmethod def",decaratorfunc,383 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractproperty def",decaratorfunc,384 Programming in Python 3- a complete introduction to the Python language,"@abc.abstractmethod def",decaratorfunc,384 Programming in Python 3- a complete introduction to the Python language,"@property def",decaratorfunc,384 Programming in Python 3- a complete introduction to the Python language,"@coroutine def",decaratorfunc,398 Programming in Python 3- a complete introduction to the Python language,"@coroutine decorator to do this for us. def",decaratorfunc,398 Programming in Python 3- a complete introduction to the Python language,"@functools.wraps(function) def",decaratorfunc,398 Programming in Python 3- a complete introduction to the Python language,"@coroutine def",decaratorfunc,399 Programming in Python 3- a complete introduction to the Python language,"@coroutine def",decaratorfunc,403 Programming in Python 3- a complete introduction to the Python language,"@coroutine def",decaratorfunc,403 Programming in Python 3- a complete introduction to the Python language,"@coroutine def",decaratorfunc,403 Programming in Python 3- a complete introduction to the Python language,@property and @class,decaratorclass,353 Programming in Python 3- a complete introduction to the Python language,"@delegate class decorator from the book’s Util module. Here is the start of a new version of the SortedList class",decaratorclass,375 Programming in Python 3- a complete introduction to the Python language,"@Util.complete_comparisons class",decaratorclass,376 Programming in Python 3- a complete introduction to the Python language,"@property and @name.setter decorators, we could create class",decaratorclass,389 Programming in Python 3- a complete introduction to the Python language,"@valid_number(""quantity"", minimum=1, maximum=1000) class",decaratorclass,404 Programming in Python 3- a complete introduction to the Python language,"@property and @classmethod. We learned how to create custom descrip- tors and saw three very different examples of their use. Next we studied class",decaratorclass,407 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,136 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,136 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,136 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,138 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,138 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,516 Programming in Python 3- a complete introduction to the Python language,enumerate(),enumfunc,597 Programming in Python 3- a complete introduction to the Python language,enumerate() (built-in),enumfunc,603 Programming in Python 3- a complete introduction to the Python language,"leaps = [y for y in range(1900, 1940)]",simpleListComp,116 Programming in Python 3- a complete introduction to the Python language,"leaps = [y for y in range(1900, 1940) if y % 4 == 0]",simpleListComp,116 Programming in Python 3- a complete introduction to the Python language,"that is, dirs[:] = [dir for dir in dirs if not dir.startswith(""."")]",simpleListComp,229 Programming in Python 3- a complete introduction to the Python language,"leaps = [y for y in range(1900, 1940) if (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0)]",listCompIf,116 Programming in Python 3- a complete introduction to the Python language,"codes = [s + z + c for s in ""MF"" for z in ""SMLX"" for c in ""BGW"" if not (s == ""F"" and z == ""X"")]",listCompIf,117 Programming in Python 3- a complete introduction to the Python language,"mode = [number for number, frequency in frequencies.items() if frequency == highest_frequency]",listCompIf,151 Programming in Python 3- a complete introduction to the Python language,"file_sizes = {name: os.path.getsize(name) for name in os.listdir(""."")}",simpleDictComp,131 Programming in Python 3- a complete introduction to the Python language,"inverted_d = {v: k for k, v in d.items()}",simpleDictComp,132 Programming in Python 3- a complete introduction to the Python language,"text = (yield) for match in regex.finditer(text)",generatorExpression,398 Programming in Python 3- a complete introduction to the Python language,"struct.pack(), struct.unpack()",struct,294 Programming in Python 3- a complete introduction to the Python language,struct.Struct() class. The struct.pack(),struct,294 Programming in Python 3- a complete introduction to the Python language,struct.unpack(),struct,294 Programming in Python 3- a complete introduction to the Python language,struct.calcsize(),struct,294 Programming in Python 3- a complete introduction to the Python language,struct.Struct(),struct,294 Programming in Python 3- a complete introduction to the Python language,struct.Struct(),struct,294 Programming in Python 3- a complete introduction to the Python language,struct.Struct.unpack(),struct,299 Programming in Python 3- a complete introduction to the Python language,struct.unpack(),struct,300 Programming in Python 3- a complete introduction to the Python language,pickle.load(),pickle,265 Programming in Python 3- a complete introduction to the Python language,"pickle.dump(self, fh, pickle.HIGHEST_PROTOCOL)",pickle,290 Programming in Python 3- a complete introduction to the Python language,pickle.load() function),pickle,292 Programming in Python 3- a complete introduction to the Python language,"pickle.dump(data, fh, pickle.HIGHEST_PROTOCOL)",pickle,386 Programming in Python 3- a complete introduction to the Python language,pickle.loads(),pickle,460 Programming in Python 3- a complete introduction to the Python language,pickle.dump(),pickle,463 Programming in Python 3- a complete introduction to the Python language,"pickle.dump(self.data, fh, pickle.HIGHEST_PROTOCOL)",pickle,581 Programming in Python 3- a complete introduction to the Python language,shelve.Shelf.sync(),shelve,473 Programming in Python 3- a complete introduction to the Python language,"dbm.py program, and returns a 2-tuple (title, DVD ID), or (None, None)",dbm,481 Programming in Python 3- a complete introduction to the Python language,"dbm.py, except for the find_bookmark()",dbm,484 Programming in Python 3- a complete introduction to the Python language,dbm.py (example),dbm,603 Programming in Python 3- a complete introduction to the Python language,re.finditer(),re,308 Programming in Python 3- a complete introduction to the Python language,re.finditer(),re,309 Programming in Python 3- a complete introduction to the Python language,re.compile(),re,495 Programming in Python 3- a complete introduction to the Python language,re.compile(),re,496 Programming in Python 3- a complete introduction to the Python language,re.search(),re,496 Programming in Python 3- a complete introduction to the Python language,re.compile(),re,496 Programming in Python 3- a complete introduction to the Python language,re.escape(s),re,498 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,498 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,499 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,500 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,500 Programming in Python 3- a complete introduction to the Python language,"re.split(), re.sub(), and re.subn()",re,500 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,500 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,500 Programming in Python 3- a complete introduction to the Python language,re.sub() uses the regex &#(\d+),re,500 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,500 Programming in Python 3- a complete introduction to the Python language,re.sub() call uses the regex &([A-Za-z]+),re,501 Programming in Python 3- a complete introduction to the Python language,re.sub() function calls the local char_from_entity(),re,501 Programming in Python 3- a complete introduction to the Python language,"re.sub() call’s regex, \n(?:[ \xA0\t]+\n)",re,501 Programming in Python 3- a complete introduction to the Python language,re.sub(),re,501 Programming in Python 3- a complete introduction to the Python language,re.search(),re,504 Programming in Python 3- a complete introduction to the Python language,re.split() function (or the regex object’s split() method),re,505 Programming in Python 3- a complete introduction to the Python language,"re.split(r""\s+"", text)",re,505 Programming in Python 3- a complete introduction to the Python language,import re,importre,64 Programming in Python 3- a complete introduction to the Python language,"def items_in_key_order(d): for key in sorted(d): yield",generatorYield,339 Programming in Python 3- a complete introduction to the Python language,"def __get__(self, instance, owner=None):",descriptorGet,371 Programming in Python 3- a complete introduction to the Python language,"def __get__(self, instance, owner=None):",descriptorGet,371 Programming in Python 3- a complete introduction to the Python language,"def __get__(self, instance, owner=None):",descriptorGet,372 Programming in Python 3- a complete introduction to the Python language,"def __get__(self, instance, owner=None):",descriptorGet,374 Programming in Python 3- a complete introduction to the Python language,"def __get__(self, instance, owner=None):",descriptorGet,406 Programming in Python 3- a complete introduction to the Python language,"def __set__(self, instance, value):",descriptorSet,372 Programming in Python 3- a complete introduction to the Python language,"def __set__(self, instance, value):",descriptorSet,374 Programming in Python 3- a complete introduction to the Python language,"def __set__(self, instance, value):",descriptorSet,406 Programming in Python 3- a complete introduction to the Python language,property(),classprop,243 Programming in Python 3- a complete introduction to the Python language,property(),classprop,243 Programming in Python 3- a complete introduction to the Python language,property() and classmethod(),classprop,370 Programming in Python 3- a complete introduction to the Python language,property(),classprop,373 Programming in Python 3- a complete introduction to the Python language,property(),classprop,381 Programming in Python 3- a complete introduction to the Python language,property(),classprop,595 Programming in Python 3- a complete introduction to the Python language,property() (abc module),classprop,595 Programming in Python 3- a complete introduction to the Python language,property(),classprop,597 Programming in Python 3- a complete introduction to the Python language,property(),classprop,601 Programming in Python 3- a complete introduction to the Python language,property(),classprop,615 Programming in Python 3- a complete introduction to the Python language,classmethod(),classmethod2,254 Programming in Python 3- a complete introduction to the Python language,classmethod(),classmethod2,597 Programming in Python 3- a complete introduction to the Python language,classmethod(),classmethod2,599 Programming in Python 3- a complete introduction to the Python language,classmethod(),classmethod2,601 Programming in Python 3- a complete introduction to the Python language,staticmethod(),staticmethod2,252 Programming in Python 3- a complete introduction to the Python language,staticmethod(),staticmethod2,597 Programming in Python 3- a complete introduction to the Python language,staticmethod(),staticmethod2,601 Programming in Python 3- a complete introduction to the Python language,staticmethod(),staticmethod2,621 Programming in Python 3- a complete introduction to the Python language,"__slots__ = (""x"", ""y"")",__slots__,360 Programming in Python 3- a complete introduction to the Python language,"__slots__ = (); or the memory and speed savings will be lost.",__slots__,360 Programming in Python 3- a complete introduction to the Python language,"__slots__ = (""__name"", ""__description"", ""__price"")",__slots__,370 Programming in Python 3- a complete introduction to the Python language,__slots__ = (),__slots__,372 Programming in Python 3- a complete introduction to the Python language,"__slots__ = (""attribute_name"",)",__slots__,372 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,203 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,209 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,424 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,424 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,426 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,430 Programming in Python 3- a complete introduction to the Python language,"if __name__ == ""__main__"":",__name__,431 Programming in Python 3- a complete introduction to the Python language,"return (""{0}({1})"".format(self.__class__",__class__,248 Programming in Python 3- a complete introduction to the Python language,one of which is called __class__,__class__,249 Programming in Python 3- a complete introduction to the Python language,"return (""{0}({1})"".format(self.__class__",__class__,255 Programming in Python 3- a complete introduction to the Python language,"self.__class__.__name__, other.__class__",__class__,256 Programming in Python 3- a complete introduction to the Python language,self.__class__,__class__,256 Programming in Python 3- a complete introduction to the Python language,self=self.__class__,__class__,256 Programming in Python 3- a complete introduction to the Python language,format(self=self.__class__,__class__,257 Programming in Python 3- a complete introduction to the Python language,"types = [\""'\"" + arg.__class__",__class__,257 Programming in Python 3- a complete introduction to the Python language,self=self.__class__,__class__,257 Programming in Python 3- a complete introduction to the Python language,"types = [""'"" + arg.__class__",__class__,258 Programming in Python 3- a complete introduction to the Python language,self=self.__class__,__class__,258 Programming in Python 3- a complete introduction to the Python language,self.__class__,__class__,269 Programming in Python 3- a complete introduction to the Python language,self.__class__,__class__,270 Programming in Python 3- a complete introduction to the Python language,d.__class__,__class__,275 Programming in Python 3- a complete introduction to the Python language,format(self.__class__,__class__,361 Programming in Python 3- a complete introduction to the Python language,classname = self.__class__,__class__,363 Programming in Python 3- a complete introduction to the Python language,"subclass.) Every object has a __class__ special attribute, so self.__class__",__class__,363 Programming in Python 3- a complete introduction to the Python language,self.__class__,__class__,363 Programming in Python 3- a complete introduction to the Python language,"name = ""_"" + self.__class__",__class__,386 Programming in Python 3- a complete introduction to the Python language,creates a private dictionary called __dict__,__dict__,360 Programming in Python 3- a complete introduction to the Python language,"to add or remove attributes, we can create classes that don’t have a __dict__",__dict__,360 Programming in Python 3- a complete introduction to the Python language,attributes of the specified names and no __dict__,__dict__,360 Programming in Python 3- a complete introduction to the Python language,if name in self.__dict__,__dict__,361 Programming in Python 3- a complete introduction to the Python language,self.__dict__,__dict__,361 Programming in Python 3- a complete introduction to the Python language,if name in self.__dict__,__dict__,361 Programming in Python 3- a complete introduction to the Python language,the object’s __dict__,__dict__,362 Programming in Python 3- a complete introduction to the Python language,under the hood all of an object’s nonspecial attributes are held in self.__dict__,__dict__,363 Programming in Python 3- a complete introduction to the Python language,__slots__ variable to ensure that the class has no __dict__,__dict__,370 Programming in Python 3- a complete introduction to the Python language,"try: try_suite except exception_group1 as variable1: except_suite1 … except exception_groupN as variableN: except_suiteN else: else_suite finally:",tryexceptelsefinally,160 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(filename, ""w"", encoding=""utf8"") fh.write(html) except EnvironmentError as err: print(""ERROR"", err) else: print(""Saved skeleton"", filename) finally:",tryexceptelsefinally,186 Programming in Python 3- a complete introduction to the Python language,"try: index = lst.index(target) except ValueError: index = -1 return index Here, we have effectively used the try … except block to turn an exception into a return value; the same approach can also be used to catch one kind of exception and raise another instead—a technique we will see shortly. Python also offers a simpler try … finally block which is sometimes useful: try: try_suite finally: finally_suite No matter what happens in the try block’s suite (apart from the computer or program crashing!), the finally block’s suite will be executed. The with statement used with a context manager (both covered in Chapter 8) can be used to achieve a similar effect to using a try … finally block. One common pattern of use for try … except … finally blocks is for handling file errors. For example, the noblanks.py program reads a list of filenames on the command line, and for each one produces another file with the same name, but with its extension changed to .nb, and with the same contents except for no blank lines. Here’s the program’s read_data() function: def read_data(filename): lines = [] fh = None try: fh = open(filename, encoding=""utf8"") for line in fh: if line.strip(): lines.append(line) except (IOError, OSError) as err: print(err) return [] finally:",tryexceptfinally,163 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(file, ""rb"") magic = fh.read(1000) for get_file_type in get_file_type_functions: filetype = get_file_type(magic, os.path.splitext(file)[1]) if filetype is not None: print(""{0:.<20}{1}"".format(filetype, file)) break else: print(""{0:.<20}{1}"".format(""Unknown"", file)) except EnvironmentError as err: print(err) finally:",tryexceptfinally,344 Programming in Python 3- a complete introduction to the Python language,"try: result = function(*args, **kwargs) return result except Exception as err: exception = err finally:",tryexceptfinally,356 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(filename) for line in fh: process(line) try: except EnvironmentError as err: with open(filename) as fh: print(err) finally:",tryexceptfinally,367 Programming in Python 3- a complete introduction to the Python language,"try: server = CarRegistrationServer(("""", 9653), RequestHandler) server.serve_forever() except Exception as err: print(""ERROR"", err) finally:",tryexceptfinally,462 Programming in Python 3- a complete introduction to the Python language,"try: tar = tarfile.open(archive) for member in tar.getmembers(): if member.name.startswith(UNTRUSTED_PREFIXES): print(""untrusted prefix, ignoring"", member.name) elif "".."" in member.name: print(""suspect path, ignoring"", member.name) else: tar.extract(member) print(""unpacked"", member.name) except (tarfile.TarError, EnvironmentError) as err: error(err) finally:",tryfinally,219 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(self.filename, ""rb"") data = pickle.load(fh) (self.__width, self.__height, self.__background, self.__data) = data self.__colors = (set(self.__data.values()) | {self.__background}) except (EnvironmentError, pickle.UnpicklingError) as err: raise LoadError(str(err)) finally:",tryfinally,265 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(filename, ""rb"") magic = fh.read(len(GZIP_MAGIC)) if magic == GZIP_MAGIC: fh.close() fh = gzip.open(filename, ""rb"") else: fh.seek(0) self.clear() self.update(pickle.load(fh)) return True except (EnvironmentError, pickle.UnpicklingError) as err: print(""{0}: import error: {1}"".format( os.path.basename(sys.argv[0]), err)) return False finally:",tryfinally,292 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(filename, ""r"", encoding=""utf8"") code = fh.read() module = type(sys)(name) sys.modules[name] = module exec(code, module.__dict__) modules.append(module) except (EnvironmentError, SyntaxError) as err: sys.modules.pop(name, None) print(err) finally:",tryfinally,345 Programming in Python 3- a complete introduction to the Python language,"try: for file in sys.argv[1:]: print(file) html = open(file, encoding=""utf8"").read() for matcher in matchers: matcher.send(html) finally:",tryfinally,399 Programming in Python 3- a complete introduction to the Python language,"try: filename = self.work_queue.get() self.process(filename) finally:",tryfinally,445 Programming in Python 3- a complete introduction to the Python language,"try: results = results_queue.get() if results: print(results) finally:",tryfinally,448 Programming in Python 3- a complete introduction to the Python language,"try: db = shelve.open(filename, protocol=pickle.HIGHEST_PROTOCOL) ... finally:",tryfinally,472 Programming in Python 3- a complete introduction to the Python language,"with open(self.filename, ""wb"") as fh:",withfunc,386 Programming in Python 3- a complete introduction to the Python language,"with open(self.filename, ""rb"") as fh:",withfunc,386 Programming in Python 3- a complete introduction to the Python language,"with open(self.filename, ""wb"") as fh:",withfunc,581 Programming in Python 3- a complete introduction to the Python language,"with open(self.filename, ""rb"") as fh:",withfunc,582 Programming in Python 3- a complete introduction to the Python language,"while True: line = input(""integer: "") if line: try: number = int(line) except ValueError as err: print(err) continue total += number count += 1 else:",whileelse,33 Programming in Python 3- a complete introduction to the Python language,"while True: try: line = input(msg) if not line and default is not None: return default i = int(line) if i < minimum: print(""must be >="", minimum) else:",whileelse,42 Programming in Python 3- a complete introduction to the Python language,"while True: try: line = input() if count == 0: color = ""lightgreen"" elif count % 2: color = ""white"" else:",whileelse,97 Programming in Python 3- a complete introduction to the Python language,"while True: site = None i = line.find(""http://"", i) if i > -1: i += len(""http://"") for j in range(i, len(line)): if not (line[j].isalnum() or line[j] in "".-""): site = line[i:j].lower() break if site and ""."" in site: sites.setdefault(site, set()).add(filename) i = j else:",whileelse,129 Programming in Python 3- a complete introduction to the Python language,"while loop: while boolean_expression: while_suite else:",whileelse,158 Programming in Python 3- a complete introduction to the Python language,"while loop: def list_find(lst, target): index = 0 while index < len(lst): if lst[index] == target: break index += 1 else: index = -1 return index This function searches the given list looking for the target. If the target is found, the break statement terminates the loop, causing the appropriate index position to be returned. If the target is not found, the loop runs to completion and terminates normally. After normal termination, the else suite is executed, and the index position is set to -1 and returned. for Loops | Like a while loop, the full syntax of the for … in loop also includes an optional else clause: for expression in iterable: for_suite else:",whileelse,159 Programming in Python 3- a complete introduction to the Python language,"while True: try: line = input(message) if not line: if default is not None: return default if minimum_length == 0: return """" else:",whileelse,187 Programming in Python 3- a complete introduction to the Python language,"while left < right: middle = (left + right) // 2 if self.__key(self.__list[middle]) < key: left = middle + 1 else: right = middle return left This private method calculates the index position where the given value be- longs in the list, that is, the index position where the value is (if it is in the list), or where it should go (if it isn’t in the list). It computes the comparison key for the given value using the sorted list’s key function, and compares the com- parison key with the computed comparison keys of the items that the method examines. The algorithm used is binary search (also called binary chop), which has excellent performance even on very large lists—for example, at most, 21 comparisons are required to find a value’s position in a list of 1000 000 items.# Compare this with a plain unsorted list which uses linear search and needs an average of 500 000 comparisons, and at worst 1000 000 comparisons, to find a value in a list of 1000 000 items. def remove(self, value): index = self.__bisect_left(value) if index < len(self.__list) and self.__list[index] == value: del self.__list[index] else:",whileelse,269 Programming in Python 3- a complete introduction to the Python language,"while index < length: self.__seek_to_index(index) state = self.__fh.read(1) if state != _OKAY: for next in range(index + 1, length): self.__seek_to_index(next) state = self.__fh.read(1) if state == _OKAY: self[index] = self[next] del self[next] break else:",whileelse,327 Programming in Python 3- a complete introduction to the Python language,"while len(result) < 5: x = next(generator) if abs(x - 0.5) < sys.float_info.epsilon: x = generator.send(1.0) result.append(x) We create a variable to refer to the generator and call the built-in next() func- tion which retrieves the next item from the generator it is given. (The same effect can be achieved by calling the generator’s __next__() special method, in this case, x = generator.__next__().) If the value is equal to 0.5 we send the value 1.0 into the generator (which immediately yields this value back).This time the result list is [0.0, 0.25, 1.0, 1.25, 1.5]. In the next subsection we will review the magic-numbers.py program which pro- cesses files given on the command line. Unfortunately, the Windows shell pro- gram (cmd.exe) does not provide wildcard expansion (also called file globbing), so if a program is run on Windows with the argument *.*, the literal text “*.*” will go into the sys.argv list instead of all the files in the current directory. We solve this problem by creating two different get_files() functions, one for Windows and the other for Unix, both of which use generators. Here’s the code: if sys.platform.startswith(""win""): def get_files(names): for name in names: if os.path.isfile(name): yield name else: for file in glob.iglob(name): if not os.path.isfile(file): continue yield file else:",whileelse,340 Programming in Python 3- a complete introduction to the Python language,"while True: filename = (yield) print(filename) We have used the same @coroutine decorator that we created in the subsubsection. The get_files() coroutine is essentially a wrapper around the function and that expects to be given paths or filenames to work on. previous os.walk() @coroutine def get_files(receiver): while True: path = (yield) if os.path.isfile(path): receiver.send(os.path.abspath(path)) else:",whileelse,403 Programming in Python 3- a complete introduction to the Python language,"while True: matches = [] start = Console.get_string(message, ""title"") if not start: return None for title in db: if title.lower().startswith(start.lower()): matches.append(title) if len(matches) == 0: print(""There are no dvds starting with"", start) continue elif len(matches) == 1: return matches[0] elif len(matches) > DISPLAY_LIMIT: print(""Too many dvds start with {0}; try entering "" ""more of the title"".format(start)) continue else:",whileelse,474 Programming in Python 3- a complete introduction to the Python language,"while True: start = Console.get_string(message, ""title"") if not start: return (None, None) cursor.execute(""SELECT title, id FROM dvds "" ""WHERE title LIKE ? ORDER BY title"", (start + ""%"",)) records = cursor.fetchall() if len(records) == 0: print(""There are no dvds starting with"", start) continue elif len(records) == 1: return records[0] elif len(records) > DISPLAY_LIMIT: print(""Too many dvds ({0}) start with {1}; try entering "" ""more of the title"".format(len(records), start)) continue else:",whileelse,481 Programming in Python 3- a complete introduction to the Python language,"while data.pos < len(data.text): if not data.advance_up_to(""[]/""): break if data.text[data.pos] == ""["": data.brackets += 1 parse_block(data) elif data.text[data.pos] == ""/"": parse_new_row(data) elif data.text[data.pos] == ""]"": data.brackets -= 1 data.advance_by(1) else: raise LexError(""expecting '[', ']', or '/'; "" ""but got '{0}'"".format(data.text[data.pos])) if data.brackets: raise LexError(""ran out of text when expecting '{0}'"" .format(']' if data.brackets > 0 else '[')) This function is the heart of the recursive descent parser. It iterates over the text looking for the start or end of a block or a new row marker. If it reaches the start of a block it increments the brackets count and calls parse_block(); if it reaches a new row marker it calls parse_new_row(); and if it reaches the end of a block it decrements the brackets count and advances to the next character. If any other character is encountered it is an error and is reported accordingly. Similarly, when all the data has been parsed, if the brackets count is not zero the function reports the error. def parse_block(data): data.advance_by(1) nextBlock = data.text.find(""["", data.pos) endOfBlock = data.text.find(""]"", data.pos) if nextBlock == -1 or endOfBlock < nextBlock: parse_block_data(data, endOfBlock) else:",whileelse,527 Programming in Python 3- a complete introduction to the Python language,"while boolean_expression: suite Actually, the while loop’s full syntax is more sophisticated than this, since both break and continue are supported, and also an optional else clause that we will discuss in Chapter 4. The break statement switches control to the statement following the innermost loop in which the break statement appears—that is, it breaks out of the loop. The continue statement switches control to the start of the loop. Both break and continue are normally used inside if statements to conditionally change a loop’s behavior. while True: item = get_next_item() if not item: break process_item(item) This while loop has a very typical structure and runs as long as there are items to process. (Both get_next_item() and process_item() are assumed to be custom functions defined elsewhere.) In this example, the while statement’s suite contains an if statement, which itself has a suite—as it must—in this case consisting of a single break statement. The for … in Statement | Python’s for loop reuses the in keyword (which in other contexts is the mem- bership operator), and has the following syntax: for variable in iterable: suite Just like the while loop, the for loop supports both break",whilebreak,27 Programming in Python 3- a complete introduction to the Python language,"while True: try: line = input() if line: number = int(line) total += number count += 1 except ValueError as err: print(err) continue except EOFError: break",whilebreak,34 Programming in Python 3- a complete introduction to the Python language,"while True: try: line = input() if line: try: number = int(line) except ValueError as err: print(err) continue total += number count += 1 except EOFError: break",whilebreak,35 Programming in Python 3- a complete introduction to the Python language,"while True: report_id = unpack_string(fh, False) if report_id is None: break data = {} data[""report_id""] = report_id for name in (""airport"", ""aircraft_id"", ""aircraft_type"", ""narrative""): data[name] = unpack_string(fh) other_data = fh.read(NumbersStruct.size) numbers = NumbersStruct.unpack(other_data) data[""date""] = datetime.date.fromordinal(numbers[0]) data[""pilot_percent_hours_on_type""] = numbers[1] data[""pilot_total_hours""] = numbers[2] data[""midair""] = numbers[3] incident = Incident(**data) self[incident.report_id] = incident return True The while block loops until we run out of data. We start by trying to get a report ID. If we get None we’ve reached the end of the file and can break",whilebreak,301 Programming in Python 3- a complete introduction to the Python language,"while True: data = self.__fh.read(self.__record_size) if not data: break",whilebreak,328 Programming in Python 3- a complete introduction to the Python language,"while True: yield next_quarter next_quarter += 0.25 This function will return 0.0, 0.25, 0.5, and so on, forever. Here is how we could use the generator: result = [] for x in quarters(): result.append(x) if x >= 1.0: break The break",whilebreak,339 Programming in Python 3- a complete introduction to the Python language,"while True: event = getNextEvent() if event: if event == Terminate: break",whilebreak,568 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,36 Programming in Python 3- a complete introduction to the Python language,while row < rows:,whilesimple,43 Programming in Python 3- a complete introduction to the Python language,while column < columns:,whilesimple,43 Programming in Python 3- a complete introduction to the Python language,while len(s) < 10:,whilesimple,43 Programming in Python 3- a complete introduction to the Python language,while code < end:,whilesimple,88 Programming in Python 3- a complete introduction to the Python language,while x is None:,whilesimple,93 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,136 Programming in Python 3- a complete introduction to the Python language,while i < len(x):,whilesimple,138 Programming in Python 3- a complete introduction to the Python language,while username in usernames:,whilesimple,148 Programming in Python 3- a complete introduction to the Python language,"while def list_find(lst, target):",whilesimple,159 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,184 Programming in Python 3- a complete introduction to the Python language,while ord(a) < ord(z):,whilesimple,276 Programming in Python 3- a complete introduction to the Python language,while ord(a) < ord(z):,whilesimple,276 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,339 Programming in Python 3- a complete introduction to the Python language,"while item.startswith(indent, i):",whilesimple,350 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,398 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,399 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,403 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,403 Programming in Python 3- a complete introduction to the Python language,while pipes:,whilesimple,439 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,445 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,448 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,448 Programming in Python 3- a complete introduction to the Python language,while True:,whilesimple,456 Programming in Python 3- a complete introduction to the Python language,while self.pos < position:,whilesimple,526 Programming in Python 3- a complete introduction to the Python language,from importable import *,fromstarstatements,193 Programming in Python 3- a complete introduction to the Python language,from os.path import *,fromstarstatements,194 Programming in Python 3- a complete introduction to the Python language,from importable import *,fromstarstatements,194 Programming in Python 3- a complete introduction to the Python language,from os.path import *,fromstarstatements,194 Programming in Python 3- a complete introduction to the Python language,from Graphics import *,fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,from package import *,fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,"from module import *",fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,"from module import *",fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,from module import *,fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,from Graphics.Vector import *,fromstarstatements,198 Programming in Python 3- a complete introduction to the Python language,"from module import *",fromstarstatements,204 Programming in Python 3- a complete introduction to the Python language,"from CharGrid import *",fromstarstatements,206 Programming in Python 3- a complete introduction to the Python language,from importable import *,fromstarstatements,227 Programming in Python 3- a complete introduction to the Python language,"import importable1, importable2, ..., importableN import importable as preferred_name",asextension,193 Programming in Python 3- a complete introduction to the Python language,from importable import object as preferred_name,asextension,193 Programming in Python 3- a complete introduction to the Python language,from Graphics import Tiff as picture,asextension,197 Programming in Python 3- a complete introduction to the Python language,"circle = Shape.Circle(5, 28, 45) # assumes: import ShapeAlt as Shape",asextension,243 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, x=0, y=0)",__init__,236 Programming in Python 3- a complete introduction to the Python language,method __init__(),__init__,237 Programming in Python 3- a complete introduction to the Python language,"the __init__() method, since the object.__new__()",__init__,237 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, x=0, y=0)",__init__,238 Programming in Python 3- a complete introduction to the Python language,class __init__() method by calling super().__init__(),__init__,238 Programming in Python 3- a complete introduction to the Python language,s __init__(),__init__,238 Programming in Python 3- a complete introduction to the Python language,s __init__(),__init__,238 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, radius, x=0, y=0)",__init__,240 Programming in Python 3- a complete introduction to the Python language,of __init__() and __eq__(),__init__,242 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, value=0.0)",__init__,246 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, sequence=None, key=None)",__init__,267 Programming in Python 3- a complete introduction to the Python language,"the __init__() method’s type-testing elif clause.)",__init__,272 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, dictionary=None, key=None, **kwargs)",__init__,273 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, incidents)",__init__,319 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, filename, record_size, auto_flush=True)",__init__,323 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, identity, name, quantity, price)",__init__,330 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, filename)",__init__,330 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, x=0, y=0)",__init__,360 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, *attribute_names)",__init__,365 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, forename, surname, email)",__init__,365 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, name, description, price)",__init__,370 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, attribute_name)",__init__,371 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, attribute_name)",__init__,371 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, x=0, y=0)",__init__,372 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, attribute_name)",__init__,372 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, name, extension)",__init__,373 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, getter, setter=None)",__init__,373 Programming in Python 3- a complete introduction to the Python language,s __init__(),__init__,379 Programming in Python 3- a complete introduction to the Python language,made __init__(),__init__,381 Programming in Python 3- a complete introduction to the Python language,the __init__(),__init__,381 Programming in Python 3- a complete introduction to the Python language,the __init__(),__init__,381 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, model, price, fuel)",__init__,382 Programming in Python 3- a complete introduction to the Python language,the __init__(),__init__,382 Programming in Python 3- a complete introduction to the Python language,The __init__() and undo(),__init__,384 Programming in Python 3- a complete introduction to the Python language,def __init__(self),__init__,384 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, filename, *attribute_names)",__init__,385 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, filename)",__init__,386 Programming in Python 3- a complete introduction to the Python language,the __init__(),__init__,386 Programming in Python 3- a complete introduction to the Python language,"def __init__(cls, classname, bases, dictionary)",__init__,388 Programming in Python 3- a complete introduction to the Python language,its __init__(),__init__,389 Programming in Python 3- a complete introduction to the Python language,to __init__(),__init__,389 Programming in Python 3- a complete introduction to the Python language,"reimplementing __init__() is sufficient, although this can also be done in __new__()",__init__,389 Programming in Python 3- a complete introduction to the Python language,than __init__(),__init__,391 Programming in Python 3- a complete introduction to the Python language,an __init__(),__init__,391 Programming in Python 3- a complete introduction to the Python language,and __init__(),__init__,391 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, name, productid, category, price, quantity)",__init__,405 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, getter, setter)",__init__,406 Programming in Python 3- a complete introduction to the Python language,The __init__(),__init__,408 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, work_queue, word, number)",__init__,445 Programming in Python 3- a complete introduction to the Python language,The __init__() method must call the base class __init__(),__init__,445 Programming in Python 3- a complete introduction to the Python language,"s __init__() and run() methods, and the process()",__init__,452 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, address)",__init__,460 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, filename, mode)",__init__,463 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, name, color=""white"")",__init__,524 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, text)",__init__,525 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, parent)",__init__,569 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, parent)",__init__,575 Programming in Python 3- a complete introduction to the Python language,"def __init__(self, parent, name=None, url=None)",__init__,586 Programming in Python 3- a complete introduction to the Python language,"519 __init__()",__init__,608 Programming in Python 3- a complete introduction to the Python language,"253 __init__()",__init__,620 Programming in Python 3- a complete introduction to the Python language,"391 __init__()",__init__,624 Programming in Python 3- a complete introduction to the Python language,"try: fh = open(filename, encoding=""utf8"") errors = False for lino, line in enumerate(fh, start=1): for column, c in enumerate(line, start=1): try: The code begins conventionally enough, setting the file object to None and putting all the file handling in a try block. The program reads the file line by line and reads each line character by character. Notice that we have two try blocks; the outer one is used to handle file object exceptions, and the inner one is used to handle parsing exceptions. ... elif state == PARSING_ENTITY: if c == "";"": if entity.startswith(""#""): if frozenset(entity[1:]) - HEXDIGITS: raise InvalidNumericEntityError() elif not entity.isalpha(): raise InvalidAlphaEntityError() ...",trytry,166 Programming in Python 3- a complete introduction to the Python language,"try: tree = xml.etree.ElementTree.parse(filename) except (EnvironmentError, xml.parsers.expat.ExpatError) as err: print(""{0}: import error: {1}"".format( os.path.basename(sys.argv[0]), err)) return False By default, the element tree parser uses the expat XML parser under the hood which is why we must be ready to catch expat exceptions. self.clear() for element in tree.findall(""incident""): try: data = {} for attribute in (""report_id"", ""date"", ""aircraft_id"", ""aircraft_type"", ""pilot_percent_hours_on_type"", ""pilot_total_hours"", ""midair""): data[attribute] = element.get(attribute) data[""date""] = datetime.datetime.strptime( data[""date""], ""%Y-%m-%d"").date() data[""pilot_percent_hours_on_type""] = ( float(data[""pilot_percent_hours_on_type""])) data[""pilot_total_hours""] = int( data[""pilot_total_hours""]) data[""midair""] = bool(int(data[""midair""])) data[""airport""] = element.find(""airport"").text.strip() narrative = element.find(""narrative"").text data[""narrative""] = (narrative.strip() if narrative is not None else """") incident = Incident(**data) self[incident.report_id] = incident except (ValueError, LookupError, IncidentError) as err: print(""{0}: import error: {1}"".format( os.path.basename(sys.argv[0]), err)) return False return True",trytry,312 Programming in Python 3- a complete introduction to the Python language,"try: dom = xml.dom.minidom.parse(filename) except (EnvironmentError, xml.parsers.expat.ExpatError) as err: print(""{0}: import error: {1}"".format( os.path.basename(sys.argv[0]), err)) return False Parsing an XML file into a DOM is easy since the module does all the hard work for us, but we must be ready to handle expat errors since just like an element tree, the expat XML parser is the default parser used by the DOM classes under the hood. self.clear() for element in dom.getElementsByTagName(""incident""): try: data = {} for attribute in (""report_id"", ""date"", ""aircraft_id"", ""aircraft_type"", ""pilot_percent_hours_on_type"", ""pilot_total_hours"", ""midair""): data[attribute] = element.getAttribute(attribute) data[""date""] = datetime.datetime.strptime( data[""date""], ""%Y-%m-%d"").date() data[""pilot_percent_hours_on_type""] = ( float(data[""pilot_percent_hours_on_type""])) data[""pilot_total_hours""] = int( data[""pilot_total_hours""]) data[""midair""] = bool(int(data[""midair""])) airport = element.getElementsByTagName(""airport"")[0]",trytry,315 Programming in Python 3- a complete introduction to the Python language,"try: module = __import__(name) modules.append(module) except (ImportError, SyntaxError) as err: print(err) This is the easiest way to dynamically import modules and is slightly safer than using exec(), although like any dynamic import, it is by no means secure because we don’t know what is being executed when the module is imported. None of the techniques shown here handles packages or modules in different paths, but it is not difficult to extend the code to accommodate these—although it is worth reading the online documentation, especially for __import__(), if more sophistication is required. Having imported the module we need to be able to access the functionality it provides. This can be achieved using Python’s built-in introspection functions, getattr() and hasattr(). Here’s how we have used them to implement the get_function() function: def get_function(module, function_name): function = get_function.cache.get((module, function_name), None) if function is None: try: function = getattr(module, function_name) if not hasattr(function, ""__call__""): raise AttributeError() get_function.cache[module, function_name] = function except AttributeError: function = None return function get_function.cache = {} Ignoring the cache-related code for a moment, what the function does is call getattr() on the module object with the name of the function we want. If there is no such attribute an AttributeError exception is raised, but if there is such an attribute we use hasattr() to check that the attribute itself has the __call__ attribute—something that all callables (functions and methods) have. (Further on we will see a nicer way of checking whether an attribute is collec- tions. Callable ® 392",trytry,347 Programming in Python 3- a complete introduction to the Python language,"try: with open(source) as fin: with open(target, ""w"") as fout: for line in fin: fout.write(process(line)) except EnvironmentError as err: print(err) Here we read lines from the source file and write processed versions of them to the target file. Using nested with statements can quickly lead to a lot of indentation. Fortu- nately, the standard library’s contextlib module provides some additional sup- port for context managers, including the contextlib.nested() function which allows two or more context managers to be handled in the same with statement rather than having to nest with statements. Here is a replacement for the code just shown, but omitting most of the lines that are identical to before: try: with contextlib.nested(open(source), open(target, ""w"")) as ( fin, fout): for line in fin:",trytry,367 Programming in Python 3- a complete introduction to the Python language,"try: with open(source) as fin, open(target, ""w"") as fout: for line in fin: Using this syntax keeps context managers and the variables they are associ- ated with together, making the with statement much more readable than if we were to nest them or to use contextlib.nested(). It isn’t only file objects that are context managers. For example, several threading-related classes used for locking are context managers. Context managers can also be used with decimal.Decimal numbers; this is useful if we want to perform some calculations with certain settings (such as a particular precision) in effect. If we want to create a custom context manager we must create a class that provides two methods: __enter__() and __exit__(). Whenever a with statement is used on an instance of such a class, the __enter__() method is called and the return value is used for the as variable (or thrown away if there isn’t one). When control leaves the scope of the with statement the __exit__() method is called (with details of an exception if one has occurred passed as arguments). Suppose we want to perform several operations on a list in an atomic manner—that is, we either want all the operations to be done or none of them so that the resultant list is always in a known state. For example, if we have a list of integers and want to append an integer, delete an integer, and change a couple of integers, all as a single operation, we could write code like this: Thread- ing ® 439 try: with AtomicList(items) as atomic: atomic.append(58289) del atomic[3] atomic[8] = 81738 atomic[index] = 38172 except (AttributeError, IndexError, ValueError) as err: print(""no changes applied:"", err) If no exception occurs, all the operations are applied to the original list (items), but if an exception occurs, no changes are made at all. Here is the code for the AtomicList context manager: class AtomicList: def __init__(self, alist, shallow_copy=True):",trytry,368 Programming in Python 3- a complete introduction to the Python language,"try: x = float(number) print(""<td align='right'>{0:d}</td>"".format(round(x))) except ValueError: field = field.title() field = field.replace("" And "", "" and "") if len(field) <= maxwidth: field = escape_html(field) else:",tryexceptelse,98 Programming in Python 3- a complete introduction to the Python language,"try: for row, record in enumerate(table): for column, field in enumerate(record): for index, item in enumerate(field): if item == target: raise FoundException() except FoundException: print(""found at ({0}, {1}, {2})"".format(row, column, index)) else:",tryexceptelse,165 Programming in Python 3- a complete introduction to the Python language,"try: try_suite except exception1 as variable1: exception_suite1 … except exceptionN as variableN:",tryexcept,28 Programming in Python 3- a complete introduction to the Python language,"try: i = int(s) print(""valid integer entered:"", i) except ValueError as err:",tryexcept,29 Programming in Python 3- a complete introduction to the Python language,"try: i = int(input(msg)) return i except ValueError as err:",tryexcept,36 Programming in Python 3- a complete introduction to the Python language,"try: digits = sys.argv[1] row = 0 while row < 7: line = """" column = 0 while column < len(digits): number = int(digits[column]) digit = Digits[number] line += digit[row] + "" "" column += 1 print(line) row += 1 except IndexError: print(""usage: bigdigits.py <number>"") except ValueError as err:",tryexcept,40 Programming in Python 3- a complete introduction to the Python language,"try: i = line.index(opener) start = i + len(opener) j = line.index(closer, start) return line[start:j] except ValueError:",tryexcept,73 Programming in Python 3- a complete introduction to the Python language,"try: product *= next(i) except StopIteration:",tryexcept,136 Programming in Python 3- a complete introduction to the Python language,"try: number = float(x) numbers.append(number) frequencies[number] += 1 except ValueError as err:",tryexcept,150 Programming in Python 3- a complete introduction to the Python language,"try: print(""\nMake HTML Skeleton\n"") populate_information(information) make_html_skeleton(**information) except CancelledError:",tryexcept,184 Programming in Python 3- a complete introduction to the Python language,"try: for column in range(column0, column1): _grid[row][column] = char except IndexError:",tryexcept,208 Programming in Python 3- a complete introduction to the Python language,"try: import bz2 except ImportError:",tryexcept,218 Programming in Python 3- a complete introduction to the Python language,"try: self.__keys.remove(key) except ValueError:",tryexcept,275 Programming in Python 3- a complete introduction to the Python language,"try: tree.write(filename, ""UTF-8"") except EnvironmentError as err:",tryexcept,311 Programming in Python 3- a complete introduction to the Python language,"try: exec(""import "" + name) modules.append(sys.modules[name]) except SyntaxError as err:",tryexcept,346 Programming in Python 3- a complete introduction to the Python language,"try: blocks = parse(blocks) svg = file.replace("".blk"", "".svg"") if not BlockOutput.save_blocks_as_svg(blocks, svg): print(""Error: failed to save {0}"".format(svg) except ValueError as err:",tryexcept,412 Programming in Python 3- a complete introduction to the Python language,"try: i = int(data) ... except ValueError as err:",tryexcept,416 Programming in Python 3- a complete introduction to the Python language,"try: with open(filename, ""rb"") as fh: while True: current = fh.read(BLOCK_SIZE) if not current: break current = current.decode(""utf8"", ""ignore"") if (word in current or word in previous[-len(word):] + current[:len(word)]): print(""{0}{1}"".format(number, filename)) break if len(current) != BLOCK_SIZE: break previous = current except EnvironmentError as err:",tryexcept,440 Programming in Python 3- a complete introduction to the Python language,"try: key = (os.path.getsize(fullname), filename) except EnvironmentError:",tryexcept,446 Programming in Python 3- a complete introduction to the Python language,"try: md5 = hashlib.md5() with open(filename, ""rb"") as fh: md5.update(fh.read()) md5 = md5.digest() md5s[md5].add(filename) with self.Md5_lock: self.md5_from_filename[filename] = md5 except EnvironmentError:",tryexcept,449 Programming in Python 3- a complete introduction to the Python language,"try: with self.CallLock: function = self.Call[data[0]] reply = function(self, *data[1:]) except Finish:",tryexcept,465 Programming in Python 3- a complete introduction to the Python language,"try: parse(data) except LexError as err:",tryexcept,526 Programming in Python 3- a complete introduction to the Python language,"try: parser.parseFile(file) except ParseException as err:",tryexcept,535 Programming in Python 3- a complete introduction to the Python language,"try: parser.parseFile(fh) except ParseException as err:",tryexcept,537 Programming in Python 3- a complete introduction to the Python language,"try: return parser.parse(text, lexer=lexer) except ValueError as err:",tryexcept,562 Programming in Python 3- a complete introduction to the Python language,"S = {7, ""veil"", 0, -29, (""x"", 11), ""sun"", frozenset({8, 4, 7}), 913}",nestedDict,118 Programming in Python 3- a complete introduction to the Python language,"modeline = ""mode = {0:{fmt}}",nestedDict,152 Programming in Python 3- a complete introduction to the Python language,"mean:{fmt}} = {median:{fmt}}",nestedDict,153 Programming in Python 3- a complete introduction to the Python language,std. dev. = {std_dev:{fmt}},nestedDict,153 Programming in Python 3- a complete introduction to the Python language,lambda parameters: expression,lambda,179 Programming in Python 3- a complete introduction to the Python language,lambda function:,lambda,179 Programming in Python 3- a complete introduction to the Python language,"lambda e: (e[1], e[2]) with e being each 3-tuple ele-",lambda,180 Programming in Python 3- a complete introduction to the Python language,"lambda self, identity, amount:",lambda,332 Programming in Python 3- a complete introduction to the Python language,"lambda self, identity, amount:",lambda,332 Programming in Python 3- a complete introduction to the Python language,"lambda self, *a, **kw: """,lambda,375 Programming in Python 3- a complete introduction to the Python language,"lambda self, *a, **kw: self._SortedList__list.pop(*a, **kw)",lambda,376 Programming in Python 3- a complete introduction to the Python language,"lambda self, price: super().set_price(price))",lambda,382 Programming in Python 3- a complete introduction to the Python language,lambda self: self.__stack.pop()),lambda,384 Programming in Python 3- a complete introduction to the Python language,lambda self: self.__stack.append(item)),lambda,384 Programming in Python 3- a complete introduction to the Python language,"lambda x: x > 0, [1, -2, 3, -4])) # returns: [1, 3]",lambda,392 Programming in Python 3- a complete introduction to the Python language,"lambda x, y: x * y, [1, 2, 3, 4]) # returns: 24",lambda,393 Programming in Python 3- a complete introduction to the Python language,"lambda x, y: x + y.",lambda,393 Programming in Python 3- a complete introduction to the Python language,"lambda x: x.endswith("".py""), files)))",lambda,393 Programming in Python 3- a complete introduction to the Python language,"lambda tokens: int(tokens[0]))(""seconds"")",lambda,536 Programming in Python 3- a complete introduction to the Python language,lambda tokens: len(tokens.new_rows)),lambda,538 Programming in Python 3- a complete introduction to the Python language,lambda tokens: tokens.name.strip()),lambda,538 Programming in Python 3- a complete introduction to the Python language,lambda *ignore: principalScale.focus_set()),lambda,572 Programming in Python 3- a complete introduction to the Python language,lambda *ignore: rateScale.focus_set()),lambda,572 Programming in Python 3- a complete introduction to the Python language,lambda *ignore: yearsScale.focus_set()),lambda,572 Programming in Python 3- a complete introduction to the Python language,lambda *ignore: nameEntry.focus_set()),lambda,588 Programming in Python 3- a complete introduction to the Python language,lambda *ignore: urlEntry.focus_set()),lambda,588 Programming in Python 3- a complete introduction to the Python language,"def sum_of_powers(*args, power=1):",funcwithkeywordonly,175 Programming in Python 3- a complete introduction to the Python language,"def heron2(a, b, c, *, units=""square meters""):",funcwithkeywordonly,175 Programming in Python 3- a complete introduction to the Python language,"def print_setup(*, paper=""Letter"", copies=1, color=False):",funcwithkeywordonly,176 Programming in Python 3- a complete introduction to the Python language,"def handle_request(*items, wait_for_reply=True): SizeStruct = struct.Struct(""!I"") data = pickle.dumps(items, 3) try: with SocketManager(tuple(Address)) as sock: sock.sendall(SizeStruct.pack(len(data))) sock.sendall(data) if not wait_for_reply: return size_data = sock.recv(SizeStruct.size) size = SizeStruct.unpack(size_data)[0] result = bytearray() while True: data = sock.recv(4000) if not data: break result.extend(data) if len(result) >= size:",funcwithkeywordonly,459 Programming in Python 3- a complete introduction to the Python language,"def add_person_details(ssn, surname, **kwargs):",funcwith2star,176 Programming in Python 3- a complete introduction to the Python language,"def print_args(*args, **kwargs):",funcwith2star,177 Programming in Python 3- a complete introduction to the Python language,"def update(self, dictionary=None, **kwargs):",funcwith2star,274 Programming in Python 3- a complete introduction to the Python language,"def wrapper(*args, **kwargs):",funcwith2star,354 Programming in Python 3- a complete introduction to the Python language,def product(*args):,funcwithstar,175 Programming in Python 3- a complete introduction to the Python language,def product(*args):,funcwithstar,181 Programming in Python 3- a complete introduction to the Python language,def product(*args):,funcwithstar,181 Programming in Python 3- a complete introduction to the Python language,def conjunction(*fuzzies):,funcwithstar,253 Programming in Python 3- a complete introduction to the Python language,"def {0}(self, *args):",funcwithstar,257 Programming in Python 3- a complete introduction to the Python language,"def __xor__(self, *args):",funcwithstar,258 Programming in Python 3- a complete introduction to the Python language,"def pop(self, key, *args):",funcwithstar,277 Programming in Python 3- a complete introduction to the Python language,"def range_of_floats(*args) -> ""author=Reginald Perrin"":",funcwithstar,359 Programming in Python 3- a complete introduction to the Python language,def quit(*ignore):,funcwithstar,458 Programming in Python 3- a complete introduction to the Python language,def stop_server(*ignore):,funcwithstar,459 Programming in Python 3- a complete introduction to the Python language,"def __exit__(self, *ignore):",funcwithstar,461 Programming in Python 3- a complete introduction to the Python language,"def __exit__(self, *ignore):",funcwithstar,463 Programming in Python 3- a complete introduction to the Python language,"def shutdown(self, *ignore):",funcwithstar,468 Programming in Python 3- a complete introduction to the Python language,"def updateUi(self, *ignore):",funcwithstar,573 Programming in Python 3- a complete introduction to the Python language,"def fileNew(self, *ignore):",funcwithstar,579 Programming in Python 3- a complete introduction to the Python language,"def fileSave(self, *ignore):",funcwithstar,581 Programming in Python 3- a complete introduction to the Python language,"def fileOpen(self, *ignore):",funcwithstar,582 Programming in Python 3- a complete introduction to the Python language,"def editAdd(self, *ignore):",funcwithstar,583 Programming in Python 3- a complete introduction to the Python language,"def editEdit(self, *ignore):",funcwithstar,584 Programming in Python 3- a complete introduction to the Python language,"def editDelete(self, *ignore):",funcwithstar,584 Programming in Python 3- a complete introduction to the Python language,"def editShowWebPage(self, *ignore):",funcwithstar,585 Programming in Python 3- a complete introduction to the Python language,class exceptionName(baseException):,simpleclass,165 Programming in Python 3- a complete introduction to the Python language,class FoundException(Exception):,simpleclass,165 Programming in Python 3- a complete introduction to the Python language,class InvalidEntityError(Exception):,simpleclass,166 Programming in Python 3- a complete introduction to the Python language,class InvalidNumericEntityError(InvalidEntityError):,simpleclass,166 Programming in Python 3- a complete introduction to the Python language,class InvalidAlphaEntityError(InvalidEntityError):,simpleclass,166 Programming in Python 3- a complete introduction to the Python language,class InvalidTagContentError(Exception):,simpleclass,166 Programming in Python 3- a complete introduction to the Python language,class CancelledError(Exception):,simpleclass,183 Programming in Python 3- a complete introduction to the Python language,class RangeError(Exception):,simpleclass,205 Programming in Python 3- a complete introduction to the Python language,class RowRangeError(RangeError):,simpleclass,205 Programming in Python 3- a complete introduction to the Python language,class ColumnRangeError(RangeError):,simpleclass,205 Programming in Python 3- a complete introduction to the Python language,class className(base_classes):,simpleclass,235 Programming in Python 3- a complete introduction to the Python language,class Circle(Point):,simpleclass,240 Programming in Python 3- a complete introduction to the Python language,class ImageError(Exception):,simpleclass,259 Programming in Python 3- a complete introduction to the Python language,class CoordinateError(ImageError):,simpleclass,259 Programming in Python 3- a complete introduction to the Python language,class SortedDict(dict):,simpleclass,273 Programming in Python 3- a complete introduction to the Python language,class IncidentError(Exception):,simpleclass,287 Programming in Python 3- a complete introduction to the Python language,class IncidentCollection(dict):,simpleclass,288 Programming in Python 3- a complete introduction to the Python language,class Cooker(Appliance):,simpleclass,382 Programming in Python 3- a complete introduction to the Python language,class CharCounter(TextFilter):,simpleclass,382 Programming in Python 3- a complete introduction to the Python language,class RunLengthDecode(TextFilter):,simpleclass,383 Programming in Python 3- a complete introduction to the Python language,class Stack(Undo):,simpleclass,384 Programming in Python 3- a complete introduction to the Python language,class LoadableSaveable(type):,simpleclass,388 Programming in Python 3- a complete introduction to the Python language,class InvalidDataError(Exception):,simpleclass,416 Programming in Python 3- a complete introduction to the Python language,class LexError(Exception):,simpleclass,526 Programming in Python 3- a complete introduction to the Python language,"raise a TypeError. But we can easily achieve what we want using str.format()",raise,77 Programming in Python 3- a complete introduction to the Python language,raise a ValueError exception if the string or item is not found. The str.find(),raise,158 Programming in Python 3- a complete introduction to the Python language,raise exception(args),raise,164 Programming in Python 3- a complete introduction to the Python language,raise exception(args),raise,164 Programming in Python 3- a complete introduction to the Python language,"raise EOFError(""missing ';' at end of "" + filename)",raise,168 Programming in Python 3- a complete introduction to the Python language,raise CancelledError(),raise,184 Programming in Python 3- a complete introduction to the Python language,raise RowRangeError(),raise,208 Programming in Python 3- a complete introduction to the Python language,raise ColumnRangeError(),raise,208 Programming in Python 3- a complete introduction to the Python language,"raise TypeError(). The third way (which is also the most Pythonically correct)",raise,239 Programming in Python 3- a complete introduction to the Python language,raise NotImplementedError(),raise,255 Programming in Python 3- a complete introduction to the Python language,"raise a TypeError. Here is how we can make FuzzyBool.__add__()",raise,256 Programming in Python 3- a complete introduction to the Python language,"raise TypeError(""unsupported operand type(s)",raise,256 Programming in Python 3- a complete introduction to the Python language,"raise TypeError(""unsupported operand type(s)",raise,258 Programming in Python 3- a complete introduction to the Python language,raise CoordinateError(str(coordinate)),raise,261 Programming in Python 3- a complete introduction to the Python language,raise CoordinateError(str(coordinate)),raise,262 Programming in Python 3- a complete introduction to the Python language,raise CoordinateError(str(coordinate)),raise,262 Programming in Python 3- a complete introduction to the Python language,raise NoFilenameError(),raise,265 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""{0}.remove(x)",raise,269 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""{0}.index(x)",raise,270 Programming in Python 3- a complete introduction to the Python language,"raise TypeError(""use add()",raise,271 Programming in Python 3- a complete introduction to the Python language,raise KeyError(key),raise,275 Programming in Python 3- a complete introduction to the Python language,raise KeyError(key),raise,277 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""missing or corrupt string size"")",raise,299 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""missing or corrupt string"")",raise,299 Programming in Python 3- a complete introduction to the Python language,"raise a ValueError exception to indicate corrupt or missing data. The struct.unpack()",raise,299 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""invalid .aib file format"")",raise,300 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""unrecognized .aib file version"")",raise,300 Programming in Python 3- a complete introduction to the Python language,"raise IncidentError(""missing data"")",raise,308 Programming in Python 3- a complete introduction to the Python language,"raise IncidentError(""missing data"")",raise,320 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""invalid price"")",raise,355 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""cannot change a const attribute"")",raise,361 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""cannot delete a const attribute"")",raise,361 Programming in Python 3- a complete introduction to the Python language,"raise NotImplementedError()), or with an actual (concrete)",raise,378 Programming in Python 3- a complete introduction to the Python language,raise NotImplementedError(),raise,382 Programming in Python 3- a complete introduction to the Python language,raise NotImplementedError(),raise,382 Programming in Python 3- a complete introduction to the Python language,"raise InvalidDataError(""Invalid data received"")",raise,416 Programming in Python 3- a complete introduction to the Python language,"raise InvalidDataError(""Invalid data received"")",raise,417 Programming in Python 3- a complete introduction to the Python language,raise Finish(),raise,468 Programming in Python 3- a complete introduction to the Python language,"raise our own exception (a ValueError)",raise,541 Programming in Python 3- a complete introduction to the Python language,"raise LexError(""too many ']'s"")",raise,556 Programming in Python 3- a complete introduction to the Python language,"raise LexError(""syntax error"")",raise,557 Programming in Python 3- a complete introduction to the Python language,"raise LexError(""syntax error"")",raise,557 Programming in Python 3- a complete introduction to the Python language,"raise LexError(""unbalanced brackets []"")",raise,557 Programming in Python 3- a complete introduction to the Python language,"raise ValueError(""Unknown error"")",raise,561 Programming in Python 3- a complete introduction to the Python language,"assert left != right, ""the bracket characters must differ""",assert,201 Programming in Python 3- a complete introduction to the Python language,"assert max_rows > 0 and max_columns > 0, ""too small""",assert,207 Programming in Python 3- a complete introduction to the Python language,"assert len(char) == 1, _CHAR_ASSERT_TEMPLATE.format(char)",assert,207 Programming in Python 3- a complete introduction to the Python language,"assert len(char) == 1, _CHAR_ASSERT_TEMPLATE.format(char)",assert,208 Programming in Python 3- a complete introduction to the Python language,"assert radius > 0, ""radius must be nonzero and non-negative""",assert,244 Programming in Python 3- a complete introduction to the Python language,"assert len(coordinate) == 2, ""coordinate should be a 2-tuple""",assert,261 Programming in Python 3- a complete introduction to the Python language,"assert len(coordinate) == 2, ""coordinate should be a 2-tuple""",assert,262 Programming in Python 3- a complete introduction to the Python language,"assert len(coordinate) == 2, ""coordinate should be a 2-tuple""",assert,262 Programming in Python 3- a complete introduction to the Python language,"assert len(report_id) >= 8 and len(report_id.split()) == 1, \",assert,287 Programming in Python 3- a complete introduction to the Python language,"assert len(record) == self.record_size, (",assert,324 Programming in Python 3- a complete introduction to the Python language,"assert len(identity) > 3, (""invalid bike identity '{0}'""",assert,330 Programming in Python 3- a complete introduction to the Python language,"assert result >= 0, function.__name__ + ""() result isn't >= 0""",assert,354 Programming in Python 3- a complete introduction to the Python language,"assert result >= 0, function.__name__ + ""() result isn't >= 0""",assert,354 Programming in Python 3- a complete introduction to the Python language,assert len(results) == 1,assert,540 Programming in Python 3- a complete introduction to the Python language,assert len(result) == 1,assert,547 Programming in Python 3- a complete introduction to the Python language,"for country in [""Denmark"", ""Finland"", ""Norway"", ""Sweden""]:",forwithlist,27 Programming in Python 3- a complete introduction to the Python language,"for i in [1, 2, 4, 8]:",forwithlist,136 Programming in Python 3- a complete introduction to the Python language,"for row in (0, 1, 2, 3, 4, 5, 6):",forwithtuple,40 Programming in Python 3- a complete introduction to the Python language,"for _ in (0, 1, 2, 3, 4, 5):",forwithtuple,51 Programming in Python 3- a complete introduction to the Python language,"for x, y in ((1, 1), (2, 4), (3, 9)):",forwithtuple,106 Programming in Python 3- a complete introduction to the Python language,"for x, y in ((-3, 4), (5, 12), (28, -45)):",forwithtuple,108 Programming in Python 3- a complete introduction to the Python language,"for function in (""function_a"", ""function_b"", ""function_c""):",forwithtuple,430 Programming in Python 3- a complete introduction to the Python language,"for function in (""function_a"", ""function_b"", ""function_c""):",forwithtuple,431 Programming in Python 3- a complete introduction to the Python language,"Given the assignment L = [-17.5, ""kilo"", 49, ""V"", [""ram"", 5, ""echo""], 7]",nestedList,110 Programming in Python 3- a complete introduction to the Python language,"x = [53, 68, [""A"", ""B"", ""C""]]",nestedList,145 Programming in Python 3- a complete introduction to the Python language,"x = [53, 68, [""A"", ""B"", ""C""]]",nestedList,145 Programming in Python 3- a complete introduction to the Python language,t]*(?P<key>\w+)[ \t]*=[ \t]*(?P<value>[^\n]+)(?<![ \t],nestedList,492 Programming in Python 3- a complete introduction to the Python language,"p[0] = [p[1], p[2], p[4]]",nestedList,559 Programming in Python 3- a complete introduction to the Python language,"p[0] = [p[1], p[2], p[3]]",nestedList,560 Programming in Python 3- a complete introduction to the Python language,"p[0] = [p[1], p[2]]",nestedList,560 Programming in Python 3- a complete introduction to the Python language,"p[0] = [p[1], p[2], p[3]]",nestedList,561 Programming in Python 3- a complete introduction to the Python language,"for column, field in enumerate(record): for index, item in enumerate(field):",fornested,165 Programming in Python 3- a complete introduction to the Python language,"d5 = {""id"": 1948, ""name"": ""Washer"", ""size"": 3}",simpleDict,124 Programming in Python 3- a complete introduction to the Python language,"d = {}.fromkeys(""ABCD"", 3) # d == {'A': 3, 'B': 3, 'C': 3, 'D': 3}",simpleDict,127 Programming in Python 3- a complete introduction to the Python language,"Chapter 3. Collection Data Types = {0:6}",simpleDict,153 Programming in Python 3- a complete introduction to the Python language,a={0:.1%} b={1:.0%},simpleDict,246 Programming in Python 3- a complete introduction to the Python language,midair={0.midair:d},simpleDict,303 Programming in Python 3- a complete introduction to the Python language,for line in open(filename),openfunc,127 Programming in Python 3- a complete introduction to the Python language,bar “Reading and Writing Text Files” (® 131) for an explanation of the open(),openfunc,127 Programming in Python 3- a complete introduction to the Python language,Files are opened using the built-in open(),openfunc,128 Programming in Python 3- a complete introduction to the Python language,possible it is best to specify the encoding using open(),openfunc,128 Programming in Python 3- a complete introduction to the Python language,"fin = open(filename, encoding=""utf8"")",openfunc,128 Programming in Python 3- a complete introduction to the Python language,"fout = open(filename, ""w"", encoding=""utf8"")",openfunc,128 Programming in Python 3- a complete introduction to the Python language,Because open(),openfunc,128 Programming in Python 3- a complete introduction to the Python language,"for line in open(filename, encoding=""utf8"")",openfunc,128 Programming in Python 3- a complete introduction to the Python language,for line in open(filename),openfunc,129 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(open(filename), start=1)",openfunc,137 Programming in Python 3- a complete introduction to the Python language,called open(),openfunc,138 Programming in Python 3- a complete introduction to the Python language,The file object returned by the open(),openfunc,138 Programming in Python 3- a complete introduction to the Python language,"for name in open(filename, encoding=""utf8"")",openfunc,139 Programming in Python 3- a complete introduction to the Python language,"fh = open(""test-names1.txt"", ""w"", encoding=""utf8"")",openfunc,139 Programming in Python 3- a complete introduction to the Python language,We have not shown the get_forenames_and_surnames() function or the open(),openfunc,140 Programming in Python 3- a complete introduction to the Python language,"for line in open(filename, encoding=""utf8"")",openfunc,147 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(open(filename, encoding=""ascii"")",openfunc,150 Programming in Python 3- a complete introduction to the Python language,"We set the file object, fh, to None because it is possible that the open()",openfunc,164 Programming in Python 3- a complete introduction to the Python language,"binary = open(left_align_png, ""rb"").read()",openfunc,217 Programming in Python 3- a complete introduction to the Python language,"The binary data could be written to a file using open(filename, ""wb"")",openfunc,218 Programming in Python 3- a complete introduction to the Python language,"fh = urllib.request.urlopen(""http://www.python.org/index.html"")",openfunc,223 Programming in Python 3- a complete introduction to the Python language,The urllib.request.urlopen(),openfunc,223 Programming in Python 3- a complete introduction to the Python language,binary = gzip.open(filename).read(),openfunc,225 Programming in Python 3- a complete introduction to the Python language,The gzip module’s gzip.open(),openfunc,225 Programming in Python 3- a complete introduction to the Python language,built-in open(),openfunc,225 Programming in Python 3- a complete introduction to the Python language,"If compression has been requested, we use the gzip module’s gzip.open()",openfunc,291 Programming in Python 3- a complete introduction to the Python language,"function to open the file; otherwise, we use the built-in open()",openfunc,291 Programming in Python 3- a complete introduction to the Python language,create a new file object using the gzip.open(),openfunc,292 Programming in Python 3- a complete introduction to the Python language,"compressed we use the file object returned by open(), calling its seek()",openfunc,292 Programming in Python 3- a complete introduction to the Python language,"fh = gzip.open(filename, ""wb"")",openfunc,295 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, ""wb"")",openfunc,295 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, ""rb"")",openfunc,300 Programming in Python 3- a complete introduction to the Python language,"fh = gzip.open(filename, ""rb"")",openfunc,300 Programming in Python 3- a complete introduction to the Python language,we used for reading pickles to open the file using gzip.open(),openfunc,300 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, ""w"", encoding=""utf8"")",openfunc,303 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, encoding=""utf8"")",openfunc,304 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, encoding=""utf8"")",openfunc,308 Programming in Python 3- a complete introduction to the Python language,"the string ""utf8"". This works fine for Python’s built-in open()",openfunc,311 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, ""w"", encoding=""utf8"")",openfunc,314 Programming in Python 3- a complete introduction to the Python language,between the encoding string used for the built-in open(),openfunc,314 Programming in Python 3- a complete introduction to the Python language,"fh = open(filename, ""w"", encoding=""utf8"")",openfunc,316 Programming in Python 3- a complete introduction to the Python language,"self.__fh = open(filename, mode)",openfunc,324 Programming in Python 3- a complete introduction to the Python language,"fh = open(compactfile, ""wb"")",openfunc,328 Programming in Python 3- a complete introduction to the Python language,"self.__fh = open(self.__fh.name, ""r+b"")",openfunc,329 Programming in Python 3- a complete introduction to the Python language,that open(),openfunc,366 Programming in Python 3- a complete introduction to the Python language,we call open(),openfunc,395 Programming in Python 3- a complete introduction to the Python language,"blocks = open(file, encoding=""utf8"").read()",openfunc,414 Programming in Python 3- a complete introduction to the Python language,"return open(*args, **kwargs)",openfunc,414 Programming in Python 3- a complete introduction to the Python language,main() function. It looks like we have a call to open(),openfunc,414 Programming in Python 3- a complete introduction to the Python language,"blocks = open(file, encoding=""utf8"").read()",openfunc,414 Programming in Python 3- a complete introduction to the Python language,"with contextlib.closing(gzip.open(filename, ""rb""))",openfunc,462 Programming in Python 3- a complete introduction to the Python language,"self.fh = gzip.open(self.filename, self.mode)",openfunc,463 Programming in Python 3- a complete introduction to the Python language,"care about Python 3.1 or later, we can simply write, with gzip.open(...)",openfunc,463 Programming in Python 3- a complete introduction to the Python language,since from Python 3.1 the gzip.open(),openfunc,463 Programming in Python 3- a complete introduction to the Python language,"dictionaries, so we don’t have to learn any new syntax beyond the shelve.open()",openfunc,473 Programming in Python 3- a complete introduction to the Python language,the built-in open() function as the fh (“file handle”),openfunc,537 Programming in Python 3- a complete introduction to the Python language,files; see file object and open(),openfunc,605 Programming in Python 3- a complete introduction to the Python language,see also file object and open(),openfunc,609 Programming in Python 3- a complete introduction to the Python language,to a file using the file object’s write(),write,128 Programming in Python 3- a complete introduction to the Python language,fh.write(line),write,139 Programming in Python 3- a complete introduction to the Python language,"fh.write(""{0:.<25}.{1}\n"".format(name, year))",write,140 Programming in Python 3- a complete introduction to the Python language,"a file object’s write() method, and the other is to use the print()",write,210 Programming in Python 3- a complete introduction to the Python language,"sys.stdout.write(""Another error message\n"")",write,210 Programming in Python 3- a complete introduction to the Python language,sys.stdout.write(),write,211 Programming in Python 3- a complete introduction to the Python language,text to a file using either the built-in print() function or a file object’s write(),write,227 Programming in Python 3- a complete introduction to the Python language,fh.write(MAGIC),write,295 Programming in Python 3- a complete introduction to the Python language,fh.write(FORMAT_VERSION),write,295 Programming in Python 3- a complete introduction to the Python language,fh.write(data),write,295 Programming in Python 3- a complete introduction to the Python language,"ing the XML, creating an element tree and using its write()",write,309 Programming in Python 3- a complete introduction to the Python language,ating a DOM and using its write(),write,309 Programming in Python 3- a complete introduction to the Python language,"fh.write('<?xml version=""1.0"" encoding=""UTF-8""?>\n')",write,316 Programming in Python 3- a complete introduction to the Python language,"fh.write(""<incidents>\n"")",write,316 Programming in Python 3- a complete introduction to the Python language,"fh.write(""</incidents>\n"")",write,317 Programming in Python 3- a complete introduction to the Python language,f.write(s),write,323 Programming in Python 3- a complete introduction to the Python language,self.__fh.write(_OKAY),write,324 Programming in Python 3- a complete introduction to the Python language,self.__fh.write(record),write,324 Programming in Python 3- a complete introduction to the Python language,self.__fh.write(_DELETED),write,326 Programming in Python 3- a complete introduction to the Python language,self.__fh.write(_OKAY),write,326 Programming in Python 3- a complete introduction to the Python language,fh.write(data),write,328 Programming in Python 3- a complete introduction to the Python language,data.write(info),write,416 Programming in Python 3- a complete introduction to the Python language,data.write(info),write,416 Programming in Python 3- a complete introduction to the Python language,self.wfile.write(SizeStruct.pack(len(data))),write,465 Programming in Python 3- a complete introduction to the Python language,self.wfile.write(data),write,465 Programming in Python 3- a complete introduction to the Python language,a single string using the file object’s read(),read,128 Programming in Python 3- a complete introduction to the Python language,"html = fh.read().decode(""utf8"")",read,223 Programming in Python 3- a complete introduction to the Python language,length_data = fh.read(uint16.size),read,299 Programming in Python 3- a complete introduction to the Python language,data = fh.read(length),read,299 Programming in Python 3- a complete introduction to the Python language,magic = fh.read(len(GZIP_MAGIC)),read,300 Programming in Python 3- a complete introduction to the Python language,magic = fh.read(len(MAGIC)),read,300 Programming in Python 3- a complete introduction to the Python language,version = fh.read(len(FORMAT_VERSION)),read,300 Programming in Python 3- a complete introduction to the Python language,for incident_match in incident_re.finditer(fh.read()),read,308 Programming in Python 3- a complete introduction to the Python language,f.read(count),read,322 Programming in Python 3- a complete introduction to the Python language,state = self.__fh.read(1),read,325 Programming in Python 3- a complete introduction to the Python language,return self.__fh.read(self.record_size),read,325 Programming in Python 3- a complete introduction to the Python language,state = self.__fh.read(1),read,326 Programming in Python 3- a complete introduction to the Python language,state = self.__fh.read(1),read,326 Programming in Python 3- a complete introduction to the Python language,state = self.__fh.read(1),read,327 Programming in Python 3- a complete introduction to the Python language,state = self.__fh.read(1),read,328 Programming in Python 3- a complete introduction to the Python language,stdin = sys.stdin.buffer.read(),read,439 Programming in Python 3- a complete introduction to the Python language,stdin = sys.stdin.read(),read,440 Programming in Python 3- a complete introduction to the Python language,calling threading.Thread(),read,446 Programming in Python 3- a complete introduction to the Python language,have created a function and we pass that to threading.Thread(),read,447 Programming in Python 3- a complete introduction to the Python language,This function is passed as an argument to threading.Thread(),read,448 Programming in Python 3- a complete introduction to the Python language,size_data = self.rfile.read(SizeStruct.size),read,465 Programming in Python 3- a complete introduction to the Python language,data = pickle.loads(self.rfile.read(size)),read,465 Programming in Python 3- a complete introduction to the Python language,lexer.input(file.read()),read,553 Programming in Python 3- a complete introduction to the Python language,lexer.input(fh.read()),read,555 Programming in Python 3- a complete introduction to the Python language,if fh.readline(),readline,518 Programming in Python 3- a complete introduction to the Python language,import sys,importfunc,37 Programming in Python 3- a complete introduction to the Python language,import a,importfunc,37 Programming in Python 3- a complete introduction to the Python language,import statement,importfunc,37 Programming in Python 3- a complete introduction to the Python language,import random,importfunc,37 Programming in Python 3- a complete introduction to the Python language,import statements,importfunc,37 Programming in Python 3- a complete introduction to the Python language,import random,importfunc,41 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,47 Programming in Python 3- a complete introduction to the Python language,"import in",importfunc,50 Programming in Python 3- a complete introduction to the Python language,"import 38",importfunc,51 Programming in Python 3- a complete introduction to the Python language,import math,importfunc,51 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,59 Programming in Python 3- a complete introduction to the Python language,import math,importfunc,60 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,61 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,61 Programming in Python 3- a complete introduction to the Python language,import decimal,importfunc,61 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,66 Programming in Python 3- a complete introduction to the Python language,import locale,importfunc,84 Programming in Python 3- a complete introduction to the Python language,import cmath,importfunc,93 Programming in Python 3- a complete introduction to the Python language,import math,importfunc,93 Programming in Python 3- a complete introduction to the Python language,import sys,importfunc,93 Programming in Python 3- a complete introduction to the Python language,import of,importfunc,96 Programming in Python 3- a complete introduction to the Python language,import sys,importfunc,97 Programming in Python 3- a complete introduction to the Python language,import string,importfunc,127 Programming in Python 3- a complete introduction to the Python language,import sys,importfunc,127 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,139 Programming in Python 3- a complete introduction to the Python language,import statement,importfunc,140 Programming in Python 3- a complete introduction to the Python language,import copy,importfunc,145 Programming in Python 3- a complete introduction to the Python language,import datetime,importfunc,183 Programming in Python 3- a complete introduction to the Python language,import functionality,importfunc,189 Programming in Python 3- a complete introduction to the Python language,import collections,importfunc,193 Programming in Python 3- a complete introduction to the Python language,import importable,importfunc,193 Programming in Python 3- a complete introduction to the Python language,import MyModuleA,importfunc,193 Programming in Python 3- a complete introduction to the Python language,import MyModuleB,importfunc,193 Programming in Python 3- a complete introduction to the Python language,import statements,importfunc,193 Programming in Python 3- a complete introduction to the Python language,"import statements",importfunc,193 Programming in Python 3- a complete introduction to the Python language,import syntax,importfunc,194 Programming in Python 3- a complete introduction to the Python language,import lots,importfunc,194 Programming in Python 3- a complete introduction to the Python language,import everything,importfunc,194 Programming in Python 3- a complete introduction to the Python language,import os,importfunc,194 Programming in Python 3- a complete introduction to the Python language,import importable,importfunc,194 Programming in Python 3- a complete introduction to the Python language,import of,importfunc,196 Programming in Python 3- a complete introduction to the Python language,import any,importfunc,197 Programming in Python 3- a complete introduction to the Python language,import and,importfunc,197 Programming in Python 3- a complete introduction to the Python language,import only,importfunc,198 Programming in Python 3- a complete introduction to the Python language,import using,importfunc,198 Programming in Python 3- a complete introduction to the Python language,import is,importfunc,199 Programming in Python 3- a complete introduction to the Python language,import name,importfunc,199 Programming in Python 3- a complete introduction to the Python language,import other,importfunc,199 Programming in Python 3- a complete introduction to the Python language,import Png,importfunc,199 Programming in Python 3- a complete introduction to the Python language,import string,importfunc,200 Programming in Python 3- a complete introduction to the Python language,"import the",importfunc,200 Programming in Python 3- a complete introduction to the Python language,import TextUtil,importfunc,202 Programming in Python 3- a complete introduction to the Python language,import TextUtil,importfunc,202 Programming in Python 3- a complete introduction to the Python language,import doctest,importfunc,203 Programming in Python 3- a complete introduction to the Python language,import doctest,importfunc,209 Programming in Python 3- a complete introduction to the Python language,import optparse,importfunc,212 Programming in Python 3- a complete introduction to the Python language,import heapq,importfunc,216 Programming in Python 3- a complete introduction to the Python language,import importable,importfunc,227 Programming in Python 3- a complete introduction to the Python language,"import the",importfunc,229 Programming in Python 3- a complete introduction to the Python language,import collections,importfunc,231 Programming in Python 3- a complete introduction to the Python language,import Shape,importfunc,236 Programming in Python 3- a complete introduction to the Python language,"import 195",importfunc,240 Programming in Python 3- a complete introduction to the Python language,"import FuzzyBoolAlt",importfunc,253 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,272 Programming in Python 3- a complete introduction to the Python language,"import and",importfunc,309 Programming in Python 3- a complete introduction to the Python language,import and,importfunc,333 Programming in Python 3- a complete introduction to the Python language,import math,importfunc,342 Programming in Python 3- a complete introduction to the Python language,"import modules",importfunc,407 Programming in Python 3- a complete introduction to the Python language,import pdb,importfunc,420 Programming in Python 3- a complete introduction to the Python language,import pdb,importfunc,420 Programming in Python 3- a complete introduction to the Python language,"import and",importfunc,421 Programming in Python 3- a complete introduction to the Python language,import doctest,importfunc,424 Programming in Python 3- a complete introduction to the Python language,import the,importfunc,424 Programming in Python 3- a complete introduction to the Python language,import doctest,importfunc,424 Programming in Python 3- a complete introduction to the Python language,import unittest,importfunc,424 Programming in Python 3- a complete introduction to the Python language,import both,importfunc,426 Programming in Python 3- a complete introduction to the Python language,import unittest,importfunc,427 Programming in Python 3- a complete introduction to the Python language,import test_Atomic,importfunc,427 Programming in Python 3- a complete introduction to the Python language,import multiprocessing,importfunc,445 Programming in Python 3- a complete introduction to the Python language,"import and",importfunc,472 Programming in Python 3- a complete introduction to the Python language,import each,importfunc,532 Programming in Python 3- a complete introduction to the Python language,import and,importfunc,544 Programming in Python 3- a complete introduction to the Python language,import brings,importfunc,544 Programming in Python 3- a complete introduction to the Python language,import we,importfunc,580 Programming in Python 3- a complete introduction to the Python language,import and,importfunc,589 Programming in Python 3- a complete introduction to the Python language,import statement,importfunc,606 Programming in Python 3- a complete introduction to the Python language,import order,importfunc,608 Programming in Python 3- a complete introduction to the Python language,"from now on. import sys",importfromsimple,38 Programming in Python 3- a complete introduction to the Python language,from os import path,importfromsimple,194 Programming in Python 3- a complete introduction to the Python language,from os.path import basename,importfromsimple,194 Programming in Python 3- a complete introduction to the Python language,from Graphics import Png,importfromsimple,197 Programming in Python 3- a complete introduction to the Python language,from module import syntax,importfromsimple,199 Programming in Python 3- a complete introduction to the Python language,"from names to objects. Modules are namespaces—for example, after the statement import math",importfromsimple,233 Programming in Python 3- a complete introduction to the Python language,from one program and import it,importfromsimple,472 Programming in Python 3- a complete introduction to the Python language,self.x = x,simpleattr,236 Programming in Python 3- a complete introduction to the Python language,self.y = y,simpleattr,236 Programming in Python 3- a complete introduction to the Python language,self.x = x,simpleattr,238 Programming in Python 3- a complete introduction to the Python language,self.y = y,simpleattr,238 Programming in Python 3- a complete introduction to the Python language,self.radius = radius,simpleattr,240 Programming in Python 3- a complete introduction to the Python language,self.__radius = radius,simpleattr,244 Programming in Python 3- a complete introduction to the Python language,self.__value = value if 0.0 <= value <= 1.0 else 0.0,simpleattr,246 Programming in Python 3- a complete introduction to the Python language,"self.__value = min(self.__value, other.__value)",simpleattr,248 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__background = background,simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__data = {},simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__width = width,simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__height = height,simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__colors = {self.__background},simpleattr,260 Programming in Python 3- a complete introduction to the Python language,self.__data[tuple(coordinate)] = color,simpleattr,262 Programming in Python 3- a complete introduction to the Python language,self.__colors = (set(self.__data.values()) |,simpleattr,263 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,265 Programming in Python 3- a complete introduction to the Python language,self.__key = key or _identity,simpleattr,267 Programming in Python 3- a complete introduction to the Python language,self.__list = sequence.__list[:],simpleattr,267 Programming in Python 3- a complete introduction to the Python language,"self.__list = sorted(list(sequence), key=self.__key)",simpleattr,267 Programming in Python 3- a complete introduction to the Python language,self.__list[index] == value):,simpleattr,269 Programming in Python 3- a complete introduction to the Python language,self.__list[index] == value):,simpleattr,270 Programming in Python 3- a complete introduction to the Python language,self.__list[index] == value),simpleattr,271 Programming in Python 3- a complete introduction to the Python language,self.__list = [],simpleattr,271 Programming in Python 3- a complete introduction to the Python language,"self.__keys = SortedList.SortedList(super().keys(), key)",simpleattr,273 Programming in Python 3- a complete introduction to the Python language,"self.__keys = SortedList.SortedList(super().keys(),",simpleattr,274 Programming in Python 3- a complete introduction to the Python language,self.__report_id = report_id,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.date = date,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.airport = airport,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.aircraft_id = aircraft_id,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.aircraft_type = aircraft_type,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.pilot_percent_hours_on_type = pilot_percent_hours_on_type,simpleattr,287 Programming in Python 3- a complete introduction to the Python language,self.pilot_total_hours = pilot_total_hours,simpleattr,288 Programming in Python 3- a complete introduction to the Python language,self.midair = midair,simpleattr,288 Programming in Python 3- a complete introduction to the Python language,self.narrative = narrative,simpleattr,288 Programming in Python 3- a complete introduction to the Python language,self.__date = date,simpleattr,288 Programming in Python 3- a complete introduction to the Python language,self.__data = {},simpleattr,319 Programming in Python 3- a complete introduction to the Python language,"self.__text = """"",simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__incidents = incidents,simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__data = {},simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__data[key] = datetime.datetime.strptime(,simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__data[key] = float(value),simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__data[key] = bool(int(value)),simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__data[key] = value,simpleattr,319 Programming in Python 3- a complete introduction to the Python language,"self.__text = """"",simpleattr,319 Programming in Python 3- a complete introduction to the Python language,self.__incidents[incident.report_id] = incident,simpleattr,320 Programming in Python 3- a complete introduction to the Python language,self.__data[name] = self.__text.strip(),simpleattr,320 Programming in Python 3- a complete introduction to the Python language,"self.__text = """"",simpleattr,320 Programming in Python 3- a complete introduction to the Python language,self.__text += text,simpleattr,320 Programming in Python 3- a complete introduction to the Python language,self.__record_size = record_size + 1,simpleattr,323 Programming in Python 3- a complete introduction to the Python language,self.auto_flush = auto_flush,simpleattr,324 Programming in Python 3- a complete introduction to the Python language,self.__identity = identity,simpleattr,330 Programming in Python 3- a complete introduction to the Python language,self.name = name,simpleattr,330 Programming in Python 3- a complete introduction to the Python language,self.quantity = quantity,simpleattr,330 Programming in Python 3- a complete introduction to the Python language,self.price = price,simpleattr,330 Programming in Python 3- a complete introduction to the Python language,"self.__file = BinaryRecordFile.BinaryRecordFile(filename,",simpleattr,330 Programming in Python 3- a complete introduction to the Python language,self.__index_from_identity = {},simpleattr,330 Programming in Python 3- a complete introduction to the Python language,self.__index_from_identity[bike.identity] = index,simpleattr,331 Programming in Python 3- a complete introduction to the Python language,self.__file[index] = _record_from_bike(bike),simpleattr,331 Programming in Python 3- a complete introduction to the Python language,self.__index_from_identity[bike.identity] = index,simpleattr,331 Programming in Python 3- a complete introduction to the Python language,self.__file[index] = _record_from_bike(bike),simpleattr,331 Programming in Python 3- a complete introduction to the Python language,self.x = x,simpleattr,360 Programming in Python 3- a complete introduction to the Python language,self.y = y,simpleattr,360 Programming in Python 3- a complete introduction to the Python language,self.attribute_names = attribute_names,simpleattr,365 Programming in Python 3- a complete introduction to the Python language,self.forename = forename,simpleattr,365 Programming in Python 3- a complete introduction to the Python language,self.surname = surname,simpleattr,365 Programming in Python 3- a complete introduction to the Python language,self.email = email,simpleattr,365 Programming in Python 3- a complete introduction to the Python language,self.original = alist,simpleattr,369 Programming in Python 3- a complete introduction to the Python language,self.shallow_copy = shallow_copy,simpleattr,369 Programming in Python 3- a complete introduction to the Python language,self.modified = (self.original[:] if self.shallow_copy,simpleattr,369 Programming in Python 3- a complete introduction to the Python language,self.original[:] = self.modified,simpleattr,369 Programming in Python 3- a complete introduction to the Python language,self.__name = name,simpleattr,370 Programming in Python 3- a complete introduction to the Python language,self.description = description,simpleattr,370 Programming in Python 3- a complete introduction to the Python language,self.price = price,simpleattr,370 Programming in Python 3- a complete introduction to the Python language,self.attribute_name = attribute_name,simpleattr,371 Programming in Python 3- a complete introduction to the Python language,self.attribute_name = attribute_name,simpleattr,371 Programming in Python 3- a complete introduction to the Python language,self.cache = {},simpleattr,371 Programming in Python 3- a complete introduction to the Python language,self.x = x,simpleattr,372 Programming in Python 3- a complete introduction to the Python language,self.y = y,simpleattr,372 Programming in Python 3- a complete introduction to the Python language,self.attribute_name = attribute_name,simpleattr,372 Programming in Python 3- a complete introduction to the Python language,"self.__storage[id(instance), self.attribute_name] = value",simpleattr,372 Programming in Python 3- a complete introduction to the Python language,self.__name = name,simpleattr,373 Programming in Python 3- a complete introduction to the Python language,self.extension = extension,simpleattr,373 Programming in Python 3- a complete introduction to the Python language,self.__extension = extension,simpleattr,373 Programming in Python 3- a complete introduction to the Python language,self.__getter = getter,simpleattr,373 Programming in Python 3- a complete introduction to the Python language,self.__setter = setter,simpleattr,374 Programming in Python 3- a complete introduction to the Python language,self.__name__ = getter.__name__,simpleattr,374 Programming in Python 3- a complete introduction to the Python language,self.__setter = setter,simpleattr,374 Programming in Python 3- a complete introduction to the Python language,self.__list = [],simpleattr,375 Programming in Python 3- a complete introduction to the Python language,self.__model = model,simpleattr,381 Programming in Python 3- a complete introduction to the Python language,self.price = price,simpleattr,381 Programming in Python 3- a complete introduction to the Python language,self.__price = price,simpleattr,381 Programming in Python 3- a complete introduction to the Python language,self.fuel = fuel,simpleattr,382 Programming in Python 3- a complete introduction to the Python language,self.__undos = [],simpleattr,383 Programming in Python 3- a complete introduction to the Python language,self.__stack = [],simpleattr,384 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,385 Programming in Python 3- a complete introduction to the Python language,self.__attribute_names = [],simpleattr,385 Programming in Python 3- a complete introduction to the Python language,self.__stack = [],simpleattr,386 Programming in Python 3- a complete introduction to the Python language,self.__undos = [],simpleattr,387 Programming in Python 3- a complete introduction to the Python language,self.name = name,simpleattr,405 Programming in Python 3- a complete introduction to the Python language,self.productid = productid,simpleattr,405 Programming in Python 3- a complete introduction to the Python language,self.category = category,simpleattr,405 Programming in Python 3- a complete introduction to the Python language,self.price = price,simpleattr,405 Programming in Python 3- a complete introduction to the Python language,self.quantity = quantity,simpleattr,405 Programming in Python 3- a complete introduction to the Python language,self.getter = getter,simpleattr,406 Programming in Python 3- a complete introduction to the Python language,self.setter = setter,simpleattr,406 Programming in Python 3- a complete introduction to the Python language,self.original_list = list(range(10)),simpleattr,427 Programming in Python 3- a complete introduction to the Python language,self.work_queue = work_queue,simpleattr,445 Programming in Python 3- a complete introduction to the Python language,self.word = word,simpleattr,445 Programming in Python 3- a complete introduction to the Python language,self.number = number,simpleattr,445 Programming in Python 3- a complete introduction to the Python language,self.work_queue = work_queue,simpleattr,448 Programming in Python 3- a complete introduction to the Python language,self.md5_from_filename = md5_from_filename,simpleattr,448 Programming in Python 3- a complete introduction to the Python language,self.results_queue = results_queue,simpleattr,448 Programming in Python 3- a complete introduction to the Python language,self.number = number,simpleattr,448 Programming in Python 3- a complete introduction to the Python language,self.address = address,simpleattr,460 Programming in Python 3- a complete introduction to the Python language,"self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)",simpleattr,460 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,463 Programming in Python 3- a complete introduction to the Python language,self.mode = mode,simpleattr,463 Programming in Python 3- a complete introduction to the Python language,"self.Cars[license] = Car(seats, mileage, owner)",simpleattr,467 Programming in Python 3- a complete introduction to the Python language,self.name = name,simpleattr,524 Programming in Python 3- a complete introduction to the Python language,self.color = color,simpleattr,524 Programming in Python 3- a complete introduction to the Python language,self.children = [],simpleattr,524 Programming in Python 3- a complete introduction to the Python language,self.text = text,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.pos = 0,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.line = 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.column = 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.brackets = 0,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.stack = [Block.get_root_block()],simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.pos += 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,"self.text[self.pos] == ""\n""):",simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.line += 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.column = 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.column += 1,simpleattr,525 Programming in Python 3- a complete introduction to the Python language,self.parent = parent,simpleattr,569 Programming in Python 3- a complete introduction to the Python language,"self.grid(row=0, column=0)",simpleattr,569 Programming in Python 3- a complete introduction to the Python language,self.principal = tkinter.DoubleVar(),simpleattr,569 Programming in Python 3- a complete introduction to the Python language,self.rate = tkinter.DoubleVar(),simpleattr,570 Programming in Python 3- a complete introduction to the Python language,self.years = tkinter.IntVar(),simpleattr,570 Programming in Python 3- a complete introduction to the Python language,self.amount = tkinter.StringVar(),simpleattr,570 Programming in Python 3- a complete introduction to the Python language,self.parent = parent,simpleattr,575 Programming in Python 3- a complete introduction to the Python language,self.filename = None,simpleattr,575 Programming in Python 3- a complete introduction to the Python language,self.dirty = False,simpleattr,575 Programming in Python 3- a complete introduction to the Python language,self.data = {},simpleattr,575 Programming in Python 3- a complete introduction to the Python language,"self.parent[""menu""] = menubar",simpleattr,575 Programming in Python 3- a complete introduction to the Python language,self.toolbar_images = [],simpleattr,576 Programming in Python 3- a complete introduction to the Python language,"self.listBox = tkinter.Listbox(frame,",simpleattr,578 Programming in Python 3- a complete introduction to the Python language,"self.listBox.grid(row=1, column=0, sticky=tkinter.NSEW)",simpleattr,578 Programming in Python 3- a complete introduction to the Python language,"self.statusbar = tkinter.Label(frame, text=""Ready..."",",simpleattr,578 Programming in Python 3- a complete introduction to the Python language,"self.statusbar.grid(row=2, column=0, columnspan=2,",simpleattr,578 Programming in Python 3- a complete introduction to the Python language,"self.statusbar[""text""] = """"",simpleattr,579 Programming in Python 3- a complete introduction to the Python language,self.dirty = False,simpleattr,579 Programming in Python 3- a complete introduction to the Python language,self.filename = None,simpleattr,579 Programming in Python 3- a complete introduction to the Python language,self.data = {},simpleattr,579 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,581 Programming in Python 3- a complete introduction to the Python language,"self.filename += "".bmf""",simpleattr,581 Programming in Python 3- a complete introduction to the Python language,self.dirty = False,simpleattr,581 Programming in Python 3- a complete introduction to the Python language,"self.filename, err), parent=self.parent)",simpleattr,581 Programming in Python 3- a complete introduction to the Python language,"self.statusbar[""text""] = text",simpleattr,581 Programming in Python 3- a complete introduction to the Python language,self.filename = filename,simpleattr,582 Programming in Python 3- a complete introduction to the Python language,self.dirty = False,simpleattr,582 Programming in Python 3- a complete introduction to the Python language,self.data = pickle.load(fh),simpleattr,582 Programming in Python 3- a complete introduction to the Python language,"self.filename, err), parent=self.parent)",simpleattr,583 Programming in Python 3- a complete introduction to the Python language,self.data[form.name] = form.url,simpleattr,583 Programming in Python 3- a complete introduction to the Python language,self.dirty = True,simpleattr,583 Programming in Python 3- a complete introduction to the Python language,self.data[form.name] = form.url,simpleattr,584 Programming in Python 3- a complete introduction to the Python language,self.dirty = True,simpleattr,584 Programming in Python 3- a complete introduction to the Python language,self.dirty = True,simpleattr,585 Programming in Python 3- a complete introduction to the Python language,self.parent = parent,simpleattr,586 Programming in Python 3- a complete introduction to the Python language,self.accepted = False,simpleattr,586 Programming in Python 3- a complete introduction to the Python language,self.nameVar = tkinter.StringVar(),simpleattr,586 Programming in Python 3- a complete introduction to the Python language,self.urlVar = tkinter.StringVar(),simpleattr,586 Programming in Python 3- a complete introduction to the Python language,self.name = self.nameVar.get(),simpleattr,588 Programming in Python 3- a complete introduction to the Python language,self.url = self.urlVar.get(),simpleattr,588 Programming in Python 3- a complete introduction to the Python language,self.accepted = True,simpleattr,588 Programming in Python 3- a complete introduction to the Python language,"augmented assignment operators such as += and *=. The +, -, and * operators",assignIncrement,29 Programming in Python 3- a complete introduction to the Python language,a += 8,assignIncrement,30 Programming in Python 3- a complete introduction to the Python language,"shorthand for assigning the results of an operation—for example, a += 8 is es-",assignIncrement,30 Programming in Python 3- a complete introduction to the Python language,"case when the statement a += 8 is encountered, Python computes a + 8, stores",assignIncrement,30 Programming in Python 3- a complete introduction to the Python language,The right-hand operand for the list += operator must be an iterable;,assignIncrement,32 Programming in Python 3- a complete introduction to the Python language,seeds += 5,assignIncrement,32 Programming in Python 3- a complete introduction to the Python language,The list += operator extends the list by appending each item of the iterable it,assignIncrement,32 Programming in Python 3- a complete introduction to the Python language,line += s,assignIncrement,43 Programming in Python 3- a complete introduction to the Python language,column += 1,assignIncrement,43 Programming in Python 3- a complete introduction to the Python language,row += 1,assignIncrement,43 Programming in Python 3- a complete introduction to the Python language,"use += with the item made into a single-item list—for example, even += [12].",assignIncrement,44 Programming in Python 3- a complete introduction to the Python language,ment operators such as += and *=; these create new objects and rebind behind,assignIncrement,45 Programming in Python 3- a complete introduction to the Python language,"expression i += True. Naturally, the correct way to do this is i += 1.",assignIncrement,52 Programming in Python 3- a complete introduction to the Python language,code += 1,assignIncrement,88 Programming in Python 3- a complete introduction to the Python language,count += 1,assignIncrement,98 Programming in Python 3- a complete introduction to the Python language,field += c,assignIncrement,99 Programming in Python 3- a complete introduction to the Python language,field += c,assignIncrement,99 Programming in Python 3- a complete introduction to the Python language,can also use the augmented assignment versions of these operators (+= and,assignIncrement,101 Programming in Python 3- a complete introduction to the Python language,"cation), and [] (slice), and with in and not in to test for membership. The += and *= augmented assignment operators can be used even though tuples are",assignIncrement,105 Programming in Python 3- a complete introduction to the Python language,total += sale.quantity * sale.price,assignIncrement,109 Programming in Python 3- a complete introduction to the Python language,L += m,assignIncrement,112 Programming in Python 3- a complete introduction to the Python language,operator += does the same thing,assignIncrement,112 Programming in Python 3- a complete introduction to the Python language,numbers[i] += 1,assignIncrement,113 Programming in Python 3- a complete introduction to the Python language,d[key] += 1,assignIncrement,125 Programming in Python 3- a complete introduction to the Python language,We cannot use the syntax words[word] += 1 because this will raise a KeyError,assignIncrement,127 Programming in Python 3- a complete introduction to the Python language,words[word] += 1,assignIncrement,129 Programming in Python 3- a complete introduction to the Python language,words[word] += 1,assignIncrement,133 Programming in Python 3- a complete introduction to the Python language,i += 1,assignIncrement,138 Programming in Python 3- a complete introduction to the Python language,x += t,assignIncrement,141 Programming in Python 3- a complete introduction to the Python language,"2, 3), and so on. The += operator extends a list, that is, it appends each item in",assignIncrement,141 Programming in Python 3- a complete introduction to the Python language,count += 1,assignIncrement,148 Programming in Python 3- a complete introduction to the Python language,count += 1,assignIncrement,171 Programming in Python 3- a complete introduction to the Python language,result += arg ** power,assignIncrement,175 Programming in Python 3- a complete introduction to the Python language,word += char,assignIncrement,201 Programming in Python 3- a complete introduction to the Python language,counts[c] += 1,assignIncrement,201 Programming in Python 3- a complete introduction to the Python language,ascii_text += chr(c),assignIncrement,217 Programming in Python 3- a complete introduction to the Python language,"example, using += looks like the left-hand operand is being changed but in fact",assignIncrement,248 Programming in Python 3- a complete introduction to the Python language,x += y,assignIncrement,250 Programming in Python 3- a complete introduction to the Python language,count += 1,assignIncrement,270 Programming in Python 3- a complete introduction to the Python language,index += 1,assignIncrement,270 Programming in Python 3- a complete introduction to the Python language,count += 1,assignIncrement,270 Programming in Python 3- a complete introduction to the Python language,p += q,assignIncrement,282 Programming in Python 3- a complete introduction to the Python language,"narrative += line + ""\n""",assignIncrement,304 Programming in Python 3- a complete introduction to the Python language,index += 1,assignIncrement,327 Programming in Python 3- a complete introduction to the Python language,value += bike.value,assignIncrement,329 Programming in Python 3- a complete introduction to the Python language,bike.quantity += amount,assignIncrement,331 Programming in Python 3- a complete introduction to the Python language,next_quarter += 0.25,assignIncrement,340 Programming in Python 3- a complete introduction to the Python language,i += len(indent),assignIncrement,350 Programming in Python 3- a complete introduction to the Python language,level += 1,assignIncrement,350 Programming in Python 3- a complete introduction to the Python language,add_entry() we had to use nonlocal for level because the += operator applied to,assignIncrement,353 Programming in Python 3- a complete introduction to the Python language,total += value,assignIncrement,394 Programming in Python 3- a complete introduction to the Python language,t.lexer.lineno += len(t.value),assignIncrement,552 Programming in Python 3- a complete introduction to the Python language,brackets += 1,assignIncrement,556 Programming in Python 3- a complete introduction to the Python language,"def letter_count(text, letters=string.ascii_letters):",funcdefault,171 Programming in Python 3- a complete introduction to the Python language,"def shorten(text, length=25, indicator=""...""):",funcdefault,171 Programming in Python 3- a complete introduction to the Python language,"def find(l, s, i=0):",funcdefault,173 Programming in Python 3- a complete introduction to the Python language,"def linear_search(l, s, i=0):",funcdefault,173 Programming in Python 3- a complete introduction to the Python language,"def first_index_of(sorted_name_list, name, start=0):",funcdefault,173 Programming in Python 3- a complete introduction to the Python language,"def shorten(text, length=25, indicator=""...""):",funcdefault,174 Programming in Python 3- a complete introduction to the Python language,"def simplify(text, whitespace=string.whitespace, delete=""""):",funcdefault,200 Programming in Python 3- a complete introduction to the Python language,"def is_balanced(text, brackets=""()[]{}<>""):",funcdefault,201 Programming in Python 3- a complete introduction to the Python language,"def resize(max_rows, max_columns, char=None):",funcdefault,207 Programming in Python 3- a complete introduction to the Python language,"def add_horizontal_line(row, column0, column1, char=""-""):",funcdefault,208 Programming in Python 3- a complete introduction to the Python language,"def error(message, exit_status=1):",funcdefault,219 Programming in Python 3- a complete introduction to the Python language,"def load(self, filename=None):",funcdefault,265 Programming in Python 3- a complete introduction to the Python language,"def pop(self, index=-1):",funcdefault,271 Programming in Python 3- a complete introduction to the Python language,"def setdefault(self, key, value=None):",funcdefault,276 Programming in Python 3- a complete introduction to the Python language,"def export_binary(self, filename, compress=False):",funcdefault,293 Programming in Python 3- a complete introduction to the Python language,"def unpack_string(fh, eof_is_error=True):",funcdefault,299 Programming in Python 3- a complete introduction to the Python language,"def compact(self, keep_backup=False):",funcdefault,328 Programming in Python 3- a complete introduction to the Python language,def quarters(next_quarter=0.0):,funcdefault,339 Programming in Python 3- a complete introduction to the Python language,def quarters(next_quarter=0.0):,funcdefault,339 Programming in Python 3- a complete introduction to the Python language,"def pop(self, index=-1):",funcdefault,375 Programming in Python 3- a complete introduction to the Python language,"def quit(self, event=None):",funcdefault,573 Programming in Python 3- a complete introduction to the Python language,"def setStatusBar(self, text, timeout=5000):",funcdefault,581 Programming in Python 3- a complete introduction to the Python language,"def fileQuit(self, event=None):",funcdefault,583 Programming in Python 3- a complete introduction to the Python language,"def ok(self, event=None):",funcdefault,588 Programming in Python 3- a complete introduction to the Python language,"def close(self, event=None):",funcdefault,588 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,40 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,40 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,112 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,112 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,112 Programming in Python 3- a complete introduction to the Python language,range(n)),rangefunc,115 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,115 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,116 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,116 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,138 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,138 Programming in Python 3- a complete introduction to the Python language,"range(5)), list(range(9, 14)), tuple(range(10, -11, -5))",rangefunc,138 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,138 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,138 Programming in Python 3- a complete introduction to the Python language,"range(1, 5))",rangefunc,139 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,139 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,140 Programming in Python 3- a complete introduction to the Python language,range(6)),rangefunc,141 Programming in Python 3- a complete introduction to the Python language,range(6))),rangefunc,141 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,154 Programming in Python 3- a complete introduction to the Python language,"range(a, z)",rangefunc,276 Programming in Python 3- a complete introduction to the Python language,"range(a, z)",rangefunc,276 Programming in Python 3- a complete introduction to the Python language,"range(""m"", ""v"")",rangefunc,276 Programming in Python 3- a complete introduction to the Python language,"range(""m"", ""v""))",rangefunc,276 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,359 Programming in Python 3- a complete introduction to the Python language,range(),rangefunc,597 Programming in Python 3- a complete introduction to the Python language,range() (built-in),rangefunc,616 Programming in Python 3- a complete introduction to the Python language,def functionName(arguments):,simplefunc,36 Programming in Python 3- a complete introduction to the Python language,def get_int(msg):,simplefunc,36 Programming in Python 3- a complete introduction to the Python language,def print_unicode_table(word):,simplefunc,88 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def print_start():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def print_line():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def extract_fields():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def escape_html():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def print_end():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,97 Programming in Python 3- a complete introduction to the Python language,def print_start():,simplefunc,98 Programming in Python 3- a complete introduction to the Python language,def print_end():,simplefunc,98 Programming in Python 3- a complete introduction to the Python language,def extract_fields(line):,simplefunc,99 Programming in Python 3- a complete introduction to the Python language,def escape_html(text):,simplefunc,100 Programming in Python 3- a complete introduction to the Python language,def f(x):,simplefunc,106 Programming in Python 3- a complete introduction to the Python language,def get_forenames_and_surnames():,simplefunc,139 Programming in Python 3- a complete introduction to the Python language,def swap(t):,simplefunc,143 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,147 Programming in Python 3- a complete introduction to the Python language,def print_users(users):,simplefunc,148 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,150 Programming in Python 3- a complete introduction to the Python language,def calculate_median(numbers):,simplefunc,152 Programming in Python 3- a complete introduction to the Python language,def functionName(parameters):,simplefunc,170 Programming in Python 3- a complete introduction to the Python language,def print_digits(digits):,simplefunc,177 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,184 Programming in Python 3- a complete introduction to the Python language,def populate_information(information):,simplefunc,184 Programming in Python 3- a complete introduction to the Python language,def clear_screen():,simplefunc,206 Programming in Python 3- a complete introduction to the Python language,def clear_screen():,simplefunc,206 Programming in Python 3- a complete introduction to the Python language,def clear_screen():,simplefunc,206 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,212 Programming in Python 3- a complete introduction to the Python language,def untar(archive):,simplefunc,219 Programming in Python 3- a complete introduction to the Python language,def distance_from_origin(self):,simplefunc,236 Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,236 Programming in Python 3- a complete introduction to the Python language,def __str__(self):,simplefunc,236 Programming in Python 3- a complete introduction to the Python language,def distance_from_origin(self):,simplefunc,238 Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,239 Programming in Python 3- a complete introduction to the Python language,def __str__(self):,simplefunc,240 Programming in Python 3- a complete introduction to the Python language,def edge_distance_from_origin(self):,simplefunc,240 Programming in Python 3- a complete introduction to the Python language,def area(self):,simplefunc,243 Programming in Python 3- a complete introduction to the Python language,def __invert__(self):,simplefunc,246 Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,248 Programming in Python 3- a complete introduction to the Python language,def __str__(self):,simplefunc,249 Programming in Python 3- a complete introduction to the Python language,def __bool__(self):,simplefunc,249 Programming in Python 3- a complete introduction to the Python language,def __int__(self):,simplefunc,249 Programming in Python 3- a complete introduction to the Python language,def __float__(self):,simplefunc,249 Programming in Python 3- a complete introduction to the Python language,def __hash__(self):,simplefunc,249 Programming in Python 3- a complete introduction to the Python language,def __invert__(self):,simplefunc,254 Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,255 Programming in Python 3- a complete introduction to the Python language,def __bool__(self):,simplefunc,255 Programming in Python 3- a complete introduction to the Python language,def __int__(self):,simplefunc,255 Programming in Python 3- a complete introduction to the Python language,def __neg__(self):,simplefunc,256 Programming in Python 3- a complete introduction to the Python language,def __neg__(self):,simplefunc,257 Programming in Python 3- a complete introduction to the Python language,def __iter__(self):,simplefunc,271 Programming in Python 3- a complete introduction to the Python language,def __reversed__(self):,simplefunc,271 Programming in Python 3- a complete introduction to the Python language,def clear(self):,simplefunc,271 Programming in Python 3- a complete introduction to the Python language,def __len__(self):,simplefunc,271 Programming in Python 3- a complete introduction to the Python language,def __str__(self):,simplefunc,271 Programming in Python 3- a complete introduction to the Python language,def copy(self):,simplefunc,272 Programming in Python 3- a complete introduction to the Python language,def popitem(self):,simplefunc,277 Programming in Python 3- a complete introduction to the Python language,def clear(self):,simplefunc,277 Programming in Python 3- a complete introduction to the Python language,def values(self):,simplefunc,277 Programming in Python 3- a complete introduction to the Python language,def items(self):,simplefunc,277 Programming in Python 3- a complete introduction to the Python language,def __iter__(self):,simplefunc,277 Programming in Python 3- a complete introduction to the Python language,def __repr__(self):,simplefunc,278 Programming in Python 3- a complete introduction to the Python language,def __str__(self):,simplefunc,278 Programming in Python 3- a complete introduction to the Python language,def copy(self):,simplefunc,279 Programming in Python 3- a complete introduction to the Python language,def values(self):,simplefunc,288 Programming in Python 3- a complete introduction to the Python language,def items(self):,simplefunc,288 Programming in Python 3- a complete introduction to the Python language,def __iter__(self):,simplefunc,288 Programming in Python 3- a complete introduction to the Python language,def pack_string(string):,simplefunc,293 Programming in Python 3- a complete introduction to the Python language,def get_text(node_list):,simplefunc,315 Programming in Python 3- a complete introduction to the Python language,def flush(self):,simplefunc,324 Programming in Python 3- a complete introduction to the Python language,def close(self):,simplefunc,324 Programming in Python 3- a complete introduction to the Python language,def __len__(self):,simplefunc,326 Programming in Python 3- a complete introduction to the Python language,def inplace_compact(self):,simplefunc,327 Programming in Python 3- a complete introduction to the Python language,def __iter__(self):,simplefunc,332 Programming in Python 3- a complete introduction to the Python language,def _bike_from_record(record):,simplefunc,332 Programming in Python 3- a complete introduction to the Python language,def _record_from_bike(bike):,simplefunc,333 Programming in Python 3- a complete introduction to the Python language,def items_in_key_order(d):,simplefunc,339 Programming in Python 3- a complete introduction to the Python language,def get_files(names):,simplefunc,340 Programming in Python 3- a complete introduction to the Python language,def area_of_sphere(r):,simplefunc,342 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,343 Programming in Python 3- a complete introduction to the Python language,def load_modules():,simplefunc,344 Programming in Python 3- a complete introduction to the Python language,def factorial(x):,simplefunc,349 Programming in Python 3- a complete introduction to the Python language,def update_indented_list(entry):,simplefunc,350 Programming in Python 3- a complete introduction to the Python language,def update_indented_list(entry):,simplefunc,353 Programming in Python 3- a complete introduction to the Python language,def positive_result(function):,simplefunc,354 Programming in Python 3- a complete introduction to the Python language,def positive_result(function):,simplefunc,354 Programming in Python 3- a complete introduction to the Python language,def decorator(function):,simplefunc,355 Programming in Python 3- a complete introduction to the Python language,def logged(function):,simplefunc,356 Programming in Python 3- a complete introduction to the Python language,def logged(function):,simplefunc,356 Programming in Python 3- a complete introduction to the Python language,def strictly_typed(function):,simplefunc,358 Programming in Python 3- a complete introduction to the Python language,def make_strip_function(characters):,simplefunc,365 Programming in Python 3- a complete introduction to the Python language,def strip_function(string):,simplefunc,365 Programming in Python 3- a complete introduction to the Python language,def __enter__(self):,simplefunc,369 Programming in Python 3- a complete introduction to the Python language,def clear(self):,simplefunc,375 Programming in Python 3- a complete introduction to the Python language,def decorator(cls):,simplefunc,375 Programming in Python 3- a complete introduction to the Python language,def complete_comparisons(cls):,simplefunc,377 Programming in Python 3- a complete introduction to the Python language,def get_price(self):,simplefunc,381 Programming in Python 3- a complete introduction to the Python language,def undo(self):,simplefunc,384 Programming in Python 3- a complete introduction to the Python language,def pop(self):,simplefunc,384 Programming in Python 3- a complete introduction to the Python language,def save(self):,simplefunc,386 Programming in Python 3- a complete introduction to the Python language,def load(self):,simplefunc,386 Programming in Python 3- a complete introduction to the Python language,def load(self):,simplefunc,386 Programming in Python 3- a complete introduction to the Python language,def clear(self):,simplefunc,387 Programming in Python 3- a complete introduction to the Python language,def decorator(cls):,simplefunc,405 Programming in Python 3- a complete introduction to the Python language,def getter(self):,simplefunc,405 Programming in Python 3- a complete introduction to the Python language,def process(data):,simplefunc,416 Programming in Python 3- a complete introduction to the Python language,def setUp(self):,simplefunc,427 Programming in Python 3- a complete introduction to the Python language,def test_list_succeed(self):,simplefunc,427 Programming in Python 3- a complete introduction to the Python language,def test_list_fail(self):,simplefunc,428 Programming in Python 3- a complete introduction to the Python language,def process():,simplefunc,428 Programming in Python 3- a complete introduction to the Python language,def test_list_fail(self):,simplefunc,428 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,437 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,443 Programming in Python 3- a complete introduction to the Python language,def run(self):,simplefunc,445 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,446 Programming in Python 3- a complete introduction to the Python language,def print_results(results_queue):,simplefunc,448 Programming in Python 3- a complete introduction to the Python language,def run(self):,simplefunc,448 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,456 Programming in Python 3- a complete introduction to the Python language,def get_car_details(previous_license):,simplefunc,457 Programming in Python 3- a complete introduction to the Python language,def retrieve_car_details(previous_license):,simplefunc,457 Programming in Python 3- a complete introduction to the Python language,def change_mileage(previous_license):,simplefunc,458 Programming in Python 3- a complete introduction to the Python language,def __enter__(self):,simplefunc,460 Programming in Python 3- a complete introduction to the Python language,def main():,simplefunc,462 Programming in Python 3- a complete introduction to the Python language,def load(filename):,simplefunc,462 Programming in Python 3- a complete introduction to the Python language,def __enter__(self):,simplefunc,463 Programming in Python 3- a complete introduction to the Python language,def handle(self):,simplefunc,465 Programming in Python 3- a complete introduction to the Python language,def add_dvd(db):,simplefunc,473 Programming in Python 3- a complete introduction to the Python language,def edit_dvd(db):,simplefunc,473 Programming in Python 3- a complete introduction to the Python language,def list_dvds(db):,simplefunc,475 Programming in Python 3- a complete introduction to the Python language,def remove_dvd(db):,simplefunc,475 Programming in Python 3- a complete introduction to the Python language,def connect(filename):,simplefunc,476 Programming in Python 3- a complete introduction to the Python language,def add_dvd(db):,simplefunc,478 Programming in Python 3- a complete introduction to the Python language,def edit_dvd(db):,simplefunc,480 Programming in Python 3- a complete introduction to the Python language,def list_dvds(db):,simplefunc,482 Programming in Python 3- a complete introduction to the Python language,def dvd_count(db):,simplefunc,482 Programming in Python 3- a complete introduction to the Python language,def remove_dvd(db):,simplefunc,482 Programming in Python 3- a complete introduction to the Python language,def html2text(html_text):,simplefunc,499 Programming in Python 3- a complete introduction to the Python language,def char_from_entity(match):,simplefunc,499 Programming in Python 3- a complete introduction to the Python language,def has_children(self):,simplefunc,524 Programming in Python 3- a complete introduction to the Python language,def location(self):,simplefunc,525 Programming in Python 3- a complete introduction to the Python language,def _advance_by_one(self):,simplefunc,525 Programming in Python 3- a complete introduction to the Python language,def parse(data):,simplefunc,527 Programming in Python 3- a complete introduction to the Python language,def parse_new_row(data):,simplefunc,528 Programming in Python 3- a complete introduction to the Python language,def accumulate(tokens):,simplefunc,535 Programming in Python 3- a complete introduction to the Python language,def add_song(tokens):,simplefunc,537 Programming in Python 3- a complete introduction to the Python language,def add_block(tokens):,simplefunc,540 Programming in Python 3- a complete introduction to the Python language,def t_KEY(t):,simplefunc,551 Programming in Python 3- a complete introduction to the Python language,def t_VALUE(t):,simplefunc,551 Programming in Python 3- a complete introduction to the Python language,def t_newline(t):,simplefunc,552 Programming in Python 3- a complete introduction to the Python language,def t_error(t):,simplefunc,552 Programming in Python 3- a complete introduction to the Python language,def t_INFO(t):,simplefunc,554 Programming in Python 3- a complete introduction to the Python language,def t_entry_SECONDS(t):,simplefunc,554 Programming in Python 3- a complete introduction to the Python language,def t_entry_TITLE(t):,simplefunc,554 Programming in Python 3- a complete introduction to the Python language,def t_filename_FILENAME(t):,simplefunc,554 Programming in Python 3- a complete introduction to the Python language,def t_SYMBOL(t):,simplefunc,558 Programming in Python 3- a complete introduction to the Python language,def p_formula_quantifier(p):,simplefunc,559 Programming in Python 3- a complete introduction to the Python language,def p_formula_binary(p):,simplefunc,560 Programming in Python 3- a complete introduction to the Python language,def p_formula_not(p):,simplefunc,560 Programming in Python 3- a complete introduction to the Python language,def p_formula_boolean(p):,simplefunc,560 Programming in Python 3- a complete introduction to the Python language,def p_formula_group(p):,simplefunc,560 Programming in Python 3- a complete introduction to the Python language,def p_formula_symbol(p):,simplefunc,560 Programming in Python 3- a complete introduction to the Python language,def p_formula_equals(p):,simplefunc,561 Programming in Python 3- a complete introduction to the Python language,def p_term(p):,simplefunc,561 Programming in Python 3- a complete introduction to the Python language,def p_termlist(p):,simplefunc,561 Programming in Python 3- a complete introduction to the Python language,def p_error(p):,simplefunc,561 Programming in Python 3- a complete introduction to the Python language,def clearStatusBar(self):,simplefunc,579 Programming in Python 3- a complete introduction to the Python language,def okayToContinue(self):,simplefunc,580 Programming in Python 3- a complete introduction to the Python language,"return True, even if each has been assigned separately as we",return,22 Programming in Python 3- a complete introduction to the Python language,return the operand that determined the result—they do,return,24 Programming in Python 3- a complete introduction to the Python language,return a Boolean (unless they actually have Boolean operands). Let’s see,return,24 Programming in Python 3- a complete introduction to the Python language,"return in a Boolean context.",return,25 Programming in Python 3- a complete introduction to the Python language,"return Every Python function has a return value; this defaults",return,36 Programming in Python 3- a complete introduction to the Python language,"return value, in which case value is returned.",return,36 Programming in Python 3- a complete introduction to the Python language,return value can be just one value or a tuple of values. The return value,return,36 Programming in Python 3- a complete introduction to the Python language,"return state-",return,36 Programming in Python 3- a complete introduction to the Python language,return to this program in the exercises to improve its,return,41 Programming in Python 3- a complete introduction to the Python language,return i,return,42 Programming in Python 3- a complete introduction to the Python language,return either default (if the user just pressed,return,42 Programming in Python 3- a complete introduction to the Python language,return the operand that determined,return,44 Programming in Python 3- a complete introduction to the Python language,"return True",return,50 Programming in Python 3- a complete introduction to the Python language,return the operand that determined,return,56 Programming in Python 3- a complete introduction to the Python language,return abs(a - b) <= sys.float_info.epsilon,return,59 Programming in Python 3- a complete introduction to the Python language,return to this topic in the next section,return,63 Programming in Python 3- a complete introduction to the Python language,return (CR),return,64 Programming in Python 3- a complete introduction to the Python language,return a string that when represented as UTF-8 encoded bytes will always,return,66 Programming in Python 3- a complete introduction to the Python language,return None,return,73 Programming in Python 3- a complete introduction to the Python language,return line[start:j],return,73 Programming in Python 3- a complete introduction to the Python language,return None,return,73 Programming in Python 3- a complete introduction to the Python language,return value version on the right intersperses what we want with error,return,73 Programming in Python 3- a complete introduction to the Python language,return True if the string,return,74 Programming in Python 3- a complete introduction to the Python language,return a suitable string to display themselves.,return,80 Programming in Python 3- a complete introduction to the Python language,return x,return,94 Programming in Python 3- a complete introduction to the Python language,return fields,return,99 Programming in Python 3- a complete introduction to the Python language,return text,return,100 Programming in Python 3- a complete introduction to the Python language,return a tuple of two values: maxwidth (an int) and format (a str). When,return,102 Programming in Python 3- a complete introduction to the Python language,"return x, x ** 2",return,106 Programming in Python 3- a complete introduction to the Python language,"return a * b * c # here, * is the multiplication operator",return,111 Programming in Python 3- a complete introduction to the Python language,"return anything), the latter accepting the same optional arguments as",return,115 Programming in Python 3- a complete introduction to the Python language,return value is used to perform the comparisons used when sorting. As,return,115 Programming in Python 3- a complete introduction to the Python language,"return a list of every item in the iterable, and is semantically no",return,116 Programming in Python 3- a complete introduction to the Python language,return value is always the same,return,118 Programming in Python 3- a complete introduction to the Python language,return values of functions,return,123 Programming in Python 3- a complete introduction to the Python language,return dictionary,return,126 Programming in Python 3- a complete introduction to the Python language,"return the associated number, and",return,129 Programming in Python 3- a complete introduction to the Python language,"return the supplied default of 0, and this value plus",return,129 Programming in Python 3- a complete introduction to the Python language,return the last key–value item in the,return,134 Programming in Python 3- a complete introduction to the Python language,return each of its items one at a time. Any,return,135 Programming in Python 3- a complete introduction to the Python language,return the,return,135 Programming in Python 3- a complete introduction to the Python language,"return value each time,",return,135 Programming in Python 3- a complete introduction to the Python language,return value equals the sentinel.,return,135 Programming in Python 3- a complete introduction to the Python language,"return forenames, surnames",return,139 Programming in Python 3- a complete introduction to the Python language,return to four tuples.,return,140 Programming in Python 3- a complete introduction to the Python language,"return t[1], t[0]",return,143 Programming in Python 3- a complete introduction to the Python language,return the data with a suitable,return,146 Programming in Python 3- a complete introduction to the Python language,return user,return,147 Programming in Python 3- a complete introduction to the Python language,"return to the caller (main()), which inserts the user",return,148 Programming in Python 3- a complete introduction to the Python language,return username,return,148 Programming in Python 3- a complete introduction to the Python language,return the username to the caller.,return,148 Programming in Python 3- a complete introduction to the Python language,"return Statistics(mean, mode, median, std_dev)",return,151 Programming in Python 3- a complete introduction to the Python language,return a Statistics named tuple,return,151 Programming in Python 3- a complete introduction to the Python language,return mode,return,151 Programming in Python 3- a complete introduction to the Python language,return median,return,152 Programming in Python 3- a complete introduction to the Python language,return math.sqrt(variance),return,152 Programming in Python 3- a complete introduction to the Python language,return statement (if the loop is in a,return,158 Programming in Python 3- a complete introduction to the Python language,"return the index position of a given string or item, or",return,158 Programming in Python 3- a complete introduction to the Python language,return statement (if the loop,return,159 Programming in Python 3- a complete introduction to the Python language,return index,return,160 Programming in Python 3- a complete introduction to the Python language,return values.,return,160 Programming in Python 3- a complete introduction to the Python language,return an empty list.,return,164 Programming in Python 3- a complete introduction to the Python language,return value since the function finishes as a,return,164 Programming in Python 3- a complete introduction to the Python language,return [],return,164 Programming in Python 3- a complete introduction to the Python language,return to the interpreter. If you know what module,return,169 Programming in Python 3- a complete introduction to the Python language,return math.sqrt(s * (s - a) * (s - b) * (s - c)),return,170 Programming in Python 3- a complete introduction to the Python language,return value. The return value is either a single,return,170 Programming in Python 3- a complete introduction to the Python language,"return statement. If we use return with no arguments,",return,170 Programming in Python 3- a complete introduction to the Python language,"return statement at all, the function will return None.",return,170 Programming in Python 3- a complete introduction to the Python language,return in certain kinds of functions.),return,170 Programming in Python 3- a complete introduction to the Python language,return count,return,171 Programming in Python 3- a complete introduction to the Python language,return text,return,171 Programming in Python 3- a complete introduction to the Python language,"return (depending on their emphasis), but never how they do",return,173 Programming in Python 3- a complete introduction to the Python language,return the index position of the first occurrence of a,return,173 Programming in Python 3- a complete introduction to the Python language,return text,return,174 Programming in Python 3- a complete introduction to the Python language,return result,return,175 Programming in Python 3- a complete introduction to the Python language,return result,return,175 Programming in Python 3- a complete introduction to the Python language,"return ""{0} {1}"".format(area, units)",return,175 Programming in Python 3- a complete introduction to the Python language,return (or yield) statement. The result of a lambda expres-,return,179 Programming in Python 3- a complete introduction to the Python language,"return e[1], e[2], which",return,179 Programming in Python 3- a complete introduction to the Python language,return 0.5 * b * h,return,180 Programming in Python 3- a complete introduction to the Python language,return result,return,181 Programming in Python 3- a complete introduction to the Python language,return result,return,181 Programming in Python 3- a complete introduction to the Python language,return line,return,187 Programming in Python 3- a complete introduction to the Python language,"return "" "".join(result)",return,201 Programming in Python 3- a complete introduction to the Python language,return False,return,202 Programming in Python 3- a complete introduction to the Python language,return not any(counts.values()),return,202 Programming in Python 3- a complete introduction to the Python language,"return False; otherwise, the relevant count is decremented. At the end every",return,202 Programming in Python 3- a complete introduction to the Python language,return value is a string containing all the lines that,return,211 Programming in Python 3- a complete introduction to the Python language,"return value of 2 signifies a usage error, 1 signifies any other kind of error, and 0",return,212 Programming in Python 3- a complete introduction to the Python language,"return identical ISO 8601-format date/time strings.",return,214 Programming in Python 3- a complete introduction to the Python language,return a list of the unique,return,215 Programming in Python 3- a complete introduction to the Python language,return every element in the entire XML document.,return,225 Programming in Python 3- a complete introduction to the Python language,"return math.hypot(self.x, self.y)",return,236 Programming in Python 3- a complete introduction to the Python language,return self.x == other.x and self.y == other.y,return,236 Programming in Python 3- a complete introduction to the Python language,"return ""Point({0.x!r}, {0.y!r})"".format(self)",return,236 Programming in Python 3- a complete introduction to the Python language,"return ""({0.x!r}, {0.y!r})"".format(self)",return,236 Programming in Python 3- a complete introduction to the Python language,"return math.hypot(self.x, self.y)",return,238 Programming in Python 3- a complete introduction to the Python language,return self.x == other.x and self.y == other.y,return,238 Programming in Python 3- a complete introduction to the Python language,"return NotImplemented. In this third case,",return,239 Programming in Python 3- a complete introduction to the Python language,return NotImplement-,return,239 Programming in Python 3- a complete introduction to the Python language,"return ""Point({0.x!r}, {0.y!r})"".format(self)",return,239 Programming in Python 3- a complete introduction to the Python language,"return ""({0.x!r}, {0.y!r})"".format(self)",return,240 Programming in Python 3- a complete introduction to the Python language,return abs(self.distance_from_origin() -,return,240 Programming in Python 3- a complete introduction to the Python language,"return a single float value, so",return,243 Programming in Python 3- a complete introduction to the Python language,return math.pi * (self.radius ** 2),return,243 Programming in Python 3- a complete introduction to the Python language,return abs(self.distance_from_origin - self.radius),return,243 Programming in Python 3- a complete introduction to the Python language,return math.pi * (self.radius ** 2),return,243 Programming in Python 3- a complete introduction to the Python language,return self.__radius,return,244 Programming in Python 3- a complete introduction to the Python language,return the appropriate resultant FuzzyBool. And to,return,246 Programming in Python 3- a complete introduction to the Python language,return FuzzyBool(1.0 -,return,246 Programming in Python 3- a complete introduction to the Python language,return self,return,248 Programming in Python 3- a complete introduction to the Python language,return self to support the chaining of operations.,return,248 Programming in Python 3- a complete introduction to the Python language,return str(self.__value),return,249 Programming in Python 3- a complete introduction to the Python language,return the floating-point value formatted as a,return,249 Programming in Python 3- a complete introduction to the Python language,return self.__value > 0.5,return,249 Programming in Python 3- a complete introduction to the Python language,return round(self.__value),return,249 Programming in Python 3- a complete introduction to the Python language,return self.__value,return,249 Programming in Python 3- a complete introduction to the Python language,return either True or False. The __int__() special method provides integer,return,249 Programming in Python 3- a complete introduction to the Python language,return 0 for any FuzzyBool value except 1.0). Floating-point,return,249 Programming in Python 3- a complete introduction to the Python language,return self.__value < other.__value,return,249 Programming in Python 3- a complete introduction to the Python language,return self.__value == other.__value,return,249 Programming in Python 3- a complete introduction to the Python language,return hash(id(self)),return,249 Programming in Python 3- a complete introduction to the Python language,"return format(self.__value, format_spec)",return,251 Programming in Python 3- a complete introduction to the Python language,return self.__value.__format__(format_spec),return,251 Programming in Python 3- a complete introduction to the Python language,return a string.,return,251 Programming in Python 3- a complete introduction to the Python language,return FuzzyBool(min([float(x) for x in,return,251 Programming in Python 3- a complete introduction to the Python language,return FuzzyBool(min(fuzzies)),return,253 Programming in Python 3- a complete introduction to the Python language,"return super().__new__(cls,",return,253 Programming in Python 3- a complete introduction to the Python language,return FuzzyBool(1.0 - float(self)),return,254 Programming in Python 3- a complete introduction to the Python language,"return FuzzyBool(min(self, other))",return,254 Programming in Python 3- a complete introduction to the Python language,"return FuzzyBool(min(self, other))",return,254 Programming in Python 3- a complete introduction to the Python language,return self > 0.5,return,255 Programming in Python 3- a complete introduction to the Python language,return round(self),return,255 Programming in Python 3- a complete introduction to the Python language,return NotImplemented,return,256 Programming in Python 3- a complete introduction to the Python language,return here only if the need arises in practice.,return,256 Programming in Python 3- a complete introduction to the Python language,return self.__background,return,260 Programming in Python 3- a complete introduction to the Python language,return self.__width,return,261 Programming in Python 3- a complete introduction to the Python language,return self.__height,return,261 Programming in Python 3- a complete introduction to the Python language,return set(self.__colors),return,261 Programming in Python 3- a complete introduction to the Python language,return im-,return,261 Programming in Python 3- a complete introduction to the Python language,return a,return,261 Programming in Python 3- a complete introduction to the Python language,return set(self.__data.values()) | {self.__background},return,261 Programming in Python 3- a complete introduction to the Python language,return to this theme shortly.),return,261 Programming in Python 3- a complete introduction to the Python language,"return self.__data.get(tuple(coordinate), self.__background)",return,261 Programming in Python 3- a complete introduction to the Python language,"return a suitable string, for example, '<Image.Image object at",return,263 Programming in Python 3- a complete introduction to the Python language,return self.__key,return,268 Programming in Python 3- a complete introduction to the Python language,return count,return,270 Programming in Python 3- a complete introduction to the Python language,return count,return,270 Programming in Python 3- a complete introduction to the Python language,return index,return,270 Programming in Python 3- a complete introduction to the Python language,return self.__list[index],return,270 Programming in Python 3- a complete introduction to the Python language,return iter(self.__list),return,271 Programming in Python 3- a complete introduction to the Python language,return an iterator to the,return,271 Programming in Python 3- a complete introduction to the Python language,return reversed(self.__list),return,271 Programming in Python 3- a complete introduction to the Python language,return (index < len(self.__list) and,return,271 Programming in Python 3- a complete introduction to the Python language,return self.__list.pop(index),return,271 Programming in Python 3- a complete introduction to the Python language,return len(self.__list),return,271 Programming in Python 3- a complete introduction to the Python language,"return SortedList(self, self.__key)",return,272 Programming in Python 3- a complete introduction to the Python language,"return cls({k: value for k in iterable},",return,274 Programming in Python 3- a complete introduction to the Python language,return value is a dictionary of the given class. For example:,return,275 Programming in Python 3- a complete introduction to the Python language,"return super().__setitem__(key, value)",return,275 Programming in Python 3- a complete introduction to the Python language,return its result to the,return,275 Programming in Python 3- a complete introduction to the Python language,return a StopIteration exception is raised.,return,276 Programming in Python 3- a complete introduction to the Python language,return a list,return,276 Programming in Python 3- a complete introduction to the Python language,return result,return,276 Programming in Python 3- a complete introduction to the Python language,return the result of calling the base class implemen-,return,276 Programming in Python 3- a complete introduction to the Python language,"return super().setdefault(key, value)",return,276 Programming in Python 3- a complete introduction to the Python language,return args[0],return,277 Programming in Python 3- a complete introduction to the Python language,"return super().pop(key, args)",return,277 Programming in Python 3- a complete introduction to the Python language,return item,return,277 Programming in Python 3- a complete introduction to the Python language,return the item.,return,277 Programming in Python 3- a complete introduction to the Python language,return iter(self.__keys),return,277 Programming in Python 3- a complete introduction to the Python language,return iterators: dict.values() for the dic-,return,278 Programming in Python 3- a complete introduction to the Python language,"return dictionary views, but for most purposes the behavior of",return,278 Programming in Python 3- a complete introduction to the Python language,return iter-,return,278 Programming in Python 3- a complete introduction to the Python language,return object.__repr__(self),return,278 Programming in Python 3- a complete introduction to the Python language,"return (""{"" + "", "".join([""{0!r}: {1!r}"".format(k, v)",return,278 Programming in Python 3- a complete introduction to the Python language,"return ""{"" + "", "".join(items) + ""}""",return,278 Programming in Python 3- a complete introduction to the Python language,return d,return,279 Programming in Python 3- a complete introduction to the Python language,return SortedDict(,return,279 Programming in Python 3- a complete introduction to the Python language,return self[self.__keys[index]],return,279 Programming in Python 3- a complete introduction to the Python language,"return an object’s immutable data attributes, we should normally only",return,281 Programming in Python 3- a complete introduction to the Python language,return copies of an object’s mutable data attributes to avoid the object’s,return,281 Programming in Python 3- a complete introduction to the Python language,return the account’s balance in USD and all_usd which should return,return,283 Programming in Python 3- a complete introduction to the Python language,return self.__date,return,288 Programming in Python 3- a complete introduction to the Python language,return True,return,290 Programming in Python 3- a complete introduction to the Python language,return False,return,290 Programming in Python 3- a complete introduction to the Python language,return a Boolean to the caller indicating success,return,291 Programming in Python 3- a complete introduction to the Python language,"return struct.pack(format, len(data), data)",return,293 Programming in Python 3- a complete introduction to the Python language,return True (assuming no error oc-,return,298 Programming in Python 3- a complete introduction to the Python language,return None,return,299 Programming in Python 3- a complete introduction to the Python language,"return """"",return,299 Programming in Python 3- a complete introduction to the Python language,"return struct.unpack(format, data)[0].decode(""utf8"")",return,299 Programming in Python 3- a complete introduction to the Python language,return None,return,299 Programming in Python 3- a complete introduction to the Python language,"return a tuple, even",return,299 Programming in Python 3- a complete introduction to the Python language,return an empty,return,300 Programming in Python 3- a complete introduction to the Python language,return the string that results from unpacking,return,300 Programming in Python 3- a complete introduction to the Python language,"return data.decode(""utf8""), but we prefer to go through the",return,300 Programming in Python 3- a complete introduction to the Python language,return True,return,303 Programming in Python 3- a complete introduction to the Python language,return True,return,306 Programming in Python 3- a complete introduction to the Python language,return False,return,306 Programming in Python 3- a complete introduction to the Python language,return True to the caller—unless an exception,return,306 Programming in Python 3- a complete introduction to the Python language,return here later if desired.,return,307 Programming in Python 3- a complete introduction to the Python language,return True,return,308 Programming in Python 3- a complete introduction to the Python language,"return True. If anything went wrong, the except suite will issue a suitable error mes-",return,309 Programming in Python 3- a complete introduction to the Python language,"return False, and the finally suite will close the file.",return,309 Programming in Python 3- a complete introduction to the Python language,return False,return,311 Programming in Python 3- a complete introduction to the Python language,return True,return,311 Programming in Python 3- a complete introduction to the Python language,return True,return,314 Programming in Python 3- a complete introduction to the Python language,"return """".join(text).strip()",return,315 Programming in Python 3- a complete introduction to the Python language,return False,return,316 Programming in Python 3- a complete introduction to the Python language,return True,return,316 Programming in Python 3- a complete introduction to the Python language,return False.,return,316 Programming in Python 3- a complete introduction to the Python language,return True,return,317 Programming in Python 3- a complete introduction to the Python language,return True,return,318 Programming in Python 3- a complete introduction to the Python language,return False,return,318 Programming in Python 3- a complete introduction to the Python language,return True if no parsing errors occurred.,return,318 Programming in Python 3- a complete introduction to the Python language,return self.__record_size - 1,return,324 Programming in Python 3- a complete introduction to the Python language,return self.__fh.name,return,324 Programming in Python 3- a complete introduction to the Python language,return None,return,325 Programming in Python 3- a complete introduction to the Python language,"return None; otherwise, we read and return the record. (An-",return,325 Programming in Python 3- a complete introduction to the Python language,"return self.__fh.seek(index * self.__record_size)",return,326 Programming in Python 3- a complete introduction to the Python language,return True,return,326 Programming in Python 3- a complete introduction to the Python language,return False,return,326 Programming in Python 3- a complete introduction to the Python language,return True to,return,326 Programming in Python 3- a complete introduction to the Python language,return False.,return,326 Programming in Python 3- a complete introduction to the Python language,return end // self.__record_size,return,327 Programming in Python 3- a complete introduction to the Python language,return None if record is None else _bike_from_record(record),return,331 Programming in Python 3- a complete introduction to the Python language,"return None. But if a record is retrieved we return it as a BikeStock.Bike object.",return,331 Programming in Python 3- a complete introduction to the Python language,return False,return,331 Programming in Python 3- a complete introduction to the Python language,return Bike(*parts),return,333 Programming in Python 3- a complete introduction to the Python language,"return _BIKE_STRUCT.pack(bike.identity.encode(""utf8""),",return,333 Programming in Python 3- a complete introduction to the Python language,"return only a valid choice, in this case one of “a”, “e”, “l”, “r”, “i”, “x”, and “q”. Here are",return,337 Programming in Python 3- a complete introduction to the Python language,"return ((key, d[key])",return,339 Programming in Python 3- a complete introduction to the Python language,return a generator that produces a list of key–value items,return,339 Programming in Python 3- a complete introduction to the Python language,return (file for file in names if,return,340 Programming in Python 3- a complete introduction to the Python language,return an iterator to the names of the,return,341 Programming in Python 3- a complete introduction to the Python language,return a,return,341 Programming in Python 3- a complete introduction to the Python language,return 4 * math.pi * r ** 2,return,342 Programming in Python 3- a complete introduction to the Python language,return modules,return,345 Programming in Python 3- a complete introduction to the Python language,return an empty string which,return,345 Programming in Python 3- a complete introduction to the Python language,"return 120, that is,",return,349 Programming in Python 3- a complete introduction to the Python language,return 1,return,349 Programming in Python 3- a complete introduction to the Python language,return x * factorial(x - 1),return,349 Programming in Python 3- a complete introduction to the Python language,return (b ** 2) - (4 * a * c),return,354 Programming in Python 3- a complete introduction to the Python language,return result,return,354 Programming in Python 3- a complete introduction to the Python language,return wrapper,return,354 Programming in Python 3- a complete introduction to the Python language,return the wrapper function—it is this function that,return,354 Programming in Python 3- a complete introduction to the Python language,return result,return,354 Programming in Python 3- a complete introduction to the Python language,return wrapper,return,354 Programming in Python 3- a complete introduction to the Python language,return (amount / total) * 100,return,355 Programming in Python 3- a complete introduction to the Python language,return minimum,return,355 Programming in Python 3- a complete introduction to the Python language,return maximum,return,355 Programming in Python 3- a complete introduction to the Python language,return result,return,355 Programming in Python 3- a complete introduction to the Python language,return wrapper,return,355 Programming in Python 3- a complete introduction to the Python language,return decorator,return,355 Programming in Python 3- a complete introduction to the Python language,return result if not make_integer else,return,355 Programming in Python 3- a complete introduction to the Python language,return wrapper,return,356 Programming in Python 3- a complete introduction to the Python language,return value (or exception) to the log string and write to the,return,357 Programming in Python 3- a complete introduction to the Python language,"return the function it is given, so apart",return,357 Programming in Python 3- a complete introduction to the Python language,return expression part (-> rexp). The last (or only) positional parameter,return,357 Programming in Python 3- a complete introduction to the Python language,return value or not. Annotations have no special significance to,return,357 Programming in Python 3- a complete introduction to the Python language,return False,return,358 Programming in Python 3- a complete introduction to the Python language,return True,return,358 Programming in Python 3- a complete introduction to the Python language,"return value""",return,358 Programming in Python 3- a complete introduction to the Python language,"return of {0} got {1}"".format(",return,358 Programming in Python 3- a complete introduction to the Python language,return result,return,358 Programming in Python 3- a complete introduction to the Python language,return value must be,return,359 Programming in Python 3- a complete introduction to the Python language,return type are all annotated with their types when the function it is passed is,return,359 Programming in Python 3- a complete introduction to the Python language,return value are annotated.,return,359 Programming in Python 3- a complete introduction to the Python language,return the wrapped function as usual.,return,359 Programming in Python 3- a complete introduction to the Python language,return (float(x) for x in range(*args)),return,359 Programming in Python 3- a complete introduction to the Python language,return ord(char),return,361 Programming in Python 3- a complete introduction to the Python language,return to an,return,362 Programming in Python 3- a complete introduction to the Python language,return self.__width,return,362 Programming in Python 3- a complete introduction to the Python language,return set(self.__colors),return,363 Programming in Python 3- a complete introduction to the Python language,return directly to the,return,363 Programming in Python 3- a complete introduction to the Python language,return self.__background,return,363 Programming in Python 3- a complete introduction to the Python language,return string.strip(characters),return,365 Programming in Python 3- a complete introduction to the Python language,return strip_function,return,365 Programming in Python 3- a complete introduction to the Python language,return values,return,365 Programming in Python 3- a complete introduction to the Python language,return self.modified,return,369 Programming in Python 3- a complete introduction to the Python language,return the copy so that all the changes can be made on the copy.,return,369 Programming in Python 3- a complete introduction to the Python language,return value of __exit__() is used to indicate whether any exception that,return,369 Programming in Python 3- a complete introduction to the Python language,"return False or something that evaluates to False in a Boolean context to allow any",return,369 Programming in Python 3- a complete introduction to the Python language,"return value,",return,369 Programming in Python 3- a complete introduction to the Python language,return xml.sax.saxutils.escape(,return,371 Programming in Python 3- a complete introduction to the Python language,return an XML-escaped version of it.,return,371 Programming in Python 3- a complete introduction to the Python language,return xml_text,return,371 Programming in Python 3- a complete introduction to the Python language,"return self.cache.setdefault(id(instance),",return,371 Programming in Python 3- a complete introduction to the Python language,return self,return,372 Programming in Python 3- a complete introduction to the Python language,"return self.__storage[id(instance), self.attribute_name]",return,372 Programming in Python 3- a complete introduction to the Python language,return self.__name,return,373 Programming in Python 3- a complete introduction to the Python language,return self.__extension,return,373 Programming in Python 3- a complete introduction to the Python language,return self,return,374 Programming in Python 3- a complete introduction to the Python language,return self.__getter(instance),return,374 Programming in Python 3- a complete introduction to the Python language,return the result of calling the getter func-,return,374 Programming in Python 3- a complete introduction to the Python language,"return self.__setter(instance, value)",return,374 Programming in Python 3- a complete introduction to the Python language,return self.__setter,return,374 Programming in Python 3- a complete introduction to the Python language,return the function or,return,374 Programming in Python 3- a complete introduction to the Python language,return a class—normally a modified version,return,375 Programming in Python 3- a complete introduction to the Python language,return self.__list.pop(index),return,375 Programming in Python 3- a complete introduction to the Python language,return cls,return,375 Programming in Python 3- a complete introduction to the Python language,return cls,return,377 Programming in Python 3- a complete introduction to the Python language,"return True. Furthermore, we will be required to implement __init__()",return,379 Programming in Python 3- a complete introduction to the Python language,return self.__price,return,381 Programming in Python 3- a complete introduction to the Python language,return self.__model,return,381 Programming in Python 3- a complete introduction to the Python language,return False,return,382 Programming in Python 3- a complete introduction to the Python language,return True,return,383 Programming in Python 3- a complete introduction to the Python language,return bool(self.__undos),return,384 Programming in Python 3- a complete introduction to the Python language,return super().can_undo,return,384 Programming in Python 3- a complete introduction to the Python language,"return super().__new__(mcl, classname, bases, dictionary)",return,391 Programming in Python 3- a complete introduction to the Python language,return values. One strong appeal of this kind of programming,return,392 Programming in Python 3- a complete introduction to the Python language,return True when bool() is ap-,return,393 Programming in Python 3- a complete introduction to the Python language,"return functions which can then be called to extract the specified attributes or items.",return,394 Programming in Python 3- a complete introduction to the Python language,return a text to apply the regex,return,398 Programming in Python 3- a complete introduction to the Python language,return generator,return,398 Programming in Python 3- a complete introduction to the Python language,return wrapper,return,398 Programming in Python 3- a complete introduction to the Python language,"return a value that we can process, and then we send the result",return,403 Programming in Python 3- a complete introduction to the Python language,"return a decorator,",return,405 Programming in Python 3- a complete introduction to the Python language,"return getattr(self, name)",return,405 Programming in Python 3- a complete introduction to the Python language,return cls,return,405 Programming in Python 3- a complete introduction to the Python language,return decorator,return,405 Programming in Python 3- a complete introduction to the Python language,return the value of the private data attribute. The setter function,return,406 Programming in Python 3- a complete introduction to the Python language,return self,return,406 Programming in Python 3- a complete introduction to the Python language,return self.getter(instance),return,406 Programming in Python 3- a complete introduction to the Python language,"return self.setter(instance, value)",return,406 Programming in Python 3- a complete introduction to the Python language,return data.stack[1],return,413 Programming in Python 3- a complete introduction to the Python language,return to how to create and run an experiment,return,418 Programming in Python 3- a complete introduction to the Python language,"return value, immediately",return,419 Programming in Python 3- a complete introduction to the Python language,return value. If these are always correct then we need to come up with a new,return,419 Programming in Python 3- a complete introduction to the Python language,"return value is wrong, then we know that we must investigate the function further.",return,419 Programming in Python 3- a complete introduction to the Python language,return statement (or at the end of the,return,419 Programming in Python 3- a complete introduction to the Python language,"return statement), add print(locals(), ""\n""). The built-",return,419 Programming in Python 3- a complete introduction to the Python language,"return value is in error, we know that we have located the",return,420 Programming in Python 3- a complete introduction to the Python language,return median,return,420 Programming in Python 3- a complete introduction to the Python language,return statement we,return,421 Programming in Python 3- a complete introduction to the Python language,return string,return,423 Programming in Python 3- a complete introduction to the Python language,"return anything (they actually return None),",return,423 Programming in Python 3- a complete introduction to the Python language,"return value is used we either return a constant (say, 0) or one of the arguments,",return,423 Programming in Python 3- a complete introduction to the Python language,return fake objects—third-party modules that provide,return,423 Programming in Python 3- a complete introduction to the Python language,"return string[:position] + insert + string[position:]. (And if we wrote return",return,423 Programming in Python 3- a complete introduction to the Python language,return value is the time,return,430 Programming in Python 3- a complete introduction to the Python language,return the lowest-priority items (in our case the,return,447 Programming in Python 3- a complete introduction to the Python language,"return value is a custom thread that will call the given function once the thread is",return,447 Programming in Python 3- a complete introduction to the Python language,return the license it used. Since the loop is infinite the program must be ter-,return,457 Programming in Python 3- a complete introduction to the Python language,return license,return,457 Programming in Python 3- a complete introduction to the Python language,return the license,return,457 Programming in Python 3- a complete introduction to the Python language,"return previous_license, None",return,457 Programming in Python 3- a complete introduction to the Python language,"return previous_license, None",return,457 Programming in Python 3- a complete introduction to the Python language,"return license, CarTuple(*data)",return,457 Programming in Python 3- a complete introduction to the Python language,return a tuple whose first item is a,return,458 Programming in Python 3- a complete introduction to the Python language,"return the previous license unchanged. Otherwise, we",return,458 Programming in Python 3- a complete introduction to the Python language,"return the license (which will now become the previous license), and a CarTuple",return,458 Programming in Python 3- a complete introduction to the Python language,return previous_license,return,458 Programming in Python 3- a complete introduction to the Python language,return license,return,458 Programming in Python 3- a complete introduction to the Python language,return license,return,458 Programming in Python 3- a complete introduction to the Python language,return pickle.loads(result),return,459 Programming in Python 3- a complete introduction to the Python language,return immediately—the context manager will ensure that the,return,460 Programming in Python 3- a complete introduction to the Python language,return it. In this case we know that the data will always,return,460 Programming in Python 3- a complete introduction to the Python language,return self.sock,return,461 Programming in Python 3- a complete introduction to the Python language,return pickle.load(fh),return,462 Programming in Python 3- a complete introduction to the Python language,return self.fh,return,463 Programming in Python 3- a complete introduction to the Python language,return anything.,return,463 Programming in Python 3- a complete introduction to the Python language,"return data = pickle.dumps(reply, 3)",return,465 Programming in Python 3- a complete introduction to the Python language,"return (True, car.seats, car.mileage, car.owner)",return,466 Programming in Python 3- a complete introduction to the Python language,"return (False, ""This license is not registered"")",return,466 Programming in Python 3- a complete introduction to the Python language,return a tuple whose,return,466 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot set a negative mileage"")",return,466 Programming in Python 3- a complete introduction to the Python language,"return (True, None)",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot wind the odometer back"")",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""This license is not registered"")",return,467 Programming in Python 3- a complete introduction to the Python language,return an error tuple. If no car,return,467 Programming in Python 3- a complete introduction to the Python language,"return an error tuple.",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot set an empty license"")",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot register car with invalid seats"")",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot set a negative mileage"")",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot set an empty owner"")",return,467 Programming in Python 3- a complete introduction to the Python language,"return (True, None)",return,467 Programming in Python 3- a complete introduction to the Python language,"return (False, ""Cannot register duplicate license"")",return,467 Programming in Python 3- a complete introduction to the Python language,return without sending any reply to the client.,return,468 Programming in Python 3- a complete introduction to the Python language,"return a 2-tuple of (True,",return,469 Programming in Python 3- a complete introduction to the Python language,"return director = Console.get_string(""Director"", ""director"")",return,473 Programming in Python 3- a complete introduction to the Python language,"return year = Console.get_integer(""Year"", ""year"", minimum=1896,",return,473 Programming in Python 3- a complete introduction to the Python language,"return title = Console.get_string(""Title"", ""title"", old_title)",return,473 Programming in Python 3- a complete introduction to the Python language,"return director, year, duration = db[old_title]",return,473 Programming in Python 3- a complete introduction to the Python language,return matches[which - 1] if which != 0 else None,return,474 Programming in Python 3- a complete introduction to the Python language,"return it, and if there are several matches (but fewer than",return,474 Programming in Python 3- a complete introduction to the Python language,"return ans = Console.get_bool(""Remove {0}?"".format(title), ""no"")",return,475 Programming in Python 3- a complete introduction to the Python language,return db,return,477 Programming in Python 3- a complete introduction to the Python language,return if no size is specified,return,478 Programming in Python 3- a complete introduction to the Python language,"return director = Console.get_string(""Director"", ""director"")",return,478 Programming in Python 3- a complete introduction to the Python language,"return year = Console.get_integer(""Year"", ""year"", minimum=1896,",return,478 Programming in Python 3- a complete introduction to the Python language,return director_id,return,479 Programming in Python 3- a complete introduction to the Python language,"return get_director_id(db, director)",return,479 Programming in Python 3- a complete introduction to the Python language,return fields[0] if fields is not None else None,return,480 Programming in Python 3- a complete introduction to the Python language,return a sequence of fields (or,return,480 Programming in Python 3- a complete introduction to the Python language,"return title = Console.get_string(""Title"", ""title"", title)",return,480 Programming in Python 3- a complete introduction to the Python language,"return cursor = db.cursor()",return,480 Programming in Python 3- a complete introduction to the Python language,"return year = Console.get_integer(""Year"", ""year"", year, 1896,",return,480 Programming in Python 3- a complete introduction to the Python language,"return records[which - 1] if which != 0 else (None, None)",return,481 Programming in Python 3- a complete introduction to the Python language,return cursor.fetchone()[0],return,482 Programming in Python 3- a complete introduction to the Python language,"return 487",return,483 Programming in Python 3- a complete introduction to the Python language,"return re.sub(r""\n\n+"", ""\n\n"", text.strip())",return,500 Programming in Python 3- a complete introduction to the Python language,"return value (or in the case of a lambda expression, the result of",return,501 Programming in Python 3- a complete introduction to the Python language,return a suitable,return,501 Programming in Python 3- a complete introduction to the Python language,"return bytes instead of strings, and the re.ASCII flag is implicitly",return,504 Programming in Python 3- a complete introduction to the Python language,return 2-tuples of the line number (starting from 1 as is traditional,return,516 Programming in Python 3- a complete introduction to the Python language,return the key_values dictionary. One dis-,return,517 Programming in Python 3- a complete introduction to the Python language,return [],return,518 Programming in Python 3- a complete introduction to the Python language,return an empty list.,return,519 Programming in Python 3- a complete introduction to the Python language,return the songs list to the caller. And thanks to the,return,520 Programming in Python 3- a complete introduction to the Python language,return bool(self.children),return,524 Programming in Python 3- a complete introduction to the Python language,return the root block—if the parse,return,525 Programming in Python 3- a complete introduction to the Python language,"return ""line {0}, column {1}"".format(self.line,",return,525 Programming in Python 3- a complete introduction to the Python language,return the current location as a string,return,525 Programming in Python 3- a complete introduction to the Python language,return False,return,526 Programming in Python 3- a complete introduction to the Python language,return True,return,526 Programming in Python 3- a complete introduction to the Python language,return data.stack[0],return,526 Programming in Python 3- a complete introduction to the Python language,"return the root block, which should have children (and their",return,527 Programming in Python 3- a complete introduction to the Python language,return block,return,528 Programming in Python 3- a complete introduction to the Python language,"return the block so that it can be pushed onto the stack of blocks—something we do",return,528 Programming in Python 3- a complete introduction to the Python language,return {},return,535 Programming in Python 3- a complete introduction to the Python language,return key_values,return,535 Programming in Python 3- a complete introduction to the Python language,return the key_values dictionary—or an empty dictionary if the,return,535 Programming in Python 3- a complete introduction to the Python language,return value since we,return,535 Programming in Python 3- a complete introduction to the Python language,return value and instead populating our data structure,return,536 Programming in Python 3- a complete introduction to the Python language,return values are used.),return,536 Programming in Python 3- a complete introduction to the Python language,return [],return,537 Programming in Python 3- a complete introduction to the Python language,return songs,return,537 Programming in Python 3- a complete introduction to the Python language,return a parser element that,return,540 Programming in Python 3- a complete introduction to the Python language,"return Block.Block(tokens.name, tokens.color if tokens.color",return,540 Programming in Python 3- a complete introduction to the Python language,return a Block. We also always set the,return,540 Programming in Python 3- a complete introduction to the Python language,return stack[0],return,540 Programming in Python 3- a complete introduction to the Python language,return result[0].asList(),return,547 Programming in Python 3- a complete introduction to the Python language,return t,return,551 Programming in Python 3- a complete introduction to the Python language,return t,return,551 Programming in Python 3- a complete introduction to the Python language,"return None), since if the return value is None the token is discarded.",return,552 Programming in Python 3- a complete introduction to the Python language,return t from the function if we want the token included in the,return,552 Programming in Python 3- a complete introduction to the Python language,return the dictionary to the caller just as we did with the,return,553 Programming in Python 3- a complete introduction to the Python language,return its results in,return,553 Programming in Python 3- a complete introduction to the Python language,return None,return,554 Programming in Python 3- a complete introduction to the Python language,return t,return,554 Programming in Python 3- a complete introduction to the Python language,return t,return,554 Programming in Python 3- a complete introduction to the Python language,return t,return,554 Programming in Python 3- a complete introduction to the Python language,return None; this means that,return,554 Programming in Python 3- a complete introduction to the Python language,return the key_values dictionary to,return,555 Programming in Python 3- a complete introduction to the Python language,return the root block with all its children. The block variable is used,return,556 Programming in Python 3- a complete introduction to the Python language,return stack[0]; this is the root Block that should,return,558 Programming in Python 3- a complete introduction to the Python language,return t,return,558 Programming in Python 3- a complete introduction to the Python language,return [],return,562 Programming in Python 3- a complete introduction to the Python language,return to later on. In addition to distinguishing between widgets and,return,569 Programming in Python 3- a complete introduction to the Python language,"return self.listBox.delete(0, tkinter.END)",return,579 Programming in Python 3- a complete introduction to the Python language,return True,return,580 Programming in Python 3- a complete introduction to the Python language,return self.fileSave(),return,580 Programming in Python 3- a complete introduction to the Python language,return True,return,580 Programming in Python 3- a complete introduction to the Python language,"return True right away. Otherwise, we pop up a standard message box with",return,580 Programming in Python 3- a complete introduction to the Python language,"return False. If the user says yes, reply is True, so we give",return,580 Programming in Python 3- a complete introduction to the Python language,return True if they saved and False otherwise.,return,580 Programming in Python 3- a complete introduction to the Python language,"return True because they want to continue the action they started, abandoning their",return,580 Programming in Python 3- a complete introduction to the Python language,return True,return,581 Programming in Python 3- a complete introduction to the Python language,return False to indicate that the entire operation should be cancelled.,return,581 Programming in Python 3- a complete introduction to the Python language,"return dir = (os.path.dirname(self.filename)",return,582 Programming in Python 3- a complete introduction to the Python language,"return index = indexes[0]",return,584 Programming in Python 3- a complete introduction to the Python language,"return index = indexes[0]",return,584 Programming in Python 3- a complete introduction to the Python language,"return index = indexes[0]",return,585 Programming in Python 3- a complete introduction to the Python language,"return (statement), 161, 162, 173",return,617 Programming in Python 3- a complete introduction to the Python language,if boolean_expression1:,simpleif,25 Programming in Python 3- a complete introduction to the Python language,if boolean_expression2:,simpleif,25 Programming in Python 3- a complete introduction to the Python language,if boolean_expressionN:,simpleif,25 Programming in Python 3- a complete introduction to the Python language,if statement example:,simpleif,26 Programming in Python 3- a complete introduction to the Python language,if x:,simpleif,26 Programming in Python 3- a complete introduction to the Python language,if lines < 1000:,simpleif,26 Programming in Python 3- a complete introduction to the Python language,"if lines < 10000: print(""medium"")",simpleif,26 Programming in Python 3- a complete introduction to the Python language,"if letter in ""AEIOU"":",simpleif,28 Programming in Python 3- a complete introduction to the Python language,"if they were to enter “13”, the output will be:",simpleif,29 Programming in Python 3- a complete introduction to the Python language,if count:,simpleif,33 Programming in Python 3- a complete introduction to the Python language,if count:,simpleif,34 Programming in Python 3- a complete introduction to the Python language,if default < minimum:,simpleif,42 Programming in Python 3- a complete introduction to the Python language,"if abs(nueva_área - vieja_área) < ε: print(""las áreas han convergido"")",simpleif,51 Programming in Python 3- a complete introduction to the Python language,if i != -1:,simpleif,73 Programming in Python 3- a complete introduction to the Python language,if j != -1:,simpleif,73 Programming in Python 3- a complete introduction to the Python language,if i == -1:,simpleif,74 Programming in Python 3- a complete introduction to the Python language,"if it is a JPEG file:",simpleif,74 Programming in Python 3- a complete introduction to the Python language,"if filename.lower().endswith(("".jpg"", "".jpeg"")):",simpleif,74 Programming in Python 3- a complete introduction to the Python language,if len(sys.argv) > 1:,simpleif,87 Programming in Python 3- a complete introduction to the Python language,"if sys.argv[1] in (""-h"", ""--help""):",simpleif,87 Programming in Python 3- a complete introduction to the Python language,if word != 0:,simpleif,87 Programming in Python 3- a complete introduction to the Python language,if word is None or word in name.lower():,simpleif,88 Programming in Python 3- a complete introduction to the Python language,if not allow_zero and abs(x) < sys.float_info.epsilon:,simpleif,93 Programming in Python 3- a complete introduction to the Python language,if discriminant == 0:,simpleif,94 Programming in Python 3- a complete introduction to the Python language,if discriminant > 0:,simpleif,94 Programming in Python 3- a complete introduction to the Python language,if x2 is not None:,simpleif,94 Programming in Python 3- a complete introduction to the Python language,if not field:,simpleif,98 Programming in Python 3- a complete introduction to the Python language,"if c in ""\""'"":",simpleif,99 Programming in Python 3- a complete introduction to the Python language,if field:,simpleif,99 Programming in Python 3- a complete introduction to the Python language,if condition:,simpleif,116 Programming in Python 3- a complete introduction to the Python language,"if sex == ""F"" and size == ""X"":",simpleif,117 Programming in Python 3- a complete introduction to the Python language,if ip not in seen:,simpleif,121 Programming in Python 3- a complete introduction to the Python language,if len(word) > 2:,simpleif,127 Programming in Python 3- a complete introduction to the Python language,if word not in words:,simpleif,129 Programming in Python 3- a complete introduction to the Python language,if site not in sites:,simpleif,130 Programming in Python 3- a complete introduction to the Python language,if len(sys.argv) < 3:,simpleif,137 Programming in Python 3- a complete introduction to the Python language,"if len(sys.argv) == 1 or sys.argv[1] in {""-h"", ""--help""}: print(""usage: {0} file1 [file2 [... fileN]]"".format(",simpleif,147 Programming in Python 3- a complete introduction to the Python language,if line:,simpleif,147 Programming in Python 3- a complete introduction to the Python language,if user.middlename:,simpleif,149 Programming in Python 3- a complete introduction to the Python language,"if len(sys.argv) == 1 or sys.argv[1] in {""-h"", ""--help""}: print(""usage: {0} file1 [file2 [... fileN]]"".format(",simpleif,150 Programming in Python 3- a complete introduction to the Python language,if numbers:,simpleif,150 Programming in Python 3- a complete introduction to the Python language,if not (1 <= len(mode) <= maximum_modes):,simpleif,151 Programming in Python 3- a complete introduction to the Python language,if len(numbers) % 2 == 0:,simpleif,152 Programming in Python 3- a complete introduction to the Python language,if statistics.mode is None:,simpleif,152 Programming in Python 3- a complete introduction to the Python language,if boolean_expression1:,simpleif,156 Programming in Python 3- a complete introduction to the Python language,if x == target:,simpleif,160 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,163 Programming in Python 3- a complete introduction to the Python language,if item == target:,simpleif,165 Programming in Python 3- a complete introduction to the Python language,"if found: break",simpleif,165 Programming in Python 3- a complete introduction to the Python language,"if found: break",simpleif,165 Programming in Python 3- a complete introduction to the Python language,if found:,simpleif,165 Programming in Python 3- a complete introduction to the Python language,"if isinstance(err, InvalidNumericEntityError):",simpleif,167 Programming in Python 3- a complete introduction to the Python language,"if isinstance(err, InvalidAlphaEntityError):",simpleif,167 Programming in Python 3- a complete introduction to the Python language,"if isinstance(err, InvalidTagContentError):",simpleif,167 Programming in Python 3- a complete introduction to the Python language,if skip_on_first_error:,simpleif,167 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,168 Programming in Python 3- a complete introduction to the Python language,if char in letters:,simpleif,171 Programming in Python 3- a complete introduction to the Python language,if len(text) > length:,simpleif,171 Programming in Python 3- a complete introduction to the Python language,if len(text) > length:,simpleif,174 Programming in Python 3- a complete introduction to the Python language,if not name:,simpleif,184 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,186 Programming in Python 3- a complete introduction to the Python language,if not (minimum_length <= len(line) <= maximum_length):,simpleif,187 Programming in Python 3- a complete introduction to the Python language,if char in delete:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if char in whitespace:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if word:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if word:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if c in counts:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if c in left_for_right:,simpleif,201 Programming in Python 3- a complete introduction to the Python language,if counts[left] == 0:,simpleif,202 Programming in Python 3- a complete introduction to the Python language,"if sys.platform.startswith(""win""):",simpleif,206 Programming in Python 3- a complete introduction to the Python language,if char is not None:,simpleif,207 Programming in Python 3- a complete introduction to the Python language,if not 0 <= row <= _max_rows:,simpleif,208 Programming in Python 3- a complete introduction to the Python language,if i and i % 68 == 0:,simpleif,217 Programming in Python 3- a complete introduction to the Python language,if tar is not None:,simpleif,219 Programming in Python 3- a complete introduction to the Python language,if os.path.isfile(fullname):,simpleif,221 Programming in Python 3- a complete introduction to the Python language,if len(names) > 1:,simpleif,222 Programming in Python 3- a complete introduction to the Python language,if x < 5 or x >= width - 5 or y < 5 or y >= height - 5:,simpleif,259 Programming in Python 3- a complete introduction to the Python language,if midx - 20 < x < midx + 20 and midy - 20 < y < midy + 20:,simpleif,259 Programming in Python 3- a complete introduction to the Python language,if color == self.__background:,simpleif,262 Programming in Python 3- a complete introduction to the Python language,if filename is not None:,simpleif,265 Programming in Python 3- a complete introduction to the Python language,if not self.filename:,simpleif,265 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,265 Programming in Python 3- a complete introduction to the Python language,"if filename.lower().endswith("".xpm""):",simpleif,265 Programming in Python 3- a complete introduction to the Python language,"if sequence is None: self.__list = []",simpleif,267 Programming in Python 3- a complete introduction to the Python language,"if index == len(self.__list): self.__list.append(value)",simpleif,268 Programming in Python 3- a complete introduction to the Python language,if index < len(self.__list) and self.__list[index] == value:,simpleif,270 Programming in Python 3- a complete introduction to the Python language,if kwargs:,simpleif,273 Programming in Python 3- a complete introduction to the Python language,if dictionary is None:,simpleif,274 Programming in Python 3- a complete introduction to the Python language,"if isinstance(dictionary, dict):",simpleif,274 Programming in Python 3- a complete introduction to the Python language,if kwargs:,simpleif,274 Programming in Python 3- a complete introduction to the Python language,if key not in self:,simpleif,275 Programming in Python 3- a complete introduction to the Python language,if key not in self:,simpleif,276 Programming in Python 3- a complete introduction to the Python language,if key not in self:,simpleif,277 Programming in Python 3- a complete introduction to the Python language,if len(args) == 0:,simpleif,277 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,290 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,292 Programming in Python 3- a complete introduction to the Python language,if compress:,simpleif,295 Programming in Python 3- a complete introduction to the Python language,"if not length_data: if eof_is_error:",simpleif,299 Programming in Python 3- a complete introduction to the Python language,if length == 0:,simpleif,299 Programming in Python 3- a complete introduction to the Python language,if not data or len(data) != length:,simpleif,299 Programming in Python 3- a complete introduction to the Python language,if magic == GZIP_MAGIC:,simpleif,300 Programming in Python 3- a complete introduction to the Python language,if magic != MAGIC:,simpleif,300 Programming in Python 3- a complete introduction to the Python language,if version > FORMAT_VERSION:,simpleif,300 Programming in Python 3- a complete introduction to the Python language,if not line and narrative is None:,simpleif,304 Programming in Python 3- a complete introduction to the Python language,if narrative is not None:,simpleif,304 Programming in Python 3- a complete introduction to the Python language,"if line == "".NARRATIVE_END."":",simpleif,304 Programming in Python 3- a complete introduction to the Python language,if len(data) != 9:,simpleif,304 Programming in Python 3- a complete introduction to the Python language,"if key == ""date"":",simpleif,305 Programming in Python 3- a complete introduction to the Python language,"if key == ""pilot_percent_hours_on_type"":",simpleif,305 Programming in Python 3- a complete introduction to the Python language,"if key == ""pilot_total_hours"":",simpleif,305 Programming in Python 3- a complete introduction to the Python language,"if key == ""midair"":",simpleif,305 Programming in Python 3- a complete introduction to the Python language,"if line == "".NARRATIVE_START."":",simpleif,305 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,306 Programming in Python 3- a complete introduction to the Python language,if len(data) != 9:,simpleif,308 Programming in Python 3- a complete introduction to the Python language,if node.nodeType == node.TEXT_NODE:,simpleif,315 Programming in Python 3- a complete introduction to the Python language,"if name == ""incident"":",simpleif,319 Programming in Python 3- a complete introduction to the Python language,"if key == ""date"":",simpleif,319 Programming in Python 3- a complete introduction to the Python language,"if key == ""pilot_percent_hours_on_type"":",simpleif,319 Programming in Python 3- a complete introduction to the Python language,"if key == ""pilot_total_hours"": self.__data[key] = int(value)",simpleif,319 Programming in Python 3- a complete introduction to the Python language,"if key == ""midair"":",simpleif,319 Programming in Python 3- a complete introduction to the Python language,"if name == ""incident"":",simpleif,320 Programming in Python 3- a complete introduction to the Python language,if len(self.__data) != 9:,simpleif,320 Programming in Python 3- a complete introduction to the Python language,"if name in frozenset({""airport"", ""narrative""}):",simpleif,320 Programming in Python 3- a complete introduction to the Python language,if self.auto_flush:,simpleif,324 Programming in Python 3- a complete introduction to the Python language,if state != _OKAY:,simpleif,325 Programming in Python 3- a complete introduction to the Python language,if self.auto_flush:,simpleif,325 Programming in Python 3- a complete introduction to the Python language,if offset >= end:,simpleif,325 Programming in Python 3- a complete introduction to the Python language,if state != _OKAY:,simpleif,326 Programming in Python 3- a complete introduction to the Python language,if self.auto_flush:,simpleif,326 Programming in Python 3- a complete introduction to the Python language,if state == _DELETED:,simpleif,326 Programming in Python 3- a complete introduction to the Python language,if self.auto_flush:,simpleif,326 Programming in Python 3- a complete introduction to the Python language,if self.auto_flush:,simpleif,326 Programming in Python 3- a complete introduction to the Python language,if state != _OKAY:,simpleif,328 Programming in Python 3- a complete introduction to the Python language,"if state != _OKAY: limit = index",simpleif,328 Programming in Python 3- a complete introduction to the Python language,if limit is not None:,simpleif,328 Programming in Python 3- a complete introduction to the Python language,if data[:1] == _OKAY:,simpleif,328 Programming in Python 3- a complete introduction to the Python language,if not keep_backup:,simpleif,329 Programming in Python 3- a complete introduction to the Python language,"if not bicycles.increase_stock(bike.identity, 1):",simpleif,330 Programming in Python 3- a complete introduction to the Python language,if record is None:,simpleif,331 Programming in Python 3- a complete introduction to the Python language,if record is not None:,simpleif,332 Programming in Python 3- a complete introduction to the Python language,"if action == ""a"":",simpleif,337 Programming in Python 3- a complete introduction to the Python language,"if action == ""e"":",simpleif,337 Programming in Python 3- a complete introduction to the Python language,"if action == ""l"":",simpleif,338 Programming in Python 3- a complete introduction to the Python language,"if action == ""r"": remove_dvd(db)",simpleif,338 Programming in Python 3- a complete introduction to the Python language,"if action == ""i"":",simpleif,338 Programming in Python 3- a complete introduction to the Python language,"if action == ""x"":",simpleif,338 Programming in Python 3- a complete introduction to the Python language,"if action == ""q"":",simpleif,338 Programming in Python 3- a complete introduction to the Python language,if received is None:,simpleif,340 Programming in Python 3- a complete introduction to the Python language,if get_file_type is not None:,simpleif,344 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,344 Programming in Python 3- a complete introduction to the Python language,"if name.endswith("".py"") and ""magic"" in name.lower():",simpleif,344 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,345 Programming in Python 3- a complete introduction to the Python language,if x <= 1:,simpleif,349 Programming in Python 3- a complete introduction to the Python language,if level == 0:,simpleif,351 Programming in Python 3- a complete introduction to the Python language,if level == 0:,simpleif,352 Programming in Python 3- a complete introduction to the Python language,if result < minimum:,simpleif,355 Programming in Python 3- a complete introduction to the Python language,if result > maximum:,simpleif,355 Programming in Python 3- a complete introduction to the Python language,if not (0 < result <= price):,simpleif,355 Programming in Python 3- a complete introduction to the Python language,if __debug__:,simpleif,356 Programming in Python 3- a complete introduction to the Python language,if exception is not None:,simpleif,356 Programming in Python 3- a complete introduction to the Python language,"if unicodedata.category(c)[0] != ""P"":",simpleif,358 Programming in Python 3- a complete introduction to the Python language,"if name == ""colors"":",simpleif,363 Programming in Python 3- a complete introduction to the Python language,"if name in frozenset({""background"", ""width"", ""height""}): return self.__dict__[""_{classname}__{name}"".format(",simpleif,363 Programming in Python 3- a complete introduction to the Python language,if statements for each one like this:,simpleif,363 Programming in Python 3- a complete introduction to the Python language,"if name == ""background"":",simpleif,363 Programming in Python 3- a complete introduction to the Python language,if fh is not None:,simpleif,367 Programming in Python 3- a complete introduction to the Python language,if exc_type is None:,simpleif,369 Programming in Python 3- a complete introduction to the Python language,if xml_text is not None:,simpleif,371 Programming in Python 3- a complete introduction to the Python language,if instance is None:,simpleif,372 Programming in Python 3- a complete introduction to the Python language,if instance is None:,simpleif,374 Programming in Python 3- a complete introduction to the Python language,if self.__setter is None:,simpleif,374 Programming in Python 3- a complete introduction to the Python language,"if attribute_name.startswith(""__""):",simpleif,375 Programming in Python 3- a complete introduction to the Python language,if cls.__eq__ is object.__eq__:,simpleif,377 Programming in Python 3- a complete introduction to the Python language,if L is a SortedList. One easy way to fix this is to inherit the relevant ABC:,simpleif,379 Programming in Python 3- a complete introduction to the Python language,"if c in chars: count += 1",simpleif,382 Programming in Python 3- a complete introduction to the Python language,"if key.startswith(""get_"")]:",simpleif,391 Programming in Python 3- a complete introduction to the Python language,if match is not None:,simpleif,399 Programming in Python 3- a complete introduction to the Python language,if filename.endswith(suffixes):,simpleif,403 Programming in Python 3- a complete introduction to the Python language,if not empty_allowed and not value:,simpleif,405 Programming in Python 3- a complete introduction to the Python language,if instance is None:,simpleif,406 Programming in Python 3- a complete introduction to the Python language,"if BlockOutput.save_blocks_as_svg(blocks, svg): File ""BlockOutput.py"", line 141, in save_blocks_as_svg",simpleif,413 Programming in Python 3- a complete introduction to the Python language,"if len(numbers) % 2 == 0: (Pdb)",simpleif,420 Programming in Python 3- a complete introduction to the Python language,if key[0] == 0:,simpleif,446 Programming in Python 3- a complete introduction to the Python language,if len(names) > 1:,simpleif,448 Programming in Python 3- a complete introduction to the Python language,if md5 is not None:,simpleif,449 Programming in Python 3- a complete introduction to the Python language,if len(filenames) == 1:,simpleif,450 Programming in Python 3- a complete introduction to the Python language,if len(sys.argv) > 1:,simpleif,456 Programming in Python 3- a complete introduction to the Python language,if car is not None:,simpleif,457 Programming in Python 3- a complete introduction to the Python language,if not license:,simpleif,457 Programming in Python 3- a complete introduction to the Python language,if not ok:,simpleif,457 Programming in Python 3- a complete introduction to the Python language,if car is None:,simpleif,458 Programming in Python 3- a complete introduction to the Python language,if mileage == 0:,simpleif,458 Programming in Python 3- a complete introduction to the Python language,if not ok:,simpleif,458 Programming in Python 3- a complete introduction to the Python language,"if server is not None: server.shutdown()",simpleif,462 Programming in Python 3- a complete introduction to the Python language,if car is not None:,simpleif,466 Programming in Python 3- a complete introduction to the Python language,if mileage < 0:,simpleif,466 Programming in Python 3- a complete introduction to the Python language,if car is not None:,simpleif,467 Programming in Python 3- a complete introduction to the Python language,"if car.mileage < mileage: car.mileage = mileage",simpleif,467 Programming in Python 3- a complete introduction to the Python language,if not license:,simpleif,467 Programming in Python 3- a complete introduction to the Python language,"if seats not in {2, 4, 5, 6, 7, 8, 9}:",simpleif,467 Programming in Python 3- a complete introduction to the Python language,if mileage < 0:,simpleif,467 Programming in Python 3- a complete introduction to the Python language,if not owner:,simpleif,467 Programming in Python 3- a complete introduction to the Python language,if license not in self.Cars:,simpleif,467 Programming in Python 3- a complete introduction to the Python language,if db is not None:,simpleif,472 Programming in Python 3- a complete introduction to the Python language,if not title:,simpleif,473 Programming in Python 3- a complete introduction to the Python language,if not director:,simpleif,473 Programming in Python 3- a complete introduction to the Python language,if old_title is None:,simpleif,473 Programming in Python 3- a complete introduction to the Python language,if not title:,simpleif,473 Programming in Python 3- a complete introduction to the Python language,"if title != old_title: del db[old_title]",simpleif,473 Programming in Python 3- a complete introduction to the Python language,if len(db) > DISPLAY_LIMIT:,simpleif,475 Programming in Python 3- a complete introduction to the Python language,if not start or title.lower().startswith(start.lower()):,simpleif,475 Programming in Python 3- a complete introduction to the Python language,if title is None:,simpleif,475 Programming in Python 3- a complete introduction to the Python language,if ans:,simpleif,475 Programming in Python 3- a complete introduction to the Python language,if create:,simpleif,476 Programming in Python 3- a complete introduction to the Python language,if not title:,simpleif,478 Programming in Python 3- a complete introduction to the Python language,if not director:,simpleif,478 Programming in Python 3- a complete introduction to the Python language,if director_id is not None:,simpleif,479 Programming in Python 3- a complete introduction to the Python language,if title is None:,simpleif,480 Programming in Python 3- a complete introduction to the Python language,if not title:,simpleif,480 Programming in Python 3- a complete introduction to the Python language,if not director:,simpleif,480 Programming in Python 3- a complete introduction to the Python language,if dvd_count(db) > DISPLAY_LIMIT:,simpleif,482 Programming in Python 3- a complete introduction to the Python language,if start is None:,simpleif,482 Programming in Python 3- a complete introduction to the Python language,if ans:,simpleif,483 Programming in Python 3- a complete introduction to the Python language,"if not line or line.startswith(""#""):",simpleif,516 Programming in Python 3- a complete introduction to the Python language,if key_value:,simpleif,516 Programming in Python 3- a complete introduction to the Python language,if lowercase_keys:,simpleif,516 Programming in Python 3- a complete introduction to the Python language,if not ini_header:,simpleif,516 Programming in Python 3- a complete introduction to the Python language,"if not line: continue",simpleif,519 Programming in Python 3- a complete introduction to the Python language,if state == WANT_INFO:,simpleif,519 Programming in Python 3- a complete introduction to the Python language,if info:,simpleif,519 Programming in Python 3- a complete introduction to the Python language,if not self.pos < len(self.text):,simpleif,526 Programming in Python 3- a complete introduction to the Python language,if self.text[self.pos] in characters:,simpleif,526 Programming in Python 3- a complete introduction to the Python language,if not name and color is None:,simpleif,528 Programming in Python 3- a complete introduction to the Python language,"if isinstance(item, Block.Block):",simpleif,542 Programming in Python 3- a complete introduction to the Python language,"if isinstance(item, list) and item:",simpleif,542 Programming in Python 3- a complete introduction to the Python language,"if isinstance(item, int): if item == EmptyBlock:",simpleif,542 Programming in Python 3- a complete introduction to the Python language,if lowercase_keys:,simpleif,551 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""KEY"":",simpleif,553 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""VALUE"":",simpleif,553 Programming in Python 3- a complete introduction to the Python language,if key is None:,simpleif,553 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""SECONDS"":",simpleif,555 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""TITLE"":",simpleif,555 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""FILENAME"":",simpleif,555 Programming in Python 3- a complete introduction to the Python language,if title is not None and seconds is not None:,simpleif,555 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""NODE_START"":",simpleif,556 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""NODE_END"":",simpleif,556 Programming in Python 3- a complete introduction to the Python language,if brackets < 0:,simpleif,556 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""COLOR"":",simpleif,557 Programming in Python 3- a complete introduction to the Python language,if block is None or Block.is_new_row(block):,simpleif,557 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""NAME"":",simpleif,557 Programming in Python 3- a complete introduction to the Python language,if block is None or Block.is_new_row(block):,simpleif,557 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""EMPTY_NODE"":",simpleif,557 Programming in Python 3- a complete introduction to the Python language,"if token.type == ""NEW_ROWS"":",simpleif,557 Programming in Python 3- a complete introduction to the Python language,if brackets:,simpleif,557 Programming in Python 3- a complete introduction to the Python language,if p is None:,simpleif,561 Programming in Python 3- a complete introduction to the Python language,"if sys.platform.startswith(""win""):",simpleif,573 Programming in Python 3- a complete introduction to the Python language,if label is None:,simpleif,576 Programming in Python 3- a complete introduction to the Python language,if not self.okayToContinue():,simpleif,579 Programming in Python 3- a complete introduction to the Python language,if not self.dirty:,simpleif,580 Programming in Python 3- a complete introduction to the Python language,"if reply is None: return False",simpleif,580 Programming in Python 3- a complete introduction to the Python language,if reply:,simpleif,580 Programming in Python 3- a complete introduction to the Python language,if self.filename is None:,simpleif,581 Programming in Python 3- a complete introduction to the Python language,"if not filename: return False",simpleif,581 Programming in Python 3- a complete introduction to the Python language,"if not self.filename.endswith("".bmf""):",simpleif,581 Programming in Python 3- a complete introduction to the Python language,if not self.okayToContinue():,simpleif,582 Programming in Python 3- a complete introduction to the Python language,if filename:,simpleif,582 Programming in Python 3- a complete introduction to the Python language,"if self.okayToContinue(): self.parent.destroy()",simpleif,583 Programming in Python 3- a complete introduction to the Python language,if form.accepted and form.name:,simpleif,583 Programming in Python 3- a complete introduction to the Python language,if not indexes or len(indexes) > 1:,simpleif,584 Programming in Python 3- a complete introduction to the Python language,if form.accepted and form.name:,simpleif,584 Programming in Python 3- a complete introduction to the Python language,if form.name != name:,simpleif,584 Programming in Python 3- a complete introduction to the Python language,if not indexes or len(indexes) > 1:,simpleif,584 Programming in Python 3- a complete introduction to the Python language,if not indexes or len(indexes) > 1:,simpleif,585 Programming in Python 3- a complete introduction to the Python language,"if sys.platform.startswith(""win""):",simpleif,585 Programming in Python 3- a complete introduction to the Python language,if name is not None:,simpleif,586 Programming in Python 3- a complete introduction to the Python language,"print(""Hello"", ""World!"")",printfunc,9 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,9 Programming in Python 3- a complete introduction to the Python language,"print() function. For one thing, print()",printfunc,10 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,10 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,10 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,12 Programming in Python 3- a complete introduction to the Python language,"print(route, type(route))",printfunc,17 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,17 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,17 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,18 Programming in Python 3- a complete introduction to the Python language,"print(""x is nonzero"")",printfunc,26 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,26 Programming in Python 3- a complete introduction to the Python language,"print(""small"")",printfunc,26 Programming in Python 3- a complete introduction to the Python language,"print(""large"")",printfunc,26 Programming in Python 3- a complete introduction to the Python language,print(country),printfunc,27 Programming in Python 3- a complete introduction to the Python language,print(country),printfunc,27 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,28 Programming in Python 3- a complete introduction to the Python language,print(countries),printfunc,28 Programming in Python 3- a complete introduction to the Python language,"print(letter, ""is a vowel"")",printfunc,28 Programming in Python 3- a complete introduction to the Python language,"print(letter, ""is a consonant"")",printfunc,28 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,29 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,32 Programming in Python 3- a complete introduction to the Python language,"print(""Type integers, each followed by Enter; or just Enter to finish"")",printfunc,33 Programming in Python 3- a complete introduction to the Python language,"print(""count ="", count, ""total ="", total, ""mean ="", total / count)",printfunc,33 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,34 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,34 Programming in Python 3- a complete introduction to the Python language,"print(""Type integers, each followed by Enter; or ^D or ^Z to finish"")",printfunc,34 Programming in Python 3- a complete introduction to the Python language,"print(""count ="", count, ""total ="", total, ""mean ="", total / count)",printfunc,34 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,36 Programming in Python 3- a complete introduction to the Python language,print(sys.argv),printfunc,37 Programming in Python 3- a complete introduction to the Python language,"print(err, ""in"", digits)",printfunc,40 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,42 Programming in Python 3- a complete introduction to the Python language,print(line),printfunc,43 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,45 Programming in Python 3- a complete introduction to the Python language,"print(""Hello"")",printfunc,51 Programming in Python 3- a complete introduction to the Python language,print(23 / 1.05),printfunc,62 Programming in Python 3- a complete introduction to the Python language,"print(decimal.Decimal(23) / decimal.Decimal(""1.05""))",printfunc,62 Programming in Python 3- a complete introduction to the Python language,print() on the result of decimal.Decimal(23),printfunc,63 Programming in Python 3- a complete introduction to the Python language,print(euros),printfunc,65 Programming in Python 3- a complete introduction to the Python language,print(s),printfunc,70 Programming in Python 3- a complete introduction to the Python language,print(s),printfunc,70 Programming in Python 3- a complete introduction to the Python language,"print(filename, ""is a JPEG image"")",printfunc,74 Programming in Python 3- a complete introduction to the Python language,"print(""lived about"", int(died[0]) - int(born[0]), ""years"")",printfunc,75 Programming in Python 3- a complete introduction to the Python language,"print(""20749"".translate(table))",printfunc,76 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,76 Programming in Python 3- a complete introduction to the Python language,"print(decimal.Decimal(""3.4084""))",printfunc,80 Programming in Python 3- a complete introduction to the Python language,"print(""usage: {0} [string]"".format(sys.argv[0]))",printfunc,87 Programming in Python 3- a complete introduction to the Python language,"print(""usage: {0[0]} [string]"".format(sys.argv))",printfunc,88 Programming in Python 3- a complete introduction to the Python language,"print(""------- ----- --- {0:-<40}"".format(""""))",printfunc,88 Programming in Python 3- a complete introduction to the Python language,"print(""------- ----- --- {0}"".format(""-"" * 40))",printfunc,88 Programming in Python 3- a complete introduction to the Python language,"print(b""Tage \xc3\x85s\xc3\xa9n"".decode(""utf8""))",printfunc,91 Programming in Python 3- a complete introduction to the Python language,"print(b""Tage \xc5s\xe9n"".decode(""latin1""))",printfunc,92 Programming in Python 3- a complete introduction to the Python language,"print(""zero is not allowed"")",printfunc,93 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,94 Programming in Python 3- a complete introduction to the Python language,"print(""ax\N{SUPERSCRIPT TWO} + bx + c = 0"")",printfunc,94 Programming in Python 3- a complete introduction to the Python language,print(equation),printfunc,94 Programming in Python 3- a complete introduction to the Python language,"print(""<table border='1'>"")",printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(""</table>"")",printfunc,98 Programming in Python 3- a complete introduction to the Python language,print() function calls in main(),printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(""<tr bgcolor='{0}'>"".format(color))",printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(""<td></td>"")",printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(""<td>{0}</td>"".format(field))",printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(""</tr>"")",printfunc,98 Programming in Python 3- a complete introduction to the Python language,"print(x, y)",printfunc,106 Programming in Python 3- a complete introduction to the Python language,"print(math.hypot(x, y))",printfunc,108 Programming in Python 3- a complete introduction to the Python language,"print(""Total ${0:.2f}"".format(total))",printfunc,109 Programming in Python 3- a complete introduction to the Python language,"print(""{0} {1}"".format(aircraft.manufacturer, aircraft.model))",printfunc,109 Programming in Python 3- a complete introduction to the Python language,"print(item[0], item[1])",printfunc,125 Programming in Python 3- a complete introduction to the Python language,"print(key, value)",printfunc,125 Programming in Python 3- a complete introduction to the Python language,print(value),printfunc,125 Programming in Python 3- a complete introduction to the Python language,print(key),printfunc,125 Programming in Python 3- a complete introduction to the Python language,print(key),printfunc,125 Programming in Python 3- a complete introduction to the Python language,"print(""'{0}' occurs {1} times"".format(word, words[word]))",printfunc,127 Programming in Python 3- a complete introduction to the Python language,"print(""{0} is referred to in:"".format(site))",printfunc,130 Programming in Python 3- a complete introduction to the Python language,"print(""{green} {olive} {lime}"".format(**greens))",printfunc,131 Programming in Python 3- a complete introduction to the Python language,print(product),printfunc,136 Programming in Python 3- a complete introduction to the Python language,print(product),printfunc,136 Programming in Python 3- a complete introduction to the Python language,"print(""usage: grepword.py word infile1 [infile2 [... infileN]]"")",printfunc,137 Programming in Python 3- a complete introduction to the Python language,print(t),printfunc,140 Programming in Python 3- a complete introduction to the Python language,"print(""{0:.<{nw}} ({1.id:4})",printfunc,149 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,149 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,149 Programming in Python 3- a complete introduction to the Python language,"print(""no numbers found"")",printfunc,150 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,155 Programming in Python 3- a complete introduction to the Python language,"print(""{0} file{1}"".format((count if count != 0 else ""no"")",printfunc,158 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,164 Programming in Python 3- a complete introduction to the Python language,"print(""found at ({0}, {1}, {2})"".format(row, column, index))",printfunc,165 Programming in Python 3- a complete introduction to the Python language,"print(""not found"")",printfunc,165 Programming in Python 3- a complete introduction to the Python language,"print(""not found"")",printfunc,165 Programming in Python 3- a complete introduction to the Python language,print() call to raise),printfunc,167 Programming in Python 3- a complete introduction to the Python language,"print(""ERROR unexpected EOF:"", err)",printfunc,168 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,168 Programming in Python 3- a complete introduction to the Python language,"print(""SSN ="", ssn)",printfunc,176 Programming in Python 3- a complete introduction to the Python language,"print(""positional argument {0} = {1}"".format(i, arg))",printfunc,177 Programming in Python 3- a complete introduction to the Python language,"print(""keyword argument {0} = {1}"".format(key, kwargs[key]))",printfunc,177 Programming in Python 3- a complete introduction to the Python language,"print(dictionary[int(digit)], end="" "")",printfunc,177 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,177 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,177 Programming in Python 3- a complete introduction to the Python language,print() Function” (® 181),printfunc,177 Programming in Python 3- a complete introduction to the Python language,"print(""{0} file{1} processed"".format(count, s(count)))",printfunc,179 Programming in Python 3- a complete introduction to the Python language,"print(""Cancelled"")",printfunc,184 Programming in Python 3- a complete introduction to the Python language,"print(""ERROR"", err)",printfunc,187 Programming in Python 3- a complete introduction to the Python language,print(os.path.basename(filename)),printfunc,194 Programming in Python 3- a complete introduction to the Python language,print(path.basename(filename)),printfunc,194 Programming in Python 3- a complete introduction to the Python language,print(path.basename(filename)),printfunc,194 Programming in Python 3- a complete introduction to the Python language,print(basename(filename)),printfunc,194 Programming in Python 3- a complete introduction to the Python language,print(basename(filename)),printfunc,194 Programming in Python 3- a complete introduction to the Python language,"print(""An error message"", file=sys.stdout)",printfunc,210 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,211 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,211 Programming in Python 3- a complete introduction to the Python language,"print(x, end="" "")",printfunc,216 Programming in Python 3- a complete introduction to the Python language,print(message),printfunc,219 Programming in Python 3- a complete introduction to the Python language,"print(""{filename} ({size} bytes)",printfunc,222 Programming in Python 3- a complete introduction to the Python language,"print(""\t{0}"".format(name))",printfunc,222 Programming in Python 3- a complete introduction to the Python language,"print(""stock movement failed for"", bike.identity)",printfunc,330 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,346 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,352 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,367 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,412 Programming in Python 3- a complete introduction to the Python language,print() with str.format(),printfunc,412 Programming in Python 3- a complete introduction to the Python language,"print(datetime.datetime.strptime(date, format))",printfunc,415 Programming in Python 3- a complete introduction to the Python language,print(process(line)),printfunc,417 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,419 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,419 Programming in Python 3- a complete introduction to the Python language,"print() statements, we can start by putting a print()",printfunc,419 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,419 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,419 Programming in Python 3- a complete introduction to the Python language,"print(locals(), ""\n"")",printfunc,420 Programming in Python 3- a complete introduction to the Python language,"print(locals(), ""\n"")",printfunc,420 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,420 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,421 Programming in Python 3- a complete introduction to the Python language,print(runner.run(suite)),printfunc,425 Programming in Python 3- a complete introduction to the Python language,print(runner.run(suite)),printfunc,427 Programming in Python 3- a complete introduction to the Python language,"print(""{function}() {sec:.6f} sec"".format(**locals()))",printfunc,430 Programming in Python 3- a complete introduction to the Python language,print() statement since by default the cProfile.run(),printfunc,431 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,434 Programming in Python 3- a complete introduction to the Python language,"print(""{0}{1}"".format(number, err))",printfunc,440 Programming in Python 3- a complete introduction to the Python language,print(data[0]),printfunc,457 Programming in Python 3- a complete introduction to the Python language,print(data[0]),printfunc,458 Programming in Python 3- a complete introduction to the Python language,"print(""Mileage successfully changed"")",printfunc,458 Programming in Python 3- a complete introduction to the Python language,"print(""{0}: is the server running?"".format(err))",printfunc,459 Programming in Python 3- a complete introduction to the Python language,"print(""Loaded {0} car registrations"".format(len(cars)))",printfunc,462 Programming in Python 3- a complete introduction to the Python language,"print(""Saved {0} car registrations"".format(len(cars)))",printfunc,462 Programming in Python 3- a complete introduction to the Python language,"print(""server cannot load data: {0}"".format(err))",printfunc,462 Programming in Python 3- a complete introduction to the Python language,"print(""{0}: {1}"".format(i + 1, match))",printfunc,474 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,475 Programming in Python 3- a complete introduction to the Python language,"print(""{title} ({year})",printfunc,475 Programming in Python 3- a complete introduction to the Python language,"print(""{0}: {1}"".format(i + 1, record[0]))",printfunc,481 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,482 Programming in Python 3- a complete introduction to the Python language,"print(""{0[0]} ({0[1]})",printfunc,482 Programming in Python 3- a complete introduction to the Python language,"print(""{0} is duplicated"".format(match.group(""word"")))",printfunc,496 Programming in Python 3- a complete introduction to the Python language,"print(""This is not a .m3u file"")",printfunc,518 Programming in Python 3- a complete introduction to the Python language,"print(""parse error: {0}"".format(err))",printfunc,535 Programming in Python 3- a complete introduction to the Python language,"print(""parse error: {0}"".format(err))",printfunc,537 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,562 Programming in Python 3- a complete introduction to the Python language,print(err),printfunc,577 Programming in Python 3- a complete introduction to the Python language,print(),printfunc,597 Programming in Python 3- a complete introduction to the Python language,print() (built-in),printfunc,615 Programming in Python 3- a complete introduction to the Python language,"p = (4, ""frog"", 9, -33, 9, 2)",simpleTuple,23 Programming in Python 3- a complete introduction to the Python language,"x, y = (1234567890, 1234.56)",simpleTuple,85 Programming in Python 3- a complete introduction to the Python language,"a, b = (1, 2)",simpleTuple,106 Programming in Python 3- a complete introduction to the Python language,"eyes = (""brown"", ""hazel"", ""amber"", ""green"", ""blue"", ""gray"")",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"colors = (hair, eyes)",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"things = (1, -7.5, (""pea"", (5, ""Xyz""), ""queue""))",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"MANUFACTURER, MODEL, SEATING = (0, 1, 2)",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"MINIMUM, MAXIMUM = (0, 1)",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"aircraft = (""Airbus"", ""A320-200"", (100, 220))",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"a, b = (b, a)",simpleTuple,107 Programming in Python 3- a complete introduction to the Python language,"t = (1, 2, 3, 4)",simpleTuple,139 Programming in Python 3- a complete introduction to the Python language,"args == (1, 2, 3, 4)",simpleTuple,175 Programming in Python 3- a complete introduction to the Python language,"args == (5, 3, 8)",simpleTuple,175 Programming in Python 3- a complete introduction to the Python language,"args == (11,)",simpleTuple,175 Programming in Python 3- a complete introduction to the Python language,"key = (os.path.getsize(fullname), filename)",simpleTuple,221 Programming in Python 3- a complete introduction to the Python language,"circle = (11, 60, 8)",simpleTuple,231 Programming in Python 3- a complete introduction to the Python language,"join=(\"" and\"" if len(args) == 1 else \"",\"")",simpleTuple,257 Programming in Python 3- a complete introduction to the Python language,"join=("" and"" if len(args) == 1 else "","")",simpleTuple,258 Programming in Python 3- a complete introduction to the Python language,"items = struct.unpack(""<2h"", data) # items == (11, -9)",simpleTuple,294 Programming in Python 3- a complete introduction to the Python language,"items == (11, -9)",simpleTuple,294 Programming in Python 3- a complete introduction to the Python language,"matchers = (regex_matcher(receiver, URL_RE)",simpleTuple,398 Programming in Python 3- a complete introduction to the Python language,"GET_CAR_DETAILS=( lambda self, *args: self.get_car_details(*args))",simpleTuple,464 Programming in Python 3- a complete introduction to the Python language,"CHANGE_MILEAGE=( lambda self, *args: self.change_mileage(*args))",simpleTuple,464 Programming in Python 3- a complete introduction to the Python language,"CHANGE_OWNER=( lambda self, *args: self.change_owner(*args))",simpleTuple,464 Programming in Python 3- a complete introduction to the Python language,"NEW_REGISTRATION=( lambda self, *args: self.new_registration(*args))",simpleTuple,464 Programming in Python 3- a complete introduction to the Python language,"db[title] = (director, year, duration)",simpleTuple,473 Programming in Python 3- a complete introduction to the Python language,"db[title] = (director, year, duration)",simpleTuple,473 Programming in Python 3- a complete introduction to the Python language,"by a literal = (i.e., a terminal)",simpleTuple,511 Programming in Python 3- a complete introduction to the Python language,"color = (Word(""#"", hexnums, exact=7)",simpleTuple,538 Programming in Python 3- a complete introduction to the Python language,"tokens = (""INI_HEADER"", ""COMMENT"", ""KEY"", ""VALUE"")",simpleTuple,551 Programming in Python 3- a complete introduction to the Python language,"tokens = (""M3U"", ""INFO"", ""SECONDS"", ""TITLE"", ""FILENAME"")",simpleTuple,553 Programming in Python 3- a complete introduction to the Python language,"states = ((""entry"", ""exclusive""), (""filename"", ""exclusive""))",simpleTuple,554 Programming in Python 3- a complete introduction to the Python language,"precedence = ((""nonassoc"", ""FORALL"", ""EXISTS"")",simpleTuple,561 Programming in Python 3- a complete introduction to the Python language,"x = [""zebra"", 49, -879, ""aardvark"", 200]",simpleList,19 Programming in Python 3- a complete introduction to the Python language,"a = [""Retention"", 3, None]",simpleList,21 Programming in Python 3- a complete introduction to the Python language,"b = [""Retention"", 3, None]",simpleList,21 Programming in Python 3- a complete introduction to the Python language,"countries = [""Denmark"", ""Finland"", ""Norway"", ""Sweden""]",simpleList,27 Programming in Python 3- a complete introduction to the Python language,seeds += [5],simpleList,32 Programming in Python 3- a complete introduction to the Python language,"seeds += [9, 1, 5, ""poppy""]",simpleList,32 Programming in Python 3- a complete introduction to the Python language,"seeds = [""sesame"", ""sunflower"", ""pumpkin""]",simpleList,32 Programming in Python 3- a complete introduction to the Python language,"One = ["" * "", ""** "", "" * "", "" * "", "" * "", "" * "", ""***""]",simpleList,39 Programming in Python 3- a complete introduction to the Python language,"Digits = [Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine]",simpleList,39 Programming in Python 3- a complete introduction to the Python language,"how to create tuples and lists from literals, for example, even = [2, 4, 6, 8]",simpleList,44 Programming in Python 3- a complete introduction to the Python language,"treatises = [""Arithmetica"", ""Conics"", ""Elements""]",simpleList,70 Programming in Python 3- a complete introduction to the Python language,"stock = [""paper"", ""envelopes"", ""notepads"", ""pens"", ""paper clips""]",simpleList,78 Programming in Python 3- a complete introduction to the Python language,fields = [],simpleList,99 Programming in Python 3- a complete introduction to the Python language,sales = [],simpleList,108 Programming in Python 3- a complete introduction to the Python language,"first, *rest = [9, 2, -4, 8, 7]",simpleList,111 Programming in Python 3- a complete introduction to the Python language,"L = [2, 3, 5]",simpleList,111 Programming in Python 3- a complete introduction to the Python language,"using either slicing or one of the list methods. For example, given the list woods = [""Cedar"", ""Yew"", ""Fir""]",simpleList,113 Programming in Python 3- a complete introduction to the Python language,"woods += [""Kauri"", ""Larch""]",simpleList,113 Programming in Python 3- a complete introduction to the Python language,"woods[2:2] = [""Pine""]",simpleList,114 Programming in Python 3- a complete introduction to the Python language,"of it with the code L[2:5] = [""X"", ""Y""]",simpleList,114 Programming in Python 3- a complete introduction to the Python language,woods[2:4] = [],simpleList,114 Programming in Python 3- a complete introduction to the Python language,"we have the list, x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",simpleList,114 Programming in Python 3- a complete introduction to the Python language,Here is the complete solution: x[1::2] = [0] * len(x[1::2],simpleList,115 Programming in Python 3- a complete introduction to the Python language,leaps = [],simpleList,115 Programming in Python 3- a complete introduction to the Python language,"example, leaps = [1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, 1936]",simpleList,116 Programming in Python 3- a complete introduction to the Python language,temp = [],simpleList,116 Programming in Python 3- a complete introduction to the Python language,codes = [],simpleList,117 Programming in Python 3- a complete introduction to the Python language,"x = [-2, 9, 7, -4, 3]",simpleList,136 Programming in Python 3- a complete introduction to the Python language,forenames = [],simpleList,139 Programming in Python 3- a complete introduction to the Python language,surnames = [],simpleList,139 Programming in Python 3- a complete introduction to the Python language,x = [],simpleList,141 Programming in Python 3- a complete introduction to the Python language,temp = [],simpleList,142 Programming in Python 3- a complete introduction to the Python language,x = [],simpleList,142 Programming in Python 3- a complete introduction to the Python language,"songs = [""Because"", ""Boys"", ""Carol""]",simpleList,144 Programming in Python 3- a complete introduction to the Python language,"songs = [""Because"", ""Boys"", ""Carol""]",simpleList,144 Programming in Python 3- a complete introduction to the Python language,"mode = [5.00, 7.00, 50.00]",simpleList,149 Programming in Python 3- a complete introduction to the Python language,numbers = [],simpleList,150 Programming in Python 3- a complete introduction to the Python language,"elements = [(2, 12, ""Mg""), (1, 11, ""Na""), (1, 3, ""Li""), (2, 4, ""Be"")]",simpleList,179 Programming in Python 3- a complete introduction to the Python language,"__all__ = [""Bmp"", ""Jpeg"", ""Png"", ""Tiff"", ""Xpm""]",simpleList,197 Programming in Python 3- a complete introduction to the Python language,result = [],simpleList,201 Programming in Python 3- a complete introduction to the Python language,_grid = [],simpleList,206 Programming in Python 3- a complete introduction to the Python language,_grid = [],simpleList,207 Programming in Python 3- a complete introduction to the Python language,heap = [],simpleList,216 Programming in Python 3- a complete introduction to the Python language,stations = [],simpleList,225 Programming in Python 3- a complete introduction to the Python language,"circle = [36, 77, 8]",simpleList,232 Programming in Python 3- a complete introduction to the Python language,result = [],simpleList,276 Programming in Python 3- a complete introduction to the Python language,items = [],simpleList,278 Programming in Python 3- a complete introduction to the Python language,text = [],simpleList,315 Programming in Python 3- a complete introduction to the Python language,result = [],simpleList,340 Programming in Python 3- a complete introduction to the Python language,get_file_type_functions = [],simpleList,343 Programming in Python 3- a complete introduction to the Python language,modules = [],simpleList,344 Programming in Python 3- a complete introduction to the Python language,entries = [],simpleList,350 Programming in Python 3- a complete introduction to the Python language,indented_list = [],simpleList,350 Programming in Python 3- a complete introduction to the Python language,values = [],simpleList,365 Programming in Python 3- a complete introduction to the Python language,data = [],simpleList,386 Programming in Python 3- a complete introduction to the Python language,result = [],simpleList,423 Programming in Python 3- a complete introduction to the Python language,t]*(\w+)[ \t]*=[ \t],simpleList,491 Programming in Python 3- a complete introduction to the Python language,t]*=[ \t],simpleList,492 Programming in Python 3- a complete introduction to the Python language,image_files = [],simpleList,497 Programming in Python 3- a complete introduction to the Python language,new_names = [],simpleList,501 Programming in Python 3- a complete introduction to the Python language,NAME ::= [a-zA-Z],simpleList,511 Programming in Python 3- a complete introduction to the Python language,NAME ::= [a-zA-Z],simpleList,511 Programming in Python 3- a complete introduction to the Python language,TITLE ::= [^\n],simpleList,518 Programming in Python 3- a complete introduction to the Python language,FILENAME ::= [^\n],simpleList,518 Programming in Python 3- a complete introduction to the Python language,songs = [],simpleList,518 Programming in Python 3- a complete introduction to the Python language,NAME ::= [^][/],simpleList,522 Programming in Python 3- a complete introduction to the Python language,VARIABLE ::= [a-zA-Z],simpleList,532 Programming in Python 3- a complete introduction to the Python language,songs = [],simpleList,536 Programming in Python 3- a complete introduction to the Python language,stack = [Block.get_root_block()],simpleList,540 Programming in Python 3- a complete introduction to the Python language,SYMBOL ::= [a-zA-Z],simpleList,544 Programming in Python 3- a complete introduction to the Python language,songs = [],simpleList,555 Programming in Python 3- a complete introduction to the Python language,stack = [Block.get_root_block()],simpleList,556 Programming in Python 3- a complete introduction to the Python language,"filetypes=[(""Bookmarks files"", ""*.bmf"")]",simpleList,581 Programming in Python 3- a complete introduction to the Python language,"filetypes=[(""Bookmarks files"", ""*.bmf"")]",simpleList,582 Programming in Python 3- a complete introduction to the Python language,for country in countries:,forsimple,27 Programming in Python 3- a complete introduction to the Python language,for field in fields:,forsimple,98 Programming in Python 3- a complete introduction to the Python language,for c in line:,forsimple,99 Programming in Python 3- a complete introduction to the Python language,for sale in sales:,forsimple,109 Programming in Python 3- a complete introduction to the Python language,for item in L:,forsimple,112 Programming in Python 3- a complete introduction to the Python language,for i in range(len(L)):,forsimple,112 Programming in Python 3- a complete introduction to the Python language,for i in range(len(numbers)):,forsimple,113 Programming in Python 3- a complete introduction to the Python language,"for year in range(1900, 1940):",forsimple,115 Programming in Python 3- a complete introduction to the Python language,for item in iterable:,forsimple,116 Programming in Python 3- a complete introduction to the Python language,for ip in ips:,forsimple,121 Programming in Python 3- a complete introduction to the Python language,for ip in set(ips):,forsimple,121 Programming in Python 3- a complete introduction to the Python language,for ip in sorted(set(ips)):,forsimple,121 Programming in Python 3- a complete introduction to the Python language,for item in d.items():,forsimple,125 Programming in Python 3- a complete introduction to the Python language,"for key, value in d.items():",forsimple,125 Programming in Python 3- a complete introduction to the Python language,for value in d.values():,forsimple,125 Programming in Python 3- a complete introduction to the Python language,for key in d:,forsimple,125 Programming in Python 3- a complete introduction to the Python language,for key in d.keys():,forsimple,125 Programming in Python 3- a complete introduction to the Python language,for key in d:,forsimple,125 Programming in Python 3- a complete introduction to the Python language,for filename in sys.argv[1:]:,forsimple,127 Programming in Python 3- a complete introduction to the Python language,for word in line.lower().split():,forsimple,127 Programming in Python 3- a complete introduction to the Python language,for word in sorted(words):,forsimple,127 Programming in Python 3- a complete introduction to the Python language,for filename in sys.argv[1:]:,forsimple,129 Programming in Python 3- a complete introduction to the Python language,for site in sorted(sites):,forsimple,130 Programming in Python 3- a complete introduction to the Python language,"for filename in sorted(sites[site], key=str.lower):",forsimple,130 Programming in Python 3- a complete introduction to the Python language,for filename in sys.argv[2:]:,forsimple,137 Programming in Python 3- a complete introduction to the Python language,for i in range(len(x)):,forsimple,138 Programming in Python 3- a complete introduction to the Python language,for i in range(100):,forsimple,139 Programming in Python 3- a complete introduction to the Python language,"for t in zip(range(4), range(0, 10, 2), range(1, 10, 2)):",forsimple,140 Programming in Python 3- a complete introduction to the Python language,"for t in zip(range(-10, 0, 1), range(0, 10, 2), range(1, 10, 2)):",forsimple,141 Programming in Python 3- a complete introduction to the Python language,for item in x:,forsimple,142 Programming in Python 3- a complete introduction to the Python language,"for key, value in sorted(temp):",forsimple,142 Programming in Python 3- a complete introduction to the Python language,for filename in sys.argv[1:]:,forsimple,147 Programming in Python 3- a complete introduction to the Python language,for key in sorted(users):,forsimple,149 Programming in Python 3- a complete introduction to the Python language,for filename in sys.argv[1:]:,forsimple,150 Programming in Python 3- a complete introduction to the Python language,for x in line.split():,forsimple,150 Programming in Python 3- a complete introduction to the Python language,for number in numbers:,forsimple,152 Programming in Python 3- a complete introduction to the Python language,"for index, x in enumerate(lst):",forsimple,159 Programming in Python 3- a complete introduction to the Python language,"for row, record in enumerate(table):",forsimple,165 Programming in Python 3- a complete introduction to the Python language,for char in text:,forsimple,171 Programming in Python 3- a complete introduction to the Python language,for arg in args:,forsimple,175 Programming in Python 3- a complete introduction to the Python language,for arg in args:,forsimple,175 Programming in Python 3- a complete introduction to the Python language,for key in sorted(kwargs):,forsimple,176 Programming in Python 3- a complete introduction to the Python language,"for i, arg in enumerate(args):",forsimple,177 Programming in Python 3- a complete introduction to the Python language,for key in kwargs:,forsimple,177 Programming in Python 3- a complete introduction to the Python language,for digit in digits:,forsimple,177 Programming in Python 3- a complete introduction to the Python language,for arg in args:,forsimple,181 Programming in Python 3- a complete introduction to the Python language,for arg in args:,forsimple,181 Programming in Python 3- a complete introduction to the Python language,for char in text:,forsimple,201 Programming in Python 3- a complete introduction to the Python language,"for left, right in zip(brackets[::2], brackets[1::2]):",forsimple,201 Programming in Python 3- a complete introduction to the Python language,for c in text:,forsimple,201 Programming in Python 3- a complete introduction to the Python language,for row in range(_max_rows):,forsimple,207 Programming in Python 3- a complete introduction to the Python language,for column in range(_max_columns):,forsimple,207 Programming in Python 3- a complete introduction to the Python language,"for x in heapq.merge([1, 3, 5, 8], [2, 4, 7], [0, 1, 6, 8, 9]):",forsimple,216 Programming in Python 3- a complete introduction to the Python language,"for i, c in enumerate(base64.b64encode(binary)):",forsimple,217 Programming in Python 3- a complete introduction to the Python language,for name in os.listdir(path):,forsimple,221 Programming in Python 3- a complete introduction to the Python language,"for root, dirs, files in os.walk(path):",forsimple,221 Programming in Python 3- a complete introduction to the Python language,for filename in files:,forsimple,221 Programming in Python 3- a complete introduction to the Python language,"for size, filename in sorted(data):",forsimple,222 Programming in Python 3- a complete introduction to the Python language,for name in names:,forsimple,222 Programming in Python 3- a complete introduction to the Python language,"for element in tree.getiterator(""station_name""):",forsimple,225 Programming in Python 3- a complete introduction to the Python language,for x in range(width):,forsimple,259 Programming in Python 3- a complete introduction to the Python language,for y in range(height):,forsimple,259 Programming in Python 3- a complete introduction to the Python language,for x in y:,forsimple,262 Programming in Python 3- a complete introduction to the Python language,"for key, value in dictionary.items():",forsimple,274 Programming in Python 3- a complete introduction to the Python language,"for example, for letter in letter_range(""m"", ""v""):",forsimple,276 Programming in Python 3- a complete introduction to the Python language,for key in self.__keys:,forsimple,277 Programming in Python 3- a complete introduction to the Python language,for key in self.__keys:,forsimple,277 Programming in Python 3- a complete introduction to the Python language,"for key, value in self.items():",forsimple,278 Programming in Python 3- a complete introduction to the Python language,for report_id in self.keys():,forsimple,288 Programming in Python 3- a complete introduction to the Python language,for report_id in self.keys():,forsimple,288 Programming in Python 3- a complete introduction to the Python language,for report_id in sorted(super().keys()):,forsimple,288 Programming in Python 3- a complete introduction to the Python language,for incident in self.values():,forsimple,295 Programming in Python 3- a complete introduction to the Python language,for incident in self.values():,forsimple,303 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(fh, start=1):",forsimple,304 Programming in Python 3- a complete introduction to the Python language,for match in key_value_re.finditer(keyvalues):,forsimple,308 Programming in Python 3- a complete introduction to the Python language,for incident in self.values():,forsimple,310 Programming in Python 3- a complete introduction to the Python language,for incident in self.values():,forsimple,313 Programming in Python 3- a complete introduction to the Python language,for node in node_list:,forsimple,315 Programming in Python 3- a complete introduction to the Python language,for writing out the incidents in XML:,forsimple,316 Programming in Python 3- a complete introduction to the Python language,for incident in self.values():,forsimple,317 Programming in Python 3- a complete introduction to the Python language,"for key, value in attributes.items():",forsimple,319 Programming in Python 3- a complete introduction to the Python language,"for index in range(len(self) - 1, 0, -1):",forsimple,328 Programming in Python 3- a complete introduction to the Python language,for bike in bicycles:,forsimple,329 Programming in Python 3- a complete introduction to the Python language,for bike in bicycles:,forsimple,329 Programming in Python 3- a complete introduction to the Python language,for index in range(len(self.__file)):,forsimple,330 Programming in Python 3- a complete introduction to the Python language,for index in range(len(self.__file)):,forsimple,332 Programming in Python 3- a complete introduction to the Python language,for module in modules:,forsimple,343 Programming in Python 3- a complete introduction to the Python language,for file in get_files(sys.argv[1:]):,forsimple,344 Programming in Python 3- a complete introduction to the Python language,"for name in os.listdir(os.path.dirname(__file__) or "".""):",forsimple,344 Programming in Python 3- a complete introduction to the Python language,for item in indented_list:,forsimple,350 Programming in Python 3- a complete introduction to the Python language,for entry in sorted(entries):,forsimple,350 Programming in Python 3- a complete introduction to the Python language,for subentry in sorted(entry[CHILDREN]):,forsimple,353 Programming in Python 3- a complete introduction to the Python language,for c in s:,forsimple,358 Programming in Python 3- a complete introduction to the Python language,for arg in arg_spec.args + arg_spec.kwonlyargs:,forsimple,358 Programming in Python 3- a complete introduction to the Python language,for attribute_name in self.attribute_names:,forsimple,365 Programming in Python 3- a complete introduction to the Python language,for line in fh:,forsimple,367 Programming in Python 3- a complete introduction to the Python language,for name in method_names:,forsimple,375 Programming in Python 3- a complete introduction to the Python language,for c in text:,forsimple,382 Programming in Python 3- a complete introduction to the Python language,for name in attribute_names:,forsimple,385 Programming in Python 3- a complete introduction to the Python language,for name in self.__attribute_names:,forsimple,386 Programming in Python 3- a complete introduction to the Python language,"for name, value in zip(self.__attribute_names, data):",forsimple,386 Programming in Python 3- a complete introduction to the Python language,"for value in itertools.chain(data_list1, data_list2, data_list3):",forsimple,394 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate1(lines):",forsimple,395 Programming in Python 3- a complete introduction to the Python language,for matcher in matchers:,forsimple,399 Programming in Python 3- a complete introduction to the Python language,for arg in sys.argv[1:]:,forsimple,402 Programming in Python 3- a complete introduction to the Python language,"for root, dirs, files in os.walk(path):",forsimple,403 Programming in Python 3- a complete introduction to the Python language,for filename in files:,forsimple,403 Programming in Python 3- a complete introduction to the Python language,"for i in range(-2, len(string) + 2):",forsimple,423 Programming in Python 3- a complete introduction to the Python language,for i in range(1000):,forsimple,431 Programming in Python 3- a complete introduction to the Python language,for filename in lines[1:]:,forsimple,440 Programming in Python 3- a complete introduction to the Python language,for i in range(opts.count):,forsimple,443 Programming in Python 3- a complete introduction to the Python language,for filename in filelist:,forsimple,443 Programming in Python 3- a complete introduction to the Python language,"for root, dirs, files in os.walk(path):",forsimple,446 Programming in Python 3- a complete introduction to the Python language,for filename in files:,forsimple,446 Programming in Python 3- a complete introduction to the Python language,for i in range(opts.count):,forsimple,447 Programming in Python 3- a complete introduction to the Python language,"for size, filename in sorted(data):",forsimple,447 Programming in Python 3- a complete introduction to the Python language,for filename in filenames:,forsimple,449 Programming in Python 3- a complete introduction to the Python language,for filenames in md5s.values():,forsimple,450 Programming in Python 3- a complete introduction to the Python language,"for i, match in enumerate(matches):",forsimple,474 Programming in Python 3- a complete introduction to the Python language,"for title in sorted(db, key=str.lower):",forsimple,475 Programming in Python 3- a complete introduction to the Python language,"for i, record in enumerate(records):",forsimple,481 Programming in Python 3- a complete introduction to the Python language,for record in cursor:,forsimple,482 Programming in Python 3- a complete introduction to the Python language,for match in double_word_re.finditer(text):,forsimple,496 Programming in Python 3- a complete introduction to the Python language,for match in image_re.finditer(text):,forsimple,497 Programming in Python 3- a complete introduction to the Python language,"for each nonoverlapping match in string s (or in the start:",forsimple,499 Programming in Python 3- a complete introduction to the Python language,for name in names:,forsimple,501 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(file, start=1):",forsimple,516 Programming in Python 3- a complete introduction to the Python language,"for lino, line in enumerate(fh, start=2):",forsimple,519 Programming in Python 3- a complete introduction to the Python language,for x in range(amount):,forsimple,525 Programming in Python 3- a complete introduction to the Python language,for item in items:,forsimple,542 Programming in Python 3- a complete introduction to the Python language,for x in range(item):,forsimple,542 Programming in Python 3- a complete introduction to the Python language,for token in lexer:,forsimple,553 Programming in Python 3- a complete introduction to the Python language,for token in lexer:,forsimple,555 Programming in Python 3- a complete introduction to the Python language,for token in lexer:,forsimple,556 Programming in Python 3- a complete introduction to the Python language,for x in range(len(token.value)):,forsimple,557 Programming in Python 3- a complete introduction to the Python language,"for name in sorted(self.data, key=str.lower):",forsimple,582 Programming in Python 3- a complete introduction to the Python language,"for name in sorted(self.data, key=str.lower):",forsimple,583 Programming in Python 3- a complete introduction to the Python language,"for name in sorted(self.data, key=str.lower):",forsimple,584 Programming in Python 3- a complete introduction to the Python language,"sentially the same as a = a + 8. However, there are two important subtleties here,",assignwithSum,30 Programming in Python 3- a complete introduction to the Python language,"maximum = get_int(""maximum (or Enter for "" + str(default) + ""): "",",assignwithSum,42 Programming in Python 3- a complete introduction to the Python language,"phone1 = re.compile(""^((?:[(]\\d+[)])?\\s*\\d+(?:-\\d+)?)$"")",assignwithSum,64 Programming in Python 3- a complete introduction to the Python language,"phone2 = re.compile(r""^((?:[(]\d+[)])?\s*\d+(?:-\d+)?)$"")",assignwithSum,65 Programming in Python 3- a complete introduction to the Python language,start = i + len(opener),assignwithSum,73 Programming in Python 3- a complete introduction to the Python language,"result = s[:i], s[i], s[i + 1:]",assignwithSum,74 Programming in Python 3- a complete introduction to the Python language,1.5x² + -3.0x + 6.0 = 0 → x = (1+1.7320508j) or x = (1-1.7320508j),assignwithSum,93 Programming in Python 3- a complete introduction to the Python language,"strip = string.whitespace + string.punctuation + string.digits + ""\""'""",assignwithSum,127 Programming in Python 3- a complete introduction to the Python language,"words[word] = words.get(word, 0) + 1",assignwithSum,127 Programming in Python 3- a complete introduction to the Python language,"words[word] = words.get(word, 0) + 1",assignwithSum,129 Programming in Python 3- a complete introduction to the Python language,"words[word] = words.get(word, 0) + 1",assignwithSum,132 Programming in Python 3- a complete introduction to the Python language,text = text[:length - len(indicator)] + indicator,assignwithSum,171 Programming in Python 3- a complete introduction to the Python language,text = text[:length - len(indicator)] + indicator,assignwithSum,174 Programming in Python 3- a complete introduction to the Python language,"UNTRUSTED_PREFIXES = tuple([""/"", ""\\""] +",assignwithSum,218 Programming in Python 3- a complete introduction to the Python language,"q = eval(p.__module__ + ""."" + repr(p))",assignwithSum,240 Programming in Python 3- a complete introduction to the Python language,a = chr(ord(a) + 1),assignwithSum,276 Programming in Python 3- a complete introduction to the Python language,a = chr(ord(a) + 1),assignwithSum,276 Programming in Python 3- a complete introduction to the Python language,p = q + r,assignwithSum,282 Programming in Python 3- a complete introduction to the Python language,"key_value_re = re.compile(r""^\s*(?P<key>[^=]+?)\s*=\s*""",assignwithSum,307 Programming in Python 3- a complete introduction to the Python language,"compactfile = self.__fh.name + "".$$$""",assignwithSum,328 Programming in Python 3- a complete introduction to the Python language,"backupfile = self.__fh.name + "".bak""",assignwithSum,328 Programming in Python 3- a complete introduction to the Python language,"level = level + 1, so level is set to refer to a new integer object. But when we call",assignwithSum,353 Programming in Python 3- a complete introduction to the Python language,"URL_RE = re.compile(r""""""href=(?P<quote>['""])(?P<url>[^\1]+?)""""""",assignwithSum,397 Programming in Python 3- a complete introduction to the Python language,"H1_RE = re.compile(r""<h1>(?P<h1>.+?)</h1>"", flags)",assignwithSum,397 Programming in Python 3- a complete introduction to the Python language,"H2_RE = re.compile(r""<h2>(?P<h2>.+?)</h2>"", flags)",assignwithSum,397 Programming in Python 3- a complete introduction to the Python language,"start, end = 0, files_per_process + (len(filelist) % opts.count)",assignwithSum,437 Programming in Python 3- a complete introduction to the Python language,"regex is (?P=name). For example, (?P<word>\w+)\s+(?P=word) matches duplicate",assignwithSum,492 Programming in Python 3- a complete introduction to the Python language,"double_word_re = re.compile(r""\b(?P<word>\w+)\s+(?P=word)(?!\w)"",",assignwithSum,496 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""&#(\d+);"", lambda m: chr(int(m.group(1))), text)",assignwithSum,500 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""&([A-Za-z]+);"", char_from_entity, text)",assignwithSum,500 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""\n(?:[ \xA0\t]+\n)+"", ""\n"", text)",assignwithSum,500 Programming in Python 3- a complete introduction to the Python language,"name = re.sub(r""(\w+(?:\s+\w+)*)\s+(\w+)"", r""\2, \1"", name)",assignwithSum,501 Programming in Python 3- a complete introduction to the Python language,"name = re.sub(r""(?P<forenames>\w+(?:\s+\w+)*)""",assignwithSum,502 Programming in Python 3- a complete introduction to the Python language,"name = re.sub(r""(?P<forenames>\w+\.?(?:\s+\w+\.?)*)""",assignwithSum,503 Programming in Python 3- a complete introduction to the Python language,ATTRIBUTE_FILE ::= ATTRIBUTE+,assignwithSum,511 Programming in Python 3- a complete introduction to the Python language,"INI_HEADER = re.compile(r""^\[[^]]+\]$"")",assignwithSum,516 Programming in Python 3- a complete introduction to the Python language,"KEY_VALUE_RE = re.compile(r""^(?P<key>\w+)\s*=\s*(?P<value>.*)$"")",assignwithSum,516 Programming in Python 3- a complete introduction to the Python language,"INFO_RE = re.compile(r""#EXTINF:(?P<seconds>-?\d+),(?P<title>.+)"")",assignwithSum,518 Programming in Python 3- a complete introduction to the Python language,BLOCKS ::= NODES+,assignwithSum,522 Programming in Python 3- a complete introduction to the Python language,NODES ::= NEW_ROW* \s* NODE+,assignwithSum,522 Programming in Python 3- a complete introduction to the Python language,"parser element by writing key_value = key + Suppress(""="") + value. We can spec-",assignwithSum,531 Programming in Python 3- a complete introduction to the Python language,"var_list = variable | variable + Suppress("","") + var_list # WRONG!",assignwithSum,533 Programming in Python 3- a complete introduction to the Python language,"var_list = variable + ZeroOrMore(Suppress("","") + variable)",assignwithSum,533 Programming in Python 3- a complete introduction to the Python language,"plus_expression = operand + ZeroOrMore(Suppress(""+"") + operand)",assignwithSum,533 Programming in Python 3- a complete introduction to the Python language,"ini_header = left_bracket + CharsNotIn(""]"") + right_bracket",assignwithSum,534 Programming in Python 3- a complete introduction to the Python language,key_value = Word(alphanums) + equals + restOfLine,assignwithSum,534 Programming in Python 3- a complete introduction to the Python language,"seconds = Combine(Optional(""-"") + Word(nums)).setParseAction(",assignwithSum,536 Programming in Python 3- a complete introduction to the Python language,"info = Suppress(""#EXTINF:"") + seconds + Suppress("","") + title",assignwithSum,536 Programming in Python 3- a complete introduction to the Python language,entry = info + LineEnd() + filename + LineEnd(),assignwithSum,536 Programming in Python 3- a complete introduction to the Python language,"parser = Suppress(""#EXTM3U"") + OneOrMore(entry)",assignwithSum,536 Programming in Python 3- a complete introduction to the Python language,"node_data = Optional(color + Suppress("":"")) + Optional(name)",assignwithSum,539 Programming in Python 3- a complete introduction to the Python language,node = left_bracket - node_data + nodes + right_bracket,assignwithSum,539 Programming in Python 3- a complete introduction to the Python language,forall_expression = Group(forall + symbol + colon + formula),assignwithSum,545 Programming in Python 3- a complete introduction to the Python language,exists_expression = Group(exists + symbol + colon + formula),assignwithSum,545 Programming in Python 3- a complete introduction to the Python language,"t_ignore_INI_HEADER = r""\[[^]]+\]""",assignwithSum,551 Programming in Python 3- a complete introduction to the Python language,"t_NAME = r""[^][/\n]+""",assignwithSum,556 Programming in Python 3- a complete introduction to the Python language,"t_NEW_ROWS = r""/+""",assignwithSum,556 Programming in Python 3- a complete introduction to the Python language,"icon = path + ""interest.ico""",assignwithSum,573 Programming in Python 3- a complete introduction to the Python language,"icon = path + ""bookmark.ico""",assignwithSum,585 Programming in Python 3- a complete introduction to the Python language,C:\py3eg\>path=c:\python31;%path%,simpleAssign,11 Programming in Python 3- a complete introduction to the Python language,"path=c:\python31;%path% and to save this file in the C:\Windows directory. Then,",simpleAssign,11 Programming in Python 3- a complete introduction to the Python language,z = x,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,The syntax is simply objectReference = value. There is no need for predecla-,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,The = operator is not the same as the variable assignment operator in some,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,other languages. The = operator binds an object reference to an object in,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,the object on the right of the = operator; if the object reference does not exist it,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,is created by the = operator.,simpleAssign,15 Programming in Python 3- a complete introduction to the Python language,z = x,simpleAssign,17 Programming in Python 3- a complete introduction to the Python language,b = a,simpleAssign,21 Programming in Python 3- a complete introduction to the Python language,b = None,simpleAssign,21 Programming in Python 3- a complete introduction to the Python language,"expected semantics: < less than, <= less than or equal to, == equal to, != not",simpleAssign,21 Programming in Python 3- a complete introduction to the Python language,"equal to, >= greater than or equal to, and > greater than. These operators",simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,a = 2,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,b = 6,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,a == b,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,"a <= b, a != b, a >= b, a > b",simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,a == b,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,"The moral of this is to use == and != when comparing values, and to use is and",simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,a = 9,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,0 <= a <= 10,simpleAssign,22 Programming in Python 3- a complete introduction to the Python language,five = 5,simpleAssign,24 Programming in Python 3- a complete introduction to the Python language,two = 2,simpleAssign,24 Programming in Python 3- a complete introduction to the Python language,zero = 0,simpleAssign,24 Programming in Python 3- a complete introduction to the Python language,nought = 0,simpleAssign,24 Programming in Python 3- a complete introduction to the Python language,"s = input(""enter an integer: "")",simpleAssign,29 Programming in Python 3- a complete introduction to the Python language,a = 5,simpleAssign,30 Programming in Python 3- a complete introduction to the Python language,The second subtlety is that a operator= b is not quite the same as a = a operator,simpleAssign,30 Programming in Python 3- a complete introduction to the Python language,total = 0,simpleAssign,33 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,33 Programming in Python 3- a complete introduction to the Python language,count = 4 total = 39 mean = 9.75,simpleAssign,33 Programming in Python 3- a complete introduction to the Python language,total = 0,simpleAssign,34 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,34 Programming in Python 3- a complete introduction to the Python language,count = 37 total = 1839 mean = 49.7027027027,simpleAssign,35 Programming in Python 3- a complete introduction to the Python language,"age = get_int(""enter your age: "")",simpleAssign,36 Programming in Python 3- a complete introduction to the Python language,"x = random.randint(1, 6)",simpleAssign,37 Programming in Python 3- a complete introduction to the Python language,"y = random.choice([""apple"", ""banana"", ""cherry"", ""durian""])",simpleAssign,37 Programming in Python 3- a complete introduction to the Python language,"rows = get_int(""rows: "", 1, None)",simpleAssign,42 Programming in Python 3- a complete introduction to the Python language,"columns = get_int(""columns: "", 1, None)",simpleAssign,42 Programming in Python 3- a complete introduction to the Python language,"minimum = get_int(""minimum (or Enter for 0): "", -1000000, 0)",simpleAssign,42 Programming in Python 3- a complete introduction to the Python language,default = 1000,simpleAssign,42 Programming in Python 3- a complete introduction to the Python language,default = 2 * minimum,simpleAssign,42 Programming in Python 3- a complete introduction to the Python language,row = 0,simpleAssign,43 Programming in Python 3- a complete introduction to the Python language,column = 0,simpleAssign,43 Programming in Python 3- a complete introduction to the Python language,"i = random.randint(minimum, maximum)",simpleAssign,43 Programming in Python 3- a complete introduction to the Python language,s = str(i),simpleAssign,43 Programming in Python 3- a complete introduction to the Python language,even[1] = 16.,simpleAssign,44 Programming in Python 3- a complete introduction to the Python language,count = 6 sum = 25 lowest = 1 highest = 8 mean = 4.16666666667,simpleAssign,47 Programming in Python 3- a complete introduction to the Python language,π = math.pi,simpleAssign,51 Programming in Python 3- a complete introduction to the Python language,ε = 0.0000001,simpleAssign,51 Programming in Python 3- a complete introduction to the Python language,nueva_área = π * radio * radio,simpleAssign,51 Programming in Python 3- a complete introduction to the Python language,stretch-factor = 1,simpleAssign,52 Programming in Python 3- a complete introduction to the Python language,2miles = 2,simpleAssign,52 Programming in Python 3- a complete introduction to the Python language,str = 3 # Legal but BAD,simpleAssign,52 Programming in Python 3- a complete introduction to the Python language,l'impôt31 = 4,simpleAssign,52 Programming in Python 3- a complete introduction to the Python language,l_impôt31 = 5,simpleAssign,52 Programming in Python 3- a complete introduction to the Python language,"ment versions (+=, -=, /=, //=, %=, and **=) where x op= y is logically equivalent to",simpleAssign,54 Programming in Python 3- a complete introduction to the Python language,x = x op y in the normal case when reading x’s value has no side effects.,simpleAssign,54 Programming in Python 3- a complete introduction to the Python language,"Objects can be created by assigning literals to variables, for example, x = 17, or",simpleAssign,54 Programming in Python 3- a complete introduction to the Python language,"by calling the relevant data type as a function, for example, x = int(17). Some",simpleAssign,54 Programming in Python 3- a complete introduction to the Python language,"an object with a default value is created—for example, x = int() creates an",simpleAssign,54 Programming in Python 3- a complete introduction to the Python language,where i op= j is logically equivalent to i = i op j in the normal case when,simpleAssign,55 Programming in Python 3- a complete introduction to the Python language,t = True,simpleAssign,56 Programming in Python 3- a complete introduction to the Python language,f = False,simpleAssign,56 Programming in Python 3- a complete introduction to the Python language,"equal to x as an int; e.g., math.ceil(5.4) == 6",simpleAssign,58 Programming in Python 3- a complete introduction to the Python language,"to x as an int; e.g., math.floor(5.4) == 5",simpleAssign,58 Programming in Python 3- a complete introduction to the Python language,"the exponent (as an int) so, x = Returns the sum of the values in iterable i as a float",simpleAssign,58 Programming in Python 3- a complete introduction to the Python language,"the float.as_integer_ratio() method. For example, given x = 2.75, the call",simpleAssign,59 Programming in Python 3- a complete introduction to the Python language,s = 14.25.hex(),simpleAssign,59 Programming in Python 3- a complete introduction to the Python language,f = float.fromhex(s),simpleAssign,60 Programming in Python 3- a complete introduction to the Python language,t = f.hex(),simpleAssign,60 Programming in Python 3- a complete introduction to the Python language,float f == 14.25,simpleAssign,60 Programming in Python 3- a complete introduction to the Python language,a = decimal.Decimal(9876),simpleAssign,61 Programming in Python 3- a complete introduction to the Python language,"b = decimal.Decimal(""54321.012345678987654321"")",simpleAssign,62 Programming in Python 3- a complete introduction to the Python language,s *= 10,simpleAssign,70 Programming in Python 3- a complete introduction to the Python language,i = line.find(opener),simpleAssign,73 Programming in Python 3- a complete introduction to the Python language,"j = line.find(closer, start)",simpleAssign,73 Programming in Python 3- a complete introduction to the Python language,"s.count(""m"", 6) == s[6:].count(""m"")",simpleAssign,74 Programming in Python 3- a complete introduction to the Python language,"s.count(""m"", 5, -3) == s[5:-3].count(""m"")",simpleAssign,74 Programming in Python 3- a complete introduction to the Python language,"i = s.rfind(""/"")",simpleAssign,74 Programming in Python 3- a complete introduction to the Python language,"result = s.rpartition(""/"")",simpleAssign,74 Programming in Python 3- a complete introduction to the Python language,"fields = record.split(""*"")",simpleAssign,75 Programming in Python 3- a complete introduction to the Python language,"born = fields[1].split(""-"")",simpleAssign,75 Programming in Python 3- a complete introduction to the Python language,"died = fields[2].split(""-"")",simpleAssign,75 Programming in Python 3- a complete introduction to the Python language,"from the fields list, for example, year_born = int(fields[1].split(""-"")[0]).",simpleAssign,75 Programming in Python 3- a complete introduction to the Python language,"s = s.format(""The"", x, ""tops"")",simpleAssign,77 Programming in Python 3- a complete introduction to the Python language,"who} turned {age} this year"".format(who=""She"", age=88)",simpleAssign,78 Programming in Python 3- a complete introduction to the Python language,"d = dict(animal=""elephant"", weight=12000)",simpleAssign,78 Programming in Python 3- a complete introduction to the Python language,math.pi==3.14159265359 sys.maxunicode==65535',simpleAssign,78 Programming in Python 3- a complete introduction to the Python language,number = 47,simpleAssign,79 Programming in Python 3- a complete introduction to the Python language,"center = pad",simpleAssign,82 Programming in Python 3- a complete introduction to the Python language,maxwidth = 12,simpleAssign,82 Programming in Python 3- a complete introduction to the Python language,"alignment character (< for left align, ^ for center, > for right align, and = for the",simpleAssign,83 Programming in Python 3- a complete introduction to the Python language,"0:0=12}"".format(8749203) # 0 fill, minimum width 12",simpleAssign,83 Programming in Python 3- a complete introduction to the Python language,"0:0=12}"".format(-8749203) # 0 fill, minimum width 12",simpleAssign,83 Programming in Python 3- a complete introduction to the Python language,word = None,simpleAssign,87 Programming in Python 3- a complete introduction to the Python language,word = 0,simpleAssign,87 Programming in Python 3- a complete introduction to the Python language,word = sys.argv[1].lower(),simpleAssign,87 Programming in Python 3- a complete introduction to the Python language,"code = ord("" "")",simpleAssign,88 Programming in Python 3- a complete introduction to the Python language,end = sys.maxunicode,simpleAssign,88 Programming in Python 3- a complete introduction to the Python language,c = chr(code),simpleAssign,88 Programming in Python 3- a complete introduction to the Python language,"name = unicodedata.name(c, ""*** unknown ***"")",simpleAssign,88 Programming in Python 3- a complete introduction to the Python language,Quadratic equations are equations of the form 2ax + bx + c = 0 where a ≠0,simpleAssign,92 Programming in Python 3- a complete introduction to the Python language,ax² + bx + c = 0,simpleAssign,93 Programming in Python 3- a complete introduction to the Python language,2.5x² + 0.0x + -7.25 = 0 → x = 1.70293863659 or x = -1.70293863659,simpleAssign,93 Programming in Python 3- a complete introduction to the Python language,x = None,simpleAssign,93 Programming in Python 3- a complete introduction to the Python language,x = float(input(msg)),simpleAssign,93 Programming in Python 3- a complete introduction to the Python language,x = None,simpleAssign,93 Programming in Python 3- a complete introduction to the Python language,"a = get_float(""enter a: "", False)",simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,"b = get_float(""enter b: "", True)",simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,"c = get_float(""enter c: "", True)",simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,x1 = None,simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,x2 = None,simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,root = math.sqrt(discriminant),simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,root = cmath.sqrt(discriminant),simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,"equation = (""{0}x\N{SUPERSCRIPT TWO} + {1}x + {2} = 0""",simpleAssign,94 Programming in Python 3- a complete introduction to the Python language,"equation = (""{a}x\N{SUPERSCRIPT TWO} + {b}x + {c} = 0""",simpleAssign,95 Programming in Python 3- a complete introduction to the Python language,"equation = (""{}x\N{SUPERSCRIPT TWO} + {}x + {} = 0""",simpleAssign,95 Programming in Python 3- a complete introduction to the Python language,maxwidth = 100,simpleAssign,97 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,97 Programming in Python 3- a complete introduction to the Python language,fields = extract_fields(line),simpleAssign,98 Programming in Python 3- a complete introduction to the Python language,"number = field.replace("","", """")",simpleAssign,98 Programming in Python 3- a complete introduction to the Python language,quote = None,simpleAssign,99 Programming in Python 3- a complete introduction to the Python language,quote = c,simpleAssign,99 Programming in Python 3- a complete introduction to the Python language,elif quote == c: # end of quoted string,simpleAssign,99 Programming in Python 3- a complete introduction to the Python language,quote = None,simpleAssign,99 Programming in Python 3- a complete introduction to the Python language,"text = text.replace(""&"", ""&"")",simpleAssign,100 Programming in Python 3- a complete introduction to the Python language,"text = text.replace(""<"", ""<"")",simpleAssign,100 Programming in Python 3- a complete introduction to the Python language,"text = text.replace("">"", "">"")",simpleAssign,100 Programming in Python 3- a complete introduction to the Python language,"example, setting maxwidth if “maxwidth=n” is given, and similarly setting",simpleAssign,103 Programming in Python 3- a complete introduction to the Python language,format if “format=s” is given. Here is a run showing the usage output:,simpleAssign,103 Programming in Python 3- a complete introduction to the Python language,csv2html.py [maxwidth=int] [format=str] < infile.csv > outfile.html,simpleAssign,103 Programming in Python 3- a complete introduction to the Python language,csv2html2_ans.py maxwidth=20 format=0.2f < mydata.csv > mydata.html,simpleAssign,103 Programming in Python 3- a complete introduction to the Python language,"Sale = collections.namedtuple(""Sale"",",simpleAssign,108 Programming in Python 3- a complete introduction to the Python language,total = 0,simpleAssign,109 Programming in Python 3- a complete introduction to the Python language,"Aircraft = collections.namedtuple(""Aircraft"",",simpleAssign,109 Programming in Python 3- a complete introduction to the Python language,"Seating = collections.namedtuple(""Seating"", ""minimum maximum"")",simpleAssign,109 Programming in Python 3- a complete introduction to the Python language,"aircraft = Aircraft(""Airbus"", ""A320-200"", Seating(100, 220))",simpleAssign,109 Programming in Python 3- a complete introduction to the Python language,L[0] == L[-6] == -17.5,simpleAssign,110 Programming in Python 3- a complete introduction to the Python language,L[1] == L[-5] == 'kilo',simpleAssign,110 Programming in Python 3- a complete introduction to the Python language,L[1][0] == L[-5][0] == 'k',simpleAssign,110 Programming in Python 3- a complete introduction to the Python language,L[4][2] == L[4][-1] == L[-2][2] == L[-2][-1] == 'echo',simpleAssign,111 Programming in Python 3- a complete introduction to the Python language,L[4][2][1] == L[4][2][-3] == L[-2][-1][1] == L[-2][-1][-3] == 'c',simpleAssign,111 Programming in Python 3- a complete introduction to the Python language,L[i] = process(L[i]),simpleAssign,112 Programming in Python 3- a complete introduction to the Python language,x = 8143 # object ref. 'x' created; int of value 8143 created,simpleAssign,113 Programming in Python 3- a complete introduction to the Python language,"example, we could sort the woods list like this: woods.sort(key=str.lower). The",simpleAssign,115 Programming in Python 3- a complete introduction to the Python language,if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):,simpleAssign,116 Programming in Python 3- a complete introduction to the Python language,"This could also be done using leaps = list(range(1900, 1940)). Now we’ll add a",simpleAssign,116 Programming in Python 3- a complete introduction to the Python language,"Note that although == and != have their usual meanings, with the",simpleAssign,118 Programming in Python 3- a complete introduction to the Python language,s -= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,s &= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,s <= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,s >= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,s ^= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,s |= t,simpleAssign,120 Programming in Python 3- a complete introduction to the Python language,seen = set(),simpleAssign,121 Programming in Python 3- a complete introduction to the Python language,filenames = set(filenames),simpleAssign,121 Programming in Python 3- a complete introduction to the Python language,"filenames = set(filenames) - {""MAKEFILE"", ""Makefile"", ""makefile""}",simpleAssign,121 Programming in Python 3- a complete introduction to the Python language,"case of the == and != operators, the order of the operands does not matter, and",simpleAssign,122 Programming in Python 3- a complete introduction to the Python language,f == s will produce True if both sets contain the same items.,simpleAssign,122 Programming in Python 3- a complete introduction to the Python language,"erators (== and !=), with the comparisons being applied item by item (and recur-",simpleAssign,123 Programming in Python 3- a complete introduction to the Python language,"d1 = dict({""id"": 1948, ""name"": ""Washer"", ""size"": 3})",simpleAssign,124 Programming in Python 3- a complete introduction to the Python language,"d2 = dict(id=1948, name=""Washer"", size=3)",simpleAssign,124 Programming in Python 3- a complete introduction to the Python language,"d3 = dict([(""id"", 1948), (""name"", ""Washer""), (""size"", 3)])",simpleAssign,124 Programming in Python 3- a complete introduction to the Python language,"d4 = dict(zip((""id"", ""name"", ""size""), (1948, ""Washer"", 3)))",simpleAssign,124 Programming in Python 3- a complete introduction to the Python language,"we use the = operator, for example, d[""X""] = 59. And to delete an item we use",simpleAssign,124 Programming in Python 3- a complete introduction to the Python language,"s = set(""ACX"")",simpleAssign,127 Programming in Python 3- a complete introduction to the Python language,matches = d.keys() & s,simpleAssign,127 Programming in Python 3- a complete introduction to the Python language,word = word.strip(strip),simpleAssign,127 Programming in Python 3- a complete introduction to the Python language,words[word] = 0,simpleAssign,129 Programming in Python 3- a complete introduction to the Python language,i = 0,simpleAssign,129 Programming in Python 3- a complete introduction to the Python language,sites[site] = set(),simpleAssign,130 Programming in Python 3- a complete introduction to the Python language,"greens = dict(green=""#0080000"", olive=""#808000"", lime=""#00FF00"")",simpleAssign,131 Programming in Python 3- a complete introduction to the Python language,"format(green=greens.green, olive=greens.olive, lime=greens.lime), but is eas-",simpleAssign,131 Programming in Python 3- a complete introduction to the Python language,"key m, the code x = d[m] will raise a KeyError exception. But if d is a suitably",simpleAssign,132 Programming in Python 3- a complete introduction to the Python language,words = collections.defaultdict(int),simpleAssign,133 Programming in Python 3- a complete introduction to the Python language,"x = words[""xyz""] and there was no item with key ""xyz"", when the access is",simpleAssign,133 Programming in Python 3- a complete introduction to the Python language,"d = collections.OrderedDict([('z', -4), ('e', 19), ('k', 7)])",simpleAssign,134 Programming in Python 3- a complete introduction to the Python language,tasks = collections.OrderedDict(),simpleAssign,134 Programming in Python 3- a complete introduction to the Python language,"ordered dictionary; or we can call popitem(last=False), in which case the first",simpleAssign,134 Programming in Python 3- a complete introduction to the Python language,dictionary like this: d = collections.OrderedDict(sorted(d.items())). Note that,simpleAssign,134 Programming in Python 3- a complete introduction to the Python language,product = 1,simpleAssign,136 Programming in Python 3- a complete introduction to the Python language,product *= i,simpleAssign,136 Programming in Python 3- a complete introduction to the Python language,product = 1,simpleAssign,136 Programming in Python 3- a complete introduction to the Python language,"i = iter([1, 2, 4, 8])",simpleAssign,136 Programming in Python 3- a complete introduction to the Python language,word = sys.argv[1],simpleAssign,137 Programming in Python 3- a complete introduction to the Python language,x[i] = abs(x[i]),simpleAssign,138 Programming in Python 3- a complete introduction to the Python language,i = 0,simpleAssign,138 Programming in Python 3- a complete introduction to the Python language,x[i] = abs(x[i]),simpleAssign,138 Programming in Python 3- a complete introduction to the Python language,"forenames, surnames = get_forenames_and_surnames()",simpleAssign,139 Programming in Python 3- a complete introduction to the Python language,limit = 100,simpleAssign,140 Programming in Python 3- a complete introduction to the Python language,"years = list(range(1970, 2013)) * 3",simpleAssign,140 Programming in Python 3- a complete introduction to the Python language,"sorted(x, reverse=True)",simpleAssign,141 Programming in Python 3- a complete introduction to the Python language,"sorted(x, key=abs)",simpleAssign,141 Programming in Python 3- a complete introduction to the Python language,"x = sorted(x, key=str.lower)",simpleAssign,142 Programming in Python 3- a complete introduction to the Python language,"x = list(zip((1, 3, 1, 3), (""pram"", ""dorie"", ""kayak"", ""canoe"")))",simpleAssign,142 Programming in Python 3- a complete introduction to the Python language,"sorted(x, key=swap)",simpleAssign,143 Programming in Python 3- a complete introduction to the Python language,"sorted([""1.3"", -7.5, ""5"", 4, ""-2.4"", 1], key=float)",simpleAssign,143 Programming in Python 3- a complete introduction to the Python language,beatles = songs,simpleAssign,144 Programming in Python 3- a complete introduction to the Python language,beatles = songs[:],simpleAssign,144 Programming in Python 3- a complete introduction to the Python language,copy_of_dict_d = dict(d),simpleAssign,144 Programming in Python 3- a complete introduction to the Python language,copy_of_list_L = list(L),simpleAssign,144 Programming in Python 3- a complete introduction to the Python language,copy_of_set_s = set(s),simpleAssign,144 Programming in Python 3- a complete introduction to the Python language,y = x[:] # shallow copy,simpleAssign,145 Programming in Python 3- a complete introduction to the Python language,y[1] = 40,simpleAssign,145 Programming in Python 3- a complete introduction to the Python language,y = copy.deepcopy(x),simpleAssign,145 Programming in Python 3- a complete introduction to the Python language,y[1] = 40,simpleAssign,145 Programming in Python 3- a complete introduction to the Python language,"ID, FORENAME, MIDDLENAME, SURNAME, DEPARTMENT = range(5)",simpleAssign,146 Programming in Python 3- a complete introduction to the Python language,"User = collections.namedtuple(""User"",",simpleAssign,146 Programming in Python 3- a complete introduction to the Python language,usernames = set(),simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,line = line.rstrip(),simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,"user = process_line(line, usernames)",simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,user.id)] = user,simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,"fields = line.split("":"")",simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,"username = generate_username(fields, usernames)",simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,"user = User(username, fields[FORENAME], fields[MIDDLENAME],",simpleAssign,147 Programming in Python 3- a complete introduction to the Python language,"user = User(username, fields[1], fields[2], fields[3], fields[0])",simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,username = original_name = username[:8].lower(),simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,count = 1,simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,namewidth = 32,simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,usernamewidth = 9,simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,"Name"", ""ID"", ""Username"", nw=namewidth, uw=usernamewidth))",simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,"nw=namewidth, uw=usernamewidth))",simpleAssign,148 Programming in Python 3- a complete introduction to the Python language,user = users[key],simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,"name, user, nw=namewidth, uw=usernamewidth))",simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,count = 183,simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,mean = 130.56,simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,median = 43.00,simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,std. dev. = 235.01,simpleAssign,149 Programming in Python 3- a complete introduction to the Python language,"Statistics = collections.namedtuple(""Statistics"",",simpleAssign,150 Programming in Python 3- a complete introduction to the Python language,frequencies = collections.defaultdict(int),simpleAssign,150 Programming in Python 3- a complete introduction to the Python language,"statistics = calculate_statistics(numbers, frequencies)",simpleAssign,150 Programming in Python 3- a complete introduction to the Python language,start=1):,simpleAssign,150 Programming in Python 3- a complete introduction to the Python language,"a plain dict, the update code would have been frequencies[number] = frequen-",simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,"mat(filename, lino, etc., or explicitly named arguments, .format(filename=file-",simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,"name, lino=lino, etc.), we have retrieved the names and values of the local",simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,mean = sum(numbers) / len(numbers),simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,"mode = calculate_mode(frequencies, 3)",simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,median = calculate_median(numbers),simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,"std_dev = calculate_std_dev(numbers, mean)",simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,highest_frequency = max(frequencies.values()),simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,mode = None,simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,frequency equals the highest value. We can compare using operator == since,simpleAssign,151 Programming in Python 3- a complete introduction to the Python language,numbers = sorted(numbers),simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,middle = len(numbers) // 2,simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,median = numbers[middle],simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,total = 0,simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,variance = total / (len(numbers) - 1),simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,elif len(statistics.mode) == 1:,simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,"statistics.mode[0], fmt=real)",simpleAssign,152 Programming in Python 3- a complete introduction to the Python language,"count, modeline, fmt=real, **statistics._asdict()))",simpleAssign,153 Programming in Python 3- a complete introduction to the Python language,"s"" if count != 1 else """")))",simpleAssign,158 Programming in Python 3- a complete introduction to the Python language,found = False,simpleAssign,165 Programming in Python 3- a complete introduction to the Python language,found = True,simpleAssign,165 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,166 Programming in Python 3- a complete introduction to the Python language,elif state == PARSING_ENTITY:,simpleAssign,168 Programming in Python 3- a complete introduction to the Python language,"sequence of comma-separated identifiers, or as a sequence of identifier=value",simpleAssign,170 Programming in Python 3- a complete introduction to the Python language,letters = frozenset(letters),simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,parameter=default syntax. This allows us to call letter_count() with just one,simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,"values with parameters that don’t have defaults, so def bad(a, b=1, c): won’t",simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,"arguments, passing each argument in the form name=value.",simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,"shorten(length=7, text=""The Silkie"")",simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,"shorten(""The Silkie"", indicator=""&"", length=7) # returns: 'The Si&'",simpleAssign,171 Programming in Python 3- a complete introduction to the Python language,result = 1,simpleAssign,175 Programming in Python 3- a complete introduction to the Python language,result *= arg,simpleAssign,175 Programming in Python 3- a complete introduction to the Python language,result = 0,simpleAssign,175 Programming in Python 3- a complete introduction to the Python language,"ample, sum_of_powers(1, 3, 5, power=2).",simpleAssign,175 Programming in Python 3- a complete introduction to the Python language,area = math.sqrt(s * (s - a) * (s - b) * (s - c)),simpleAssign,175 Programming in Python 3- a complete introduction to the Python language,"color=True). But if we attempt to use positional arguments, for example,",simpleAssign,176 Programming in Python 3- a complete introduction to the Python language,"options = dict(paper=""A4"", color=True)",simpleAssign,176 Programming in Python 3- a complete introduction to the Python language,"forename=""Lexis"", age=47). This provides us with a lot of flexibility. And we",simpleAssign,176 Programming in Python 3- a complete introduction to the Python language,"dictionary = ENGLISH if Language == ""en"" else FRENCH",simpleAssign,177 Programming in Python 3- a complete introduction to the Python language,"s = lambda x: """" if x == 1 else ""s""",simpleAssign,179 Programming in Python 3- a complete introduction to the Python language,"elements.sort(key=lambda e: (e[1], e[2]))",simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,elements.sort(key=lambda e: e[1:3]),simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,"elements.sort(key=lambda e: (e[2].lower(), e[1]))",simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,"area = lambda b, h: 0.5 * b * h",simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,minus_one_dict = collections.defaultdict(lambda: -1),simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,"point_zero_dict = collections.defaultdict(lambda: (0, 0))",simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,"message_dict = collections.defaultdict(lambda: ""No message available"")",simpleAssign,180 Programming in Python 3- a complete introduction to the Python language,result = 1,simpleAssign,181 Programming in Python 3- a complete introduction to the Python language,result *= arg,simpleAssign,181 Programming in Python 3- a complete introduction to the Python language,result = 1,simpleAssign,181 Programming in Python 3- a complete introduction to the Python language,result *= arg,simpleAssign,181 Programming in Python 3- a complete introduction to the Python language,"x = product(1, 2, 0, 4, 8)",simpleAssign,181 Programming in Python 3- a complete introduction to the Python language,"meta equiv=""content-type"" content=""text/html; charset=utf-8"" />",simpleAssign,183 Programming in Python 3- a complete introduction to the Python language,"information = dict(name=None, year=datetime.date.today().year,",simpleAssign,184 Programming in Python 3- a complete introduction to the Python language,"filename=None, title=None, description=None,",simpleAssign,184 Programming in Python 3- a complete introduction to the Python language,"keywords=None, stylesheet=None)",simpleAssign,184 Programming in Python 3- a complete introduction to the Python language,"name = get_string(""Enter your name (for copyright)"", ""name"",",simpleAssign,184 Programming in Python 3- a complete introduction to the Python language,"year = get_integer(""Enter copyright year"", ""year"",",simpleAssign,184 Programming in Python 3- a complete introduction to the Python language,title = xml.sax.saxutils.escape(title),simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,description = xml.sax.saxutils.escape(description),simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,html = HTML_TEMPLATE.format(**locals()),simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,"explicitly using key=value syntax, we have used mapping unpacking on the",simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,"write the format() call as .format(title=title, copyright=copyright, etc.)",simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,186 Programming in Python 3- a complete introduction to the Python language,"def get_string(message, name=""string"", default=None,",simpleAssign,187 Programming in Python 3- a complete introduction to the Python language,"minimum_length=0, maximum_length=80):",simpleAssign,187 Programming in Python 3- a complete introduction to the Python language,ing key=value syntax to pass local variables to str.format() with a format string,simpleAssign,187 Programming in Python 3- a complete introduction to the Python language,"def get_integer(message, name=""integer"", default=None, minimum=0,",simpleAssign,188 Programming in Python 3- a complete introduction to the Python language,"maximum=100, allow_zero=True):",simpleAssign,188 Programming in Python 3- a complete introduction to the Python language,"image = Graphics.Bmp.load(""bashful.bmp"")",simpleAssign,197 Programming in Python 3- a complete introduction to the Python language,"image = Jpeg.load(""doc.jpeg"")",simpleAssign,197 Programming in Python 3- a complete introduction to the Python language,"image = Png.load(""dopey.png"")",simpleAssign,197 Programming in Python 3- a complete introduction to the Python language,"image = picture.load(""grumpy.tiff"")",simpleAssign,197 Programming in Python 3- a complete introduction to the Python language,"image = Xpm.load(""sleepy.xpm"")",simpleAssign,198 Programming in Python 3- a complete introduction to the Python language,"image = Graphics.Vector.Eps.load(""sneezy.eps"")",simpleAssign,198 Programming in Python 3- a complete introduction to the Python language,"image = Svg.load(""snow.svg"")",simpleAssign,199 Programming in Python 3- a complete introduction to the Python language,counts[left] = 0,simpleAssign,201 Programming in Python 3- a complete introduction to the Python language,left_for_right[right] = left,simpleAssign,201 Programming in Python 3- a complete introduction to the Python language,left = left_for_right[c],simpleAssign,201 Programming in Python 3- a complete introduction to the Python language,counts[left] -= 1,simpleAssign,202 Programming in Python 3- a complete introduction to the Python language,text = TextUtil.simplify(text) # text == 'a puzzling conundrum',simpleAssign,202 Programming in Python 3- a complete introduction to the Python language,"add_rectangle(6, 42, 11, 46, fill=True)",simpleAssign,204 Programming in Python 3- a complete introduction to the Python language,_max_rows = 25,simpleAssign,206 Programming in Python 3- a complete introduction to the Python language,_max_columns = 80,simpleAssign,206 Programming in Python 3- a complete introduction to the Python language,_background_char = char,simpleAssign,207 Programming in Python 3- a complete introduction to the Python language,_max_rows = max_rows,simpleAssign,207 Programming in Python 3- a complete introduction to the Python language,_max_columns = max_columns,simpleAssign,207 Programming in Python 3- a complete introduction to the Python language,"char_at(8, 20) == char_at(8, 24) == ""=""",simpleAssign,208 Programming in Python 3- a complete introduction to the Python language,sys.stdout = io.StringIO(),simpleAssign,211 Programming in Python 3- a complete introduction to the Python language,original sys.stdout with the statement sys.stdout = sys.__stdout__.),simpleAssign,211 Programming in Python 3- a complete introduction to the Python language,parser = optparse.OptionParser(),simpleAssign,212 Programming in Python 3- a complete introduction to the Python language,"parser.set_defaults(maxwidth=100, format="".0f"")",simpleAssign,212 Programming in Python 3- a complete introduction to the Python language,"opts, args = parser.parse_args()",simpleAssign,212 Programming in Python 3- a complete introduction to the Python language,"can use any of -w80, -w 80, --maxwidth=80, or --maxwidth 80. After the command",simpleAssign,212 Programming in Python 3- a complete introduction to the Python language,"moon_datetime_a = datetime.datetime(1969, 7, 20, 20, 17, 40)",simpleAssign,214 Programming in Python 3- a complete introduction to the Python language,moon_time = calendar.timegm(moon_datetime_a.utctimetuple()),simpleAssign,214 Programming in Python 3- a complete introduction to the Python language,moon_datetime_b = datetime.datetime.utcfromtimestamp(moon_time),simpleAssign,214 Programming in Python 3- a complete introduction to the Python language,"LEFT_ALIGN_PNG = b""""""\",simpleAssign,217 Programming in Python 3- a complete introduction to the Python language,binary = base64.b64decode(LEFT_ALIGN_PNG),simpleAssign,218 Programming in Python 3- a complete introduction to the Python language,BZ2_AVAILABLE = True,simpleAssign,218 Programming in Python 3- a complete introduction to the Python language,BZ2_AVAILABLE = False,simpleAssign,218 Programming in Python 3- a complete introduction to the Python language,tar = None,simpleAssign,219 Programming in Python 3- a complete introduction to the Python language,"fullname = os.path.join(path, name)",simpleAssign,221 Programming in Python 3- a complete introduction to the Python language,date_from_name[fullname] = os.path.getmtime(fullname),simpleAssign,221 Programming in Python 3- a complete introduction to the Python language,data = collections.defaultdict(list),simpleAssign,221 Programming in Python 3- a complete introduction to the Python language,"fullname = os.path.join(root, filename)",simpleAssign,221 Programming in Python 3- a complete introduction to the Python language,"names = data[(size, filename)]",simpleAssign,222 Programming in Python 3- a complete introduction to the Python language,"fh = io.StringIO(binary.decode(""utf8""))",simpleAssign,225 Programming in Python 3- a complete introduction to the Python language,tree = xml.etree.ElementTree.ElementTree(),simpleAssign,225 Programming in Python 3- a complete introduction to the Python language,root = tree.parse(fh),simpleAssign,225 Programming in Python 3- a complete introduction to the Python language,"o ORDER, --order=ORDER",simpleAssign,229 Programming in Python 3- a complete introduction to the Python language,"by using long options, ls.py --modified --sizes --order=size misc/, or any com-",simpleAssign,229 Programming in Python 3- a complete introduction to the Python language,distance = distance_from_origin(*circle[:2]),simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,distance = edge_distance_from_origin(*circle),simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,"Circle = collections.namedtuple(""Circle"", ""x y radius"")",simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,"circle = Circle(13, 84, 9)",simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,"distance = distance_from_origin(circle.x, circle.y)",simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,"circle = Circle(33, 56, -5)",simpleAssign,231 Programming in Python 3- a complete introduction to the Python language,circle = circle._replace(radius=12),simpleAssign,232 Programming in Python 3- a complete introduction to the Python language,we can write things like circle[RADIUS] = 5. But using a list brings additional,simpleAssign,232 Programming in Python 3- a complete introduction to the Python language,"nary might be an alternative, for example, circle = dict(x=36, y=77, radius=8),",simpleAssign,232 Programming in Python 3- a complete introduction to the Python language,"jects are also namespaces; for example, if we have z = complex(1, 2), the z ob-",simpleAssign,233 Programming in Python 3- a complete introduction to the Python language,"the class with any necessary arguments; for example, x = complex(4, 8) creates",simpleAssign,235 Programming in Python 3- a complete introduction to the Python language,a = Shape.Point(),simpleAssign,236 Programming in Python 3- a complete introduction to the Python language,"b = Shape.Point(3, 4)",simpleAssign,236 Programming in Python 3- a complete introduction to the Python language,"a == b, a != b",simpleAssign,236 Programming in Python 3- a complete introduction to the Python language,"y = a.y), and the class integrates nicely with all of Python’s other classes by",simpleAssign,236 Programming in Python 3- a complete introduction to the Python language,"into one, but Python keeps them separate. When an object is created (e.g., p = Shape.Point()), first the special method __new__() is called to create the object,",simpleAssign,237 Programming in Python 3- a complete introduction to the Python language,"For example, if we execute p = Shape.Point(), Python begins by looking for",simpleAssign,237 Programming in Python 3- a complete introduction to the Python language,"All instances of custom classes support == by default, and the comparison",simpleAssign,238 Programming in Python 3- a complete introduction to the Python language,x <= y Returns True if x is less than or equal to y,simpleAssign,239 Programming in Python 3- a complete introduction to the Python language,x == y Returns True if x is equal to y,simpleAssign,239 Programming in Python 3- a complete introduction to the Python language,x != y Returns True if x is not equal to y,simpleAssign,239 Programming in Python 3- a complete introduction to the Python language,x >= y Returns True if x is greater than or equal to y,simpleAssign,239 Programming in Python 3- a complete introduction to the Python language,"p = Shape.Point(3, 9)",simpleAssign,240 Programming in Python 3- a complete introduction to the Python language,"p = Shape.Point(28, 45)",simpleAssign,242 Programming in Python 3- a complete introduction to the Python language,"c = Shape.Circle(5, 28, 45)",simpleAssign,242 Programming in Python 3- a complete introduction to the Python language,area = property(area),simpleAssign,243 Programming in Python 3- a complete introduction to the Python language,circle = Circle(-2),simpleAssign,244 Programming in Python 3- a complete introduction to the Python language,circle = Circle(4),simpleAssign,244 Programming in Python 3- a complete introduction to the Python language,circle.radius = 6,simpleAssign,244 Programming in Python 3- a complete introduction to the Python language,"The Circle’s initializer, Circle.__init__(), includes the statement self.radius = radius; this will call the radius property’s setter, so if an invalid radius is given",simpleAssign,245 Programming in Python 3- a complete introduction to the Python language,a = FuzzyBool.FuzzyBool(.875),simpleAssign,245 Programming in Python 3- a complete introduction to the Python language,b = FuzzyBool.FuzzyBool(.25),simpleAssign,245 Programming in Python 3- a complete introduction to the Python language,a >= b,simpleAssign,245 Programming in Python 3- a complete introduction to the Python language,b |= FuzzyBool.FuzzyBool(.5),simpleAssign,246 Programming in Python 3- a complete introduction to the Python language,returns: 'a=87.5% b=50%',simpleAssign,246 Programming in Python 3- a complete introduction to the Python language,"immutable—but with the provision of augmented assignment operators (&= and |=) to ensure that they are convenient to use.",simpleAssign,246 Programming in Python 3- a complete introduction to the Python language,"operator, or for __ior__() which provides the in-place |= operator, since both",simpleAssign,248 Programming in Python 3- a complete introduction to the Python language,"We have created an eval()-able representational form. For example, given f = FuzzyBool.FuzzyBool(.75); repr(f) will produce the string 'FuzzyBool(0.75)'.",simpleAssign,249 Programming in Python 3- a complete introduction to the Python language,"from ==, and >= from <=. We have shown only two representative methods",simpleAssign,249 Programming in Python 3- a complete introduction to the Python language,x *= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x //= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x **= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x ^= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x <<= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x -= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x %= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x /= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x &= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x |= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,x >>= y,simpleAssign,250 Programming in Python 3- a complete introduction to the Python language,value if 0.0 <= value <= 1.0 else 0.0),simpleAssign,253 Programming in Python 3- a complete introduction to the Python language,"So when we write f = FuzzyBool(0.7), under the hood Python calls Fuzzy-",simpleAssign,254 Programming in Python 3- a complete introduction to the Python language,"width, height = 240, 60",simpleAssign,259 Programming in Python 3- a complete introduction to the Python language,"midx, midy = width // 2, height // 2",simpleAssign,259 Programming in Python 3- a complete introduction to the Python language,"image = Image.Image(width, height, ""square_eye.img"")",simpleAssign,259 Programming in Python 3- a complete introduction to the Python language,"image[x, y] = border_color",simpleAssign,259 Programming in Python 3- a complete introduction to the Python language,"image[x, y] = square_color",simpleAssign,259 Programming in Python 3- a complete introduction to the Python language,if (not (0 <= coordinate[0] < self.width) or,simpleAssign,261 Programming in Python 3- a complete introduction to the Python language,not (0 <= coordinate[1] < self.height)):,simpleAssign,261 Programming in Python 3- a complete introduction to the Python language,"__setitem__(self, k, v) y[k] = v",simpleAssign,262 Programming in Python 3- a complete introduction to the Python language,if (not (0 <= coordinate[0] < self.width) or,simpleAssign,262 Programming in Python 3- a complete introduction to the Python language,not (0 <= coordinate[1] < self.height)):,simpleAssign,262 Programming in Python 3- a complete introduction to the Python language,if (not (0 <= coordinate[0] < self.width) or,simpleAssign,262 Programming in Python 3- a complete introduction to the Python language,not (0 <= coordinate[1] < self.height)):,simpleAssign,262 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,265 Programming in Python 3- a complete introduction to the Python language,"read using the single statement, data = pickle.load(fh). The data object is an",simpleAssign,265 Programming in Python 3- a complete introduction to the Python language,"letters = SortedList.SortedList((""H"", ""c"", ""B"", ""G"", ""e""), str.lower)",simpleAssign,266 Programming in Python 3- a complete introduction to the Python language,_identity = lambda x: x,simpleAssign,267 Programming in Python 3- a complete introduction to the Python language,sequence.key == self.__key):,simpleAssign,267 Programming in Python 3- a complete introduction to the Python language,more obvious alternative would have been self.__key = key if key is not None,simpleAssign,268 Programming in Python 3- a complete introduction to the Python language,index = self.__bisect_left(value),simpleAssign,268 Programming in Python 3- a complete introduction to the Python language,key = self.__key(value),simpleAssign,269 Programming in Python 3- a complete introduction to the Python language,"left, right = 0, len(self.__list)",simpleAssign,269 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,269 Programming in Python 3- a complete introduction to the Python language,index = self.__bisect_left(value),simpleAssign,269 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,270 Programming in Python 3- a complete introduction to the Python language,index = self.__bisect_left(value),simpleAssign,270 Programming in Python 3- a complete introduction to the Python language,index = self.__bisect_left(value),simpleAssign,270 Programming in Python 3- a complete introduction to the Python language,"This method provides support for the x = L[n] syntax, where L is a sorted list",simpleAssign,270 Programming in Python 3- a complete introduction to the Python language,"We don’t want the user to change an item at a given index position (so L[n] = x is disallowed); otherwise, the sorted list’s order might be invalidated. The",simpleAssign,271 Programming in Python 3- a complete introduction to the Python language,index = self.__bisect_left(value),simpleAssign,271 Programming in Python 3- a complete introduction to the Python language,__copy__ = copy,simpleAssign,272 Programming in Python 3- a complete introduction to the Python language,"d = SortedDict.SortedDict(dict(s=1, A=2, y=6), str.lower)",simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,"d[""z""] = 4",simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,"d[""T""] = 5",simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,"d[""n""] = 3",simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,"d[""A""] = 17",simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,dictionary = dictionary or {},simpleAssign,273 Programming in Python 3- a complete introduction to the Python language,"fromkeys(cls, iterable, value=None, key=None):",simpleAssign,274 Programming in Python 3- a complete introduction to the Python language,"d = MyDict.fromkeys(""VEINS"", 3)",simpleAssign,275 Programming in Python 3- a complete introduction to the Python language,This method implements the d[key] = value syntax. If the key isn’t in the,simpleAssign,275 Programming in Python 3- a complete introduction to the Python language,"caller to support chaining, for example, x = d[key] = value.",simpleAssign,275 Programming in Python 3- a complete introduction to the Python language,item = super().popitem(),simpleAssign,277 Programming in Python 3- a complete introduction to the Python language,keys = __iter__,simpleAssign,277 Programming in Python 3- a complete introduction to the Python language,"The base class methods dict.get(), dict.__getitem__() (for the v = d[k] syntax),",simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,d = SortedDict(),simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,d.__keys = self.__keys.copy(),simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,using the copy_of_x = ClassOfX(x) idiom that Python’s built-in types support.,simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,"And just as we did for SortedList, we have set __copy__ = copy so that the",simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,self[self.__keys[index]] = value,simpleAssign,279 Programming in Python 3- a complete introduction to the Python language,"possible, eval(repr(x)) == x, and we saw how to support this. When an",simpleAssign,281 Programming in Python 3- a complete introduction to the Python language,p = q - r,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p -= q,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p = q * n,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p *= n,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p = q / n,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p /= n,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p = q // n # Point.__floordiv__(),simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,p //= n,simpleAssign,282 Programming in Python 3- a complete introduction to the Python language,"simple doctests that include saving and loading—use code such as name = os.path.join(tempfile.gettempdir(), account_name) to provide a suitable",simpleAssign,283 Programming in Python 3- a complete introduction to the Python language,"r READER, --reader=READER",simpleAssign,287 Programming in Python 3- a complete introduction to the Python language,"w WRITER, --writer=WRITER",simpleAssign,287 Programming in Python 3- a complete introduction to the Python language,keys = __iter__,simpleAssign,288 Programming in Python 3- a complete introduction to the Python language,"word = b""Animal""",simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,"x = b""A""",simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,word[0] == x,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,word[:1] == x,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,word[0] == x[0] # returns: True,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,word[0] == 65;,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,"x == b""A""",simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,"word[:1] == b""A""; x == b""A""",simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,word[0] == 65;,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,x[0] == 65,simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,"data = b""5 Hills \x35\x20\x48\x69\x6C\x6C\x73""",simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,data = bytearray(data),simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,data == b'5 Hills 5 Bills',simpleAssign,290 Programming in Python 3- a complete introduction to the Python language,"GZIP_MAGIC = b""\x1F\x8B""",simpleAssign,291 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,292 Programming in Python 3- a complete introduction to the Python language,"MAGIC = b""AIB\x00""",simpleAssign,293 Programming in Python 3- a complete introduction to the Python language,"FORMAT_VERSION = b""\x00\x01""",simpleAssign,293 Programming in Python 3- a complete introduction to the Python language,"data = string.encode(""utf8"")",simpleAssign,293 Programming in Python 3- a complete introduction to the Python language,"data = struct.pack(""<2h"", 11, -9)",simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,data == b'\x0b\x00\xf7\xff',simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,"TWO_SHORTS = struct.Struct(""<2h"")",simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,"data = TWO_SHORTS.pack(11, -9)",simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,items = TWO_SHORTS.unpack(data),simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,data == b'\x0b\x00\xf7\xff',simpleAssign,294 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,295 Programming in Python 3- a complete introduction to the Python language,data = bytearray(),simpleAssign,295 Programming in Python 3- a complete introduction to the Python language,"NumbersStruct = struct.Struct(""<Idi?"")",simpleAssign,298 Programming in Python 3- a complete introduction to the Python language,"uint16 = struct.Struct(""<H"")",simpleAssign,299 Programming in Python 3- a complete introduction to the Python language,length = uint16.unpack(length_data)[0],simpleAssign,299 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,300 Programming in Python 3- a complete introduction to the Python language,followed by all the one-line data items written in key=valueform. For the multi-,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,date=2007-09-27,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,aircraft_id=1675B,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,aircraft_type=DHC-2-MK1,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,airport=MERLE K (MUDHOLE) SMITH,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,pilot_percent_hours_on_type=46.1538461538,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,pilot_total_hours=13000,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,midair=0,simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,"wrapper = textwrap.TextWrapper(initial_indent=""",simpleAssign,302 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,303 Programming in Python 3- a complete introduction to the Python language,"airport=incident.airport.strip(),",simpleAssign,303 Programming in Python 3- a complete introduction to the Python language,narrative=narrative)),simpleAssign,303 Programming in Python 3- a complete introduction to the Python language,narrative lines; we could be at a key=value line; or we could be at a report ID,simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,narrative = None,simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,line = line.rstrip(),simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,"data[""narrative""] = textwrap.dedent(",simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,incident = Incident(**data),simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,self[incident.report_id] = incident,simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,narrative = None,simpleAssign,304 Programming in Python 3- a complete introduction to the Python language,"data[""report_id""] = line[1:-1]",simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,"key, value = line.split(""="", 1)",simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,"data[key] = datetime.datetime.strptime(value,",simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,data[key] = float(value),simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,data[key] = int(value),simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,data[key] = bool(int(value)),simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,data[key] = value,simpleAssign,305 Programming in Python 3- a complete introduction to the Python language,"three more possibilities: We are reading key=value items, we are at a narrative",simpleAssign,306 Programming in Python 3- a complete introduction to the Python language,"In the case of reading a line of key=value data, we split the line on the first = character, specifying a maximum of one split—this means that the value",simpleAssign,306 Programming in Python 3- a complete introduction to the Python language,can safely include = characters. All the data read is in the form of Unicode,simpleAssign,306 Programming in Python 3- a complete introduction to the Python language,"If the line doesn’t contain an = character, we check to see whether we’ve read",simpleAssign,306 Programming in Python 3- a complete introduction to the Python language,incident_re = re.compile(,simpleAssign,307 Programming in Python 3- a complete introduction to the Python language,"The second regular expression, key_value_re, is used to capture key=value lines,",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"lowed by non-= characters which are captured into the key match group, fol-",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"lowed by an = character, followed by all the remaining characters in the line",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[""report_id""] = incident_match.group(""id"")",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[""narrative""] = textwrap.dedent(",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"keyvalues = incident_match.group(""keyvalues"")",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[match.group(""key"")] = match.group(""value"")",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[""date""] = datetime.datetime.strptime(",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[""pilot_total_hours""] = int(",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"data[""midair""] = bool(int(data[""midair""]))",simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,incident = Incident(**data),simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,self[incident.report_id] = incident,simpleAssign,308 Programming in Python 3- a complete introduction to the Python language,"the key=value strings in one go using the keyvalues match group, and apply",simpleAssign,309 Programming in Python 3- a complete introduction to the Python language,"individual key=value line. For each (key, value) pair found, we put them in the",simpleAssign,309 Programming in Python 3- a complete introduction to the Python language,match too many or too few key=value lines. The end is the same as before—we,simpleAssign,309 Programming in Python 3- a complete introduction to the Python language,"root = xml.etree.ElementTree.Element(""incidents"")",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"element = xml.etree.ElementTree.Element(""incident"",",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"report_id=incident.report_id,",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"date=incident.date.isoformat(),",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"aircraft_id=incident.aircraft_id,",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"aircraft_type=incident.aircraft_type,",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,pilot_percent_hours_on_type=str(,simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,"pilot_total_hours=str(incident.pilot_total_hours),",simpleAssign,310 Programming in Python 3- a complete introduction to the Python language,midair=str(int(incident.midair))),simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,"airport = xml.etree.ElementTree.SubElement(element,",simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,airport.text = incident.airport.strip(),simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,"narrative = xml.etree.ElementTree.SubElement(element,",simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,narrative.text = incident.narrative.strip(),simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,tree = xml.etree.ElementTree.ElementTree(root),simpleAssign,311 Programming in Python 3- a complete introduction to the Python language,dom = xml.dom.minidom.getDOMImplementation(),simpleAssign,313 Programming in Python 3- a complete introduction to the Python language,"tree = dom.createDocument(None, ""incidents"", None)",simpleAssign,313 Programming in Python 3- a complete introduction to the Python language,root = tree.documentElement,simpleAssign,313 Programming in Python 3- a complete introduction to the Python language,"element = tree.createElement(""incident"")",simpleAssign,313 Programming in Python 3- a complete introduction to the Python language,text_element = tree.createTextNode(text),simpleAssign,314 Programming in Python 3- a complete introduction to the Python language,name_element = tree.createElement(name),simpleAssign,314 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,314 Programming in Python 3- a complete introduction to the Python language,"data[""airport""] = get_text(airport.childNodes)",simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,narrative = element.getElementsByTagName(,simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,"data[""narrative""] = get_text(narrative.childNodes)",simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,incident = Incident(**data),simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,self[incident.report_id] = incident,simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,316 Programming in Python 3- a complete introduction to the Python language,report_id=xml.sax.saxutils.quoteattr(,simpleAssign,317 Programming in Python 3- a complete introduction to the Python language,aircraft_id=xml.sax.saxutils.quoteattr(,simpleAssign,317 Programming in Python 3- a complete introduction to the Python language,aircraft_type=xml.sax.saxutils.quoteattr(,simpleAssign,317 Programming in Python 3- a complete introduction to the Python language,"airport=xml.sax.saxutils.escape(incident.airport),",simpleAssign,317 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,318 Programming in Python 3- a complete introduction to the Python language,handler = IncidentSaxHandler(self),simpleAssign,318 Programming in Python 3- a complete introduction to the Python language,parser = xml.sax.make_parser(),simpleAssign,318 Programming in Python 3- a complete introduction to the Python language,incident = Incident(**self.__data),simpleAssign,320 Programming in Python 3- a complete introduction to the Python language,"Contact = struct.Struct(""<15si"")",simpleAssign,321 Programming in Python 3- a complete introduction to the Python language,"contacts = BinaryRecordFile.BinaryRecordFile(filename, Contact.size)",simpleAssign,321 Programming in Python 3- a complete introduction to the Python language,"contacts[4] = Contact.pack(""Abe Baker"".encode(""utf8""), 762)",simpleAssign,321 Programming in Python 3- a complete introduction to the Python language,"contacts[5] = Contact.pack(""Cindy Dove"".encode(""utf8""), 987)",simpleAssign,321 Programming in Python 3- a complete introduction to the Python language,contact_data = Contact.unpack(contacts[5]),simpleAssign,323 Programming in Python 3- a complete introduction to the Python language,"_DELETED = b""\x01""",simpleAssign,323 Programming in Python 3- a complete introduction to the Python language,"_OKAY = b""\x02""",simpleAssign,323 Programming in Python 3- a complete introduction to the Python language,"This method supports the brf[i] = data syntax where brf is a binary record file,",simpleAssign,324 Programming in Python 3- a complete introduction to the Python language,end = self.__fh.tell(),simpleAssign,325 Programming in Python 3- a complete introduction to the Python language,offset = index * self.__record_size,simpleAssign,325 Programming in Python 3- a complete introduction to the Python language,end = self.__fh.tell(),simpleAssign,327 Programming in Python 3- a complete introduction to the Python language,index = 0,simpleAssign,327 Programming in Python 3- a complete introduction to the Python language,length = len(self),simpleAssign,327 Programming in Python 3- a complete introduction to the Python language,limit = None,simpleAssign,328 Programming in Python 3- a complete introduction to the Python language,The line if data[:1] == _OKAY: is quite subtle. Both the,simpleAssign,329 Programming in Python 3- a complete introduction to the Python language,bicycles = BikeStock.BikeStock(bike_file),simpleAssign,329 Programming in Python 3- a complete introduction to the Python language,value = 0.0,simpleAssign,329 Programming in Python 3- a complete introduction to the Python language,record = self.__file[index],simpleAssign,330 Programming in Python 3- a complete introduction to the Python language,bike = _bike_from_record(record),simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,index = len(self.__file),simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,record = self.__file[self.__index_from_identity[identity]],simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,index = self.__index_from_identity[identity],simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,record = self.__file[index],simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,bike = _bike_from_record(record),simpleAssign,331 Programming in Python 3- a complete introduction to the Python language,record = self.__file[index],simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,"_BIKE_STRUCT = struct.Struct(""<8s30sid"")",simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,"ID, NAME, QUANTITY, PRICE = range(4)",simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,parts = list(_BIKE_STRUCT.unpack(record)),simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,"parts[ID] = parts[ID].decode(""utf8"").rstrip(""\x00"")",simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,"parts[NAME] = parts[NAME].decode(""utf8"").rstrip(""\x00"")",simpleAssign,332 Programming in Python 3- a complete introduction to the Python language,"b BLOCKSIZE, --blocksize=BLOCKSIZE",simpleAssign,335 Programming in Python 3- a complete introduction to the Python language,"e ENCODING, --encoding=ENCODING",simpleAssign,335 Programming in Python 3- a complete introduction to the Python language,"functions = dict(a=add_dvd, e=edit_dvd,",simpleAssign,338 Programming in Python 3- a complete introduction to the Python language,"l=list_dvds, r=remove_dvd,",simpleAssign,338 Programming in Python 3- a complete introduction to the Python language,"i=import_, x=export, q=quit)",simpleAssign,338 Programming in Python 3- a complete introduction to the Python language,"result = call[extension, reader](filename)",simpleAssign,338 Programming in Python 3- a complete introduction to the Python language,next_quarter = received,simpleAssign,340 Programming in Python 3- a complete introduction to the Python language,generator = quarters(),simpleAssign,340 Programming in Python 3- a complete introduction to the Python language,"x = eval(""(2 ** 31) - 1"")",simpleAssign,341 Programming in Python 3- a complete introduction to the Python language,x == 2147483647,simpleAssign,341 Programming in Python 3- a complete introduction to the Python language,"context[""math""] = math",simpleAssign,342 Programming in Python 3- a complete introduction to the Python language,"into a dictionary, for example, context = globals().copy(). This still gives exec()",simpleAssign,342 Programming in Python 3- a complete introduction to the Python language,"area_of_sphere = context[""area_of_sphere""]",simpleAssign,343 Programming in Python 3- a complete introduction to the Python language,area = area_of_sphere(5),simpleAssign,343 Programming in Python 3- a complete introduction to the Python language,area == 314.15926535897933,simpleAssign,343 Programming in Python 3- a complete introduction to the Python language,modules = load_modules(),simpleAssign,343 Programming in Python 3- a complete introduction to the Python language,"get_file_type = get_function(module, ""get_file_type"")",simpleAssign,344 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,344 Programming in Python 3- a complete introduction to the Python language,filename = name,simpleAssign,344 Programming in Python 3- a complete introduction to the Python language,name = os.path.splitext(name)[0],simpleAssign,344 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,345 Programming in Python 3- a complete introduction to the Python language,"We read the text of the file into the code string. The next line, module = type(sys)(name), is quite subtle. When we call type() it returns the type object",simpleAssign,345 Programming in Python 3- a complete introduction to the Python language,"example, we can get the integer 5 in variable x by writing x = 5, or x = int(5),",simpleAssign,345 Programming in Python 3- a complete introduction to the Python language,"or x = type(0)(5), or int_type = type(0); x = int_type(5). In this case we’ve used",simpleAssign,345 Programming in Python 3- a complete introduction to the Python language,"Given the before list, the after list is produced by this call: after = Indent-",simpleAssign,349 Programming in Python 3- a complete introduction to the Python language,"KEY, ITEM, CHILDREN = range(3)",simpleAssign,350 Programming in Python 3- a complete introduction to the Python language,level = 0,simpleAssign,350 Programming in Python 3- a complete introduction to the Python language,i = 0,simpleAssign,350 Programming in Python 3- a complete introduction to the Python language,key = item.strip().lower(),simpleAssign,350 Programming in Python 3- a complete introduction to the Python language,level -= 1,simpleAssign,352 Programming in Python 3- a complete introduction to the Python language,"result = function(*args, **kwargs)",simpleAssign,354 Programming in Python 3- a complete introduction to the Python language,wrapper.__name__ = function.__name__,simpleAssign,354 Programming in Python 3- a complete introduction to the Python language,wrapper.__doc__ = function.__doc__,simpleAssign,354 Programming in Python 3- a complete introduction to the Python language,"result = function(*args, **kwargs)",simpleAssign,354 Programming in Python 3- a complete introduction to the Python language,"result = function(*args, **kwargs)",simpleAssign,355 Programming in Python 3- a complete introduction to the Python language,"discounted_price(price, percentage, make_integer=False):",simpleAssign,355 Programming in Python 3- a complete introduction to the Python language,result = price * ((100 - percentage) / 100),simpleAssign,355 Programming in Python 3- a complete introduction to the Python language,"called: discounted_price(210, 5, make_integer=True) -> 200",simpleAssign,356 Programming in Python 3- a complete introduction to the Python language,"logger = logging.getLogger(""Logger"")",simpleAssign,356 Programming in Python 3- a complete introduction to the Python language,handler = logging.FileHandler(os.path.join(,simpleAssign,356 Programming in Python 3- a complete introduction to the Python language,result = exception = None,simpleAssign,356 Programming in Python 3- a complete introduction to the Python language,annotations = function.__annotations__,simpleAssign,358 Programming in Python 3- a complete introduction to the Python language,arg_spec = inspect.getfullargspec(function),simpleAssign,358 Programming in Python 3- a complete introduction to the Python language,"result = function(*args, **kwargs)",simpleAssign,358 Programming in Python 3- a complete introduction to the Python language,"With the Ord class available, we can create an instance, ord = Ord(), and then",simpleAssign,361 Programming in Python 3- a complete introduction to the Python language,ord = Ord(). This is because the instance has the same name as the built-in ord(),simpleAssign,361 Programming in Python 3- a complete introduction to the Python language,name] = value,simpleAssign,361 Programming in Python 3- a complete introduction to the Python language,"With this class we can create a constant object, say, const = Const(), and set any",simpleAssign,361 Programming in Python 3- a complete introduction to the Python language,"attributes we like on it, for example, const.limit = 591. But once an attribute’s",simpleAssign,361 Programming in Python 3- a complete introduction to the Python language,v = x.n Returns the value of object x’s n,simpleAssign,362 Programming in Python 3- a complete introduction to the Python language,v = x.n Returns the value of object x’s n,simpleAssign,362 Programming in Python 3- a complete introduction to the Python language,x.n = v Sets object x’s n attribute’s value,simpleAssign,362 Programming in Python 3- a complete introduction to the Python language,"Const = collections.namedtuple(""_"", ""min max"")(191, 591)",simpleAssign,362 Programming in Python 3- a complete introduction to the Python language,"Offset = collections.namedtuple(""_"", ""id name description"")(*range(3))",simpleAssign,362 Programming in Python 3- a complete introduction to the Python language,"strip_punctuation = make_strip_function("",;:.!?"")",simpleAssign,365 Programming in Python 3- a complete introduction to the Python language,"list by surnames like this: people.sort(key=SortKey(""surname"")). If",simpleAssign,365 Programming in Python 3- a complete introduction to the Python language,"ple.sort(key=SortKey(""surname"", ""forename"")). And if we had people with the",simpleAssign,365 Programming in Python 3- a complete introduction to the Python language,"example, to sort by surname we could write: people.sort(key=operator.attr-",simpleAssign,366 Programming in Python 3- a complete introduction to the Python language,"people.sort(key=operator.attrgetter(""surname"", ""forename"")). The operator.",simpleAssign,366 Programming in Python 3- a complete introduction to the Python language,fh = None,simpleAssign,367 Programming in Python 3- a complete introduction to the Python language,the modified list. (We cannot do self.original = self.modified because that,simpleAssign,369 Programming in Python 3- a complete introduction to the Python language,"name_as_xml = XmlShadow(""name"")",simpleAssign,370 Programming in Python 3- a complete introduction to the Python language,"description_as_xml = XmlShadow(""description"")",simpleAssign,370 Programming in Python 3- a complete introduction to the Python language,"product = Product(""Chisel <3cm>"", ""Chisel & cap"", 45.25)",simpleAssign,370 Programming in Python 3- a complete introduction to the Python language,xml_text = self.cache.get(id(instance)),simpleAssign,371 Programming in Python 3- a complete introduction to the Python language,"x = ExternalStorage(""x"")",simpleAssign,372 Programming in Python 3- a complete introduction to the Python language,"y = ExternalStorage(""y"")",simpleAssign,372 Programming in Python 3- a complete introduction to the Python language,"instance itself can be accessed. For example, if we have p = Point(3, 4), we can",simpleAssign,373 Programming in Python 3- a complete introduction to the Python language,x = y ⇔¬ ( x < y ∨ y < x),simpleAssign,376 Programming in Python 3- a complete introduction to the Python language,x ≠ y ⇔¬ ( x = y),simpleAssign,376 Programming in Python 3- a complete introduction to the Python language,"supplied. (In fact, Python automatically produces > if < is supplied, != if == is",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"supplied, and >= if <= is supplied, so it is sufficient to just implement the three",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"operators <, <=, and == and to leave Python to infer the others. However, using",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"cls.__eq__ = lambda self, other: (not",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"cls.__ne__ = lambda self, other: not cls.__eq__(self, other)",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"cls.__gt__ = lambda self, other: cls.__lt__(other, self)",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"cls.__le__ = lambda self, other: not cls.__lt__(other, self)",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"cls.__ge__ = lambda self, other: not cls.__lt__(self, other)",simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,is the decorator’s minimum requirement. And if there is a custom == we use,simpleAssign,377 Programming in Python 3- a complete introduction to the Python language,"price = abc.abstractproperty(get_price, set_price)",simpleAssign,381 Programming in Python 3- a complete introduction to the Python language,"price = property(lambda self: super().price,",simpleAssign,382 Programming in Python 3- a complete introduction to the Python language,count = 0,simpleAssign,382 Programming in Python 3- a complete introduction to the Python language,vowel_counter = CharCounter(),simpleAssign,383 Programming in Python 3- a complete introduction to the Python language,rle_encoder = RunLengthEncode(),simpleAssign,383 Programming in Python 3- a complete introduction to the Python language,rle_text = rle_encoder(text),simpleAssign,383 Programming in Python 3- a complete introduction to the Python language,rle_decoder = RunLengthDecode(),simpleAssign,383 Programming in Python 3- a complete introduction to the Python language,original_text = rle_decoder(rle_text),simpleAssign,383 Programming in Python 3- a complete introduction to the Python language,item = self.__stack.pop(),simpleAssign,384 Programming in Python 3- a complete introduction to the Python language,data = pickle.load(fh),simpleAssign,386 Programming in Python 3- a complete introduction to the Python language,g = Good(),simpleAssign,389 Programming in Python 3- a complete introduction to the Python language,"slots = list(dictionary.get(""__slots__"", []))",simpleAssign,390 Programming in Python 3- a complete introduction to the Python language,name = getter_name[4:],simpleAssign,391 Programming in Python 3- a complete introduction to the Python language,getter = dictionary.pop(getter_name),simpleAssign,391 Programming in Python 3- a complete introduction to the Python language,"setter = dictionary.get(setter_name, None)",simpleAssign,391 Programming in Python 3- a complete introduction to the Python language,"dictionary[name] = property(getter, setter)",simpleAssign,391 Programming in Python 3- a complete introduction to the Python language,"dictionary[""__slots__""] = tuple(slots)",simpleAssign,391 Programming in Python 3- a complete introduction to the Python language,"priority order like this: L.sort(key=operator.attrgetter(""priority"")).",simpleAssign,394 Programming in Python 3- a complete introduction to the Python language,"enumerate1 = functools.partial(enumerate, start=1)",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,tion (enumerate()) and a keyword argument (start=1) so that when enumerate1(),simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"reader = functools.partial(open, mode=""rt"", encoding=""utf8"")",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"writer = functools.partial(open, mode=""wt"", encoding=""utf8"")",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"loadButton = tkinter.Button(frame, text=""Load"",",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"saveButton = tkinter.Button(frame, text=""Save"",",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"command=functools.partial(doAction, ""load""))",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"command=functools.partial(doAction, ""save""))",simpleAssign,395 Programming in Python 3- a complete introduction to the Python language,"r""""""(?P=quote)"""""", re.IGNORECASE)",simpleAssign,397 Programming in Python 3- a complete introduction to the Python language,flags = re.MULTILINE|re.IGNORECASE|re.DOTALL,simpleAssign,397 Programming in Python 3- a complete introduction to the Python language,receiver = reporter(),simpleAssign,398 Programming in Python 3- a complete introduction to the Python language,"generator = function(*args, **kwargs)",simpleAssign,398 Programming in Python 3- a complete introduction to the Python language,"ignore = frozenset({""style.css"", ""favicon.png"", ""index.html""})",simpleAssign,399 Programming in Python 3- a complete introduction to the Python language,groups = match.groupdict(),simpleAssign,399 Programming in Python 3- a complete introduction to the Python language,"ment receiver = reporter() which we saw earlier, and passed as the receiver",simpleAssign,399 Programming in Python 3- a complete introduction to the Python language,pipeline = get_data(,simpleAssign,400 Programming in Python 3- a complete introduction to the Python language,"an integer (by rounding), but drop any numbers that are out of range (< 0 or >= 10). If we had the four coroutine components, acquire() (get a number), to_int()",simpleAssign,401 Programming in Python 3- a complete introduction to the Python language,pipe = acquire(to_int(check(output()))),simpleAssign,401 Programming in Python 3- a complete introduction to the Python language,"received 10, which is out of range (>= 10), and so it was filtered out.",simpleAssign,401 Programming in Python 3- a complete introduction to the Python language,pipe = acquire(check(to_int(output()))),simpleAssign,401 Programming in Python 3- a complete introduction to the Python language,pipeline = get_files(receiver),simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,"filenames and the receiver is a reporter() coroutine—created by receiver = reporter()—that",simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,"pipeline = get_files(suffix_matcher(receiver, ("".htm"", "".html"")))",simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,"pipeline = size_matcher(receiver, minimum=1024 ** 2)",simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,"pipeline = suffix_matcher(pipeline, ("".png"", "".jpg"", "".jpeg""))",simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,pipeline = get_files(pipeline),simpleAssign,402 Programming in Python 3- a complete introduction to the Python language,"size_matcher(receiver, minimum=None, maximum=None):",simpleAssign,403 Programming in Python 3- a complete introduction to the Python language,size = os.path.getsize(filename),simpleAssign,403 Programming in Python 3- a complete introduction to the Python language,if ((minimum is None or size >= minimum) and,simpleAssign,403 Programming in Python 3- a complete introduction to the Python language,maximum is None or size <= maximum)):,simpleAssign,403 Programming in Python 3- a complete introduction to the Python language,"valid_string(""name"", empty_allowed=False)",simpleAssign,404 Programming in Python 3- a complete introduction to the Python language,"valid_string(""productid"", empty_allowed=False,",simpleAssign,404 Programming in Python 3- a complete introduction to the Python language,"regex=re.compile(r""[A-Z]{3}\d{4}""))",simpleAssign,404 Programming in Python 3- a complete introduction to the Python language,"valid_string(""category"", empty_allowed=False, acceptable= frozenset([""Consumables"", ""Hardware"", ""Software"", ""Media""]))",simpleAssign,404 Programming in Python 3- a complete introduction to the Python language,"valid_number(""price"", minimum=0, maximum=1e6)",simpleAssign,404 Programming in Python 3- a complete introduction to the Python language,"def valid_string(attr_name, empty_allowed=True, regex=None,",simpleAssign,405 Programming in Python 3- a complete introduction to the Python language,acceptable=None):,simpleAssign,405 Programming in Python 3- a complete introduction to the Python language,"create an item using item = StockItem(""TV"", ""TVA4312"", ""Electrical"", 500, 1),",simpleAssign,406 Programming in Python 3- a complete introduction to the Python language,"ifications to main() are to add get_function = GetFunction() before the loop,",simpleAssign,408 Programming in Python 3- a complete introduction to the Python language,blocks = parse(blocks),simpleAssign,413 Programming in Python 3- a complete introduction to the Python language,"widths, rows = compute_widths_and_rows(cells, SCALE_BY)",simpleAssign,413 Programming in Python 3- a complete introduction to the Python language,width = len(cell.text) // cell.columns,simpleAssign,413 Programming in Python 3- a complete introduction to the Python language,i = int(data),simpleAssign,417 Programming in Python 3- a complete introduction to the Python language,numbers = sorted(numbers),simpleAssign,420 Programming in Python 3- a complete introduction to the Python language,middle = len(numbers) // 2,simpleAssign,420 Programming in Python 3- a complete introduction to the Python language,median = numbers[middle],simpleAssign,420 Programming in Python 3- a complete introduction to the Python language,suite = unittest.TestSuite(),simpleAssign,425 Programming in Python 3- a complete introduction to the Python language,runner = unittest.TextTestRunner(),simpleAssign,425 Programming in Python 3- a complete introduction to the Python language,unittest._TextTestResult run=3 errors=0 failures=0>,simpleAssign,425 Programming in Python 3- a complete introduction to the Python language,suite = unittest.TestLoader().loadTestsFromTestCase(,simpleAssign,427 Programming in Python 3- a complete introduction to the Python language,runner = unittest.TextTestRunner(),simpleAssign,427 Programming in Python 3- a complete introduction to the Python language,items = self.original_list[:],simpleAssign,427 Programming in Python 3- a complete introduction to the Python language,items = self.original_list[:],simpleAssign,428 Programming in Python 3- a complete introduction to the Python language,items = self.original_list[:],simpleAssign,428 Programming in Python 3- a complete introduction to the Python language,repeats = 1000,simpleAssign,430 Programming in Python 3- a complete introduction to the Python language,"t = timeit.Timer(""{0}(X, Y)"".format(function),",simpleAssign,430 Programming in Python 3- a complete introduction to the Python language,sec = t.timeit(repeats) / repeats,simpleAssign,430 Programming in Python 3- a complete introduction to the Python language,"child = os.path.join(os.path.dirname(__file__),",simpleAssign,437 Programming in Python 3- a complete introduction to the Python language,"opts, word, args = parse_options()",simpleAssign,437 Programming in Python 3- a complete introduction to the Python language,"filelist = get_files(args, opts.recurse)",simpleAssign,437 Programming in Python 3- a complete introduction to the Python language,files_per_process = len(filelist) // opts.count,simpleAssign,437 Programming in Python 3- a complete introduction to the Python language,number = 1,simpleAssign,437 Programming in Python 3- a complete introduction to the Python language,pipe = pipes.pop(),simpleAssign,439 Programming in Python 3- a complete introduction to the Python language,BLOCK_SIZE = 8000,simpleAssign,439 Programming in Python 3- a complete introduction to the Python language,"number = ""{0}: "".format(sys.argv[1]) if len(sys.argv) == 2 else """"",simpleAssign,439 Programming in Python 3- a complete introduction to the Python language,"lines = stdin.decode(""utf8"", ""ignore"").splitlines()",simpleAssign,439 Programming in Python 3- a complete introduction to the Python language,word = lines[0].rstrip(),simpleAssign,439 Programming in Python 3- a complete introduction to the Python language,sys.stdin = sys.stdin.detach(),simpleAssign,440 Programming in Python 3- a complete introduction to the Python language,"lines = stdin.decode(""utf8"", ""ignore"").splitlines()",simpleAssign,440 Programming in Python 3- a complete introduction to the Python language,filename = filename.rstrip(),simpleAssign,440 Programming in Python 3- a complete introduction to the Python language,"opts, word, args = parse_options()",simpleAssign,443 Programming in Python 3- a complete introduction to the Python language,"filelist = get_files(args, opts.recurse)",simpleAssign,443 Programming in Python 3- a complete introduction to the Python language,work_queue = queue.Queue(),simpleAssign,443 Programming in Python 3- a complete introduction to the Python language,"worker = Worker(work_queue, word, number)",simpleAssign,443 Programming in Python 3- a complete introduction to the Python language,worker.daemon = True,simpleAssign,443 Programming in Python 3- a complete introduction to the Python language,"opts, path = parse_options()",simpleAssign,446 Programming in Python 3- a complete introduction to the Python language,data = collections.defaultdict(list),simpleAssign,446 Programming in Python 3- a complete introduction to the Python language,"fullname = os.path.join(root, filename)",simpleAssign,446 Programming in Python 3- a complete introduction to the Python language,work_queue = queue.PriorityQueue(),simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,results_queue = queue.Queue(),simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,"worker = Worker(work_queue, md5_from_filename, results_queue,",simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,worker.daemon = True,simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,results_thread = threading.Thread(,simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,target=lambda: print_results(results_queue)),simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,results_thread.daemon = True,simpleAssign,447 Programming in Python 3- a complete introduction to the Python language,"names = data[size, filename]",simpleAssign,448 Programming in Python 3- a complete introduction to the Python language,Md5_lock = threading.Lock(),simpleAssign,448 Programming in Python 3- a complete introduction to the Python language,"size, names = self.work_queue.get()",simpleAssign,448 Programming in Python 3- a complete introduction to the Python language,md5s = collections.defaultdict(set),simpleAssign,449 Programming in Python 3- a complete introduction to the Python language,"md5 = self.md5_from_filename.get(filename, None)",simpleAssign,449 Programming in Python 3- a complete introduction to the Python language,"t COUNT, --threads=COUNT",simpleAssign,453 Programming in Python 3- a complete introduction to the Python language,Address[0] = sys.argv[1],simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,"call = dict(c=get_car_details, m=change_mileage, o=change_owner,",simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,"n=new_registration, s=stop_server, q=quit)",simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,"valid = frozenset(""cmonsq"")",simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,previous_license = None,simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,"action = Console.get_menu_choice(menu, valid, ""c"", True)",simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,previous_license = call[action](previous_license),simpleAssign,456 Programming in Python 3- a complete introduction to the Python language,"license, car = retrieve_car_details(previous_license)",simpleAssign,457 Programming in Python 3- a complete introduction to the Python language,"license = Console.get_string(""License"", ""license"",",simpleAssign,457 Programming in Python 3- a complete introduction to the Python language,license = license.upper(),simpleAssign,457 Programming in Python 3- a complete introduction to the Python language,"ok, *data = handle_request(""GET_CAR_DETAILS"", license)",simpleAssign,457 Programming in Python 3- a complete introduction to the Python language,"license, car = retrieve_car_details(previous_license)",simpleAssign,458 Programming in Python 3- a complete introduction to the Python language,"mileage = Console.get_integer(""Mileage"", ""mileage"",",simpleAssign,458 Programming in Python 3- a complete introduction to the Python language,"ok, *data = handle_request(""CHANGE_MILEAGE"", license, mileage)",simpleAssign,458 Programming in Python 3- a complete introduction to the Python language,"handle_request(""SHUTDOWN"", wait_for_reply=False)",simpleAssign,459 Programming in Python 3- a complete introduction to the Python language,"filename = os.path.join(os.path.dirname(__file__),",simpleAssign,462 Programming in Python 3- a complete introduction to the Python language,cars = load(filename),simpleAssign,462 Programming in Python 3- a complete introduction to the Python language,RequestHandler.Cars = cars,simpleAssign,462 Programming in Python 3- a complete introduction to the Python language,server = None,simpleAssign,462 Programming in Python 3- a complete introduction to the Python language,CarsLock = threading.Lock(),simpleAssign,464 Programming in Python 3- a complete introduction to the Python language,CallLock = threading.Lock(),simpleAssign,464 Programming in Python 3- a complete introduction to the Python language,Call = dict(,simpleAssign,464 Programming in Python 3- a complete introduction to the Python language,"SHUTDOWN=lambda self, *args: self.shutdown(*args))",simpleAssign,464 Programming in Python 3- a complete introduction to the Python language,on this variable some programmers would have added Cars = None as a class,simpleAssign,464 Programming in Python 3- a complete introduction to the Python language,"entries such as GET_CAR_DETAILS=get_car_details, with Python able to find the",simpleAssign,465 Programming in Python 3- a complete introduction to the Python language,"SizeStruct = struct.Struct(""!I"")",simpleAssign,465 Programming in Python 3- a complete introduction to the Python language,size = SizeStruct.unpack(size_data)[0],simpleAssign,465 Programming in Python 3- a complete introduction to the Python language,"car = copy.copy(self.Cars.get(license, None))",simpleAssign,466 Programming in Python 3- a complete introduction to the Python language,"car = self.Cars.get(license, None)",simpleAssign,466 Programming in Python 3- a complete introduction to the Python language,db = None,simpleAssign,472 Programming in Python 3- a complete introduction to the Python language,"title = Console.get_string(""Title"", ""title"")",simpleAssign,473 Programming in Python 3- a complete introduction to the Python language,maximum=datetime.date.today().year),simpleAssign,473 Programming in Python 3- a complete introduction to the Python language,"duration = Console.get_integer(""Duration (minutes)"", ""minutes"",",simpleAssign,473 Programming in Python 3- a complete introduction to the Python language,"minimum=0, maximum=60*48)",simpleAssign,473 Programming in Python 3- a complete introduction to the Python language,"old_title = find_dvd(db, ""edit"")",simpleAssign,473 Programming in Python 3- a complete introduction to the Python language,"matches = sorted(matches, key=str.lower)",simpleAssign,474 Programming in Python 3- a complete introduction to the Python language,"which = Console.get_integer(""Number (or 0 to cancel)"",",simpleAssign,474 Programming in Python 3- a complete introduction to the Python language,"number"", minimum=1, maximum=len(matches))",simpleAssign,474 Programming in Python 3- a complete introduction to the Python language,"low_zero=False. We can’t use Enter, that is, nothing, to mean cancel, since enter-",simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,"start = Console.get_string(""List those starting with """,simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,"Enter=all]"", ""start"")",simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,"director, year, duration = db[title]",simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,"The Util.s() function is simply s = lambda x: """" if x == 1 else ""s""; so here it",simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,"title = find_dvd(db, ""remove"")",simpleAssign,475 Programming in Python 3- a complete introduction to the Python language,create = not os.path.exists(filename),simpleAssign,476 Programming in Python 3- a complete introduction to the Python language,db = sqlite3.connect(filename),simpleAssign,476 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,476 Programming in Python 3- a complete introduction to the Python language,"title = Console.get_string(""Title"", ""title"")",simpleAssign,478 Programming in Python 3- a complete introduction to the Python language,maximum=datetime.date.today().year),simpleAssign,478 Programming in Python 3- a complete introduction to the Python language,"duration = Console.get_integer(""Duration (minutes)"", ""minutes"",",simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,"minimum=0, maximum=60*48)",simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,"director_id = get_and_set_director(db, director)",simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,"director_id = get_director_id(db, director)",simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,479 Programming in Python 3- a complete introduction to the Python language,fields = cursor.fetchone(),simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"title, identity = find_dvd(db, ""edit"")",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"WHERE dvds.director_id = directors.id AND """,simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"dvds.id=:id"", dict(id=identity))",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"year, duration, director = cursor.fetchone()",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"director = Console.get_string(""Director"", ""director"", director)",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"duration = Console.get_integer(""Duration (minutes)"", ""minutes"",",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"duration, minimum=0, maximum=60*48)",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"director_id = get_and_set_director(db, director)",simpleAssign,480 Programming in Python 3- a complete introduction to the Python language,"pass dict(title=title, year=year, duration=duration, director_id=director_id,",simpleAssign,481 Programming in Python 3- a complete introduction to the Python language,id=identity)) instead of locals().,simpleAssign,481 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,481 Programming in Python 3- a complete introduction to the Python language,"which = Console.get_integer(""Number (or 0 to cancel)"",",simpleAssign,481 Programming in Python 3- a complete introduction to the Python language,"number"", minimum=1, maximum=len(records))",simpleAssign,481 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,"WHERE dvds.director_id = directors.id"")",simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,start = None,simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,"start = Console.get_string(""List those starting with """,simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,"Enter=all]"", ""start"")",simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,"title, identity = find_dvd(db, ""remove"")",simpleAssign,482 Programming in Python 3- a complete introduction to the Python language,"ans = Console.get_bool(""Remove {0}?"".format(title), ""no"")",simpleAssign,483 Programming in Python 3- a complete introduction to the Python language,cursor = db.cursor(),simpleAssign,483 Programming in Python 3- a complete introduction to the Python language,"literal characters src= then at least one “word” character), and then any other",simpleAssign,490 Programming in Python 3- a complete introduction to the Python language,"example, if we have read a text file with lines of the form key=value, where",simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,"For example, the key=value regular expression will match the entire line",simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,topic= physical geography with the two captures shown shaded. Notice that,simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,"the second capture includes some whitespace, and that whitespace before the = is not accepted. We could refine the regex to be more flexible in accepting",simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,"around the = sign, but with the first capture having no leading or trailing",simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,ple: topic = physical geography. We have been careful to keep the whitespace,simpleAssign,491 Programming in Python 3- a complete introduction to the Python language,"assertions to improve the clarity of a key=value regex, for example, by chang-",simpleAssign,492 Programming in Python 3- a complete introduction to the Python language,key=value is taken from a single line with no possibility of spanning lines—,simpleAssign,492 Programming in Python 3- a complete introduction to the Python language,character class such as [ ]. Here’s the key=value regex with comments:,simpleAssign,492 Programming in Python 3- a complete introduction to the Python language,"In the case of the key=value regex, the negative lookbehind assertion means",simpleAssign,493 Programming in Python 3- a complete introduction to the Python language,"phisticated, for example, \b(Helen(?:\s+(?:P\.|Patricia))?)\s+(?=Sharman\b).",simpleAssign,494 Programming in Python 3- a complete introduction to the Python language,"by number (e.g., \1) or by name (e.g., (?P=name)). It is also possible to match",simpleAssign,494 Programming in Python 3- a complete introduction to the Python language,P=quote),simpleAssign,495 Programming in Python 3- a complete introduction to the Python language,"class we had to use a numbered backreference, \1, instead of (?P=quote), since",simpleAssign,495 Programming in Python 3- a complete introduction to the Python language,"qimage"" (capture number 2) or in ""uimage"" (capture number 3, since (?P=quote)",simpleAssign,495 Programming in Python 3- a complete introduction to the Python language,"match = re.search(r""#[\dA-Fa-f]{6}\b"", text)",simpleAssign,496 Programming in Python 3- a complete introduction to the Python language,"color_re = re.compile(r""#[\dA-Fa-f]{6}\b"")",simpleAssign,496 Programming in Python 3- a complete introduction to the Python language,match = color_re.search(text),simpleAssign,496 Programming in Python 3- a complete introduction to the Python language,"while (?P<word>) matches and captures, the \s+ and (?P=word) parts only match.",simpleAssign,496 Programming in Python 3- a complete introduction to the Python language,"image_re = re.compile(r""""""",simpleAssign,497 Programming in Python 3- a complete introduction to the Python language,P=quote),simpleAssign,497 Programming in Python 3- a complete introduction to the Python language,"code = html.entities.name2codepoint.get(match.group(1), 0xFFFD)",simpleAssign,499 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""<!--(?:.|\n)*?-->"", """", html_text)",simpleAssign,500 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""<[Pp][^>]*?>"", ""\n\n"", text)",simpleAssign,500 Programming in Python 3- a complete introduction to the Python language,"text = re.sub(r""<[^>]*?>"", """", text)",simpleAssign,500 Programming in Python 3- a complete introduction to the Python language,"charset=ISO-8859-1'/>. XML files are UTF-8 by default, but this can be over-",simpleAssign,504 Programming in Python 3- a complete introduction to the Python language,"match = re.search(r""""""(?<![-\w])",simpleAssign,504 Programming in Python 3- a complete introduction to the Python language,"encoding = match.group(match.lastindex) if match else b""utf8""",simpleAssign,504 Programming in Python 3- a complete introduction to the Python language,xmlns = http://www.w3.org/1999/xhtml,simpleAssign,506 Programming in Python 3- a complete introduction to the Python language,http-equiv = Content-Type,simpleAssign,507 Programming in Python 3- a complete introduction to the Python language,content = text/html; charset=utf-8,simpleAssign,507 Programming in Python 3- a complete introduction to the Python language,class = right,simpleAssign,507 Programming in Python 3- a complete introduction to the Python language,style = margin-right: 10px,simpleAssign,507 Programming in Python 3- a complete introduction to the Python language,ATTRIBUTE ::= NAME '=' VALUE,simpleAssign,511 Programming in Python 3- a complete introduction to the Python language,The symbol ::= means is defined as. Nonterminals are written in uppercase,simpleAssign,511 Programming in Python 3- a complete introduction to the Python language,ATTRIBUTE ::= NAME '=' VALUE '\n',simpleAssign,511 Programming in Python 3- a complete introduction to the Python language,"the text “depth = 37\n”, we can work through the BNF to see if the text match-",simpleAssign,512 Programming in Python 3- a complete introduction to the Python language,"first to produce 4 and then 4 / 2 to produce 2. By contrast, the = operator is",simpleAssign,512 Programming in Python 3- a complete introduction to the Python language,"right-associative, which is why we can write x = y = 5. When there are two or",simpleAssign,512 Programming in Python 3- a complete introduction to the Python language,"more =s they are evaluated from right to left, so y = 5 is evaluated first, giving",simpleAssign,512 Programming in Python 3- a complete introduction to the Python language,"y a value, and then x = y giving x a value. If = was not right-associative the",simpleAssign,512 Programming in Python 3- a complete introduction to the Python language,EXPRESSION ::= TERM (ADD_OPERATOR TERM)*,simpleAssign,513 Programming in Python 3- a complete introduction to the Python language,TERM ::= FACTOR (SCALE_OPERATOR FACTOR)*,simpleAssign,513 Programming in Python 3- a complete introduction to the Python language,POWER_EXPRESSION ::= FACTOR ('**' POWER_EXPRESSION)*,simpleAssign,513 Programming in Python 3- a complete introduction to the Python language,key=value format. One unusual aspect is that key names are repeated—but,simpleAssign,514 Programming in Python 3- a complete introduction to the Python language,File1=Blondie\Atomic\01-Atomic.ogg,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,Title1=Blondie - Atomic,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,Length1=230,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,File18=Blondie\Atomic\18-I'm Gonna Love You Too.ogg,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,Title18=Blondie - I'm Gonna Love You Too,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,NumberOfEntries=18,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,Version=2,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,LINE ::= INI_HEADER | KEY_VALUE | COMMENT | BLANK,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,KEY_VALUE ::= KEY \s* '=' \s* VALUE?,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,well as the ones that we would expect to be valid such as “length=126\n”. The,simpleAssign,515 Programming in Python 3- a complete introduction to the Python language,"The KEY_VALUE_RE regex allows for whitespace around the = sign,",simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,line = line.strip(),simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,key_value = KEY_VALUE_RE.match(line),simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,"key = key_value.group(""key"")",simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,key = key.lower(),simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,"key_values[key] = key_value.group(""value"")",simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,ini_header = INI_HEADER.match(line),simpleAssign,516 Programming in Python 3- a complete introduction to the Python language,"Since we expect most lines to be key=value lines, we always try to match the",simpleAssign,517 Programming in Python 3- a complete introduction to the Python language,"If the line is not a key=value line, we try to match a .ini header—and if we",simpleAssign,517 Programming in Python 3- a complete introduction to the Python language,ENTRY ::= INFO '\n' FILENAME '\n',simpleAssign,518 Programming in Python 3- a complete introduction to the Python language,"Song = collections.namedtuple(""Song"", ""title seconds filename"")",simpleAssign,518 Programming in Python 3- a complete introduction to the Python language,"WANT_INFO, WANT_FILENAME = range(2)",simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,state = WANT_INFO,simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,line = line.strip(),simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,info = INFO_RE.match(line),simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,"title = info.group(""title"")",simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,"seconds = int(info.group(""seconds""))",simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,state = WANT_FILENAME,simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,elif state == WANT_FILENAME:,simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,title = seconds = None,simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,state = WANT_INFO,simpleAssign,519 Programming in Python 3- a complete introduction to the Python language,"get_root_block = lambda: Block(None, None)",simpleAssign,524 Programming in Python 3- a complete introduction to the Python language,"get_empty_block = lambda: Block("""")",simpleAssign,524 Programming in Python 3- a complete introduction to the Python language,get_new_row = lambda: None,simpleAssign,524 Programming in Python 3- a complete introduction to the Python language,is_new_row = lambda x: x is None,simpleAssign,524 Programming in Python 3- a complete introduction to the Python language,data = Data(text),simpleAssign,526 Programming in Python 3- a complete introduction to the Python language,"block = parse_block_data(data, nextBlock)",simpleAssign,527 Programming in Python 3- a complete introduction to the Python language,color = None,simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,"colon = data.text.find("":"", data.pos)",simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,color = data.text[data.pos:colon],simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,name = data.text[data.pos:end].strip(),simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,block = Block.get_empty_block(),simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,"block = Block.Block(name, color)",simpleAssign,528 Programming in Python 3- a complete introduction to the Python language,a boolean parser element by writing boolean = true | false.,simpleAssign,531 Programming in Python 3- a complete introduction to the Python language,OPTIONAL_ITEM ::= ITEM | EMPTY,simpleAssign,532 Programming in Python 3- a complete introduction to the Python language,optional_item = item | Empty() # WRONG!,simpleAssign,532 Programming in Python 3- a complete introduction to the Python language,optional_item = Optional(item),simpleAssign,532 Programming in Python 3- a complete introduction to the Python language,"VAR_LIST ::= VARIABLE | VARIABLE ',' VAR_LIST",simpleAssign,532 Programming in Python 3- a complete introduction to the Python language,"variable = Word(alphas, alphanums)",simpleAssign,533 Programming in Python 3- a complete introduction to the Python language,var_list = Forward(),simpleAssign,533 Programming in Python 3- a complete introduction to the Python language,var_list = delimitedList(variable),simpleAssign,533 Programming in Python 3- a complete introduction to the Python language,"left_bracket, right_bracket, equals = map(Suppress, ""[]="")",simpleAssign,534 Programming in Python 3- a complete introduction to the Python language,parser = OneOrMore(ini_header | key_value),simpleAssign,534 Programming in Python 3- a complete introduction to the Python language,key=value we encounter.,simpleAssign,534 Programming in Python 3- a complete introduction to the Python language,"individually, for example, as left_bracket = Suppress(""[""), and so on, but using",simpleAssign,534 Programming in Python 3- a complete introduction to the Python language,key_value parser element—this function will be called for every key=value that,simpleAssign,535 Programming in Python 3- a complete introduction to the Python language,"key, value = tokens",simpleAssign,535 Programming in Python 3- a complete introduction to the Python language,key = key.lower() if lowercase_keys else key,simpleAssign,535 Programming in Python 3- a complete introduction to the Python language,key_values[key] = value,simpleAssign,535 Programming in Python 3- a complete introduction to the Python language,This function is called once for each key=value match. The tokens parameter is,simpleAssign,535 Programming in Python 3- a complete introduction to the Python language,"title = restOfLine(""title"")",simpleAssign,536 Programming in Python 3- a complete introduction to the Python language,"filename = restOfLine(""filename"")",simpleAssign,536 Programming in Python 3- a complete introduction to the Python language,"left_bracket, right_bracket = map(Suppress, ""[]"")",simpleAssign,538 Programming in Python 3- a complete introduction to the Python language,"new_rows = Word(""/"")(""new_rows"").setParseAction(",simpleAssign,538 Programming in Python 3- a complete introduction to the Python language,"name = CharsNotIn(""[]/\n"")(""name"").setParseAction(",simpleAssign,538 Programming in Python 3- a complete introduction to the Python language,the value EmptyBlock which earlier in the file is defined as EmptyBlock = 0. This,simpleAssign,539 Programming in Python 3- a complete introduction to the Python language,nodes = Forward(),simpleAssign,539 Programming in Python 3- a complete introduction to the Python language,"results = nodes.parseString(text, parseAll=True)",simpleAssign,540 Programming in Python 3- a complete introduction to the Python language,items = results.asList()[0],simpleAssign,540 Programming in Python 3- a complete introduction to the Python language,a = b,simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,forall x: a = b,simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,true & forall x: x = x,simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,true & (forall x: x = x),simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,forall x: x = x & true,simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,forall x: x = x) & true,simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,"than equals (=), so ~ a = b is actually ~ (a = b). This is why logicians usually put",simpleAssign,543 Programming in Python 3- a complete introduction to the Python language,TERM ::= SYMBOL | SYMBOL '(' TERM_LIST ')',simpleAssign,544 Programming in Python 3- a complete introduction to the Python language,"TERM_LIST ::= TERM | TERM ',' TERM_LIST",simpleAssign,544 Programming in Python 3- a complete introduction to the Python language,"left_parenthesis, right_parenthesis, colon = map(Suppress, ""():"")",simpleAssign,544 Programming in Python 3- a complete introduction to the Python language,"forall = Keyword(""forall"")",simpleAssign,544 Programming in Python 3- a complete introduction to the Python language,"exists = Keyword(""exists"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"implies = Literal(""->"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"or_ = Literal(""|"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"and_ = Literal(""&"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"not_ = Literal(""~"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"equals = Literal(""="")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"boolean = Keyword(""false"") | Keyword(""true"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"symbol = Word(alphas, alphanums)",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"forall = Keyword(""forall"") | Literal(""∀"")",simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,term = Forward(),simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,formula = Forward(),simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,operand = forall_expression | exists_expression | boolean | term,simpleAssign,545 Programming in Python 3- a complete introduction to the Python language,"items in the list we pass is important. In this example, = has the highest prece-",simpleAssign,547 Programming in Python 3- a complete introduction to the Python language,"result = formula.parseString(text, parseAll=True)",simpleAssign,547 Programming in Python 3- a complete introduction to the Python language,"was detected. For example, if we parse the invalid formula, forall x: = x & true,",simpleAssign,547 Programming in Python 3- a complete introduction to the Python language,forall x: = x & true,simpleAssign,547 Programming in Python 3- a complete introduction to the Python language,In this case the error location is slightly off—the error is that = x should have,simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,"the form y = x, but it is still pretty good.",simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,"We mentioned before that the ~ operator has a lower precedence than the = operator—so let’s see if this is handled correctly by the parser.",simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,true -> ~b = c,simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,true -> ~(b = c),simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,"that = has higher precedence than ~. Of course, we would need to write several",simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,Two of the formulas that we saw earlier were forall x: x = x & true and (forall,simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,"x: x = x) & true, and we pointed out that although the only difference between",simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,forall x: x = x & true,simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,forall x: x = x) & true,simpleAssign,548 Programming in Python 3- a complete introduction to the Python language,actually the same? These two formulas are true & forall x: x = x and true &,simpleAssign,549 Programming in Python 3- a complete introduction to the Python language,"forall x: x = x), and fortunately, when parsed they both produce exactly the",simpleAssign,549 Programming in Python 3- a complete introduction to the Python language,the BNF rule we’re matching (only with ::= replaced with :). Whenever a,simpleAssign,550 Programming in Python 3- a complete introduction to the Python language,"t_ignore_COMMENT = r""\#.*""",simpleAssign,551 Programming in Python 3- a complete introduction to the Python language,t.value = t.value.lower(),simpleAssign,551 Programming in Python 3- a complete introduction to the Python language,t.value = t.value[1:].strip(),simpleAssign,551 Programming in Python 3- a complete introduction to the Python language,"function, we strip off the = and any leading or trailing whitespace.",simpleAssign,552 Programming in Python 3- a complete introduction to the Python language,line = t.value.lstrip(),simpleAssign,552 Programming in Python 3- a complete introduction to the Python language,"i = line.find(""\n"")",simpleAssign,552 Programming in Python 3- a complete introduction to the Python language,line = line if i == -1 else line[:i],simpleAssign,552 Programming in Python 3- a complete introduction to the Python language,lexer = ply.lex.lex(),simpleAssign,553 Programming in Python 3- a complete introduction to the Python language,key = None,simpleAssign,553 Programming in Python 3- a complete introduction to the Python language,key = token.value,simpleAssign,553 Programming in Python 3- a complete introduction to the Python language,key_values[key] = token.value,simpleAssign,553 Programming in Python 3- a complete introduction to the Python language,key = None,simpleAssign,553 Programming in Python 3- a complete introduction to the Python language,"t_M3U = r""\#EXTM3U""",simpleAssign,554 Programming in Python 3- a complete introduction to the Python language,t.value = int(t.value[:-1]),simpleAssign,554 Programming in Python 3- a complete introduction to the Python language,title = seconds = None,simpleAssign,555 Programming in Python 3- a complete introduction to the Python language,lexer = ply.lex.lex(),simpleAssign,555 Programming in Python 3- a complete introduction to the Python language,seconds = token.value,simpleAssign,555 Programming in Python 3- a complete introduction to the Python language,title = token.value,simpleAssign,555 Programming in Python 3- a complete introduction to the Python language,title = seconds = None,simpleAssign,555 Programming in Python 3- a complete introduction to the Python language,"t_NODE_START = r""\[""",simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,"t_NODE_END = r""\]""",simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,"t_COLOR = r""(?:\#[\dA-Fa-f]{6}|[a-zA-Z]\w*):""",simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,"t_EMPTY_NODE = r""\[\]""",simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,block = None,simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,brackets = 0,simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,lexer = ply.lex.lex(),simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,block = Block.get_empty_block(),simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,brackets -= 1,simpleAssign,556 Programming in Python 3- a complete introduction to the Python language,block = None,simpleAssign,557 Programming in Python 3- a complete introduction to the Python language,block.color = token.value[:-1],simpleAssign,557 Programming in Python 3- a complete introduction to the Python language,block.name = token.value,simpleAssign,557 Programming in Python 3- a complete introduction to the Python language,"t.type = keywords.get(t.value, ""SYMBOL"")",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_EQUALS = r""=""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_NOT = r""~""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_AND = r""&""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_OR = r""\|""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_IMPLIES = r""->""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_COLON = r"":""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_COMMA = r"",""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_LPAREN = r""\(""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,"t_RPAREN = r""\)""",simpleAssign,558 Programming in Python 3- a complete introduction to the Python language,but using : rather than ::= to mean is defined by. Note that the words in the,simpleAssign,559 Programming in Python 3- a complete introduction to the Python language,p[0] = p[1],simpleAssign,560 Programming in Python 3- a complete introduction to the Python language,p[0] = p[2],simpleAssign,560 Programming in Python 3- a complete introduction to the Python language,p[0] = p[1],simpleAssign,560 Programming in Python 3- a complete introduction to the Python language,"p[0] = p[1] if len(p) == 2 else [p[1], p[3]]",simpleAssign,561 Programming in Python 3- a complete introduction to the Python language,"p[0] = p[1] if len(p) == 2 else [p[1], p[3]]",simpleAssign,561 Programming in Python 3- a complete introduction to the Python language,lexer = ply.lex.lex(),simpleAssign,562 Programming in Python 3- a complete introduction to the Python language,parser = ply.yacc.yacc(),simpleAssign,562 Programming in Python 3- a complete introduction to the Python language,"year = 2008,",simpleAssign,564 Programming in Python 3- a complete introduction to the Python language,key=value field’s value can either be an integer or a double-quoted string. String,simpleAssign,564 Programming in Python 3- a complete introduction to the Python language,of course strip whitespace from the ends. Note that the last key=value for a,simpleAssign,564 Programming in Python 3- a complete introduction to the Python language,"the list of key=values. If using PLY, the lexer is sufficient, providing you use",simpleAssign,564 Programming in Python 3- a complete introduction to the Python language,"pack() instead of grid(row=0, column=0) to achieve the same effect.",simpleAssign,569 Programming in Python 3- a complete introduction to the Python language,"principalLabel = tkinter.Label(self, text=""Principal $:"",",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"anchor=tkinter.W, underline=0)",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"principalScale = tkinter.Scale(self, variable=self.principal,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"command=self.updateUi, from_=100, to=10000000,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"resolution=100, orient=tkinter.HORIZONTAL)",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"rateLabel = tkinter.Label(self, text=""Rate %:"", underline=0,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,anchor=tkinter.W),simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"rateScale = tkinter.Scale(self, variable=self.rate,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"command=self.updateUi, from_=1, to=100,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"resolution=0.25, digits=5, orient=tkinter.HORIZONTAL)",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"yearsLabel = tkinter.Label(self, text=""Years:"", underline=0,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,anchor=tkinter.W),simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"yearsScale = tkinter.Scale(self, variable=self.years,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"command=self.updateUi, from_=1, to=50,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,orient=tkinter.HORIZONTAL),simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"amountLabel = tkinter.Label(self, text=""Amount $"",",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"actualAmountLabel = tkinter.Label(self,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,anchor=tkinter.W),simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"textvariable=self.amount, relief=tkinter.SUNKEN,",simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,anchor=tkinter.E),simpleAssign,570 Programming in Python 3- a complete introduction to the Python language,"principalLabel.grid(row=0, column=0, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.W),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"principalScale.grid(row=0, column=1, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"rateLabel.grid(row=1, column=0, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.EW),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.W),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"rateScale.grid(row=1, column=1, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.EW),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"yearsLabel.grid(row=2, column=0, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.W),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"yearsScale.grid(row=2, column=1, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.EW),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"amountLabel.grid(row=3, column=0, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.W),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,"actualAmountLabel.grid(row=3, column=1, padx=2, pady=2,",simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.EW),simpleAssign,571 Programming in Python 3- a complete introduction to the Python language,amount = self.principal.get() * (,simpleAssign,573 Programming in Python 3- a complete introduction to the Python language,application = tkinter.Tk(),simpleAssign,573 Programming in Python 3- a complete introduction to the Python language,"path = os.path.join(os.path.dirname(__file__), ""images/"")",simpleAssign,573 Programming in Python 3- a complete introduction to the Python language,window = MainWindow(application),simpleAssign,574 Programming in Python 3- a complete introduction to the Python language,menubar = tkinter.Menu(self.parent),simpleAssign,575 Programming in Python 3- a complete introduction to the Python language,fileMenu = tkinter.Menu(menubar),simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,"fileMenu.add_command(label=label, underline=0,",simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,"command=command, accelerator=shortcut_text)",simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,"menubar.add_cascade(label=""File"", menu=fileMenu, underline=0)",simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,frame = tkinter.Frame(self.parent),simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,toolbar = tkinter.Frame(frame),simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,"image = os.path.join(os.path.dirname(__file__), image)",simpleAssign,576 Programming in Python 3- a complete introduction to the Python language,image = tkinter.PhotoImage(file=image),simpleAssign,577 Programming in Python 3- a complete introduction to the Python language,"button = tkinter.Button(toolbar, image=image,",simpleAssign,577 Programming in Python 3- a complete introduction to the Python language,command=command),simpleAssign,577 Programming in Python 3- a complete introduction to the Python language,"button.grid(row=0, column=len(self.toolbar_images) -1)",simpleAssign,577 Programming in Python 3- a complete introduction to the Python language,"toolbar.grid(row=0, column=0, columnspan=2, sticky=tkinter.NW)",simpleAssign,577 Programming in Python 3- a complete introduction to the Python language,"scrollbar = tkinter.Scrollbar(frame, orient=tkinter.VERTICAL)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,yscrollcommand=scrollbar.set),simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"scrollbar[""command""] = self.listBox.yview",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"scrollbar.grid(row=1, column=1, sticky=tkinter.NS)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,anchor=tkinter.W),simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,sticky=tkinter.EW),simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.grid(row=0, column=0, sticky=tkinter.NSEW)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.columnconfigure(0, weight=999)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.columnconfigure(1, weight=1)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.rowconfigure(0, weight=1)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.rowconfigure(1, weight=999)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,"frame.rowconfigure(2, weight=1)",simpleAssign,578 Programming in Python 3- a complete introduction to the Python language,window = self.parent.winfo_toplevel(),simpleAssign,579 Programming in Python 3- a complete introduction to the Python language,"window.columnconfigure(0, weight=1)",simpleAssign,579 Programming in Python 3- a complete introduction to the Python language,"window.rowconfigure(0, weight=1)",simpleAssign,579 Programming in Python 3- a complete introduction to the Python language,reply = tkinter.messagebox.askyesnocancel(,simpleAssign,580 Programming in Python 3- a complete introduction to the Python language,"Save unsaved changes?"", parent=self.parent)",simpleAssign,580 Programming in Python 3- a complete introduction to the Python language,filename = tkinter.filedialog.asksaveasfilename(,simpleAssign,581 Programming in Python 3- a complete introduction to the Python language,parent=self.parent),simpleAssign,581 Programming in Python 3- a complete introduction to the Python language,filename = tkinter.filedialog.askopenfilename(,simpleAssign,582 Programming in Python 3- a complete introduction to the Python language,"initialdir=dir,",simpleAssign,582 Programming in Python 3- a complete introduction to the Python language,"defaultextension="".bmf"", parent=self.parent)",simpleAssign,582 Programming in Python 3- a complete introduction to the Python language,form = AddEditForm(self.parent),simpleAssign,583 Programming in Python 3- a complete introduction to the Python language,indexes = self.listBox.curselection(),simpleAssign,584 Programming in Python 3- a complete introduction to the Python language,name = self.listBox.get(index),simpleAssign,584 Programming in Python 3- a complete introduction to the Python language,"form = AddEditForm(self.parent, name, self.data[name])",simpleAssign,584 Programming in Python 3- a complete introduction to the Python language,indexes = self.listBox.curselection(),simpleAssign,584 Programming in Python 3- a complete introduction to the Python language,name = self.listBox.get(index),simpleAssign,584 Programming in Python 3- a complete introduction to the Python language,indexes = self.listBox.curselection(),simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,url = self.data[self.listBox.get(index)],simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,application = tkinter.Tk(),simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,"path = os.path.join(os.path.dirname(__file__), ""images/"")",simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,"application.iconbitmap(icon, default=icon)",simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,window = MainWindow(application),simpleAssign,585 Programming in Python 3- a complete introduction to the Python language,frame = tkinter.Frame(self),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"nameLabel = tkinter.Label(frame, text=""Name:"", underline=0)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"nameEntry = tkinter.Entry(frame, textvariable=self.nameVar)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"urlLabel = tkinter.Label(frame, text=""URL:"", underline=0)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"urlEntry = tkinter.Entry(frame, textvariable=self.urlVar)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"okButton = tkinter.Button(frame, text=""OK"", command=self.ok)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"cancelButton = tkinter.Button(frame, text=""Cancel"",",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,command=self.close),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"nameLabel.grid(row=0, column=0, sticky=tkinter.W, pady=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,padx=3),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"nameEntry.grid(row=0, column=1, columnspan=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"sticky=tkinter.EW, pady=3, padx=3)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"urlLabel.grid(row=1, column=0, sticky=tkinter.W, pady=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,padx=3),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"urlEntry.grid(row=1, column=1, columnspan=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"sticky=tkinter.EW, pady=3, padx=3)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"okButton.grid(row=2, column=2, sticky=tkinter.EW, pady=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,padx=3),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"cancelButton.grid(row=2, column=3, sticky=tkinter.EW, pady=3,",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,padx=3),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"frame.grid(row=0, column=0, sticky=tkinter.NSEW)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"frame.columnconfigure(1, weight=1)",simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,window = self.winfo_toplevel(),simpleAssign,587 Programming in Python 3- a complete introduction to the Python language,"window.columnconfigure(0, weight=1)",simpleAssign,587 Python for Kids,"pickle.dump(game_data, save_file)",pickle,142 Python for Kids,"__add__', '__class__",__class__,113 Python for Kids,"__add__', '__class__",__class__,114 Python for Kids,"if age == 12: print(""A pig fell in the mud!"") else:",ifelse,59 Python for Kids,"if age == 12: print(""A pig fell in the mud!"") else:",ifelse,59 Python for Kids,"if age == 10 or age == 11 or age == 12 or age == 13: print('What is 13 + 49 + 84 + 155 + 97? A headache!') else:",ifelse,61 Python for Kids,"if age >= 10 and age <= 13: print('What is 13 + 49 + 84 + 155 + 97? A headache!') else:",ifelse,61 Python for Kids,"if money > 1000: print(""I'm rich!!"") else:",ifelse,65 Python for Kids,"if age >= 10 and age <= 13: print('What is 13 + 49 + 84 + 155 + 97? A headache!') else:",ifelse,88 Python for Kids,"if max(player_guesses) > guess_this_number: print('Boom! You all lose') else:",ifelse,120 Python for Kids,"while step < 10000: print(step) if tired == True: break elif badweather == True: break else:",whileelse,76 Python for Kids,"while 1: if self.running == True: for sprite in self.sprites: sprite.move() self.tk.update_idletasks() self.tk.update() time.sleep(0.01) class Coords: def __init__(self, x1=0, y1=0, x2=0, y2=0): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 def within_x(co1, co2): if (co1.x1 > co2.x1 and co1.x1 < co2.x2) \ or (co1.x2 > co2.x1 and co1.x2 < co2.x2) \ or (co2.x1 > co1.x1 and co2.x1 < co1.x2) \ or (co2.x2 > co1.x1 and co2.x2 < co1.x1): return True else:",whileelse,277 Python for Kids,"while True: lots of code here lots of code here lots of code here if some_value == True: break The condition for the while loop is just True, which is always true, so the code in the block will always run (thus, the loop is eter- nal). Only if the variable some_value is true will Python break out of the loop. You can see a better example of this in “Using randint to Pick a Random Number” on page 134, but you might want to wait until you’ve read Chapter 7 before taking a look at it. What You Learned In this chapter, we used loops to perform repetitive tasks without all the repetition. We told Python what we wanted repeated by writing the tasks inside blocks of code, which we put inside loops. We used two types of loops: for loops and while loops, which are similar but can be used in different ways. We also used the break keyword to stop looping—that is, to break out of a loop. Programming Puzzles Here are some examples of loops that you can try out for yourself. The answers can be found at http://python-for-kids.com/. #1: The Hello Loop What do you think the following code will do? First, guess what will happen, and then run the code in Python to see if you were right. >>> for x in range(0, 20): print('hello %s' % x) if x < 9: break",whilebreak,78 Python for Kids,"while loop, like this: >>> import random >>> num = random.randint(1, 100) u >>> while True: v print('Guess a number between 1 and 100') w guess = input() x i = int(guess) y if i == num: print('You guessed right') z break",whilebreak,134 Python for Kids,"while 1: if ball.hit_bottom == False: ball.draw() paddle.draw() tk.update_idletasks() tk.update() time.sleep(0.01) Now the loop keeps checking hit_bottom to see if the ball has indeed hit the bottom of the screen. The code should continue",whilecontinue,213 Python for Kids,while loop are as follows:,whilesimple,77 Python for Kids,while x < 50 and y < 100:,whilesimple,77 Python for Kids,while 1:,whilesimple,197 Python for Kids,while 1:,whilesimple,199 Python for Kids,while 1:,whilesimple,200 Python for Kids,while 1:,whilesimple,204 Python for Kids,while 1:,whilesimple,206 Python for Kids,while 1:,whilesimple,210 Python for Kids,while 1:,whilesimple,216 Python for Kids,while 1:,whilesimple,236 Python for Kids,while x == 1:,whilesimple,305 Python for Kids,while x < 10:,whilesimple,306 Python for Kids,from tkinter import *,fromstarstatements,165 Python for Kids,from module-name import *,fromstarstatements,165 Python for Kids,from turtle import *,fromstarstatements,165 Python for Kids,from tkinter import *,fromstarstatements,166 Python for Kids,from tkinter import *,fromstarstatements,168 Python for Kids,from tkinter import *,fromstarstatements,169 Python for Kids,from tkinter import *,fromstarstatements,170 Python for Kids,from tkinter import *,fromstarstatements,171 Python for Kids,from tkinter import *,fromstarstatements,171 Python for Kids,from tkinter import *,fromstarstatements,172 Python for Kids,from tkinter import *,fromstarstatements,174 Python for Kids,from tkinter import *,fromstarstatements,176 Python for Kids,from tkinter import *,fromstarstatements,178 Python for Kids,from tkinter import *,fromstarstatements,178 Python for Kids,from tkinter import *,fromstarstatements,179 Python for Kids,from tkinter import *,fromstarstatements,180 Python for Kids,from tkinter import *,fromstarstatements,182 Python for Kids,from tkinter import *,fromstarstatements,183 Python for Kids,from tkinter import *,fromstarstatements,185 Python for Kids,from tkinter import *,fromstarstatements,186 Python for Kids,from tkinter import *,fromstarstatements,188 Python for Kids,from tkinter import *,fromstarstatements,188 Python for Kids,from tkinter import *,fromstarstatements,189 Python for Kids,from tkinter import *,fromstarstatements,194 Python for Kids,from tkinter import *,fromstarstatements,196 Python for Kids,from tkinter import *,fromstarstatements,199 Python for Kids,from tkinter import *,fromstarstatements,203 Python for Kids,from tkinter import *,fromstarstatements,214 Python for Kids,from tkinter import *,fromstarstatements,234 Python for Kids,from from tkinter import *,fromstarstatements,234 Python for Kids,from tkinter import *,fromstarstatements,257 Python for Kids,from tkinter import *,fromstarstatements,276 Python for Kids,from tkinter import *,fromstarstatements,286 Python for Kids,from time import *,fromstarstatements,299 Python for Kids,"nickname), as follows: import i_am_a_python_module_that_is_not_very_useful as notuseful",asextension,294 Python for Kids,"def __init__(self, spots)",__init__,106 Python for Kids,"def __init__(self, spots)",__init__,106 Python for Kids,"def __init__(self, species, number_of_legs, color)",__init__,130 Python for Kids,"def __init__(self, canvas, color)",__init__,196 Python for Kids,"def __init__(self, canvas, color)",__init__,198 Python for Kids,"def __init__(self, canvas, color)",__init__,199 Python for Kids,"def __init__(self, canvas, color)",__init__,200 Python for Kids,"def __init__(self, canvas, color)",__init__,203 Python for Kids,"def __init__(self, canvas, color)",__init__,206 Python for Kids,"def __init__(self, canvas, color)",__init__,207 Python for Kids,"def __init__(self, canvas, color)",__init__,208 Python for Kids,"def __init__(self, canvas, paddle, color)",__init__,209 Python for Kids,"def __init__(self, canvas, paddle, color)",__init__,214 Python for Kids,"def __init__(self, canvas, color)",__init__,215 Python for Kids,def __init__(self),__init__,234 Python for Kids,"def __init__(self, x1=0, y1=0, x2=0, y2=0)",__init__,238 Python for Kids,"def __init__(self, x1=0, y1=0, x2=0, y2=0)",__init__,239 Python for Kids,"def __init__(self, game)",__init__,244 Python for Kids,"def __init__(self, game, photo_image, x, y, width, height)",__init__,246 Python for Kids,"def __init__(self, game)",__init__,252 Python for Kids,"def __init__(self, game)",__init__,253 Python for Kids,"def __init__(self, game, photo_image, x, y, width, height)",__init__,274 Python for Kids,def __init__(self),__init__,276 Python for Kids,"def __init__(self, game)",__init__,278 Python for Kids,"def __init__(self, game, photo_image, x, y, width, height)",__init__,278 Python for Kids,"def __init__(self, game)",__init__,279 Python for Kids,"def __init__(self, game, photo_image, x, y, width, height)",__init__,281 Python for Kids,"def __init__(self, color)",__init__,296 Python for Kids,class Animals(Animate):,simpleclass,98 Python for Kids,class Mammals(Animals):,simpleclass,98 Python for Kids,class Giraffes(Mammals):,simpleclass,98 Python for Kids,class Animals(Animate):,simpleclass,99 Python for Kids,class Mammals(Animals):,simpleclass,100 Python for Kids,class Giraffes(Mammals):,simpleclass,100 Python for Kids,class Giraffes(Mammals):,simpleclass,104 Python for Kids,class Giraffes(Mammals):,simpleclass,105 Python for Kids,class PlatformSprite(Sprite):,simpleclass,246 Python for Kids,class StickFigureSprite(Sprite):,simpleclass,252 Python for Kids,class StickFigureSprite(Sprite):,simpleclass,253 Python for Kids,class PlatformSprite(Sprite):,simpleclass,257 Python for Kids,class StickFigureSprite(Sprite):,simpleclass,257 Python for Kids,class DoorSprite(Sprite):,simpleclass,274 Python for Kids,class PlatformSprite(Sprite):,simpleclass,278 Python for Kids,class StickFigureSprite(Sprite):,simpleclass,279 Python for Kids,class DoorSprite(Sprite):,simpleclass,281 Python for Kids,"assert statement: >>> mynumber = 10",assert,295 Python for Kids,assert mynumber < 5,assert,295 Python for Kids,assert a < 5,assert,295 Python for Kids,">>> class Things: pass",pass,95 Python for Kids,">>> class Inanimate(Things): pass",pass,95 Python for Kids,">>> class Animate(Things): pass",pass,95 Python for Kids,">>> class Sidewalks(Inanimate): pass",pass,96 Python for Kids,">>> class Animals(Animate): pass",pass,96 Python for Kids,">>> class Mammals(Animals): pass",pass,96 Python for Kids,">>> class Giraffes(Mammals): pass",pass,96 Python for Kids,"def breathe(self): pass",pass,98 Python for Kids,"def move(self): pass",pass,98 Python for Kids,"def eat_food(self): pass",pass,98 Python for Kids,"def feed_young_with_milk(self): pass",pass,98 Python for Kids,"def eat_leaves_from_trees(self): pass",pass,98 Python for Kids,">>> class Car: pass",pass,144 Python for Kids,"def draw(self): pass",pass,196 Python for Kids,"def draw(self): pass",pass,206 Python for Kids,"y def move(self): z pass",pass,245 Python for Kids,"def move(self): pass",pass,278 Python for Kids,">>> if age > 10: pass",pass,303 Python for Kids,">>> if x == 4: pass",pass,304 Python for Kids,NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init],nestedList,290 Python for Kids,"for x in range(0, 5): x for y in range(0, 5):",fornested,235 Python for Kids,"for x in range(0, 5): for y in range(0, 5):",fornested,236 Python for Kids,"for x in range(0, 5): for y in range(0, 5):",fornested,277 Python for Kids,test_file = open('c:\\test.txt'),openfunc,125 Python for Kids,test_file = open('/Users/sarahwinters/test.txt'),openfunc,126 Python for Kids,test_file = open('/home/jacob/test.txt'),openfunc,126 Python for Kids,"test_file = open('c:\\myfile.txt', 'w')",openfunc,126 Python for Kids,"test_file = open('c:\\myfile.txt', 'w')",openfunc,127 Python for Kids,"test_file = open('c:\\myfile.txt', 'w')",openfunc,127 Python for Kids,test_file = open('myfile.txt'),openfunc,127 Python for Kids,"w >>> save_file = open('save.dat', 'wb')",openfunc,142 Python for Kids,"load_file = open('save.dat', 'rb')",openfunc,143 Python for Kids,test_file.write('this is my test file'),write,127 Python for Kids,test_file.write('What is green and loud? A froghorn!'),write,127 Python for Kids,text = test_file.read(),read,125 Python for Kids,print(test_file.read()),read,127 Python for Kids,print(sys.stdin.readline()),readline,88 Python for Kids,u age = int(sys.stdin.readline()),readline,89 Python for Kids,string to a number? We included that function because readline(),readline,89 Python for Kids,values using sys.stdin.readline(),readline,90 Python for Kids,able. (We used sys.stdin.readline(),readline,112 Python for Kids,v = sys.stdin.readline(),readline,137 Python for Kids,v = sys.stdin.readline(13),readline,137 Python for Kids,import turtle,importfunc,44 Python for Kids,import time,importfunc,87 Python for Kids,import command,importfunc,87 Python for Kids,import the,importfunc,88 Python for Kids,import sys,importfunc,88 Python for Kids,import sys,importfunc,88 Python for Kids,"import modules",importfunc,89 Python for Kids,import the,importfunc,91 Python for Kids,import sys,importfunc,91 Python for Kids,import turtle,importfunc,100 Python for Kids,import the,importfunc,108 Python for Kids,import a,importfunc,130 Python for Kids,import turtle,importfunc,130 Python for Kids,import copy,importfunc,131 Python for Kids,import keyword,importfunc,133 Python for Kids,import random,importfunc,134 Python for Kids,import the,importfunc,134 Python for Kids,import random,importfunc,135 Python for Kids,import random,importfunc,136 Python for Kids,import sys,importfunc,136 Python for Kids,import sys,importfunc,137 Python for Kids,import sys,importfunc,137 Python for Kids,import sys,importfunc,138 Python for Kids,import sys,importfunc,138 Python for Kids,import time,importfunc,138 Python for Kids,import time,importfunc,140 Python for Kids,import time,importfunc,140 Python for Kids,import time,importfunc,141 Python for Kids,import pickle,importfunc,142 Python for Kids,import the,importfunc,143 Python for Kids,import copy,importfunc,144 Python for Kids,import the,importfunc,146 Python for Kids,import turtle,importfunc,146 Python for Kids,"import the",importfunc,165 Python for Kids,import turtle,importfunc,165 Python for Kids,import turtle,importfunc,165 Python for Kids,import turtle,importfunc,169 Python for Kids,import random,importfunc,172 Python for Kids,import random,importfunc,174 Python for Kids,import tkinter,importfunc,178 Python for Kids,import time,importfunc,183 Python for Kids,import time,importfunc,185 Python for Kids,import tkinter,importfunc,194 Python for Kids,import random,importfunc,194 Python for Kids,import time,importfunc,194 Python for Kids,import random,importfunc,195 Python for Kids,import random,importfunc,196 Python for Kids,import time,importfunc,196 Python for Kids,import random,importfunc,199 Python for Kids,import time,importfunc,199 Python for Kids,import random,importfunc,203 Python for Kids,import time,importfunc,203 Python for Kids,import random,importfunc,214 Python for Kids,import time,importfunc,214 Python for Kids,import random,importfunc,234 Python for Kids,import time,importfunc,234 Python for Kids,import random,importfunc,257 Python for Kids,import time,importfunc,257 Python for Kids,import random,importfunc,276 Python for Kids,import time,importfunc,276 Python for Kids,import sys,importfunc,287 Python for Kids,import time,importfunc,287 Python for Kids,import pygame2,importfunc,287 Python for Kids,import i_am_a_python_module_that_is_not_very_useful,importfunc,294 Python for Kids,import the,importfunc,298 Python for Kids,import turtle,importfunc,298 Python for Kids,import the,importfunc,299 Python for Kids,import a,importfunc,299 Python for Kids,import only,importfunc,299 Python for Kids,import everything,importfunc,299 Python for Kids,"import The",importfunc,301 Python for Kids,import keyword,importfunc,301 Python for Kids,import sys,importfunc,301 Python for Kids,import In,importfunc,309 Python for Kids,"from previous examples. First, we import the",importfromsimple,195 Python for Kids,"from When importing a module, you can import just",importfromsimple,298 Python for Kids,from turtle import Pen,importfromsimple,299 Python for Kids,from time import localtime,importfromsimple,299 Python for Kids,self.giraffe_spots = spots,simpleattr,106 Python for Kids,self.species = species,simpleattr,130 Python for Kids,self.number_of_legs = number_of_legs,simpleattr,130 Python for Kids,self.color = color,simpleattr,130 Python for Kids,self.canvas = canvas,simpleattr,198 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,198 Python for Kids,self.canvas = canvas,simpleattr,199 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,199 Python for Kids,self.canvas = canvas,simpleattr,200 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,200 Python for Kids,self.x = 0,simpleattr,200 Python for Kids,self.y = -1,simpleattr,200 Python for Kids,self.canvas_height = self.canvas.winfo_height(),simpleattr,200 Python for Kids,"self.y = -1, we set",simpleattr,200 Python for Kids,self.y = 1,simpleattr,201 Python for Kids,self.y = -1,simpleattr,201 Python for Kids,self.x = 0,simpleattr,202 Python for Kids,self.y = -1,simpleattr,202 Python for Kids,self.y = -3,simpleattr,202 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,202 Python for Kids,self.canvas = canvas,simpleattr,203 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,203 Python for Kids,self.x = starts[0],simpleattr,203 Python for Kids,self.y = -3,simpleattr,203 Python for Kids,self.canvas_height = self.canvas.winfo_height(),simpleattr,203 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,203 Python for Kids,self.canvas = canvas,simpleattr,206 Python for Kids,"self.id = canvas.create_rectangle(0, 0, 100, 10, fill=color)",simpleattr,206 Python for Kids,self.canvas = canvas,simpleattr,207 Python for Kids,"self.id = canvas.create_rectangle(0, 0, 100, 10, fill=color)",simpleattr,207 Python for Kids,self.x = 0,simpleattr,207 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,207 Python for Kids,self.x = -2,simpleattr,208 Python for Kids,self.x = 2,simpleattr,208 Python for Kids,self.canvas = canvas,simpleattr,208 Python for Kids,"self.id = canvas.create_rectangle(0, 0, 100, 10, fill=color)",simpleattr,208 Python for Kids,self.x = 0,simpleattr,208 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,208 Python for Kids,self.x = 0,simpleattr,208 Python for Kids,self.canvas = canvas,simpleattr,209 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,209 Python for Kids,self.x = starts[0],simpleattr,209 Python for Kids,self.y = -3,simpleattr,209 Python for Kids,self.canvas_height = self.canvas.winfo_height(),simpleattr,209 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,209 Python for Kids,self.y = -3. But don’t try to run the game now—we,simpleattr,210 Python for Kids,self.canvas_height = self.canvas.winfo_height(),simpleattr,213 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,213 Python for Kids,self.hit_bottom = False,simpleattr,213 Python for Kids,self.canvas = canvas,simpleattr,214 Python for Kids,self.paddle = paddle,simpleattr,214 Python for Kids,"self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleattr,214 Python for Kids,self.x = starts[0],simpleattr,214 Python for Kids,self.y = -3,simpleattr,214 Python for Kids,self.canvas_height = self.canvas.winfo_height(),simpleattr,214 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,214 Python for Kids,self.hit_bottom = False,simpleattr,214 Python for Kids,self.canvas = canvas,simpleattr,215 Python for Kids,"self.id = canvas.create_rectangle(0, 0, 100, 10, fill=color)",simpleattr,215 Python for Kids,self.x = 0,simpleattr,215 Python for Kids,self.canvas_width = self.canvas.winfo_width(),simpleattr,215 Python for Kids,self.x = 0,simpleattr,215 Python for Kids,self.x = -2,simpleattr,215 Python for Kids,self.x = 2,simpleattr,215 Python for Kids,self.tk = Tk(),simpleattr,234 Python for Kids,"self.canvas = Canvas(self.tk, width=500, height=500, \",simpleattr,234 Python for Kids,self.canvas_height = 500,simpleattr,234 Python for Kids,self.canvas_width = 500,simpleattr,234 Python for Kids,self.canvas_height = 500,simpleattr,235 Python for Kids,self.canvas_width = 500,simpleattr,235 Python for Kids,self.running = True,simpleattr,235 Python for Kids,self.sprites = [],simpleattr,236 Python for Kids,self.running = True,simpleattr,236 Python for Kids,self.x1 = x1,simpleattr,238 Python for Kids,self.y1 = y1,simpleattr,238 Python for Kids,self.x2 = x2,simpleattr,238 Python for Kids,self.y2 = y2,simpleattr,238 Python for Kids,self.x1 = x1,simpleattr,239 Python for Kids,self.y1 = y1,simpleattr,239 Python for Kids,self.x2 = x2,simpleattr,239 Python for Kids,self.y2 = y2,simpleattr,239 Python for Kids,self.images_left = [,simpleattr,253 Python for Kids,self.images_right = [,simpleattr,253 Python for Kids,self.images_right = [,simpleattr,253 Python for Kids,"self.image = game.canvas.create_image(200, 470, \",simpleattr,253 Python for Kids,self.x = -2,simpleattr,253 Python for Kids,self.coordinates = Coords(),simpleattr,254 Python for Kids,self.jump_count = 0,simpleattr,255 Python for Kids,self.last_time = time.time(),simpleattr,255 Python for Kids,self.coordinates = Coords(),simpleattr,255 Python for Kids,self.x = -2,simpleattr,255 Python for Kids,self.y = -4,simpleattr,256 Python for Kids,self.jump_count = 0,simpleattr,260 Python for Kids,self.current_image_add = -1,simpleattr,261 Python for Kids,self.last_time= time.time(),simpleattr,262 Python for Kids,self.current_image += self.current_image_add,simpleattr,262 Python for Kids,self.coordinates.x1 = xy[0],simpleattr,265 Python for Kids,self.coordinates.y1 = xy[1],simpleattr,265 Python for Kids,self.coordinates.x2 = xy[0] + 27,simpleattr,265 Python for Kids,self.coordinates.y2 = xy[1] + 30,simpleattr,265 Python for Kids,self.y = 0,simpleattr,267 Python for Kids,self.x = 0,simpleattr,268 Python for Kids,self.x = 0,simpleattr,271 Python for Kids,self.y = sprite_co.y1 - co.y2,simpleattr,271 Python for Kids,self.tk = Tk(),simpleattr,276 Python for Kids,"self.canvas = Canvas(self.tk, width=500, height=500, \",simpleattr,277 Python for Kids,self.canvas_height = 500,simpleattr,277 Python for Kids,self.canvas_width = 500,simpleattr,277 Python for Kids,"self.bg = PhotoImage(file=""background.gif"")",simpleattr,277 Python for Kids,self.sprites = [],simpleattr,277 Python for Kids,self.running = True,simpleattr,277 Python for Kids,self.game = game,simpleattr,278 Python for Kids,self.endgame = False,simpleattr,278 Python for Kids,self.coordinates = None,simpleattr,278 Python for Kids,self.photo_image = photo_image,simpleattr,278 Python for Kids,"self.image = game.canvas.create_image(x, y, \",simpleattr,278 Python for Kids,"self.coordinates = Coords(x, y, x + width, y + height)",simpleattr,278 Python for Kids,self.images_left = [,simpleattr,279 Python for Kids,self.images_right = [,simpleattr,279 Python for Kids,"self.image = game.canvas.create_image(200, 470, \",simpleattr,279 Python for Kids,self.x = -2,simpleattr,279 Python for Kids,self.y = 0,simpleattr,279 Python for Kids,self.current_image = 0,simpleattr,279 Python for Kids,self.current_image_add = 1,simpleattr,279 Python for Kids,self.jump_count = 0,simpleattr,279 Python for Kids,self.last_time = time.time(),simpleattr,279 Python for Kids,self.coordinates = Coords(),simpleattr,279 Python for Kids,self.jump_count = 0,simpleattr,279 Python for Kids,self.last_time= time.time(),simpleattr,279 Python for Kids,self.current_image += self.current_image_add,simpleattr,279 Python for Kids,self.coordinates.x1 = xy[0],simpleattr,280 Python for Kids,self.coordinates.y1 = xy[1],simpleattr,280 Python for Kids,self.coordinates.x2 = xy[0] + 27,simpleattr,280 Python for Kids,self.coordinates.y2 = xy[1] + 30,simpleattr,280 Python for Kids,self.y = 0,simpleattr,280 Python for Kids,self.x = 0,simpleattr,281 Python for Kids,self.y = sprite_co.y1 - co.y2,simpleattr,281 Python for Kids,self.y = 4,simpleattr,281 Python for Kids,self.photo_image = photo_image,simpleattr,281 Python for Kids,"self.image = game.canvas.create_image(x, y, \",simpleattr,281 Python for Kids,"self.coordinates = Coords(x, y, x + (width / 2), y + height)",simpleattr,281 Python for Kids,self.endgame = True,simpleattr,281 Python for Kids,self.color = color,simpleattr,296 Python for Kids,x self.current_image += self.current_image_add,assignIncrement,261 Python for Kids,"range(0, 5))",rangefunc,82 Python for Kids,"range(0, 1000))",rangefunc,82 Python for Kids,"range(1, 5)",rangefunc,146 Python for Kids,"range(1, 5)",rangefunc,147 Python for Kids,"range(1, 9)",rangefunc,147 Python for Kids,"range(1, 19))",rangefunc,149 Python for Kids,"range(0, 4))",rangefunc,157 Python for Kids,range(10),rangefunc,172 Python for Kids,range(100),rangefunc,172 Python for Kids,def testfunc(myname):,simplefunc,83 Python for Kids,def variable_test():,simplefunc,84 Python for Kids,def variable_test2():,simplefunc,85 Python for Kids,def spaceship_building(cans):,simplefunc,86 Python for Kids,def silly_age_joke(age):,simplefunc,88 Python for Kids,def silly_age_joke():,simplefunc,89 Python for Kids,def this_is_a_normal_function():,simplefunc,97 Python for Kids,def this_is_a_class_function():,simplefunc,97 Python for Kids,def this_is_also_a_class_function():,simplefunc,97 Python for Kids,def breathe(self):,simplefunc,99 Python for Kids,def move(self):,simplefunc,99 Python for Kids,def eat_food(self):,simplefunc,99 Python for Kids,def feed_young_with_milk(self):,simplefunc,100 Python for Kids,def eat_leaves_from_trees(self):,simplefunc,100 Python for Kids,def find_food(self):,simplefunc,104 Python for Kids,def find_food(self):,simplefunc,105 Python for Kids,def eat_leaves_from_trees(self):,simplefunc,105 Python for Kids,def dance_a_jig(self):,simplefunc,105 Python for Kids,def left_Foot_Forward(self):,simplefunc,107 Python for Kids,def lots_of_numbers(max):,simplefunc,139 Python for Kids,def lots_of_numbers(max):,simplefunc,139 Python for Kids,def mysquare(size):,simplefunc,156 Python for Kids,def hello():,simplefunc,166 Python for Kids,def movetriangle(event):,simplefunc,186 Python for Kids,def movetriangle(event):,simplefunc,186 Python for Kids,def movetriangle(event):,simplefunc,187 Python for Kids,def movetriangle(event):,simplefunc,188 Python for Kids,def draw(self):,simplefunc,198 Python for Kids,def draw(self):,simplefunc,200 Python for Kids,def draw(self):,simplefunc,200 Python for Kids,def draw(self):,simplefunc,203 Python for Kids,def draw(self):,simplefunc,203 Python for Kids,def draw(self):,simplefunc,206 Python for Kids,def draw(self):,simplefunc,208 Python for Kids,def draw(self):,simplefunc,210 Python for Kids,def draw(self):,simplefunc,213 Python for Kids,def draw(self):,simplefunc,215 Python for Kids,def draw(self):,simplefunc,215 Python for Kids,def mainloop(self):,simplefunc,236 Python for Kids,def coords(self):,simplefunc,245 Python for Kids,def animate(self):,simplefunc,260 Python for Kids,def animate(self):,simplefunc,262 Python for Kids,def coords(self):,simplefunc,264 Python for Kids,def coords(self):,simplefunc,265 Python for Kids,def move(self):,simplefunc,265 Python for Kids,def mainloop(self):,simplefunc,277 Python for Kids,def coords(self):,simplefunc,278 Python for Kids,def animate(self):,simplefunc,279 Python for Kids,def coords(self):,simplefunc,280 Python for Kids,def move(self):,simplefunc,280 Python for Kids,def minutes(years):,simplefunc,297 Python for Kids,def test():,simplefunc,300 Python for Kids,def age_in_seconds(age_in_years):,simplefunc,305 Python for Kids,"return True; otherwise, it would return False. If you are",return,57 Python for Kids,return True.,return,57 Python for Kids,"return a value, using a return state-",return,84 Python for Kids,return pocket_money + paper_route – spending,return,84 Python for Kids,return first_variable * second_variable,return,84 Python for Kids,return first_variable * second_variable * another_variable,return,85 Python for Kids,return to the turtle module we toyed with in Chapter 4.,return,100 Python for Kids,"return True, as shown here:",return,111 Python for Kids,"return False for lists, tuples, and",return,112 Python for Kids,"return true,” and so the code prints You need to enter a",return,112 Python for Kids,return value,return,143 Python for Kids,return to the world of code. To draw a yellow circle,return,153 Python for Kids,"return a number between 0 and 9,",return,172 Python for Kids,"return a number between 0 and 99, and",return,172 Python for Kids,return key. We tell tkinter that,return,187 Python for Kids,"return 1. For example, if you’ve created other shapes, it",return,189 Python for Kids,"return 2, 3, or even 100 for that matter (depending on the",return,189 Python for Kids,"return an identifying number, which can be",return,190 Python for Kids,return True,return,211 Python for Kids,return False,return,211 Python for Kids,return false.,return,212 Python for Kids,return True,return,215 Python for Kids,return False,return,215 Python for Kids,return the size of the image once,return,235 Python for Kids,return True,return,239 Python for Kids,return True,return,239 Python for Kids,return False,return,239 Python for Kids,return True at v if it is.,return,239 Python for Kids,return True at x.,return,240 Python for Kids,"return False at |. This is effectively saying, “No, the two coordi-",return,240 Python for Kids,"return the same value. To solve this problem,",return,241 Python for Kids,return True,return,241 Python for Kids,return False,return,241 Python for Kids,return True,return,241 Python for Kids,return False,return,241 Python for Kids,return True,return,242 Python for Kids,return False,return,242 Python for Kids,return True at x. If none of the if,return,243 Python for Kids,return False at y.,return,243 Python for Kids,return True,return,243 Python for Kids,return False,return,243 Python for Kids,return True at w if it is. Other-,return,243 Python for Kids,return False at x.,return,243 Python for Kids,return True,return,243 Python for Kids,return False,return,243 Python for Kids,return True (mean-,return,243 Python for Kids,return True,return,244 Python for Kids,return False,return,244 Python for Kids,return True at x because the,return,244 Python for Kids,return False at y.,return,244 Python for Kids,"return the sprite’s current position on the screen. Here’s the code for the",return,244 Python for Kids,return self.coordinates,return,245 Python for Kids,return the stick figure’s current,return,260 Python for Kids,return self.coordinates,return,264 Python for Kids,return the x and,return,264 Python for Kids,return the object,return,264 Python for Kids,return self.coordinates,return,265 Python for Kids,"return true, because its code will add the value of y",return,269 Python for Kids,return False,return,277 Python for Kids,return True,return,277 Python for Kids,return False,return,278 Python for Kids,return True,return,278 Python for Kids,return False,return,278 Python for Kids,return True,return,278 Python for Kids,return False,return,278 Python for Kids,return True,return,278 Python for Kids,return False,return,278 Python for Kids,return False,return,278 Python for Kids,return self.coordinates,return,278 Python for Kids,return self.coordinates,return,280 Python for Kids,return 0;,return,289 Python for Kids,return 0;,return,290 Python for Kids,return years * 365 * 24 * 60,return,297 Python for Kids,"return The return keyword is used to return a value from a function. For",return,305 Python for Kids,return age_in_years * 365 * 24 * 60 * 60,return,305 Python for Kids,"return keyword, 305",return,317 Python for Kids,if this worked:,simpleif,27 Python for Kids,if statement might be written in Python like this:,simpleif,54 Python for Kids,"if age > 20: print('You are too old!')",simpleif,54 Python for Kids,"if age > 20: print('You are too old!')",simpleif,54 Python for Kids,"if age > 20: ▯▯▯▯print('You are too old!')",simpleif,55 Python for Kids,"if age > 20: ▯▯▯▯print('You are too old!')",simpleif,56 Python for Kids,"if age > 20: print('You are too old!')",simpleif,56 Python for Kids,if age is greater than 10:,simpleif,57 Python for Kids,"if age > 10: print('You are too old for my jokes!')",simpleif,57 Python for Kids,"if age >= 10: print('You are too old for my jokes!')",simpleif,58 Python for Kids,"if age == 10: print('What\'s brown and sticky? A stick!!')",simpleif,58 Python for Kids,"if myval == None: print(""The variable myval doesn't have a value"")",simpleif,62 Python for Kids,"if statement, like this:",simpleif,63 Python for Kids,"if age == 10: print(""What's the best way to speak to a monster?"")",simpleif,63 Python for Kids,"if age == 10: print(""What's the best way to speak to a monster?"")",simpleif,63 Python for Kids,"if age == 10: print(""What's the best way to speak to a monster?"")",simpleif,63 Python for Kids,"if converted_age == 10: print(""What's the best way to speak to a monster?"")",simpleif,64 Python for Kids,"if statement:",simpleif,88 Python for Kids,"if age >= 10 and age <= 13: print('What is 13 + 49 + 84 + 155 + 97? A headache!')",simpleif,88 Python for Kids,"if abs(steps) > 0: print('Character is moving')",simpleif,111 Python for Kids,if statement might look like this:,simpleif,111 Python for Kids,"if steps < 0 or steps > 0: print('Character is moving')",simpleif,111 Python for Kids,"if not bool(year.rstrip()): print('You need to enter a value for your year of birth')",simpleif,112 Python for Kids,"if statements) generally won’t evaluate, as in this example:",simpleif,115 Python for Kids,"if True: print(""this won't work at all"")''')",simpleif,115 Python for Kids,"if age > 13: print('You are %s years too old' % (age - 13))",simpleif,117 Python for Kids,"if the username is jacob, the open parameter should look like this:",simpleif,126 Python for Kids,"if i < num: print('Try higher')",simpleif,134 Python for Kids,if i > num:,simpleif,134 Python for Kids,"if x % 2 == 0: t.left(175)",simpleif,149 Python for Kids,"if filled == True: t.begin_fill()",simpleif,157 Python for Kids,"if filled == True: t.end_fill()",simpleif,157 Python for Kids,"if x % 2 == 0: t.left(175)",simpleif,158 Python for Kids,"if filled == True: t.begin_fill()",simpleif,159 Python for Kids,"if x % 2 == 0: t.left(175)",simpleif,159 Python for Kids,"if filled == True: t.end_fill()",simpleif,159 Python for Kids,if image like this:,simpleif,182 Python for Kids,"if event.keysym == 'Up': canvas.move(1, 0, -3)",simpleif,187 Python for Kids,"if event.keysym == 'Down': canvas.move(1, 0, 3)",simpleif,187 Python for Kids,"if event.keysym == 'Left': canvas.move(1, -3, 0)",simpleif,187 Python for Kids,"if event.keysym == 'Up': v canvas.move(1, 0, -3)",simpleif,188 Python for Kids,"if event.keysym == 'Down': x canvas.move(1, 0, 3)",simpleif,188 Python for Kids,"if event.keysym == 'Left': z canvas.move(1, -3, 0)",simpleif,188 Python for Kids,"if the ball has hit the top or bottom of the canvas:",simpleif,202 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,202 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,202 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,203 Python for Kids,"if pos[3] >= self.canvas_height: self.y = -3",simpleif,203 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,203 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,203 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,203 Python for Kids,"if pos[3] >= self.canvas_height: self.y = -3",simpleif,203 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,203 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,203 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,206 Python for Kids,"if pos[3] >= self.canvas_height: self.y = -3",simpleif,206 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,206 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,206 Python for Kids,"if pos[0] <= 0: self.x = 0",simpleif,208 Python for Kids,if the ball has hit the bottom of the screen:,simpleif,210 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,210 Python for Kids,"if pos[3] >= self.canvas_height: self.y = -3",simpleif,210 Python for Kids,"if self.hit_paddle(pos) == True: self.y = -3",simpleif,210 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,210 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,210 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,213 Python for Kids,"if pos[3] >= self.canvas_height: self.hit_bottom = True",simpleif,213 Python for Kids,"if self.hit_paddle(pos) == True: self.y = -3",simpleif,213 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,213 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,213 Python for Kids,"if pos[2] >= paddle_pos[0] and pos[0] <= paddle_pos[2]: if pos[3] >= paddle_pos[1] and pos[3] <= paddle_pos[3]:",simpleif,215 Python for Kids,"if pos[1] <= 0: self.y = 3",simpleif,215 Python for Kids,"if pos[3] >= self.canvas_height: self.hit_bottom = True",simpleif,215 Python for Kids,"if self.hit_paddle(pos) == True: self.y = -3",simpleif,215 Python for Kids,"if pos[0] <= 0: self.x = 3",simpleif,215 Python for Kids,"if pos[2] >= self.canvas_width: self.x = -3",simpleif,215 Python for Kids,"if pos[0] <= 0: self.x = 0",simpleif,215 Python for Kids,"if ball.hit_bottom == False: ball.draw()",simpleif,216 Python for Kids,"if we use our transparent image, we get this:",simpleif,230 Python for Kids,"if co1.x1 > co2.x1 and co1.x1 < co2.x2: v return True",simpleif,239 Python for Kids,"if co1.x2 > co2.x1 and co1.x2 < co2.x2: x return True",simpleif,239 Python for Kids,if co2.x1 > co1.x1 and co2.x1 < co1.x2:,simpleif,239 Python for Kids,if co2.x2 > co1.x1 and co2.x2 < co1.x1:,simpleif,239 Python for Kids,if statements):,simpleif,241 Python for Kids,"if within_y(co1, co2): w if co1.x1 <= co2.x2 and co1.x1 >= co2.x1:",simpleif,242 Python for Kids,"if within_y(co1, co2): v if co1.x2 >= co2.x1 and co1.x2 <= co2.x2:",simpleif,243 Python for Kids,"if within_x(co1, co2): v if co1.y1 <= co2.y2 and co1.y1 >= co2.y1:",simpleif,243 Python for Kids,"if within_x(co1, co2): v y_calc = co1.y2 + y",simpleif,244 Python for Kids,"if self.y == 0: self.x = 2",simpleif,256 Python for Kids,"if self.y == 0: self.y = -4",simpleif,260 Python for Kids,if time.time() - self.last_time > 0.1:,simpleif,260 Python for Kids,"if self.current_image <= 0: | self.current_image_add = 1",simpleif,261 Python for Kids,"if self.x != 0 and self.y == 0: if time.time() - self.last_time > 0.1:",simpleif,262 Python for Kids,"if self.current_image >= 2: self.current_image_add = -1",simpleif,262 Python for Kids,"if self.current_image <= 0: self.current_image_add = 1",simpleif,262 Python for Kids,"if self.x < 0: v if self.y != 0:",simpleif,262 Python for Kids,"if self.x > 0: { if self.y != 0:",simpleif,263 Python for Kids,"if self.x < 0: if self.y != 0:",simpleif,264 Python for Kids,"if self.x > 0: if self.y != 0:",simpleif,264 Python for Kids,"if self.y < 0: w self.jump_count += 1",simpleif,265 Python for Kids,"if self.jump_count > 20: y self.y = 4",simpleif,265 Python for Kids,"if self.y > 0: { self.jump_count -= 1",simpleif,265 Python for Kids,"if self.y > 0: self.jump_count -= 1",simpleif,266 Python for Kids,"if top and self.y < 0 and collided_top(co, sprite_co): z self.y = -self.y",simpleif,268 Python for Kids,"if top and self.y < 0 and collided_top(co, sprite_co): self.y = -self.y",simpleif,269 Python for Kids,"if self.y < 0: x self.y = 0",simpleif,269 Python for Kids,"if statement:",simpleif,270 Python for Kids,"if self.y < 0: self.y = 0",simpleif,270 Python for Kids,"if left and self.x < 0 and collided_left(co, sprite_co): v self.x = 0",simpleif,271 Python for Kids,"if right and self.x > 0 and collided_right(co, sprite_co): y self.x = 0",simpleif,271 Python for Kids,"if sprite == self: continue",simpleif,271 Python for Kids,"if top and self.y < 0 and collided_top(co, sprite_co): self.y = -self.y",simpleif,271 Python for Kids,"if self.y < 0: self.y = 0",simpleif,271 Python for Kids,"if left and self.x < 0 and collided_left(co, sprite_co): self.x = 0",simpleif,272 Python for Kids,"if right and self.x > 0 and collided_right(co, sprite_co): self.x = 0",simpleif,272 Python for Kids,"if right and self.x > 0 and collided_right(co, sprite_co): self.x = 0",simpleif,272 Python for Kids,"if left and self.x < 0 and collided_left(co, sprite_co): self.x = 0",simpleif,275 Python for Kids,"if sprite.endgame: self.game.running = False",simpleif,275 Python for Kids,"if right and self.x > 0 and collided_right(co, sprite_co): self.x = 0",simpleif,275 Python for Kids,"if sprite.endgame: self.game.running = False",simpleif,275 Python for Kids,"if within_y(co1, co2): if co1.x1 <= co2.x2 and co1.x1 >= co2.x1:",simpleif,278 Python for Kids,"if within_y(co1, co2): if co1.x2 >= co2.x1 and co1.x2 <= co2.x2:",simpleif,278 Python for Kids,"if within_x(co1, co2): if co1.y1 <= co2.y2 and co1.y1 >= co2.y1:",simpleif,278 Python for Kids,"if within_x(co1, co2): y_calc = co1.y2 + y",simpleif,278 Python for Kids,"if y_calc >= co2.y1 and y_calc <= co2.y2: return True",simpleif,278 Python for Kids,"if self.y == 0: self.x = -2",simpleif,279 Python for Kids,"if self.y == 0: self.x = 2",simpleif,279 Python for Kids,"if self.y == 0: self.y = -4",simpleif,279 Python for Kids,"if self.x != 0 and self.y == 0: if time.time() - self.last_time > 0.1:",simpleif,279 Python for Kids,"if self.current_image >= 2: self.current_image_add = -1",simpleif,280 Python for Kids,"if self.current_image <= 0: self.current_image_add = 1",simpleif,280 Python for Kids,"if self.x < 0: if self.y != 0:",simpleif,280 Python for Kids,"if self.x > 0: if self.y != 0:",simpleif,280 Python for Kids,"if self.y < 0: self.jump_count += 1",simpleif,280 Python for Kids,"if self.jump_count > 20: self.y = 4",simpleif,280 Python for Kids,"if self.y > 0: self.jump_count -= 1",simpleif,280 Python for Kids,"if self.y > 0 and co.y2 >= self.game.canvas_height: self.y = 0",simpleif,280 Python for Kids,"if self.x > 0 and co.x2 >= self.game.canvas_width: self.x = 0",simpleif,281 Python for Kids,"if sprite == self: continue",simpleif,281 Python for Kids,"if top and self.y < 0 and collided_top(co, sprite_co): self.y = -self.y",simpleif,281 Python for Kids,"if self.y < 0: self.y = 0",simpleif,281 Python for Kids,"if left and self.x < 0 and collided_left(co, sprite_co): self.x = 0",simpleif,281 Python for Kids,"if sprite.endgame: self.game.running = False",simpleif,281 Python for Kids,"if right and self.x > 0 and collided_right(co, sprite_co): self.x = 0",simpleif,281 Python for Kids,"if sprite.endgame: self.game.running = False",simpleif,281 Python for Kids,if file) would look like this:,simpleif,287 Python for Kids,"if age > 10 and age < 20: print('Beware the teenager!!!!')",simpleif,294 Python for Kids,"if x == age: print('end counting')",simpleif,295 Python for Kids,"if item.startswith('b'): x continue",simpleif,296 Python for Kids,"if toy_price > 1000: v print('That toy is overpriced')",simpleif,300 Python for Kids,"if toy_price > 100: x print('That toy is expensive')",simpleif,300 Python for Kids,"if 1 in [1,2,3,4]: >>> print('number is in list')",simpleif,301 Python for Kids,"if dino == 'Tyrannosaurus' or dino == 'Allosaurus': print('Carnivores')",simpleif,302 Python for Kids,"if dino == 'Ankylosaurus' or dino == 'Apatosaurus': print('Herbivores')",simpleif,302 Python for Kids,"if age > 10: print('older than 10')",simpleif,303 Python for Kids,"if statement, you’ll get an error message:",simpleif,303 Python for Kids,if age > 10:,simpleif,303 Python for Kids,"if statement again, this time using the pass keyword:",simpleif,303 Python for Kids,"if x == 5: break",simpleif,304 Python for Kids,"print(""Hello World"")",printfunc,11 Python for Kids,"print(""Hello World"")",printfunc,11 Python for Kids,"print(""Hello World"")",printfunc,12 Python for Kids,print(fred),printfunc,19 Python for Kids,print(fred),printfunc,20 Python for Kids,print(john),printfunc,20 Python for Kids,print(number_of_coins),printfunc,20 Python for Kids,print(fred),printfunc,26 Python for Kids,print(fred),printfunc,26 Python for Kids,print(fred),printfunc,26 Python for Kids,print(fred),printfunc,27 Python for Kids,print(single_quote_str),printfunc,29 Python for Kids,print(double_quote_str),printfunc,29 Python for Kids,print(message % myscore),printfunc,30 Python for Kids,print(message),printfunc,30 Python for Kids,print(message % 1000),printfunc,30 Python for Kids,print(joke_text % bodypart1),printfunc,30 Python for Kids,print(joke_text % bodypart2),printfunc,30 Python for Kids,"print(nums % (0, 8))",printfunc,31 Python for Kids,print(10 * 'a'),printfunc,31 Python for Kids,print('%s 12 Butts Wynd' % spaces),printfunc,31 Python for Kids,print('%s Twinklebottom Heath' % spaces),printfunc,31 Python for Kids,print('%s West Snoring' % spaces),printfunc,31 Python for Kids,print(),printfunc,31 Python for Kids,print(),printfunc,31 Python for Kids,print('Dear Sir'),printfunc,31 Python for Kids,print(),printfunc,31 Python for Kids,print('I wish to report that tiles are missing from the'),printfunc,31 Python for Kids,print('outside toilet roof.'),printfunc,31 Python for Kids,print('I think it was bad wind the other night that blew them away.'),printfunc,31 Python for Kids,print(),printfunc,31 Python for Kids,print('Regards'),printfunc,31 Python for Kids,print('Malcolm Dithering'),printfunc,31 Python for Kids,print(1000 * 'snirt'),printfunc,32 Python for Kids,print(wizard_list),printfunc,33 Python for Kids,print(wizard_list),printfunc,33 Python for Kids,print(wizard_list[2]),printfunc,33 Python for Kids,print(wizard_list),printfunc,33 Python for Kids,print(wizard_list[2:5]),printfunc,34 Python for Kids,print(numbers_and_strings),printfunc,34 Python for Kids,print(mylist),printfunc,34 Python for Kids,print(wizard_list),printfunc,35 Python for Kids,print(wizard_list),printfunc,35 Python for Kids,print(wizard_list),printfunc,35 Python for Kids,print(wizard_list),printfunc,36 Python for Kids,print(list1 + list2),printfunc,36 Python for Kids,print(list3),printfunc,36 Python for Kids,print(list1 * 5),printfunc,36 Python for Kids,print(fibs[3]),printfunc,38 Python for Kids,print(fibs[3]),printfunc,38 Python for Kids,print(favorite_sports['Rebecca Clarke']),printfunc,40 Python for Kids,print(favorite_sports),printfunc,40 Python for Kids,print(favorite_sports),printfunc,40 Python for Kids,print('Why are you here?'),printfunc,54 Python for Kids,print('Why aren\'t you mowing a lawn or sorting papers?'),printfunc,54 Python for Kids,print('Why are you here?'),printfunc,55 Python for Kids,print('Why aren\'t you mowing a lawn or sorting papers?'),printfunc,55 Python for Kids,print('Why are you here?'),printfunc,56 Python for Kids,print('Why are you here?'),printfunc,56 Python for Kids,"print(""Want to hear a dirty joke?"")",printfunc,58 Python for Kids,"print(""Shh. It's a secret."")",printfunc,59 Python for Kids,"print(""Want to hear a dirty joke?"")",printfunc,59 Python for Kids,"print(""Shh. It's a secret."")",printfunc,59 Python for Kids,"print(""What do you call an unhappy cranberry?"")",printfunc,59 Python for Kids,"print(""A blueberry!"")",printfunc,59 Python for Kids,"print(""What did the green grape say to the blue grape?"")",printfunc,60 Python for Kids,"print(""Breathe! Breathe!"")",printfunc,60 Python for Kids,"print(""What did 0 say to 8?"")",printfunc,60 Python for Kids,"print(""Hi guys!"")",printfunc,60 Python for Kids,"print(""Why wasn't 10 afraid of 7?"")",printfunc,60 Python for Kids,"print(""Because rather than eating 9, 7 8 pi."")",printfunc,60 Python for Kids,"print(""Huh?"")",printfunc,60 Python for Kids,print('Huh?'),printfunc,61 Python for Kids,print('Huh?'),printfunc,61 Python for Kids,print(myval),printfunc,62 Python for Kids,"print(""From as far away as possible!"")",printfunc,63 Python for Kids,"print(""From as far away as possible!"")",printfunc,63 Python for Kids,"print(""From as far away as possible!"")",printfunc,63 Python for Kids,"print(""From as far away as possible!"")",printfunc,64 Python for Kids,print(converted_age),printfunc,64 Python for Kids,"print(""I'm not rich!!"")",printfunc,65 Python for Kids,"print(""But I might be later..."")",printfunc,65 Python for Kids,"print(""hello"")",printfunc,68 Python for Kids,"print(""hello"")",printfunc,68 Python for Kids,"print(""hello"")",printfunc,68 Python for Kids,"print(""hello"")",printfunc,68 Python for Kids,"print(""hello"")",printfunc,68 Python for Kids,print('hello'),printfunc,68 Python for Kids,"print(list(range(10, 20)))",printfunc,69 Python for Kids,print('hello %s' % x),printfunc,69 Python for Kids,print('hello %s' % x),printfunc,69 Python for Kids,print('hello %s' % x),printfunc,69 Python for Kids,print('hello %s' % x),printfunc,69 Python for Kids,print('hello %s' % x),printfunc,70 Python for Kids,print('hello %s' % x),printfunc,70 Python for Kids,print(i),printfunc,70 Python for Kids,print(wizard_list[0]),printfunc,70 Python for Kids,print(wizard_list[1]),printfunc,70 Python for Kids,print(wizard_list[2]),printfunc,70 Python for Kids,print(wizard_list[3]),printfunc,71 Python for Kids,print(wizard_list[4]),printfunc,71 Python for Kids,print(wizard_list[5]),printfunc,71 Python for Kids,print(i),printfunc,71 Python for Kids,print(i),printfunc,71 Python for Kids,print(i),printfunc,71 Python for Kids,print(i),printfunc,71 Python for Kids,print(i),printfunc,72 Python for Kids,print(j),printfunc,72 Python for Kids,print(i),printfunc,72 Python for Kids,print(j),printfunc,72 Python for Kids,print(i),printfunc,72 Python for Kids,print(j),printfunc,72 Python for Kids,print(i),printfunc,73 Python for Kids,print(j),printfunc,73 Python for Kids,print(i),printfunc,73 Python for Kids,print(j),printfunc,73 Python for Kids,print(i) statement. The unmarked lines are printed by print(j),printfunc,73 Python for Kids,"print('Week %s = %s' % (week, coins))",printfunc,74 Python for Kids,print(step),printfunc,75 Python for Kids,print(step),printfunc,76 Python for Kids,"print(x, y)",printfunc,77 Python for Kids,print('hello %s' % myname),printfunc,83 Python for Kids,"print('Hello %s %s' % (fname, lname))",printfunc,83 Python for Kids,"print(savings(10, 10, 5))",printfunc,84 Python for Kids,print(variable_test()),printfunc,84 Python for Kids,print(first_variable),printfunc,85 Python for Kids,print(first_variable),printfunc,85 Python for Kids,print(variable_test2()),printfunc,85 Python for Kids,"print('Week %s = %s cans' % (week, total_cans))",printfunc,86 Python for Kids,print(time.asctime()),printfunc,87 Python for Kids,print('Huh?'),printfunc,88 Python for Kids,print('Huh?'),printfunc,88 Python for Kids,print('How old are you?'),printfunc,89 Python for Kids,print('What is 13 + 49 + 84 + 155 + 97? A headache!'),printfunc,89 Python for Kids,print('Huh?'),printfunc,89 Python for Kids,print('I am a normal function'),printfunc,97 Python for Kids,print('I am a class function'),printfunc,97 Python for Kids,print('I am also a class function. See?'),printfunc,97 Python for Kids,print('breathing'),printfunc,99 Python for Kids,print('moving'),printfunc,99 Python for Kids,print('eating food'),printfunc,99 Python for Kids,print('feeding young'),printfunc,100 Python for Kids,print('eating leaves'),printfunc,100 Python for Kids,"print(""I've found food!"")",printfunc,104 Python for Kids,"print(""I've found food!"")",printfunc,105 Python for Kids,print(ozwald.giraffe_spots),printfunc,106 Python for Kids,print(gertrude.giraffe_spots),printfunc,106 Python for Kids,print('left foot forward'),printfunc,107 Python for Kids,print(abs(10)),printfunc,110 Python for Kids,print(abs(-10)),printfunc,110 Python for Kids,print(bool(0)),printfunc,111 Python for Kids,print(bool(1)),printfunc,111 Python for Kids,print(bool(1123.23)),printfunc,111 Python for Kids,print(bool(-500)),printfunc,111 Python for Kids,print(bool(None)),printfunc,111 Python for Kids,print(bool('a')),printfunc,111 Python for Kids,print(bool(' ')),printfunc,112 Python for Kids,print(bool('What do you call a pig doing karate? Pork Chop!')),printfunc,112 Python for Kids,print(bool(my_silly_list)),printfunc,112 Python for Kids,print(bool(my_silly_list)),printfunc,112 Python for Kids,"print(""wow"")') will actually run the statement print(""wow"")",printfunc,114 Python for Kids,"print(""this won't work at all')",printfunc,115 Python for Kids,print('ham'),printfunc,116 Python for Kids,print('sandwich'),printfunc,116 Python for Kids,print(len(creature_list)),printfunc,118 Python for Kids,print(len(enemies_map)),printfunc,118 Python for Kids,"print('the fruit at index %s is %s' % (x, fruit[x]))",printfunc,119 Python for Kids,print(max(numbers)),printfunc,119 Python for Kids,print(max(strings)),printfunc,119 Python for Kids,"print(max(10, 300, 450, 50, 90))",printfunc,120 Python for Kids,print(min(numbers)),printfunc,120 Python for Kids,print('You win'),printfunc,120 Python for Kids,print(x),printfunc,121 Python for Kids,"print(list(range(0, 5)))",printfunc,121 Python for Kids,print(count_by_twos),printfunc,122 Python for Kids,print(count_down_by_twos),printfunc,122 Python for Kids,print(my_list_of_numbers),printfunc,122 Python for Kids,print(sum(my_list_of_numbers)),printfunc,122 Python for Kids,print(sum(my_list_of_numbers)),printfunc,122 Python for Kids,print(text),printfunc,125 Python for Kids,print(a),printfunc,128 Python for Kids,print(b),printfunc,128 Python for Kids,print(harry.species),printfunc,131 Python for Kids,print(harriet.species),printfunc,131 Python for Kids,print(more_animals[0].species),printfunc,131 Python for Kids,print(more_animals[1].species),printfunc,131 Python for Kids,print(my_animals[0].species),printfunc,132 Python for Kids,print(more_animals[0].species),printfunc,132 Python for Kids,print(len(my_animals)),printfunc,132 Python for Kids,print(len(more_animals)),printfunc,132 Python for Kids,print(my_animals[0].species),printfunc,132 Python for Kids,print(more_animals[0].species),printfunc,133 Python for Kids,print(keyword.iskeyword('if')),printfunc,133 Python for Kids,print(keyword.iskeyword('ozwald')),printfunc,133 Python for Kids,print(keyword.kwlist),printfunc,133 Python for Kids,"print(random.randint(1, 100))",printfunc,134 Python for Kids,"print(random.randint(100, 1000))",printfunc,134 Python for Kids,"print(random.randint(1000, 5000))",printfunc,134 Python for Kids,print('Try lower'),printfunc,134 Python for Kids,print(random.choice(desserts)),printfunc,136 Python for Kids,print(desserts),printfunc,136 Python for Kids,print(v),printfunc,137 Python for Kids,print(v),printfunc,137 Python for Kids,print(sys.version),printfunc,138 Python for Kids,print(time.time()),printfunc,138 Python for Kids,print(x),printfunc,139 Python for Kids,print(x),printfunc,139 Python for Kids,print('it took %s seconds' % (t2-t1)),printfunc,139 Python for Kids,print(time.asctime()),printfunc,140 Python for Kids,print(time.asctime(t)),printfunc,140 Python for Kids,print(time.localtime()),printfunc,141 Python for Kids,print(year),printfunc,141 Python for Kids,print(month),printfunc,141 Python for Kids,print(x),printfunc,141 Python for Kids,print(x),printfunc,141 Python for Kids,print(loaded_game_data),printfunc,143 Python for Kids,print(car1.wheels),printfunc,144 Python for Kids,print(car1.wheels),printfunc,144 Python for Kids,print('hello there'),printfunc,166 Python for Kids,"print('I am %s feet wide, %s feet high' % (width, height))",printfunc,167 Python for Kids,print('%x' % 15),printfunc,175 Python for Kids,print('%02x' % 15),printfunc,176 Python for Kids,print(self.canvas.coords(self.id)),printfunc,201 Python for Kids,"print(within_x(c1, c2))",printfunc,240 Python for Kids,"print(""Hello World\n"")",printfunc,290 Python for Kids,print('Hello World'),printfunc,291 Python for Kids,print('counting %s' % x),printfunc,295 Python for Kids,print(car1.color),printfunc,296 Python for Kids,print(car2.color),printfunc,296 Python for Kids,print(item),printfunc,296 Python for Kids,print(what_i_want),printfunc,297 Python for Kids,print('x is %s' % x),printfunc,298 Python for Kids,print(localtime()),printfunc,299 Python for Kids,print(gmtime()),printfunc,299 Python for Kids,print(localtime()),printfunc,299 Python for Kids,print(gmtime()),printfunc,299 Python for Kids,print(a),printfunc,300 Python for Kids,print(b),printfunc,300 Python for Kids,print(a),printfunc,300 Python for Kids,print(b),printfunc,300 Python for Kids,print('I can afford that toy'),printfunc,300 Python for Kids,print('pants is in the list'),printfunc,301 Python for Kids,print('pants is not in the list'),printfunc,301 Python for Kids,print(not x),printfunc,302 Python for Kids,print('You really need to buy some pants'),printfunc,302 Python for Kids,print('x is %s' % x),printfunc,304 Python for Kids,print('x is %s' % x),printfunc,304 Python for Kids,print(seconds),printfunc,305 Python for Kids,print(age_in_seconds()),printfunc,305 Python for Kids,print('hello'),printfunc,305 Python for Kids,print('hello'),printfunc,306 Python for Kids,"fibs = (0, 1, 1, 2, 3)",simpleTuple,38 Python for Kids,"t = (2007, 5, 27, 10, 30, 48, 6, 0, 0)",simpleTuple,140 Python for Kids,"t = (2020, 2, 23, 10, 30, 48, 6, 0, 0)",simpleTuple,140 Python for Kids,"font=('Times', 15))",simpleTuple,181 Python for Kids,"font=('Helvetica', 20))",simpleTuple,181 Python for Kids,"font=('Courier', 22))",simpleTuple,181 Python for Kids,"canvas.create_text(220, 300, text='on a goose.""', font=('Courier', 30))",simpleTuple,181 Python for Kids,"some_numbers = [1, 2, 5, 10, 20]",simpleList,34 Python for Kids,"some_strings = ['Which', 'Witch', 'Is', 'Which']",simpleList,34 Python for Kids,"numbers = [1, 2, 3, 4]",simpleList,34 Python for Kids,"strings = ['I', 'kicked', 'my', 'toe', 'and', 'it', 'is', 'sore']",simpleList,34 Python for Kids,"mylist = [numbers, strings]",simpleList,34 Python for Kids,"list1 = [1, 2, 3, 4]",simpleList,36 Python for Kids,"list2 = ['I', 'tripped', 'over', 'and', 'hit', 'the', 'floor']",simpleList,36 Python for Kids,"list1 = [1, 2, 3, 4]",simpleList,36 Python for Kids,"list2 = ['I', 'ate', 'chocolate', 'and', 'I', 'want', 'more']",simpleList,36 Python for Kids,"list1 = [1, 2]",simpleList,36 Python for Kids,"u >>> hugehairypants = ['huge', 'hairy', 'pants']",simpleList,71 Python for Kids,"hugehairypants = ['huge', 'hairy', 'pants']",simpleList,71 Python for Kids,"hugehairypants = ['huge', 'hairy', 'pants']",simpleList,72 Python for Kids,"hugehairypants = ['huge', 'hairy', 'pants']",simpleList,72 Python for Kids,"u hugehairypants = ['huge', 'hairy', 'pants']",simpleList,72 Python for Kids,"hugehairypants = ['huge', 'hairy', 'pants']",simpleList,73 Python for Kids,my_silly_list = [],simpleList,112 Python for Kids,"my_silly_list = ['s', 'i', 'l', 'l', 'y']",simpleList,112 Python for Kids,"fruit = ['apple', 'banana', 'clementine', 'dragon fruit']",simpleList,119 Python for Kids,"numbers = [5, 4, 10, 30, 22]",simpleList,119 Python for Kids,"numbers = [5, 4, 10, 30, 22]",simpleList,120 Python for Kids,"player_guesses = [12, 15, 70, 45]",simpleList,120 Python for Kids,"my_animals = [harry, carrie, billy]",simpleList,131 Python for Kids,"u starts = [-3, -2, -1, 1, 2, 3]",simpleList,202 Python for Kids,"starts = [-3, -2, -1, 1, 2, 3]",simpleList,203 Python for Kids,"starts = [-3, -2, -1, 1, 2, 3]",simpleList,209 Python for Kids,"starts = [-3, -2, -1, 1, 2, 3]",simpleList,214 Python for Kids,z self.sprites = [],simpleList,235 Python for Kids,"what_i_want = ['remote controlled car', 'new bike', 'computer game']",simpleList,297 Python for Kids,"for x in range(0, 5):",forsimple,68 Python for Kids,"for x in range(0, 5):",forsimple,69 Python for Kids,for i in wizard_list:,forsimple,70 Python for Kids,for i in hugehairypants:,forsimple,71 Python for Kids,for i in hugehairypants:,forsimple,71 Python for Kids,for i in hugehairypants:,forsimple,72 Python for Kids,for j in hugehairypants:,forsimple,72 Python for Kids,for i in hugehairypants:,forsimple,72 Python for Kids,for j in hugehairypants:,forsimple,72 Python for Kids,for i in hugehairypants:,forsimple,72 Python for Kids,for j in hugehairypants:,forsimple,72 Python for Kids,for i in hugehairypants:,forsimple,73 Python for Kids,for j in hugehairypants:,forsimple,73 Python for Kids,"for week in range(1, 53):",forsimple,74 Python for Kids,"for step in range(0, 20):",forsimple,75 Python for Kids,"for that matter) outside of the block of code in the function, we get an error message:",forsimple,85 Python for Kids,"for week in range(1, 53):",forsimple,86 Python for Kids,"for x in range(0, length):",forsimple,119 Python for Kids,"for x in range(0, 5):",forsimple,121 Python for Kids,"for x in range(0, max):",forsimple,139 Python for Kids,"for x in range(0, max):",forsimple,139 Python for Kids,"for x in range(1, 61):",forsimple,141 Python for Kids,"for x in range(1, 61):",forsimple,141 Python for Kids,"for x in range(1, 5):",forsimple,146 Python for Kids,"for x in range(1, 9):",forsimple,147 Python for Kids,"for x in range(1, 38):",forsimple,147 Python for Kids,"for x in range(1, 20):",forsimple,148 Python for Kids,"for x in range(1, 19):",forsimple,149 Python for Kids,"for x in range(1, 5):",forsimple,156 Python for Kids,"for x in range(1, 5):",forsimple,157 Python for Kids,"for x in range(1, 19):",forsimple,158 Python for Kids,"for x in range(1, 19):",forsimple,159 Python for Kids,"for x in range(0, 100):",forsimple,173 Python for Kids,"for x in range(0, 60):",forsimple,184 Python for Kids,"for x in range(0, 60):",forsimple,184 Python for Kids,"for x in range(0, 60):",forsimple,185 Python for Kids,"for x in range(0, 60):",forsimple,186 Python for Kids,for the Bounce! game in Chapter 13. Here it is:,forsimple,236 Python for Kids,for sprite in self.sprites:,forsimple,236 Python for Kids,for sprite in self.game.sprites:,forsimple,268 Python for Kids,for sprite in self.game.sprites:,forsimple,271 Python for Kids,for sprite in self.game.sprites:,forsimple,281 Python for Kids,"for x in range(1, 100):",forsimple,295 Python for Kids,for item in my_items:,forsimple,296 Python for Kids,"for x in range(0, 5):",forsimple,298 Python for Kids,"for x in range(0, 7):",forsimple,304 Python for Kids,"for x in range(1, 7):",forsimple,304 Python for Kids,"for anyone.Python for Kids brings Python to life and brings you (and your parents) into the world of programming. The ever-patient Jason R. Briggs will guide you through the basics as you experi-ment with unique (and often hilarious) example programs that feature ravenous monsters, secret agents, thieving ravens, and more. New terms are defined; code is colored, dissected, and explained; and quirky, full-color illustrations keep things on the lighter side. Chapters end with programming puzzles designed to stretch your brain and strengthen your understanding. By the end of the book you’ll have programmed two complete games: a clone of the famous Pong and “Mr. Stick Man Races for the Exit”—a platform game with jumps, animation, and much more.As you strike out on your programming adventure, you’ll learn how to:M Use fundamental data structures like lists, tuples, and mapsM Organize and reuse your code with func-tions and modulesM Use control structures like loops and conditional statementsM Draw shapes and patterns with Python’s turtle moduleM Create games, animations, and other graphical wonders with tkinterWhy should serious adults have all the fun? Python for Kids is your ticket into the amaz-ing world of computer programming.ABOUT THE AUTHORJason R. Briggs has been a programmer since the age of eight, when he first learned BASIC on a Radio Shack TRS-80. He has written software professionally as a developer and systems archi-tect and served as Contributing Editor for Java Developer’s Journal. His articles have appeared in JavaWorld, ONJava, and ONLamp. Python for Kids is his first book.SHELVE IN:",forsimple,322 Python for Kids,list3 = list1 + list2,assignwithSum,36 Python for Kids,w coins = coins + magic_coins - stolen_coins,assignwithSum,74 Python for Kids,step = step + 1,assignwithSum,76 Python for Kids,the line step = step + 1.,assignwithSum,76 Python for Kids,"variable with step = step + 1, and the loop continues.",assignwithSum,76 Python for Kids,x = x + 1,assignwithSum,77 Python for Kids,y = y + 1,assignwithSum,77 Python for Kids,total_cans = total_cans + cans,assignwithSum,86 Python for Kids,a = abs(10) + abs(-10),assignwithSum,128 Python for Kids,b = abs(-10) + -10,assignwithSum,128 Python for Kids,x2 = x1 + random.randrange(width),assignwithSum,173 Python for Kids,y2 = y1 + random.randrange(height),assignwithSum,173 Python for Kids,x2 = random.randrange(x1 + random.randrange(width)),assignwithSum,174 Python for Kids,y2 = random.randrange(y1 + random.randrange(height)),assignwithSum,174 Python for Kids,"z self.coordinates = Coords(x, y, x + width, y + height)",assignwithSum,246 Python for Kids,x self.coordinates.x2 = xy[0] + 27,assignwithSum,264 Python for Kids,y self.coordinates.y2 = xy[1] + 30,assignwithSum,264 Python for Kids,"y self.coordinates = Coords(x, y, x + (width / 2), y + height)",assignwithSum,274 Python for Kids,x = x + 1,assignwithSum,306 Python for Kids,10 × 365 = 3650,simpleAssign,16 Python for Kids,20 + 3650 = 3670,simpleAssign,16 Python for Kids,fred = 100,simpleAssign,19 Python for Kids,fred = 200,simpleAssign,20 Python for Kids,fred = 200,simpleAssign,20 Python for Kids,john = fred,simpleAssign,20 Python for Kids,number_of_coins = 200,simpleAssign,20 Python for Kids,found_coins = 20,simpleAssign,21 Python for Kids,magic_coins = 10,simpleAssign,21 Python for Kids,stolen_coins = 3,simpleAssign,21 Python for Kids,stolen_coins = 2,simpleAssign,22 Python for Kids,3. Click the last prompt line (after stolen_coins = 2).,simpleAssign,22 Python for Kids,magic_coins = 13,simpleAssign,23 Python for Kids,myscore = 1000,simpleAssign,30 Python for Kids,fibs[0] = 4,simpleAssign,38 Python for Kids,fibs[0] = 4,simpleAssign,38 Python for Kids,t = turtle.Pen(),simpleAssign,44 Python for Kids,age = 13,simpleAssign,54 Python for Kids,age = 25,simpleAssign,54 Python for Kids,age = 25,simpleAssign,55 Python for Kids,age = 25,simpleAssign,56 Python for Kids,"For example, if you are 10 years old, the condition your_age == 10",simpleAssign,57 Python for Kids,age = 10,simpleAssign,57 Python for Kids,age = 10,simpleAssign,58 Python for Kids,age = 10,simpleAssign,58 Python for Kids,age = 12,simpleAssign,59 Python for Kids,age = 8,simpleAssign,59 Python for Kids,age = 12,simpleAssign,59 Python for Kids,u >>> if age == 10:,simpleAssign,59 Python for Kids,w elif age == 11:,simpleAssign,60 Python for Kids,x elif age == 12:,simpleAssign,60 Python for Kids,elif age == 13:,simpleAssign,60 Python for Kids,"with if age >= 10 and age <= 13:, the",simpleAssign,61 Python for Kids,myval = None,simpleAssign,62 Python for Kids,myval = None,simpleAssign,62 Python for Kids,age = 10,simpleAssign,63 Python for Kids,converted_age = int(age),simpleAssign,63 Python for Kids,age = 10,simpleAssign,64 Python for Kids,converted_age = str(age),simpleAssign,64 Python for Kids,Remember that if age == 10 statement that didn’t print any-,simpleAssign,64 Python for Kids,converted_age = int(age),simpleAssign,64 Python for Kids,converted_age = int(age),simpleAssign,64 Python for Kids,converted_age = int(age),simpleAssign,64 Python for Kids,converted_age = float(age),simpleAssign,64 Python for Kids,converted_age = int(age),simpleAssign,64 Python for Kids,converted_age = int(age),simpleAssign,65 Python for Kids,money = 2000,simpleAssign,65 Python for Kids,ninjas = 5,simpleAssign,66 Python for Kids,x = 0,simpleAssign,69 Python for Kids,x = 1,simpleAssign,69 Python for Kids,x = 2,simpleAssign,69 Python for Kids,x = 3,simpleAssign,70 Python for Kids,x = 4,simpleAssign,70 Python for Kids,found_coins = 20,simpleAssign,74 Python for Kids,magic_coins = 70,simpleAssign,74 Python for Kids,stolen_coins = 3,simpleAssign,74 Python for Kids,found_coins = 20,simpleAssign,74 Python for Kids,magic_coins = 70,simpleAssign,74 Python for Kids,stolen_coins = 3,simpleAssign,74 Python for Kids,u >>> coins = found_coins,simpleAssign,74 Python for Kids,step = 0,simpleAssign,76 Python for Kids,"called step with step = 0. Next, we cre-",simpleAssign,76 Python for Kids,"if tired == True:. (True is called a Boolean value, which we’ll learn",simpleAssign,76 Python for Kids,The line elif badweather == True: checks to see if the variable,simpleAssign,76 Python for Kids,u >>> x = 45,simpleAssign,77 Python for Kids,v >>> y = 80,simpleAssign,77 Python for Kids,first_variable = 10,simpleAssign,84 Python for Kids,second_variable = 20,simpleAssign,84 Python for Kids,u >>> another_variable = 100,simpleAssign,85 Python for Kids,first_variable = 10,simpleAssign,85 Python for Kids,second_variable = 20,simpleAssign,85 Python for Kids,total_cans = 0,simpleAssign,86 Python for Kids,Week 1 = 2 cans,simpleAssign,86 Python for Kids,Week 2 = 4 cans,simpleAssign,86 Python for Kids,Week 3 = 6 cans,simpleAssign,86 Python for Kids,Week 4 = 8 cans,simpleAssign,86 Python for Kids,Week 5 = 10 cans,simpleAssign,86 Python for Kids,Week 6 = 12 cans,simpleAssign,86 Python for Kids,Week 7 = 14 cans,simpleAssign,86 Python for Kids,Week 8 = 16 cans,simpleAssign,86 Python for Kids,Week 9 = 18 cans,simpleAssign,86 Python for Kids,Week 10 = 20 cans,simpleAssign,86 Python for Kids,Week 1 = 13 cans,simpleAssign,86 Python for Kids,Week 2 = 26 cans,simpleAssign,86 Python for Kids,Week 3 = 39 cans,simpleAssign,86 Python for Kids,Week 4 = 52 cans,simpleAssign,86 Python for Kids,Week 5 = 65 cans,simpleAssign,86 Python for Kids,v if age >= 10 and age <= 13:,simpleAssign,89 Python for Kids,reginald = Giraffes(),simpleAssign,96 Python for Kids,reginald = Giraffes(),simpleAssign,99 Python for Kids,reginald = Giraffes(),simpleAssign,99 Python for Kids,harold = Giraffes(),simpleAssign,99 Python for Kids,reginald = Giraffes(),simpleAssign,100 Python for Kids,harold = Giraffes(),simpleAssign,100 Python for Kids,avery = turtle.Pen(),simpleAssign,100 Python for Kids,kate = turtle.Pen(),simpleAssign,100 Python for Kids,jacob = turtle.Pen(),simpleAssign,101 Python for Kids,reginald = Giraffes(),simpleAssign,104 Python for Kids,reginald = Giraffes(),simpleAssign,104 Python for Kids,reginald = Giraffes(),simpleAssign,105 Python for Kids,"using the self parameter, with the code self.giraffe_spots = spots.",simpleAssign,106 Python for Kids,ozwald = Giraffes(100),simpleAssign,106 Python for Kids,gertrude = Giraffes(150),simpleAssign,106 Python for Kids,reginald = Giraffes(),simpleAssign,107 Python for Kids,year = input('Year of birth: '),simpleAssign,112 Python for Kids,your_calculation = input('Enter a calculation: '),simpleAssign,115 Python for Kids,your_age = input('Enter your age: '),simpleAssign,117 Python for Kids,age = float(your_age),simpleAssign,117 Python for Kids,u >>> length = len(fruit),simpleAssign,119 Python for Kids,guess_this_number = 61,simpleAssign,120 Python for Kids,"count_by_twos = list(range(0, 30, 2))",simpleAssign,122 Python for Kids,"count_down_by_twos = list(range(40, 10, -2))",simpleAssign,122 Python for Kids,"my_list_of_numbers = list(range(0, 500, 50))",simpleAssign,122 Python for Kids,t = turtle.Pen(),simpleAssign,130 Python for Kids,"harry = Animal('hippogriff', 6, 'pink')",simpleAssign,130 Python for Kids,"harry = Animal('hippogriff', 6, 'pink')",simpleAssign,131 Python for Kids,harriet = copy.copy(harry),simpleAssign,131 Python for Kids,"harry = Animal('hippogriff', 6, 'pink')",simpleAssign,131 Python for Kids,"carrie = Animal('chimera', 4, 'green polka dots')",simpleAssign,131 Python for Kids,"billy = Animal('bogill', 0, 'paisley')",simpleAssign,131 Python for Kids,more_animals = copy.copy(my_animals),simpleAssign,131 Python for Kids,"sally = Animal('sphinx', 4, 'sand')",simpleAssign,132 Python for Kids,more_animals = copy.deepcopy(my_animals),simpleAssign,132 Python for Kids,u t1 = time.time(),simpleAssign,139 Python for Kids,w t2 = time.time(),simpleAssign,139 Python for Kids,"time.struct_time(tm_year=2020, tm_mon=2, tm_mday=23, tm_hour=22,",simpleAssign,141 Python for Kids,"tm_min=18, tm_sec=39, tm_wday=0, tm_yday=73, tm_isdst=0)",simpleAssign,141 Python for Kids,"month is in the second position (1). Therefore, we use year = t[0]",simpleAssign,141 Python for Kids,"and month = t[1], like this:",simpleAssign,141 Python for Kids,t = time.localtime(),simpleAssign,141 Python for Kids,year = t[0],simpleAssign,141 Python for Kids,month = t[1],simpleAssign,141 Python for Kids,loaded_game_data = pickle.load(load_file),simpleAssign,143 Python for Kids,car1 = Car(),simpleAssign,144 Python for Kids,car1.wheels = 4,simpleAssign,144 Python for Kids,car2 = car1,simpleAssign,144 Python for Kids,car2.wheels = 3,simpleAssign,144 Python for Kids,car3 = copy.copy(car1),simpleAssign,144 Python for Kids,car3.wheels = 6,simpleAssign,144 Python for Kids,t = turtle.Pen(),simpleAssign,146 Python for Kids,is the if statement (if x % 2 == 0:). This statement checks to see if,simpleAssign,149 Python for Kids,"tor, the % in the expression x % 2 == 0, which is a way of saying, “x",simpleAssign,149 Python for Kids,175 degrees (t.left(175)) if the number in x is even (if x % 2 == 0:);,simpleAssign,150 Python for Kids,"the value of filled is set to True with if filled == True. If it is, we",simpleAssign,157 Python for Kids,"whether filled is True with if filled == True. If it is, we turn filling",simpleAssign,158 Python for Kids,tk = Tk(),simpleAssign,165 Python for Kids,"btn = Button(tk, text=""click me"")",simpleAssign,165 Python for Kids,t = turtle.Pen(),simpleAssign,165 Python for Kids,t = Pen(),simpleAssign,165 Python for Kids,"containing an object of the class Tk with tk = Tk(), just like we",simpleAssign,165 Python for Kids,"On the third line, we create a button, with btn = Button and",simpleAssign,165 Python for Kids,tk = Tk(),simpleAssign,166 Python for Kids,"btn = Button(tk, text=""click me"", command=hello)",simpleAssign,166 Python for Kids,"person(height=3, width=4)",simpleAssign,167 Python for Kids,tk = Tk(),simpleAssign,168 Python for Kids,"canvas = Canvas(tk, width=500, height=500)",simpleAssign,168 Python for Kids,"enter tk = Tk(). On the last line,",simpleAssign,168 Python for Kids,tk = Tk(),simpleAssign,169 Python for Kids,"canvas = Canvas(tk, width=500, height=500)",simpleAssign,169 Python for Kids,"turtle.setup(width=500, height=500)",simpleAssign,169 Python for Kids,t = turtle.Pen(),simpleAssign,169 Python for Kids,tk = Tk(),simpleAssign,170 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,170 Python for Kids,tk = Tk(),simpleAssign,171 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,171 Python for Kids,tk = Tk(),simpleAssign,171 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,171 Python for Kids,tk = Tk(),simpleAssign,172 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,172 Python for Kids,x1 = random.randrange(width),simpleAssign,173 Python for Kids,y1 = random.randrange(height),simpleAssign,173 Python for Kids,width and the height as parameters with x1 = random.randrange(width),simpleAssign,173 Python for Kids,"and y1 = random.randrange(height), respectively. In effect, with the",simpleAssign,173 Python for Kids,tk = Tk(),simpleAssign,174 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,174 Python for Kids,x1 = random.randrange(width),simpleAssign,174 Python for Kids,y1 = random.randrange(height),simpleAssign,174 Python for Kids,"canvas.create_rectangle(x1, y1, x2, y2, fill=fill_color)",simpleAssign,174 Python for Kids,c = colorchooser.askcolor(),simpleAssign,177 Python for Kids,"canvas.create_arc(10, 10, 200, 100, extent=180, style=ARC)",simpleAssign,177 Python for Kids,tk = Tk(),simpleAssign,178 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 10, 200, 100, extent=180, style=ARC)",simpleAssign,178 Python for Kids,tk = Tk(),simpleAssign,178 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 10, 200, 80, extent=45, style=ARC)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 80, 200, 160, extent=90, style=ARC)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 160, 200, 240, extent=135, style=ARC)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 240, 200, 320, extent=180, style=ARC)",simpleAssign,178 Python for Kids,"canvas.create_arc(10, 320, 200, 400, extent=359, style=ARC)",simpleAssign,178 Python for Kids,tk = Tk(),simpleAssign,179 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,179 Python for Kids,tk = Tk(),simpleAssign,180 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,180 Python for Kids,tk = Tk(),simpleAssign,182 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,182 Python for Kids,my_image = PhotoImage(file='c:\\test.gif'),simpleAssign,182 Python for Kids,"canvas.create_image(0, 0, anchor=NW, image=myimage)",simpleAssign,182 Python for Kids,my_image = PhotoImage(file='C:\\Users\\Joe Smith\\Desktop\\test.gif'),simpleAssign,182 Python for Kids,"image(0, 0, anchor=NW, image=myimage) displays it using the create_image",simpleAssign,183 Python for Kids,"played, and anchor=NW tells the function to use the top-left (NW, for",simpleAssign,183 Python for Kids,tk = Tk(),simpleAssign,183 Python for Kids,"canvas = Canvas(tk, width=400, height=200)",simpleAssign,183 Python for Kids,tk = Tk(),simpleAssign,185 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,185 Python for Kids,"with canvas = Canvas(tk, width=400, height=400).",simpleAssign,185 Python for Kids,tk = Tk(),simpleAssign,186 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,186 Python for Kids,tk = Tk(),simpleAssign,188 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,188 Python for Kids,tk = Tk(),simpleAssign,188 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,189 Python for Kids,"mytriangle = canvas.create_polygon(10, 10, 10, 60, 50, 35)",simpleAssign,189 Python for Kids,tk = Tk(),simpleAssign,189 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,189 Python for Kids,"mytriangle = canvas.create_polygon(10, 10, 10, 60, 50, 35,",simpleAssign,189 Python for Kids,tk = Tk(),simpleAssign,195 Python for Kids,"canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)",simpleAssign,195 Python for Kids,object we created with tk = Tk() to give the window a title. Then,simpleAssign,195 Python for Kids,"ples. For example, both bd=0 and highlightthickness=0 make sure",simpleAssign,195 Python for Kids,w self.canvas = canvas,simpleAssign,196 Python for Kids,"x self.id = canvas.create_oval(10, 10, 25, 25, fill=color)",simpleAssign,196 Python for Kids,"ball = Ball(canvas, 'red')",simpleAssign,197 Python for Kids,"ball = Ball(canvas, 'red')",simpleAssign,197 Python for Kids,tk = Tk(),simpleAssign,200 Python for Kids,"canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)",simpleAssign,200 Python for Kids,"ball = Ball(canvas, 'red')",simpleAssign,200 Python for Kids,"We’ve added three more lines to our program. With self.x = 0,",simpleAssign,200 Python for Kids,v pos = self.canvas.coords(self.id),simpleAssign,200 Python for Kids,w if pos[1] <= 0:,simpleAssign,201 Python for Kids,x if pos[3] >= self.canvas_height:,simpleAssign,201 Python for Kids,w self.x = starts[0],simpleAssign,202 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,203 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,203 Python for Kids,tk = Tk(),simpleAssign,204 Python for Kids,"canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)",simpleAssign,204 Python for Kids,"ball = Ball(canvas, 'red')",simpleAssign,204 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,206 Python for Kids,"paddle = Paddle(canvas, 'blue')",simpleAssign,206 Python for Kids,"ball = Ball(canvas, 'red')",simpleAssign,206 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,208 Python for Kids,elif pos[2] >= self.canvas_width:,simpleAssign,208 Python for Kids,"to 0 (<= 0), we set the x variable to 0 with self.x = 0. In the same",simpleAssign,209 Python for Kids,"to the canvas width (>= self.canvas_width), we also set the x vari-",simpleAssign,209 Python for Kids,able to 0 with self.x = 0.,simpleAssign,209 Python for Kids,v self.paddle = paddle,simpleAssign,209 Python for Kids,"paddle = Paddle(canvas, 'blue')",simpleAssign,210 Python for Kids,"ball = Ball(canvas, paddle, 'red')",simpleAssign,210 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,210 Python for Kids,v paddle_pos = self.canvas.coords(self.paddle.id),simpleAssign,211 Python for Kids,w if pos[2] >= paddle_pos[0] and pos[0] <= paddle_pos[2]:,simpleAssign,211 Python for Kids,x if pos[3] >= paddle_pos[1] and pos[3] <= paddle_pos[3]:,simpleAssign,211 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,213 Python for Kids,paddle_pos = self.canvas.coords(self.paddle.id),simpleAssign,215 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,215 Python for Kids,pos = self.canvas.coords(self.id),simpleAssign,215 Python for Kids,elif pos[2] >= self.canvas_width:,simpleAssign,215 Python for Kids,tk = Tk(),simpleAssign,216 Python for Kids,"canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)",simpleAssign,216 Python for Kids,"paddle = Paddle(canvas, 'blue')",simpleAssign,216 Python for Kids,"ball = Ball(canvas, paddle, 'red')",simpleAssign,216 Python for Kids,highlightthickness=0),simpleAssign,234 Python for Kids,"Next, we create the canvas with the self.canvas = Canvas line,",simpleAssign,234 Python for Kids,The backslash (\) in the self.canvas = Canvas line is used only to,simpleAssign,235 Python for Kids,"u self.bg = PhotoImage(file=""background.gif"")",simpleAssign,235 Python for Kids,v w = self.bg.width(),simpleAssign,235 Python for Kids,h = self.bg.height(),simpleAssign,235 Python for Kids,"image=self.bg, anchor='nw')",simpleAssign,235 Python for Kids,"image=self.bg, anchor='nw')",simpleAssign,236 Python for Kids,v if self.running == True:,simpleAssign,236 Python for Kids,g = Game(),simpleAssign,237 Python for Kids,x1=50,simpleAssign,240 Python for Kids,x2=100,simpleAssign,240 Python for Kids,x1=40,simpleAssign,240 Python for Kids,x2=150,simpleAssign,240 Python for Kids,"c1 = Coords(40, 40, 100, 100)",simpleAssign,240 Python for Kids,"c2 = Coords(50, 50, 150, 150)",simpleAssign,240 Python for Kids,w if y_calc >= co2.y1 and y_calc <= co2.y2:,simpleAssign,244 Python for Kids,v self.game = game,simpleAssign,244 Python for Kids,w self.endgame = False,simpleAssign,244 Python for Kids,x self.coordinates = None,simpleAssign,244 Python for Kids,x self.photo_image = photo_image,simpleAssign,246 Python for Kids,"y self.image = game.canvas.create_image(x, y, \",simpleAssign,246 Python for Kids,"image=self.photo_image, anchor='nw')",simpleAssign,246 Python for Kids,u g = Game(),simpleAssign,246 Python for Kids,"v platform1 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,246 Python for Kids,g = Game(),simpleAssign,247 Python for Kids,"platform1 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,247 Python for Kids,"platform2 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,247 Python for Kids,"platform3 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,247 Python for Kids,"platform4 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,247 Python for Kids,"platform5 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,248 Python for Kids,"platform6 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,248 Python for Kids,"platform7 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,248 Python for Kids,"platform8 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,248 Python for Kids,"platform9 = PlatformSprite(g, PhotoImage(file=""platform3.gif""), \",simpleAssign,248 Python for Kids,"platform10 = PlatformSprite(g, PhotoImage(file=""platform3.gif""), \",simpleAssign,248 Python for Kids,"w self.image = game.canvas.create_image(200, 470, \",simpleAssign,253 Python for Kids,"image=self.images_left[0], anchor='nw')",simpleAssign,253 Python for Kids,"image=self.images_left[0], anchor='nw')",simpleAssign,253 Python for Kids,v self.y = 0,simpleAssign,253 Python for Kids,w self.current_image = 0,simpleAssign,253 Python for Kids,x self.current_image_add = 1,simpleAssign,254 Python for Kids,y self.jump_count = 0,simpleAssign,254 Python for Kids,z self.last_time = time.time(),simpleAssign,254 Python for Kids,v if self.y == 0:,simpleAssign,255 Python for Kids,y if self.y == 0:,simpleAssign,255 Python for Kids,z self.x = 2,simpleAssign,255 Python for Kids,u if self.y == 0:,simpleAssign,256 Python for Kids,w self.jump_count = 0,simpleAssign,256 Python for Kids,g = Game(),simpleAssign,258 Python for Kids,"platform1 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,258 Python for Kids,u if self.x != 0 and self.y == 0:,simpleAssign,260 Python for Kids,w self.last_time = time.time(),simpleAssign,261 Python for Kids,y if self.current_image >= 2:,simpleAssign,261 Python for Kids,image=self.images_left[2]),simpleAssign,262 Python for Kids,image=self.images_left[self.current_image]),simpleAssign,262 Python for Kids,image=self.images_right[2]),simpleAssign,263 Python for Kids,image=self.images_right[self.current_image]),simpleAssign,263 Python for Kids,image=self.images_left[2]),simpleAssign,264 Python for Kids,image=self.images_left[self.current_image]),simpleAssign,264 Python for Kids,image=self.images_right[2]),simpleAssign,264 Python for Kids,image=self.images_right[self.current_image]),simpleAssign,264 Python for Kids,u xy = self.game.canvas.coords(self.image),simpleAssign,264 Python for Kids,v self.coordinates.x1 = xy[0],simpleAssign,264 Python for Kids,w self.coordinates.y1 = xy[1],simpleAssign,264 Python for Kids,xy = self.game.canvas.coords(self.image),simpleAssign,265 Python for Kids,co = self.coords(),simpleAssign,266 Python for Kids,left = True,simpleAssign,266 Python for Kids,right = True,simpleAssign,266 Python for Kids,top = True,simpleAssign,266 Python for Kids,bottom = True,simpleAssign,266 Python for Kids,falling = True,simpleAssign,266 Python for Kids,bottom = True,simpleAssign,266 Python for Kids,falling = True,simpleAssign,266 Python for Kids,u if self.y > 0 and co.y2 >= self.game.canvas_height:,simpleAssign,266 Python for Kids,v self.y = 0,simpleAssign,266 Python for Kids,w bottom = False,simpleAssign,266 Python for Kids,x elif self.y < 0 and co.y1 <= 0:,simpleAssign,267 Python for Kids,y self.y = 0,simpleAssign,267 Python for Kids,z top = False,simpleAssign,267 Python for Kids,elif self.y < 0 and co.y1 <= 0:,simpleAssign,267 Python for Kids,top = False,simpleAssign,267 Python for Kids,u if self.x > 0 and co.x2 >= self.game.canvas_width:,simpleAssign,267 Python for Kids,v self.x = 0,simpleAssign,267 Python for Kids,w right = False,simpleAssign,267 Python for Kids,x elif self.x < 0 and co.x1 <= 0:,simpleAssign,267 Python for Kids,y self.x = 0,simpleAssign,267 Python for Kids,z left = False,simpleAssign,267 Python for Kids,elif self.x < 0 and co.x1 <= 0:,simpleAssign,268 Python for Kids,left = False,simpleAssign,268 Python for Kids,v if sprite == self:,simpleAssign,268 Python for Kids,x sprite_co = sprite.coords(),simpleAssign,268 Python for Kids,top = False,simpleAssign,268 Python for Kids,top = False,simpleAssign,269 Python for Kids,v self.y = sprite_co.y1 - co.y2,simpleAssign,269 Python for Kids,y bottom = False,simpleAssign,269 Python for Kids,z top = False,simpleAssign,269 Python for Kids,bottom = False,simpleAssign,270 Python for Kids,top = False,simpleAssign,270 Python for Kids,if bottom and falling and self.y == 0 \,simpleAssign,270 Python for Kids,falling = False,simpleAssign,270 Python for Kids,if bottom and falling and self.y == 0 \,simpleAssign,270 Python for Kids,falling = False,simpleAssign,270 Python for Kids,w left = False,simpleAssign,271 Python for Kids,z right = False,simpleAssign,271 Python for Kids,elif self.x < 0 and co.x1 <= 0:,simpleAssign,271 Python for Kids,left = False,simpleAssign,271 Python for Kids,sprite_co = sprite.coords(),simpleAssign,271 Python for Kids,top = False,simpleAssign,271 Python for Kids,bottom = False,simpleAssign,271 Python for Kids,top = False,simpleAssign,271 Python for Kids,if bottom and falling and self.y == 0 \,simpleAssign,271 Python for Kids,falling = False,simpleAssign,271 Python for Kids,left = False,simpleAssign,272 Python for Kids,right = False,simpleAssign,272 Python for Kids,right = False,simpleAssign,272 Python for Kids,u if falling and bottom and self.y == 0 \,simpleAssign,272 Python for Kids,v self.y = 4,simpleAssign,272 Python for Kids,u sf = StickFigureSprite(g),simpleAssign,273 Python for Kids,w self.photo_image = photo_image,simpleAssign,274 Python for Kids,"x self.image = game.canvas.create_image(x, y, \",simpleAssign,274 Python for Kids,"image=self.photo_image, anchor='nw')",simpleAssign,274 Python for Kids,z self.endgame = True,simpleAssign,274 Python for Kids,left = False,simpleAssign,275 Python for Kids,right = False,simpleAssign,275 Python for Kids,"door = DoorSprite(g, PhotoImage(file=""door1.gif""), 45, 30, 40, 35)",simpleAssign,275 Python for Kids,sf = StickFigureSprite(g),simpleAssign,275 Python for Kids,highlightthickness=0),simpleAssign,277 Python for Kids,w = self.bg.width(),simpleAssign,277 Python for Kids,h = self.bg.height(),simpleAssign,277 Python for Kids,"image=self.bg, anchor='nw')",simpleAssign,277 Python for Kids,"image=self.photo_image, anchor='nw')",simpleAssign,278 Python for Kids,"image=self.images_left[0], anchor='nw')",simpleAssign,279 Python for Kids,image=self.images_left[2]),simpleAssign,280 Python for Kids,image=self.images_left[self.current_image]),simpleAssign,280 Python for Kids,image=self.images_right[2]),simpleAssign,280 Python for Kids,image=self.images_right[self.current_image]),simpleAssign,280 Python for Kids,xy = self.game.canvas.coords(self.image),simpleAssign,280 Python for Kids,co = self.coords(),simpleAssign,280 Python for Kids,left = True,simpleAssign,280 Python for Kids,right = True,simpleAssign,280 Python for Kids,top = True,simpleAssign,280 Python for Kids,bottom = True,simpleAssign,280 Python for Kids,falling = True,simpleAssign,280 Python for Kids,bottom = False,simpleAssign,280 Python for Kids,elif self.y < 0 and co.y1 <= 0:,simpleAssign,280 Python for Kids,top = False,simpleAssign,280 Python for Kids,right = False,simpleAssign,281 Python for Kids,elif self.x < 0 and co.x1 <= 0:,simpleAssign,281 Python for Kids,left = False,simpleAssign,281 Python for Kids,sprite_co = sprite.coords(),simpleAssign,281 Python for Kids,top = False,simpleAssign,281 Python for Kids,bottom = False,simpleAssign,281 Python for Kids,top = False,simpleAssign,281 Python for Kids,if bottom and falling and self.y == 0 \,simpleAssign,281 Python for Kids,falling = False,simpleAssign,281 Python for Kids,left = False,simpleAssign,281 Python for Kids,right = False,simpleAssign,281 Python for Kids,if falling and bottom and self.y == 0 \,simpleAssign,281 Python for Kids,"image=self.photo_image, anchor='nw')",simpleAssign,281 Python for Kids,g = Game(),simpleAssign,282 Python for Kids,"platform1 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,282 Python for Kids,"platform2 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,282 Python for Kids,"platform3 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,282 Python for Kids,"platform4 = PlatformSprite(g, PhotoImage(file=""platform1.gif""), \",simpleAssign,282 Python for Kids,"platform5 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,282 Python for Kids,"platform6 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,282 Python for Kids,"platform7 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,282 Python for Kids,"platform8 = PlatformSprite(g, PhotoImage(file=""platform2.gif""), \",simpleAssign,282 Python for Kids,"platform9 = PlatformSprite(g, PhotoImage(file=""platform3.gif""), \",simpleAssign,282 Python for Kids,"platform10 = PlatformSprite(g, PhotoImage(file=""platform3.gif""), \",simpleAssign,282 Python for Kids,"door = DoorSprite(g, PhotoImage(file=""door1.gif""), 45, 30, 40, 35)",simpleAssign,282 Python for Kids,sf = StickFigureSprite(g),simpleAssign,282 Python for Kids,tk = Tk(),simpleAssign,286 Python for Kids,"canvas = Canvas(tk, width=400, height=400)",simpleAssign,286 Python for Kids,myimage = PhotoImage(file='c:\\test.gif'),simpleAssign,286 Python for Kids,"canvas.create_image(0, 0, anchor=NW, image=myimage)",simpleAssign,286 Python for Kids,"v img = image.load_bmp(""c:\\test.bmp"")",simpleAssign,287 Python for Kids,"w screen = video.set_mode(img.width, img.height)",simpleAssign,287 Python for Kids,age = 10,simpleAssign,295 Python for Kids,car1 = Car('red'),simpleAssign,296 Python for Kids,car2 = Car('blue'),simpleAssign,296 Python for Kids,t = turtle.Pen(),simpleAssign,298 Python for Kids,t = Pen(),simpleAssign,299 Python for Kids,a = 1,simpleAssign,300 Python for Kids,b = 2,simpleAssign,300 Python for Kids,"used to tell if two things are equal (for example 10 == 10 is true,",simpleAssign,301 Python for Kids,"and 10 == 11 is false). However, there is a fundamental difference",simpleAssign,301 Python for Kids,"between is and ==. If you are comparing two things, == may return",simpleAssign,301 Python for Kids,using == in this book.,simpleAssign,301 Python for Kids,x = True,simpleAssign,302 Python for Kids,age = 15,simpleAssign,303 Python for Kids,age = 15,simpleAssign,303 Python for Kids,age = 15,simpleAssign,303 Python for Kids,seconds = age_in_seconds(9),simpleAssign,305 Python for Kids,x = 1,simpleAssign,305 Python for Kids,x = 1,simpleAssign,306 Making Use of Python,map(),map,100 Making Use of Python,"map(), and reduce()",map,112 Making Use of Python,map(),map,115 Making Use of Python,map() function helps you do this. The function map(),map,115 Making Use of Python,"map(function,sequence)",map,115 Making Use of Python,map(),map,115 Making Use of Python,"map((lambda a:a+3),[12,13,14,15,16])",map,115 Making Use of Python,"map((lambda a:a**3),[1,2,3,4,5])",map,116 Making Use of Python,"map(round,[13.4,15.6,17.8])",map,116 Making Use of Python,map(),map,116 Making Use of Python,map(),map,116 Making Use of Python,map(),map,116 Making Use of Python,map(),map,116 Making Use of Python,map(),map,116 Making Use of Python,map(),map,116 Making Use of Python,"map(lambda a,b:a+b,[4,7,3],[2,6,8])",map,116 Making Use of Python,map(),map,116 Making Use of Python,"map(func,seq1,seq2)",map,117 Making Use of Python,map(),map,117 Making Use of Python,"map(lambda a,b:(a+b,a-b),[4,7,3],[2,6,8])",map,117 Making Use of Python,map(),map,117 Making Use of Python,map(),map,117 Making Use of Python,"map(None, [4,7,3],[2,6,8])",map,117 Making Use of Python,"map(None,seq,map(square,seq))",map,117 Making Use of Python,map(),map,117 Making Use of Python,map() function. The inner map(),map,117 Making Use of Python,map(),map,118 Making Use of Python,map(),map,122 Making Use of Python,map(),map,381 Making Use of Python,enumerate(),enumfunc,303 Making Use of Python,enumerate(),enumfunc,313 Making Use of Python,if __name__ == ‘__main__’:,__name__,338 Making Use of Python,"nary attribute, __dict__",__dict__,164 Making Use of Python,attributes of a class are reflected in the __dict__,__dict__,165 Making Use of Python,and __dict__,__dict__,165 Making Use of Python,Another way to show an output in the same way as the __dict__,__dict__,165 Making Use of Python,Now let’s use the __dict__,__dict__,165 Making Use of Python,My_Class.__dict__,__dict__,165 Making Use of Python,and the __dict__,__dict__,168 Making Use of Python,i.__dict__,__dict__,168 Making Use of Python,My_Attr_Class.__dict__,__dict__,181 Making Use of Python,"try: try_statements finally: finally_statements When an exception is thrown in the try block, the execution immediately passes to the finally block. After all the statements in the finally block are executed, the exception is raised again and is handled in the except statements if present in the next higher layer of the try-except statement. Consider the following example: try: f=open(‘testfile’,’w’) f.write(‘Bank calculations for interest’) except IOError: print ‘ Error: can\’t find file or read data’ f.close() In the preceding example, the statements in the try block are executed. If an excep- tion occurs, it is handled in the except block and the file is closed. What happens when the exception does not occur? The file is never closed and remains open. Shifting the f.close() statement to the try block will also not solve our problem. In that case, when an exception occurs the file will remain open and the program control will exit the try-except statement without closing the file. The finally statement comes to your rescue in situations like these where certain statements need to be exe- cuted whether or not the exception occurs. Let’s write the preceding code again to demonstrate the use of the try-finally statement. try: f=open(‘testfile.txt’,’w’) try: f.write(‘Bank calculations for interest’) finally:",tryexceptfinally,206 Making Use of Python,"try: try_statements except Exception: except_statements II The try block throws an exception, and the except block contains code to handle the exception. II A single try statement can have multiple except statements, or an except statement can handle multiple exceptions. II An exception may have an associated value, called the argument of the exception. Every time an exception is thrown, an instance of the exception class is cre- ated. The argument of an exception and its type depend on the exception class. II The else statement is placed after all the except blocks for a particular try block and contains code that must be executed when no exception is raised by the try statement. II At times those statements must be executed regardless of the occurrence of the exception. You can place all such statements in the finally block. The syntax of the try-finally statement is this: try: try_statements finally:",tryexceptfinally,211 Making Use of Python,"while i==1: ... reg_no=raw_input(“Please enter your reg number “) ... if valid(reg_no)==1: ... tot_score=score(reg_no) ... print “Your total score is “, tot_score ... i=0 ... else:",whileelse,89 Making Use of Python,"while i>0: inp=raw_input(“Enter the password”) for pass in passwordlist: if inp==pass: valid=1 break if not valid: print “invalid password” i=i-1 continue else:",whileelse,92 Making Use of Python,"while (i<=50): #Repeats the loop 50 times while 1: #Takes user input for name and then checks if its length is 0 name=raw_input(“Enter the name “) if len(name)==0: continue else: break while 1: #Takes user input for name and then checks if its #length is not 0 reg_no=raw_input(“Enter the registration number “) if len(reg_no)==0: continue else: break j=1 tot_score=0 while j<=4: #Iterates 4 times for 4 subjects print ‘Enter score in subject’, j score=raw_input() if len(score)==0 or int(score)>100: #Checks for the length of score and that they are #not greater than 100 continue else:",whileelse,94 Making Use of Python,"while 1: if ch in (‘y’,’yes’,’Y’): yr=raw_input(‘Enter a year:’) list_yr.append(int(yr)) ch=raw_input(‘Do you want to enter another year? ‘) else:",whileelse,114 Making Use of Python,"while 1: if ch in (‘y’,’yes’,’Y’): yr=raw_input(‘Enter a year:’) list_yr.append(int(yr)) ch=raw_input(‘Do you want to enter another year? ‘) else:",whileelse,115 Making Use of Python,"while 1: if ch in (‘y’,’yes’,’Y’): inp=raw_input(‘Enter a number:’) seq.append(int(inp)) ch=raw_input(‘Do you want to enter another value? ‘) else:",whileelse,117 Making Use of Python,"while i<len(qtystr): c=ord(qtystr[i]) if (c in range(0,47) or c in range(58,255)) and c<>46: print “Please enter integers only” break else: i=i+1 if i==len(qtystr): qty=float(qtystr) if qty<>int(qty) or qty<=0: print “Invalid value for quantity” The code for creditcard.py is as follows: # creditcard.py def credit_func(cardno): #Checks if credit card no. is 16-digit and # contains only numbers if len(cardno)<>16: print “Credit card no. should be 16 digits” else:",whileelse,138 Making Use of Python,"while not KeyInput: print ch=raw_input(‘Press Enter to continue ‘) if ch!=’’: #Checks if the input is not the #Enter key print print print ‘Wrong key pressed. You can only press Enter ‘ else:",whileelse,183 Making Use of Python,"while not end: BkDet=BkFile.readline() if BkDet != ‘’: print print ‘Record number: %s’ % (record) print ‘================’ print BkDet record = record + 1 else:",whileelse,185 Making Use of Python,"while not end: SwDet=SwFile.readline() if SwDet != ‘’: print print ‘Record number: %s’ % (record) print ‘===============’ print SwDet record = record + 1 else:",whileelse,187 Making Use of Python,"while 1: TCP_Client_Socket, ClientAddress =\ TCP_Server_Socket.accept() print ‘Server has accepted the connection request from ‘,\ ClientAddress if ServerData: for i in range(len(ServerData)): TCP_Client_Socket.send(str(ServerData[i])) sleep(0.01) else:",whileelse,307 Making Use of Python,"while ch<=3: #Create four threads for four clients NewThreadObject = MyThread() NewThreadObject.start() threadarray.append(NewThreadObject) ch=ch+1 Write the Code for the Client The following is the code for creating a TCP client for the required application: # Client program from socket import * from time import sleep Hostname = ‘localhost’ PortNumber = 12345 Buffer = 500 #Establish connection with the server ServerAddress = (Hostname, PortNumber) TCP_Client_Socket = socket(AF_INET, SOCK_STREAM) TCP_Client_Socket.connect(ServerAddress) while 1: print ‘The client is connected to the server’ ServerData = TCP_Client_Socket.recv(Buffer) if not ServerData: print ‘The server has sent nothing’ break else:",whileelse,308 Making Use of Python,"while 1: line=fileupload.file.readline() data=data+line if not line: break count=count+1 print header+shtml % (fileupload.filename,data) else:",whileelse,329 Making Use of Python,"while len(filedata) < totbytes: # read each line #from the file data = self.f_data.readline() if data == ‘’: break filedata = filedata + data else:",whileelse,336 Making Use of Python,"while 1: if year<=0 or month<=0 or day<=0: break if cur_year<year: #Checks if current year # is less than year of birth break if month>12: #Checks if month of birth is greater than 12 break if month in (1,3,5,7,8,10,12):#Checks if number of days in are if day>31: #greater than 31 for applicable break #month elif month in (4,6,9,11): #Checks if number of days in if day>30: #are greater than 31 for #applicable month #date of birth break if year%4==0 and month==2: #Checks if in a leap year, #number of days if day>29: #in date of birth are greater than 29 break",whilebreak,120 Making Use of Python,"while 1: if year<=0 or month<=0 or day<=0: break #Checks if current year is less than year of birth if cur_year<year: break if cur_year==year and cur_month>month: break #Checks if month of birth is greater than 12 if month>12: break #Checks if number of days are #greater than 31 for applicable month if month in (1,3,5,7,8,10,12): if day>31: break #Checks if number of days in date of birth #are greater than 30 for applicable month elif month in (4,6,9,11): if day>30: break #Checks if in a leap year, number of days #in date of birth are greater than 29 #for february if year%4==0 and month==2: if day>29: break",whilebreak,137 Making Use of Python,"while 1: 13 print ‘Server is waiting for connection’ 14 TCP_Client_Socket, ClientAddress = TCP_Server_Socket.accept() 15 print ‘Server has accepted the connection request from ‘, ClientAddress 16 print ‘The Server is ready to receive data from the client’ 17 18 while 1: 19 ClientData = TCP_Client_Socket.recv(Buffer) 20 if not ClientData: 21 print ‘The client has closed the connection’ 22 break",whilebreak,276 Making Use of Python,"while 1: 12 print ‘The client is connected to the server’ 13 DataStr = raw_input(‘Enter data to send to the server: ‘) 14 if not DataStr: 15 print ‘The client has entered nothing; hence the connection to the server is closed’ 16 break 17 TCP_Client_Socket.send(DataStr) 18 ServerData = TCP_Client_Socket.recv(Buffer) 19 if not ServerData: 20 print ‘The server has sent nothing’ 21 break 22 print ‘The server has sent this data string: ‘, ServerData 23 TCP_Client_Socket.close() Let’s look at this code line by line to understand what is happening: II In line 1, all attributes of the socket module, including the socket() function, are imported. II In lines 3 through 5, variables are defined for the host name and port number of the server and the maximum size of data that can be exchanged. The Host- name variable will contain the name of the host on which the server is running. In this case, both the server and the client are running on the same host. There- fore, the value localhost is passed as the host name. II In line 6, an attribute, ServerAddress, that contains the address of the server, is defined. The address consists of the host name and port number of the server. II In line 8, the client socket is created and its object, TCP_Client_Socket, is returned. The arguments of the socket() module denote that the client socket belongs to the address family AF_INET. The arguments also denote that the client socket is a stream socket, SOCK_STREAM. II In line 9, the connect() method is used to connect the client to the server. The address of the server, which consists of the host name and the port number, is passed as an argument to the connect() method. II In line 11, a loop contains statement is started. This statement will be used for sending and receiving operations. II In line 13, the user at the client end is prompted for data input. The data string is stored in the attribute DataStr. II In line 14, the if condition checks whether the user at the client end has entered any data. If not, the loop started in line 11 break",whilebreak,278 Making Use of Python,"while 1: 11 DataStr=raw_input(‘Enter data to send to the server: ‘) 12 if not DataStr: 13 print ‘The user has entered nothing; hence the client socket is closed’ 14 break 15 UDP_Client_Socket.sendto(DataStr, ServerAddress) 16 ServerData, ServerAddress = UDP_Client_Socket.recvfrom(Buffer) 17 if not ServerData: 18 print ‘The server has sent nothing; hence the client socket is closed’ 19 break 20 print ‘The server has sent this data string: ‘, ServerData 21 UDP_Client_Socket.close() Let’s look at this code line by line to understand what is happening. It is quite simi- lar to the one used for TCP client. II In line 1, all attributes of the socket module, including the socket() function, are imported. II In lines 3 through 5, variables are defined for the host name and port number of the server and the maximum size of data that can be exchanged. The Host- name variable will contain the name of the host on which the server is running. In this case, both the server and the client are running on the same host. There- fore, the value localhost is passed as the host name. II In line 6, an attribute, ServerAddress, containing the address of the server is defined. The address consists of the host name and port number of the server. II In line 8, the server socket is created and its object, UDP_Client_Socket, is returned. The arguments of the socket() module denote that the server socket belongs to the address family AF_INET. The argument also denotes that the server socket is a stream socket, SOCK_DGRAM. II In line 10, a loop containing statements is started. This statement will be used for sending and receiving operations. II In line 11, the user at the client end is prompted for data input. The data string is stored in the attribute DataStr. II In line 12, the if condition checks whether the user at the client end has entered any data. If not, then the loop started in line 10 break",whilebreak,283 Making Use of Python,"while 1: #at a given address DataToServer = raw_input(‘Enter data: ‘) #Asks input for data if not Data: #Checks if the variable is blank print print ‘********************************************’ print ‘** You have entered nothing **’ print ‘** The connection to the server is closed **’ print ‘********************************************’ print break Client_Socket.send(DataToServer) #Sends data to server ServerData=Client_Socket.recv(Buffer) #Receives data from client if not ServerData: #Checks if the variable is blank print print ‘The server has ended the connection’ break",whilebreak,288 Making Use of Python,"while 1: the client’ ClientData = TCP_Client_Socket.recv(Buffer) if not ClientData: print ‘The client has closed the connection’ break",whilebreak,307 Making Use of Python,"while 1: dob=raw_input(“Enter your date of birth, mm-dd-yyyy: “) dob=isblank(dob) #Call isblank function for dob if len(dob)<>10: print “Enter date in correct format!!” continue",whilecontinue,120 Making Use of Python,while loop is this:,whilesimple,87 Making Use of Python,while evaluating_condition:,whilesimple,87 Making Use of Python,while loop:,whilesimple,88 Making Use of Python,while i==1:,whilesimple,88 Making Use of Python,while (num2 < a):,whilesimple,89 Making Use of Python,while specifying both default and required parameters for the same function:,whilesimple,104 Making Use of Python,while len(var)==0:,whilesimple,119 Making Use of Python,while num2<a:,whilesimple,126 Making Use of Python,while num2<a:,whilesimple,134 Making Use of Python,while i<len(cardno):,whilesimple,138 Making Use of Python,while (ans==’y’):,whilesimple,154 Making Use of Python,while not done:,whilesimple,187 Making Use of Python,while ctr<=3:,whilesimple,195 Making Use of Python,while i<count:,whilesimple,262 Making Use of Python,while 1:,whilesimple,281 Making Use of Python,while 1:,whilesimple,286 Making Use of Python,while 1:,whilesimple,286 Making Use of Python,while i<=3:,whilesimple,297 Making Use of Python,while j<=3:,whilesimple,297 Making Use of Python,while i<=3:,whilesimple,300 Making Use of Python,while j<=3:,whilesimple,300 Making Use of Python,while threadnumber <= 2:,whilesimple,305 Making Use of Python,while threadnumber <= 2:,whilesimple,306 Making Use of Python,while 1:,whilesimple,316 Making Use of Python,while data:,whilesimple,324 Making Use of Python,while data:,whilesimple,325 Making Use of Python,from fib import *,fromstarstatements,130 Making Use of Python,from module import *,fromstarstatements,130 Making Use of Python,from module import *,fromstarstatements,130 Making Use of Python,"from module import *",fromstarstatements,130 Making Use of Python,from module import *,fromstarstatements,275 Making Use of Python,from socket import *,fromstarstatements,275 Making Use of Python,from socket import *,fromstarstatements,277 Making Use of Python,from socket import *,fromstarstatements,281 Making Use of Python,from socket import *,fromstarstatements,283 Making Use of Python,from socket import *,fromstarstatements,286 Making Use of Python,from socket import *,fromstarstatements,287 Making Use of Python,from socket import *,fromstarstatements,307 Making Use of Python,from Tkinter import *,fromstarstatements,343 Making Use of Python,from Tkinter import *,fromstarstatements,346 Making Use of Python,from Tkinter import *,fromstarstatements,348 Making Use of Python,from Tkinter import *,fromstarstatements,350 Making Use of Python,from Tkinter import *,fromstarstatements,351 Making Use of Python,from Tkinter import *,fromstarstatements,351 Making Use of Python,from Tkinter import *,fromstarstatements,352 Making Use of Python,from Tkinter import *,fromstarstatements,352 Making Use of Python,from Tkinter import *,fromstarstatements,355 Making Use of Python,from Tkinter import *,fromstarstatements,357 Making Use of Python,from Tkinter import *,fromstarstatements,358 Making Use of Python,from Tkinter import *,fromstarstatements,359 Making Use of Python,The __init__(),__init__,167 Making Use of Python,The __init__(),__init__,167 Making Use of Python,any __init__(),__init__,167 Making Use of Python,the __init__() method has been implemented. The __init__(),__init__,167 Making Use of Python,The __init__(),__init__,167 Making Use of Python,"the __init__()",__init__,167 Making Use of Python,the __init__(),__init__,167 Making Use of Python,def __init__(self),__init__,167 Making Use of Python,The __init__(),__init__,167 Making Use of Python,"the __init__()",__init__,167 Making Use of Python,The __init__(),__init__,167 Making Use of Python,the __init__(),__init__,167 Making Use of Python,the __init__(),__init__,168 Making Use of Python,"def __init__(self, aVal, bVal)",__init__,168 Making Use of Python,the __init__(),__init__,168 Making Use of Python,def __init__(self),__init__,168 Making Use of Python,constructor __init__(),__init__,174 Making Use of Python,tor __init__(),__init__,174 Making Use of Python,the __init__(),__init__,174 Making Use of Python,the __init__(),__init__,175 Making Use of Python,def __init__(self),__init__,175 Making Use of Python,def __init__(self),__init__,175 Making Use of Python,def __init__(self),__init__,175 Making Use of Python,def __init__(self),__init__,175 Making Use of Python,def __init__(self),__init__,176 Making Use of Python,def __init__(self),__init__,176 Making Use of Python,def __init__(self),__init__,182 Making Use of Python,def __init__(self),__init__,184 Making Use of Python,def __init__(self),__init__,185 Making Use of Python,II __init__(),__init__,190 Making Use of Python,The __init__(),__init__,190 Making Use of Python,"def __init__(self,name,phno,fee,age=18,schrship=0.15)",__init__,194 Making Use of Python,"def __init__(self,name,phno,fee,age=18,schrship=0.15)",__init__,209 Making Use of Python,def __init__(self),__init__,301 Making Use of Python,the __init__(),__init__,303 Making Use of Python,"def __init__(self,func,args)",__init__,306 Making Use of Python,"def __init__(self, master)",__init__,359 Making Use of Python,"try: try_statements except Exception: except_statements The try_statements block, which is after the try statement, contains the state- ments that define the scope of exception handlers associated with it. The except_ statements block, after the except statement, contains the exception-handler code immediately after the try_statements block. The except statement catches the specified exception and executes the except_statements block. Let’s consider an example to understand better how the try-except statement works. >>> try: ... import mod ... except ImportError: ... print “Cannot locate the module” ... Cannot locate the module In the preceding example, the attempt to open the module mod is made in the block of code below the try statement. When the specified module does not exist, the excep- tion occurs. As you can see, the exception still occurs, so what is the use of exception handling? The answer to this question lies in the except statement. During program execution the interpreter tries to execute all statements in the try block. If no exception occurs, the statements in the except block are not executed, and any code after the try-except-statement is executed. If an exception occurs that is specified in the except statement, the code in the except block is executed. If an exception that is not specified in the except statement occurs, then the example here does not include the exception-handling code for that exception. In this example, occurrence of any other exception than ImportError will cause the program to halt execution. What do you do if another exception occurs? To handle multiple exceptions, you can also write mul- tiple except statements for a single try statement or catch multiple exceptions in a single except statement. Before elaborating on each of these, let’s first discuss the dif- ferent ways in which an exception can be handled. Let’s consider an example to explain this. NOTE Remember that there should not be any statement between the try block and its corresponding except block. A try block should be immediately followed by an except block. You know that the int() function converts a string value containing only alphanu- meric characters to an integer. If the string passed as an argument to the int() func- tion does not contain alphanumeric characters, it gives ValueError as follows: >>> int(‘abc’) Traceback (most recent call last): File “<stdin>”, line 1, in ? ValueError: invalid literal for int(): abc",trytry,201 Making Use of Python,"try: return int(var) except ValueError: pass Notice that the preceding code contains a try block for attempting to convert var to an integer. The except block catches ValueError if it occurs but simply ignores it. You can also choose to return a value if the exception occurs so that the function actu- ally always returns a value even if the exception occurs. For example, def int_convert(var): try: return int(var) except ValueError: return 0 You can also choose to print an appropriate message on the screen or store it in a variable. def int_convert(var): try: return int(var) except ValueError: print ‘The argument does not contain numbers’ Notice that the preceding example handles the ValueError exception in different ways but does not handle the TypeError exception at all, which might occur if any object other than a string is passed to the function. Another exception that is expected to occur can be handled using the following approaches: II A try statement with multiple except statements II A single except statement with multiple exceptions Let’s discuss each of them in detail. A try Statement with Multiple except Statements. A single try statement can have multiple except statements. This is useful when the try block contains",trytry,202 Making Use of Python,"try: try_statements except Exception1: except_statements1 except Exception2: except_statements2 : : except ExceptionN: except_statementsN In this form of try-except statement, the interpreter attempts to execute the statements in the try block. If an exception is thrown and a match is found in an except statement, the corresponding except_statements block is executed. Let’s come back to our example of the int_convert function. The ValueError that was expected to occur was handled in one except statement; however, TypeError was not handled. Let’s write another except statement to handle TypeError. >>>def int_convert(var): ... try: ... return int(var) ... except ValueError: ... print ‘The variable does not contain numbers’ ... except TypeError: ... print ‘Non-string type can\’t be converted to integer’ You can execute the preceding code using different function calls as follows: >>>int_convert(‘abc’) The variable does not contain numbers >>>int_convert([12]) Non-string type can’t be converted to integer >>> int_convert(‘12’) 12 Single except Statement with Multiple Exceptions. You can also use the same except statement to handle multiple exceptions. This can be a situation when you do not want to perform different actions when any exception occurs. The syntax of the except statement with multiple exceptions is this: try: try_statements except (Exception1[,Exception2[,...ExceptionN]]]): except_statements When multiple exceptions are handled in a single except statement, they are specified as a tuple. Let’s change the int_convert() function to display the same message when either ValueError or TypeError occur.",trytry,203 Making Use of Python,"try: ... return int(var) ... except (ValueError,TypeError): ... print ‘Wrong argument type or the argument contains alphabetic characters’ You can execute the preceding code using different function calls as follows: >>>int_convert(‘abc’) Wrong argument type or the argument contains alphabetic characters >>> int_convert([12]) Wrong argument type or the argument contains alphabetic characters >>> int_convert(‘12’) 12 NOTE You can also use the except statement with no exceptions defined as follows: try: try_statements except: except_statements This kind of a try-except statement catches all the exceptions that occur. Using this kind of try-except statement is not considered a good programming practice, though, because it catches all exceptions but does not make the programmer identify the root cause of the problem that may occur. You learned the different ways in which an exception can be handled. The ques- tion now arises, what do you do if you also want the except statement to return the value of the exception? Let’s learn how to return values by using the except statement. Argument of an Exception. An exception may have an associated value, called the argument of the exception. Every time an exception is thrown, an instance of the exception class is created. The argument of an exception and its type depend on the exception class. If you are writing the code to handle a single exception, you can have a variable follow the name of the exception in the except statement. If you are trapping multiple exceptions, you can have a vari- able follow the tuple of the exception. This variable will receive the value of the exception mostly containing the cause of the exception. The variable can receive a single value or multiple values in the form of a tuple. This tuple usually con- tains the error string, the error number, and an error location. Following is an example for a single exception: def int_convert(var): try: return int(var) except ValueError,arg: print ‘The argument does not contain numbers:’,arg",trytry,204 Making Use of Python,"try: return int(var) except (ValueError,TypeError), arg: print ‘Wrong argument type or the argument contains alphabetic characters:’, arg When you execute the preceding call using the function call int_convert([12,13]), the output will be: Wrong argument type or the argument contains alphabetic characters: object can’t be converted to int After discussing various forms of the try-except statement, let’s learn how the else statement works with the try-except statement. The else Statement. There may be some statements that you want to execute if the try statement does not generate any errors. One way out is that you can place these statements in the try block. You may not always want to do this, though, because these statements might generate some exceptions, which will be caught in the subsequent except statements. To solve this problem, you can use the else statement. The else statement is placed after all the except blocks for a particular try block and contains code that must be executed when no exception is raised by the try statement. For example, def int_convert(var): try: print int(var) except ValueError: print ‘The variable does not contain numbers’ except TypeError: print ‘Non-string type can\’t be converted to integer’ else: print ‘No exception generated’ In the preceding example, note that the else statement is placed after all the except statements. When you call the int_convert() function by using the function call int_convert(‘32’), the output will be: 32 No exception generated You can also nest try-except statements. Nested try blocks are similar to nested constructs. You can have one try block inside another. Similarly, an",trytry,205 Making Use of Python,"try: ... raise KeyboardInterrupt ... except KeyboardInterrupt: ... print ‘Sorry u cannot copy’ ... Sorry u cannot copy This section has explained how you can handle built-in standard exceptions. Let’s learn about user-defined exceptions. User-Defined Exceptions Python also allows you to create your own exceptions by deriving classes from the standard built-in exceptions. Here is an example related to RuntimeError. Here a class is created that is subclassed from RuntimeError. This is useful when you need to display more specific information when an exception is caught. In the try block, the user-defined exception is raised and caught in the except block. The variable e is used to create an instance of the class Networkerror. >>> class Networkerror(RuntimeError): ... def __init__(self,arg): ... self.args=arg ... >>> try: ... raise Networkerror(“Bad hostname”) ... except Networkerror,e: ... print e.args ... Bad hostname After the discussion in this chapter, you will agree that the try-except statement will be used to catch the exception that is generated.",trytry,208 Making Use of Python,"try: f = open(curdir + sep + self.path) self.send_response(200) self.send_header(‘Content-type’,’text/html’) self.end_headers() self.wfile.write(f.read()) f.close() except IOError: self.send_error(404,’File Not Found: %s’ % self.path) try: server=HTTPServer((‘’,8000),req_handler) print ‘Welcome to the My simple web server...’ print ‘Press ^C once or twice to quit’ server.serve_forever() except KeyboardInterrupt: print ‘^C pressed, shutting down server’ server.socket.close() When you execute the preceding code, a Web server starts. When a client browser tries to open a Web page, the Web page is displayed, as shown in Figure 14.3. Figure 14.3 The page displayed when the Web server is accessed.",trytry,320 Making Use of Python,"try: #start of the try block while ctr<=3: studobjects[ctr].displaydetails() ctr=ctr+1 except IndexError: #start of the except block print ‘Trying to access beyond the length of the list’ else:",tryexceptelse,209 Making Use of Python,"try: self.wfile.write(“SocketServer works!”) except IOError:",tryexcept,316 Making Use of Python,"try: server=HTTPServer((‘’,8000),req_handler) print ‘Welcome to the Mywebserver...’ print ‘Press ^C once or twice to quit’ server.serve_forever() except KeyboardInterrupt:",tryexcept,318 Making Use of Python,"lambda [arg1 [,arg2,.....argn]]:expression",lambda,111 Making Use of Python,lambda form as follows:,lambda,111 Making Use of Python,lambda forms:,lambda,111 Making Use of Python,"lambda a,b: a*b",lambda,111 Making Use of Python,"lambda a,b=6:a*b",lambda,111 Making Use of Python,lambda *tup: tup,lambda,111 Making Use of Python,"lambda tup=(‘a’,’b’),**dt:",lambda,111 Making Use of Python,"def tuple_func(formal1, formal2=’xyz’,**vardict):",funcwith2star,107 Making Use of Python,"def var_args_func(formal1, formal2=’xyz’,*vark,**varnk):",funcwith2star,107 Making Use of Python,"def many_args(tup=(‘a’,’b’),**dt):",funcwith2star,111 Making Use of Python,"def tuple_func(formal1, formal2=’xyz’, *vartuple):",funcwithstar,106 Making Use of Python,def tuple_arg(*tup):,funcwithstar,111 Making Use of Python,class My_Subclass(My_Base_Class):,simpleclass,171 Making Use of Python,class My_Class_A(My_Subclass):,simpleclass,172 Making Use of Python,class books(library):,simpleclass,173 Making Use of Python,class software(library):,simpleclass,173 Making Use of Python,class My_Child_Class(My_Class):,simpleclass,175 Making Use of Python,class My_Child_Class(My_Class):,simpleclass,175 Making Use of Python,class books(library):,simpleclass,176 Making Use of Python,class software(library):,simpleclass,176 Making Use of Python,class books(library):,simpleclass,183 Making Use of Python,"class def bks_method(self):",simpleclass,184 Making Use of Python,class software(library):,simpleclass,185 Making Use of Python,"class def sws_method(self):",simpleclass,185 Making Use of Python,class req_handler(BaseHTTPRequestHandler):,simpleclass,318 Making Use of Python,class req_handler(SimpleHTTPRequestHandler):,simpleclass,320 Making Use of Python,raise RuntimeError(),raise,207 Making Use of Python,raise RuntimeError(‘System not responding’),raise,207 Making Use of Python,"list_str=[‘jjj’,445,[‘vf’,23]]",nestedList,57 Making Use of Python,"dict1={‘name’:’mac’,’ecode’:6734,’dept’:’sales’}",simpleDict,37 Making Use of Python,"dict3={‘2’:1234,2:’abc’,6.5:’troy’ }",simpleDict,38 Making Use of Python,"dict1={‘name’:’mac’,’ecode’:6734,’dept’:’sales’}",simpleDict,70 Making Use of Python,"ops={‘+’:add,’-’:sub,’*’:mul}",simpleDict,113 Making Use of Python,"dict1={‘name’:’mac’,’ecode’:6734,’dept’:’sales’}",simpleDict,197 Making Use of Python,"dict1={‘name’:’Laura’, ‘studid’:’S001’}",simpleDict,327 Making Use of Python,"In Python, the base of any file-related operation is the built-in function open()",openfunc,142 Making Use of Python,The open(),openfunc,142 Making Use of Python,You can use the open() function to open any type of file. The syntax for the open(),openfunc,142 Making Use of Python,"file object = open(file_name [, access_mode][,buffering])",openfunc,142 Making Use of Python,code displays an example for the use of the open(),openfunc,143 Making Use of Python,"fileobj=open(‘/home/testfile’,’r’)",openfunc,143 Making Use of Python,"fileobj=open(‘c:/myfiles/testfile’,’wb’)",openfunc,143 Making Use of Python,"fileobj=open(‘/home/testfile’,’r+’)",openfunc,143 Making Use of Python,NOTE If you omit the access mode argument in the open(),openfunc,144 Making Use of Python,After the open(),openfunc,144 Making Use of Python,"fileobj=open(‘testfile’,’w’)",openfunc,145 Making Use of Python,"fileobj=open(‘newtestfile’,’w’)",openfunc,145 Making Use of Python,"Next, the open()",openfunc,145 Making Use of Python,"fileobj=open(‘testfile’,’r’)",openfunc,145 Making Use of Python,"fileobj1=open(‘newtestfile’,’r’)",openfunc,146 Making Use of Python,"fileobj=open(‘newtestfile’,’r’)",openfunc,146 Making Use of Python,"fileobj2=open(‘testfile’,’r’)",openfunc,146 Making Use of Python,"fileobj=open(‘testfile’,’r’)",openfunc,146 Making Use of Python,"f=open(‘testfile’,’r’)",openfunc,146 Making Use of Python,"fileobj=open(‘seekfile’,’w+’)",openfunc,148 Making Use of Python,"fileobj=open(‘tellfile’,’w+’)",openfunc,149 Making Use of Python,II open(),openfunc,154 Making Use of Python,"fileobj=open(‘course_details’,’a’)",openfunc,154 Making Use of Python,"fileobj=open(‘course_details’,’r’)",openfunc,155 Making Use of Python,II The open(),openfunc,156 Making Use of Python,"File=open(FileName,’a’)",openfunc,182 Making Use of Python,"BkFile=open(‘BookDetails’, ‘a’)",openfunc,184 Making Use of Python,"BkFile=open(‘BookDetails’, ‘a’)",openfunc,184 Making Use of Python,"BkFile=open(‘BookDetails’, ‘r’)",openfunc,185 Making Use of Python,"SwFile=open(‘SoftwareDetails’, ‘a’)",openfunc,186 Making Use of Python,"SwFile=open(‘SoftwareDetails’, ‘a’)",openfunc,186 Making Use of Python,"SwFile=open(‘SoftwareDetails’, ‘r’)",openfunc,186 Making Use of Python,"SwFile=open(‘SoftwareDetails’, ‘r’)",openfunc,186 Making Use of Python,file=open(“Myfile”),openfunc,197 Making Use of Python,the open(),openfunc,199 Making Use of Python,meaning to the arguments of the open(),openfunc,273 Making Use of Python,"WriteToFile=open(‘DataFile’, ‘a’)",openfunc,287 Making Use of Python,"ReadfromFile=open(‘DataFile’,’r’)",openfunc,287 Making Use of Python,The urllip.urlopen(),openfunc,323 Making Use of Python,The urlopen(),openfunc,323 Making Use of Python,urlopen(),openfunc,323 Making Use of Python,"urlopen(url,[,encoded_data])",openfunc,323 Making Use of Python,The urlopen(),openfunc,323 Making Use of Python,"copyfile=open(“copypage.html”,”wb”)",openfunc,324 Making Use of Python,f=urllib.urlopen(“http://www.python.org/”),openfunc,324 Making Use of Python,"copyfile=open(“copypage.html”,”wb”)",openfunc,325 Making Use of Python,f=urllib.urlopen(“http://www.python.org/”),openfunc,325 Making Use of Python,urlopen(),openfunc,381 Making Use of Python,The write(),write,144 Making Use of Python,ters in a single line or multiple lines or in a block of bytes. The write(),write,144 Making Use of Python,fileobj.write(‘This is the first line\n’),write,145 Making Use of Python,fileobj.write(‘This is the second line\n’),write,145 Making Use of Python,the functioning of print() method and stdout.write(),write,147 Making Use of Python,II stdout.write(),write,147 Making Use of Python,sys.stdout.write(‘Welcome to Python\n’),write,147 Making Use of Python,Both the examples display the text Welcome to Python. In the stdout.write(),write,147 Making Use of Python,sys.stdout.write(‘Enter a your name: ‘),write,147 Making Use of Python,sys.stdout.write(name),write,147 Making Use of Python,fileobj.write(‘Welcome to Python\n’),write,148 Making Use of Python,fileobj.write(‘Welcome to Python\n’),write,149 Making Use of Python,II write(),write,154 Making Use of Python,II write(),write,156 Making Use of Python,"BkFile.write(libM[0] + ‘,’)",write,184 Making Use of Python,"BkFile.write(libM[1] + ‘,’)",write,184 Making Use of Python,"BkFile.write(Author + ‘,’)",write,184 Making Use of Python,"BkFile.write(Publisher + ‘,’)",write,184 Making Use of Python,"BkFile.write(ISBN + ‘,’)",write,184 Making Use of Python,"BkFile.write(PageCount + ‘,’)",write,184 Making Use of Python,BkFile.write(libM[2] + ‘\n’),write,184 Making Use of Python,"SwFile.write(libM[0] + ‘,’)",write,186 Making Use of Python,"SwFile.write(libM[1] + ‘,’)",write,186 Making Use of Python,"SwFile.write(ProductOf + ‘,’)",write,186 Making Use of Python,"SwFile.write(Size + ‘,’)",write,186 Making Use of Python,SwFile.write(libM[2] + ‘\n’),write,186 Making Use of Python,and write(). The makefile(),write,273 Making Use of Python,"defines various methods to handle different situations, such as handle_write()",write,285 Making Use of Python,WriteToFile.write(DataFromClient + ‘\n’),write,287 Making Use of Python,self.wfile.write(dynhtml),write,318 Making Use of Python,copyfile.write(data),write,324 Making Use of Python,copyfile.write(data),write,325 Making Use of Python,stdout.write(),write,383 Making Use of Python,The writelines() Method. You can use the writelines(),writelines,145 Making Use of Python,list of strings to a file. The writelines(),writelines,145 Making Use of Python,"end of each string in the list, the writelines()",writelines,145 Making Use of Python,as a single string. The following example illustrates the use of writelines(),writelines,145 Making Use of Python,fileobj.writelines(list),writelines,145 Making Use of Python,fileobj.writelines(heading),writelines,155 Making Use of Python,fileobj.writelines(‘\n’),writelines,155 Making Use of Python,fileobj.writelines(details),writelines,155 Making Use of Python,fileobj.writelines(‘\n’),writelines,155 Making Use of Python,II writelines(),writelines,156 Making Use of Python,You can read the data from a file by using the read([size]) method. The read(),read,145 Making Use of Python,argument will be set to -1 in order to read the entire contents of the file. The read(),read,145 Making Use of Python,use of the read(),read,145 Making Use of Python,fileobj.read(),read,145 Making Use of Python,"Now, let’s look at the use of the size argument in the read()",read,146 Making Use of Python,fileobj1.read(3),read,146 Making Use of Python,The read(),read,146 Making Use of Python,code fileobj.read(4). When you use the read(),read,146 Making Use of Python,fileobj.read(4),read,146 Making Use of Python,fileobj.read(),read,146 Making Use of Python,"next read statement, the read()",read,146 Making Use of Python,"the end of the file. In such a case, if you execute the read()",read,148 Making Use of Python,fileobj.read(),read,148 Making Use of Python,fileobj.read(),read,148 Making Use of Python,the read(),read,148 Making Use of Python,"values, the cursor position moves to the byte zero. Now, the read()",read,148 Making Use of Python,II read(),read,154 Making Use of Python,output=fileobj.read(),read,155 Making Use of Python,II read(),read,156 Making Use of Python,"work with file functions, such as read()",read,273 Making Use of Python,"handle_read(), handle_connect(), and handle_close()",read,285 Making Use of Python,output=ReadfromFile.read(),read,287 Making Use of Python,"thread.start_new_thread(func, args,[,kwargs])",read,300 Making Use of Python,thread.get_thread(),read,300 Making Use of Python,"thread.start_new_thread(func1,())",read,300 Making Use of Python,"thread.start_new_thread(func2,())",read,300 Making Use of Python,moves to the next statement. It encounters another start_new_thread(),read,301 Making Use of Python,threading.currentThread(),read,303 Making Use of Python,class MyThread(Threading.Thread),read,304 Making Use of Python,NewThreadObject = MyThread(),read,304 Making Use of Python,thread.start_new_thread(),read,304 Making Use of Python,start_new_thread(),read,304 Making Use of Python,class MyThread(Threading.Thread),read,304 Making Use of Python,NewThreadObject = MyThread(),read,304 Making Use of Python,class MyThread(threading.Thread),read,305 Making Use of Python,NewThreadObject = MyThread(),read,305 Making Use of Python,class MyThread(threading.Thread),read,306 Making Use of Python,"NewThreadObject = MyThread(func1,(threadnumber,))",read,306 Making Use of Python,class MyThread(threading.Thread),read,307 Making Use of Python,"II thread.start_new_thread(func, args,[,kwargs])",read,313 Making Use of Python,II thread.get_thread(),read,313 Making Use of Python,II threading.currentThread(),read,313 Making Use of Python,data=f.read(500),read,324 Making Use of Python,data=f.read(500),read,324 Making Use of Python,data=f.read(500),read,325 Making Use of Python,data=f.read(500),read,325 Making Use of Python,thread.get_thread(),read,381 Making Use of Python,thread.start_new_thread(),read,381 Making Use of Python,"Two more methods help you read data from files, readline() and readlines()",readline,146 Making Use of Python,The readline() Method. You can use the readline(),readline,146 Making Use of Python,returned string. The code given here displays the functioning of readline(),readline,146 Making Use of Python,fileobj2.readline(),readline,146 Making Use of Python,f.readline(),readline,146 Making Use of Python,"In this case, first the readline()",readline,146 Making Use of Python,name=sys.stdin.readline(),readline,147 Making Use of Python,the same. When you use the stdin.readline(),readline,147 Making Use of Python,II readline(),readline,156 Making Use of Python,stdin.readline(),readline,383 Making Use of Python,"import if",importfunc,39 Making Use of Python,import time,importfunc,119 Making Use of Python,import a,importfunc,125 Making Use of Python,"import statement",importfunc,125 Making Use of Python,import the,importfunc,125 Making Use of Python,import welcome,importfunc,125 Making Use of Python,import fib,importfunc,126 Making Use of Python,import fib,importfunc,127 Making Use of Python,import fib,importfunc,127 Making Use of Python,import casemod,importfunc,128 Making Use of Python,import statements,importfunc,128 Making Use of Python,import statement,importfunc,128 Making Use of Python,import specific,importfunc,128 Making Use of Python,import statement,importfunc,128 Making Use of Python,import the,importfunc,128 Making Use of Python,import the,importfunc,129 Making Use of Python,import only,importfunc,129 Making Use of Python,import all,importfunc,130 Making Use of Python,import all,importfunc,130 Making Use of Python,import all,importfunc,130 Making Use of Python,import all,importfunc,130 Making Use of Python,import a,importfunc,130 Making Use of Python,import mymodule,importfunc,130 Making Use of Python,import mymodule,importfunc,130 Making Use of Python,"import the",importfunc,131 Making Use of Python,import sys,importfunc,131 Making Use of Python,import is,importfunc,131 Making Use of Python,import sys,importfunc,131 Making Use of Python,import the,importfunc,132 Making Use of Python,import fib,importfunc,132 Making Use of Python,import the,importfunc,132 Making Use of Python,import ___builtin__,importfunc,133 Making Use of Python,import fib1,importfunc,134 Making Use of Python,import the,importfunc,136 Making Use of Python,import statement,importfunc,136 Making Use of Python,import time,importfunc,137 Making Use of Python,import isblank_mod,importfunc,139 Making Use of Python,import qty_mod,importfunc,139 Making Use of Python,import creditcard,importfunc,139 Making Use of Python,import age_mod,importfunc,139 Making Use of Python,import statement,importfunc,140 Making Use of Python,"import statement",importfunc,140 Making Use of Python,import statement,importfunc,140 Making Use of Python,import the,importfunc,140 Making Use of Python,import the,importfunc,147 Making Use of Python,import sys,importfunc,147 Making Use of Python,import sys,importfunc,147 Making Use of Python,import os,importfunc,150 Making Use of Python,import os,importfunc,150 Making Use of Python,import os,importfunc,150 Making Use of Python,import os,importfunc,150 Making Use of Python,import os,importfunc,150 Making Use of Python,import os,importfunc,151 Making Use of Python,import os,importfunc,151 Making Use of Python,import os,importfunc,152 Making Use of Python,import os,importfunc,152 Making Use of Python,import os,importfunc,152 Making Use of Python,import os,importfunc,182 Making Use of Python,import a,importfunc,197 Making Use of Python,import statement,importfunc,197 Making Use of Python,import a,importfunc,197 Making Use of Python,import statement,importfunc,197 Making Use of Python,import mod,importfunc,197 Making Use of Python,import the,importfunc,197 Making Use of Python,"import statement",importfunc,198 Making Use of Python,import os,importfunc,209 Making Use of Python,import cgi,importfunc,233 Making Use of Python,import cgi,importfunc,234 Making Use of Python,import cgi,importfunc,235 Making Use of Python,import the,importfunc,256 Making Use of Python,import MySQLdb,importfunc,256 Making Use of Python,import MySQLdb,importfunc,258 Making Use of Python,import cgi,importfunc,259 Making Use of Python,import MySQLdb,importfunc,259 Making Use of Python,import MySQLdb,importfunc,262 Making Use of Python,import them,importfunc,275 Making Use of Python,import thread,importfunc,301 Making Use of Python,import Threading,importfunc,304 Making Use of Python,import time,importfunc,304 Making Use of Python,import Threading,importfunc,304 Making Use of Python,import SocketServer,importfunc,316 Making Use of Python,import urlparse,importfunc,322 Making Use of Python,import urllib,importfunc,325 Making Use of Python,import Cookie,importfunc,331 Making Use of Python,import Cookie,importfunc,332 Making Use of Python,import cgi,importfunc,332 Making Use of Python,import os,importfunc,332 Making Use of Python,import the,importfunc,343 Making Use of Python,import Tkinter,importfunc,343 Making Use of Python,import all,importfunc,343 Making Use of Python,import statement,importfunc,344 Making Use of Python,import all,importfunc,344 Making Use of Python,import statement,importfunc,345 Making Use of Python,import all,importfunc,345 Making Use of Python,import Tkinter,importfunc,345 Making Use of Python,import Tkinter,importfunc,354 Making Use of Python,import tkMessageBox,importfunc,354 Making Use of Python,import it,importfunc,355 Making Use of Python,import tkMessageBox,importfunc,355 Making Use of Python,import tkMessageBox,importfunc,355 Making Use of Python,import tkMessageBox,importfunc,357 Making Use of Python,import tkMessageBox,importfunc,358 Making Use of Python,import tkMessageBox,importfunc,359 Making Use of Python,import the,importfunc,370 Making Use of Python,import pythoncom,importfunc,373 Making Use of Python,from Bank.Account import fixed,importfromsimple,136 Making Use of Python,from Bank.Account.fixed import interest,importfromsimple,136 Making Use of Python,"from time import sleep,ctime,time import thread",importfromsimple,300 Making Use of Python,"from time import sleep, ctime, time import threading",importfromsimple,305 Making Use of Python,"from time import sleep, ctime, time import threading",importfromsimple,306 Making Use of Python,"from time import sleep,time,ctime import threading",importfromsimple,307 Making Use of Python,from time import sleep,importfromsimple,316 Making Use of Python,from SimpleHTTPServer import SimpleHTTPRequestHandler,importfromsimple,320 Making Use of Python,"from www.python.org and copy the Web page to another local file. import urllib",importfromsimple,324 Making Use of Python,from cgi import FieldStorage,importfromsimple,328 Making Use of Python,from random import randint,importfromsimple,332 Making Use of Python,from cgi import FieldStorage,importfromsimple,334 Making Use of Python,from os import environ,importfromsimple,334 Making Use of Python,from cStringIO import StringIO,importfromsimple,334 Making Use of Python,self.a=0,simpleattr,167 Making Use of Python,self.b=0,simpleattr,167 Making Use of Python,self.a=aVal,simpleattr,168 Making Use of Python,self.b=bVal,simpleattr,168 Making Use of Python,self.studname=name,simpleattr,194 Making Use of Python,self.studphno=phno,simpleattr,195 Making Use of Python,self.studage=age,simpleattr,195 Making Use of Python,self.studfee=fee,simpleattr,195 Making Use of Python,self.studschrship=schrship,simpleattr,195 Making Use of Python,self.studname=name,simpleattr,209 Making Use of Python,self.studphno=phno,simpleattr,209 Making Use of Python,self.studage=age,simpleattr,209 Making Use of Python,self.studfee=fee,simpleattr,209 Making Use of Python,self.studschrship=schrship,simpleattr,209 Making Use of Python,self._account={},simpleattr,301 Making Use of Python,self._account[‘1’]=self.account_savings,simpleattr,301 Making Use of Python,self._account[‘2’]=self.account_current,simpleattr,301 Making Use of Python,self._account[‘3’]=self.account_fixed,simpleattr,301 Making Use of Python,self._account[‘4’]=self.account_recrg,simpleattr,301 Making Use of Python,self.func=func,simpleattr,306 Making Use of Python,self.args=args,simpleattr,306 Making Use of Python,self.cookies[tag] = eval(unquote(eachCook[7:])),simpleattr,335 Making Use of Python,self.cookies[tag] = unquote(eachCook[7:]),simpleattr,335 Making Use of Python,self.cookies[‘info’] = self.cookies[‘stid’] = ‘’,simpleattr,335 Making Use of Python,"self.studname,self.courseid,self.assignno,self.f_name \ = self.cookies[‘info’].split(‘$’)",simpleattr,335 Making Use of Python,self.studname = self.f_name = self.courseid=self.assignno=’’,simpleattr,335 Making Use of Python,self.cookies[‘info’] = ‘$’.join\,simpleattr,337 Making Use of Python,self.error = ‘’,simpleattr,337 Making Use of Python,self.studname = val.strip().capitalize(),simpleattr,337 Making Use of Python,self.error = ‘Your name is required. (blank)’,simpleattr,337 Making Use of Python,self.error = ‘Your name is required. (missing)’,simpleattr,337 Making Use of Python,self.courseid = val.strip().capitalize(),simpleattr,337 Making Use of Python,self.error = ‘Course ID is required. (blank)’,simpleattr,337 Making Use of Python,self.error = ‘Course ID is required. (missing)’,simpleattr,337 Making Use of Python,self.assignno = val.strip().capitalize(),simpleattr,337 Making Use of Python,self.error = ‘Assignment Number is required. (blank)’,simpleattr,337 Making Use of Python,self.error = ‘Assignment Number is required. (missing)’,simpleattr,337 Making Use of Python,self.cookies[‘stid’] = unquote(form[‘cookie’].value.strip()),simpleattr,337 Making Use of Python,self.cookies[‘stid’] = ‘’,simpleattr,337 Making Use of Python,self.f_name = File_Upl.filename or ‘’,simpleattr,337 Making Use of Python,self.f_data = File_Upl.file,simpleattr,337 Making Use of Python,self.f_data = StringIO(‘(no data)’),simpleattr,337 Making Use of Python,self.f_data = StringIO(‘(no file)’),simpleattr,338 Making Use of Python,self.f_name = ‘’,simpleattr,338 Making Use of Python,"self.w=Button(top, text =”Say Hello”, command=self.Call_Hello)",simpleattr,353 Making Use of Python,self.e1=Entry(master),simpleattr,359 Making Use of Python,"self.e1.grid(row=0, column=1)",simpleattr,359 Making Use of Python,self.e2=Entry(master),simpleattr,359 Making Use of Python,"self.e2.grid(row=1, column=1)",simpleattr,359 Making Use of Python,self.e3=Entry(master),simpleattr,359 Making Use of Python,"self.e3.grid(row=2, column=1)",simpleattr,359 Making Use of Python,"self.f1=Frame(master, relief= “sunken”, bd=2)",simpleattr,359 Making Use of Python,self.v=IntVar(),simpleattr,359 Making Use of Python,"self.r1=Radiobutton(self.f1, text=”Male”,\",simpleattr,359 Making Use of Python,"self.r2=Radiobutton(self.f1, text=”Female”,\",simpleattr,359 Making Use of Python,"self.f1.grid(row=1, column=4)",simpleattr,359 Making Use of Python,"self.L1 = Listbox(master, width = 25, height = 4)",simpleattr,359 Making Use of Python,"self.L1.grid(row=4, column=1)",simpleattr,359 Making Use of Python,self.f2=Frame(master),simpleattr,359 Making Use of Python,"self.w=Button(self.f2, text =”Prerequisites”, height =1,\",simpleattr,359 Making Use of Python,"self.w1=Button(self.f2, text =”Clear”, height =1, \",simpleattr,359 Making Use of Python,"self.w2=Button(self.f2, text =”Cancel”, height=1, \",simpleattr,360 Making Use of Python,"self.f2.grid(row=4, column=4)",simpleattr,360 Making Use of Python,self.var=IntVar(),simpleattr,360 Making Use of Python,"self.c=Checkbutton(master, text=”Part-Time Course”, variable= self.var, offvalue=0, onvalue=1)",simpleattr,360 Making Use of Python,self.c.grid(row=7),simpleattr,360 Making Use of Python,self.fname = self.e1.get(),simpleattr,360 Making Use of Python,self.lname = self.e2.get(),simpleattr,360 Making Use of Python,self.age = int(self.e3.get()),simpleattr,360 Making Use of Python,self.str1 = “Dear Mr.”,simpleattr,360 Making Use of Python,self.str1 = “Dear Ms.”,simpleattr,360 Making Use of Python,self.name = self.str1 + “ “ + self.fname + “ “ + self.lname,simpleattr,360 Making Use of Python,self.varl1 = self.L1.get(self.L1.curselection()),simpleattr,360 Making Use of Python,"self.prereq = “The prereq for this course is Quality Management (Int).”",simpleattr,360 Making Use of Python,self.flag = 1,simpleattr,360 Making Use of Python,self.prereq = \,simpleattr,360 Making Use of Python,self.flag = 1,simpleattr,360 Making Use of Python,self.prereq = \,simpleattr,360 Making Use of Python,self.flag = 0,simpleattr,360 Making Use of Python,self.prereq = \,simpleattr,360 Making Use of Python,self.flag = 0,simpleattr,360 Making Use of Python,self.str2 = “\nThis course is not available part time.”,simpleattr,361 Making Use of Python,self.str2 = “\nThis course is available part time.”,simpleattr,361 Making Use of Python,self.str2 = “”,simpleattr,361 Making Use of Python,self.result = self.prereq + self.str2,simpleattr,361 Making Use of Python,x+=y,assignIncrement,26 Making Use of Python,x+=y*2,assignIncrement,26 Making Use of Python,Notice that the assignment x+=y is treated as x=x+y. After performing the first,assignIncrement,26 Making Use of Python,"def course_fee(fee, discount=0.15):",funcdefault,104 Making Use of Python,"def course_fee(discount=0.15,fee):",funcdefault,104 Making Use of Python,"def shape(type,radius=3,height=4,length=5):",funcdefault,104 Making Use of Python,"def prod2(a,b=6) :",funcdefault,111 Making Use of Python,"def fibonacci(a,num1=0,num2=1):",funcdefault,125 Making Use of Python,"def fibonacci(a,num1=0,num2=1):",funcdefault,134 Making Use of Python,def getCookie(initialvalues={}):,funcdefault,332 Making Use of Python,range(),rangefunc,69 Making Use of Python,range(),rangefunc,69 Making Use of Python,range(),rangefunc,69 Making Use of Python,range(7),rangefunc,69 Making Use of Python,range(),rangefunc,69 Making Use of Python,range(7),rangefunc,69 Making Use of Python,range(),rangefunc,69 Making Use of Python,"range(3,7)",rangefunc,69 Making Use of Python,range(),rangefunc,69 Making Use of Python,"range(-10,-100,-40)",rangefunc,69 Making Use of Python,range(),rangefunc,74 Making Use of Python,range(),rangefunc,381 Making Use of Python,def functionname(parameters):,simplefunc,101 Making Use of Python,def fnsquare(num):,simplefunc,101 Making Use of Python,def printx(x):,simplefunc,103 Making Use of Python,def square(sum):,simplefunc,108 Making Use of Python,def func():,simplefunc,109 Making Use of Python,def ruf():,simplefunc,110 Making Use of Python,def bee(arg):,simplefunc,110 Making Use of Python,def func():,simplefunc,111 Making Use of Python,def leap(n):,simplefunc,114 Making Use of Python,def square(n):,simplefunc,117 Making Use of Python,def ruf():,simplefunc,118 Making Use of Python,def ruf():,simplefunc,118 Making Use of Python,def bee():,simplefunc,118 Making Use of Python,def ruf():,simplefunc,119 Making Use of Python,def print_func(a):,simplefunc,125 Making Use of Python,def case(inp):,simplefunc,128 Making Use of Python,def bee():,simplefunc,129 Making Use of Python,def isblank(var):,simplefunc,137 Making Use of Python,def age_cal(dob):,simplefunc,138 Making Use of Python,def qty_func(qtystr):,simplefunc,138 Making Use of Python,def my_method_example(self):,simplefunc,166 Making Use of Python,def lib_method(self):,simplefunc,169 Making Use of Python,def clear_screen_method(self):,simplefunc,169 Making Use of Python,def bks_method(self):,simplefunc,169 Making Use of Python,def bks_display(self):,simplefunc,169 Making Use of Python,def sws_method(self):,simplefunc,170 Making Use of Python,def sws_display(self):,simplefunc,170 Making Use of Python,def my_base_class_method(self):,simplefunc,171 Making Use of Python,def my_subclass_method(self):,simplefunc,171 Making Use of Python,def my_subclass_method(self):,simplefunc,173 Making Use of Python,def displaydetails(self):,simplefunc,195 Making Use of Python,def int_convert(var):,simplefunc,202 Making Use of Python,def int_convert(var):,simplefunc,204 Making Use of Python,def int_convert(var):,simplefunc,205 Making Use of Python,def displaydetails(self):,simplefunc,209 Making Use of Python,def show_form():,simplefunc,236 Making Use of Python,def func1():,simplefunc,297 Making Use of Python,def func2():,simplefunc,297 Making Use of Python,def func1():,simplefunc,300 Making Use of Python,def func2():,simplefunc,300 Making Use of Python,def run(self):,simplefunc,304 Making Use of Python,def run(self):,simplefunc,304 Making Use of Python,def run(self):,simplefunc,305 Making Use of Python,def run(self):,simplefunc,306 Making Use of Python,def run(self):,simplefunc,307 Making Use of Python,def handle(self):,simplefunc,316 Making Use of Python,def do_GET(self):,simplefunc,318 Making Use of Python,def do_GET(self):,simplefunc,320 Making Use of Python,def displayError(self):,simplefunc,336 Making Use of Python,def setFBCookies(self):,simplefunc,336 Making Use of Python,def doResults(self):,simplefunc,336 Making Use of Python,def hello():,simplefunc,354 Making Use of Python,def Eval(self):,simplefunc,360 Making Use of Python,def Close(self):,simplefunc,361 Making Use of Python,def Clear(self):,simplefunc,361 Making Use of Python,return an error,return,8 Making Use of Python,return the,return,16 Making Use of Python,return the complex conjugate of the object.,return,22 Making Use of Python,return 51.,return,26 Making Use of Python,"return try",return,39 Making Use of Python,"return Escape",return,54 Making Use of Python,return the memory,return,55 Making Use of Python,"return the highest and lowest characters, respectively.",return,57 Making Use of Python,return a corresponding hexadecimal or octal equivalent as a string.,return,59 Making Use of Python,return the tuples of the key:value pairs in,return,71 Making Use of Python,return the memory address of an object.,return,73 Making Use of Python,"return the last evaluated value. For example,",return,78 Making Use of Python,"return false, the output will be 'Input",return,86 Making Use of Python,return either a true or a false value. The general,return,87 Making Use of Python,return an error:,return,102 Making Use of Python,return Statement,return,108 Making Use of Python,return a value by using the return statement. Returning a,return,108 Making Use of Python,return statement.,return,108 Making Use of Python,return num1+num2,return,108 Making Use of Python,return value can be accessed in the following way:,return,108 Making Use of Python,return sum*sum,return,108 Making Use of Python,return num1+num2,return,108 Making Use of Python,return sum*sum,return,108 Making Use of Python,return value in sum. The,return,109 Making Use of Python,return value of the square function. The main_func then returns the value of sq.,return,109 Making Use of Python,return only one value or object from a function. How do you,return,109 Making Use of Python,return multiple values by using a return statement? You can do this by using a tuple,return,109 Making Use of Python,"return (‘fff’,’city’,8023)",return,109 Making Use of Python,return ‘Hi’,return,111 Making Use of Python,return ‘Hi’,return,111 Making Use of Python,return a*b,return,111 Making Use of Python,return a*b,return,111 Making Use of Python,return tup,return,111 Making Use of Python,"return [tup,dt]",return,111 Making Use of Python,"return multiple values in the form of a list, a",return,112 Making Use of Python,return value is stored in a list.,return,112 Making Use of Python,"return variables are enclosed within square brackets, which",return,112 Making Use of Python,return values of both tup and dt will be stored in a list. As in the other,return,112 Making Use of Python,return n%4==0,return,114 Making Use of Python,return values. The syntax of the map() function is,return,115 Making Use of Python,return values of the function. The first value in each tuple is the addition of,return,117 Making Use of Python,return value of the,return,117 Making Use of Python,return n*n,return,117 Making Use of Python,return global_var+local_var,return,118 Making Use of Python,return var,return,119 Making Use of Python,return 1,return,120 Making Use of Python,return 0,return,120 Making Use of Python,return str(age),return,120 Making Use of Python,return a value by using the return statement.,return,122 Making Use of Python,return ‘Uppercase’,return,128 Making Use of Python,return ‘Lowercase’,return,128 Making Use of Python,return ‘Input character > z’,return,128 Making Use of Python,return ‘Input character > z but less than a’,return,128 Making Use of Python,return ‘Input character less than A’,return,128 Making Use of Python,return the names of functions and variables that are,return,133 Making Use of Python,return the names in the,return,133 Making Use of Python,return all the names that can be,return,133 Making Use of Python,return all the names that can be accessed globally from that function. The return,return,133 Making Use of Python,return the same dictionary in the main,return,134 Making Use of Python,return 1,return,137 Making Use of Python,return 1,return,138 Making Use of Python,return 0,return,138 Making Use of Python,return 0,return,138 Making Use of Python,return 0,return,138 Making Use of Python,return str(age),return,138 Making Use of Python,return the names in the,return,140 Making Use of Python,"return 1 and 0, and the isfile() methods",return,154 Making Use of Python,return 0 and 1 because /home is a directory and testfile is a file. You have learned,return,154 Making Use of Python,return ‘An example of method reference’,return,166 Making Use of Python,return any object other than the class object because this might lead to a,return,167 Making Use of Python,return ‘Base class method’,return,171 Making Use of Python,return ‘Subclass method’,return,171 Making Use of Python,return ‘Method of My_Class_A’,return,173 Making Use of Python,return ‘Method of My_Class_B’,return,173 Making Use of Python,return 1.,return,178 Making Use of Python,"return LibCode,Title,Price",return,182 Making Use of Python,return an error after the connection is closed.,return,257 Making Use of Python,"return value is 1 if the lock is acquired successfully, 0 if not.",return,300 Making Use of Python,"return the name of the file. When the CGI script is accessed, the screen shown in Figure",return,329 Making Use of Python,return C,return,332 Making Use of Python,"return self.cookies = {}",return,337 Making Use of Python,"return if form.has_key(‘Stud_Name’):",return,337 Making Use of Python,return the name,return,340 Making Use of Python,"return #Check for Gender",return,360 Making Use of Python,"return #Check for Prereq Course",return,360 Making Use of Python,return l-counter,return,373 Making Use of Python,return counter+1,return,373 Making Use of Python,"return statement, 108–9",return,381 Making Use of Python,"return statement, 108–9",return,386 Making Use of Python,"return statement, 108–9",return,388 Making Use of Python,if condition:,simpleif,84 Making Use of Python,"if x>0: ... print ‘Hello’",simpleif,84 Making Use of Python,if condition:,simpleif,84 Making Use of Python,if num%2==0:,simpleif,85 Making Use of Python,if construct is this:,simpleif,85 Making Use of Python,if condition1:,simpleif,85 Making Use of Python,if condition2:,simpleif,85 Making Use of Python,if condition:,simpleif,85 Making Use of Python,"if len(i)>6: ... break",simpleif,92 Making Use of Python,if a==1:,simpleif,93 Making Use of Python,if percent>=80:,simpleif,95 Making Use of Python,if choice in choices:,simpleif,95 Making Use of Python,if ch in op:,simpleif,113 Making Use of Python,if month<cur_month or (month==cur_month and day<cur_day):,simpleif,120 Making Use of Python,if statement as follows:,simpleif,132 Making Use of Python,"if __name__=’__main__’: true_suite",simpleif,132 Making Use of Python,if len(var)==0:,simpleif,137 Making Use of Python,if len(dob)<>10:,simpleif,138 Making Use of Python,if m<cur_month or (m==cur_month and d<cur_day):,simpleif,138 Making Use of Python,"if c in range(0,47) or c in range(58,255):",simpleif,139 Making Use of Python,if return_age<>0:,simpleif,139 Making Use of Python,if isblank_mod.isblank(qty_order)==1:,simpleif,139 Making Use of Python,if isblank_mod.isblank(credit)==1:,simpleif,139 Making Use of Python,if MenuChoice ==’1’:,simpleif,188 Making Use of Python,if MenuChoice ==’2’:,simpleif,188 Making Use of Python,if MenuChoice ==’3’:,simpleif,188 Making Use of Python,if MenuChoice ==’4’:,simpleif,188 Making Use of Python,if MenuChoice ==’5’:,simpleif,188 Making Use of Python,if MenuChoice ==’6’:,simpleif,189 Making Use of Python,if an argument other than a string is passed as follows:,simpleif,202 Making Use of Python,if op==’+’:,simpleif,207 Making Use of Python,if fs.has_key(‘login’) and (fs[‘login’].value!=””):,simpleif,234 Making Use of Python,if fs.has_key(‘password’):,simpleif,234 Making Use of Python,if fpass==passd:,simpleif,235 Making Use of Python,if not fs:,simpleif,236 Making Use of Python,if fs.has_key(‘login’) and (fs[‘login’].value!=””):,simpleif,236 Making Use of Python,if fs.has_key(‘password’):,simpleif,236 Making Use of Python,if fpass==passd:,simpleif,236 Making Use of Python,if ServerStr.find(‘~~’)!=-1:,simpleif,308 Making Use of Python,if not DataStr:,simpleif,309 Making Use of Python,if self.path==”/”:,simpleif,318 Making Use of Python,if not form:,simpleif,329 Making Use of Python,if form.has_key(“file_name”):,simpleif,329 Making Use of Python,if fileupload.file:,simpleif,329 Making Use of Python,if os.environ.has_key(‘HTTP_COOKIE’):,simpleif,332 Making Use of Python,if not C.has_key(eachkey):,simpleif,332 Making Use of Python,if C.has_key(‘studid’):,simpleif,332 Making Use of Python,if __name__==’__main__’:,simpleif,332 Making Use of Python,if environ.has_key(‘HTTP_COOKIE’):,simpleif,335 Making Use of Python,if len(eachCook) > 5 and eachCook[:2] == ‘FB’:,simpleif,335 Making Use of Python,if self.cookies[‘stid’] != ‘’:,simpleif,335 Making Use of Python,if not self.cookies.has_key(‘stid’) or self.cookies[‘stid’] == ‘’:,simpleif,335 Making Use of Python,if filedata == ‘’:,simpleif,336 Making Use of Python,if not self.cookies.has_key(‘stid’) or self.cookies[‘stid’] == ‘’:,simpleif,337 Making Use of Python,if form.keys() == []:,simpleif,337 Making Use of Python,if self.studname == ‘’:,simpleif,337 Making Use of Python,if form.has_key(‘Course_ID’):,simpleif,337 Making Use of Python,if self.courseid == ‘’:,simpleif,337 Making Use of Python,if form.has_key(‘Assign_No’):,simpleif,337 Making Use of Python,if self.assignno == ‘’:,simpleif,337 Making Use of Python,if form.has_key(‘cookie’):,simpleif,337 Making Use of Python,if form.has_key(‘File_Upl’):,simpleif,337 Making Use of Python,if File_Upl.file:,simpleif,337 Making Use of Python,if not self.error:,simpleif,338 Making Use of Python,if self.age < 21:,simpleif,360 Making Use of Python,if self.v.get()==1:,simpleif,360 Making Use of Python,if self.varl1 == “Quality Management (Adv.)”:,simpleif,360 Making Use of Python,if self.varl1 == “Financial Management (Adv.)”:,simpleif,360 Making Use of Python,if self.varl1 == “Project Management (Adv.)”:,simpleif,360 Making Use of Python,if self.var.get() == 1 and self.flag == 0:,simpleif,361 Making Use of Python,if __name__==’__main__’:,simpleif,373 Making Use of Python,print(),printfunc,147 Making Use of Python,print(),printfunc,147 Making Use of Python,print(‘All displayed’),printfunc,195 Making Use of Python,print(‘All displayed’),printfunc,209 Making Use of Python,print(“Hello World”),printfunc,304 Making Use of Python,print(“Hello World”),printfunc,304 Making Use of Python,print(),printfunc,383 Making Use of Python,"a,b,c)=(1,2,’learn types’)",simpleTuple,19 Making Use of Python,"x,y)=(y,x)",simpleTuple,19 Making Use of Python,"tup=(123,’abc’,345)",simpleTuple,35 Making Use of Python,"tup=(123,’abc’,345)",simpleTuple,35 Making Use of Python,"tup1=(‘ggg’,1562)",simpleTuple,35 Making Use of Python,"tup=(‘a’,’b’)",simpleTuple,36 Making Use of Python,"tuple=(567,’ddd’,[123,3214,’abc’])",simpleTuple,36 Making Use of Python,"tup=(‘welcome’,)",simpleTuple,36 Making Use of Python,"tup=(a,b)",simpleTuple,61 Making Use of Python,"tup=(‘rep’,’tree’)",simpleTuple,61 Making Use of Python,"tup1=(123,’abc’,345)",simpleTuple,67 Making Use of Python,"s= lambda tup=(‘hgh’,23)",simpleTuple,112 Making Use of Python,"tup=(‘sdsd’,23)",simpleTuple,113 Making Use of Python,"op=(‘+’,’-’,’*’)",simpleTuple,113 Making Use of Python,"tup=(‘111’,’abc’,64)",simpleTuple,133 Making Use of Python,"6 ServerAddress = (Hostname, PortNumber)",simpleTuple,275 Making Use of Python,"6 ServerAddress = (Hostname, PortNumber)",simpleTuple,278 Making Use of Python,"6 ServerAddress=(Hostname, PortNumber)",simpleTuple,281 Making Use of Python,"6 ServerAddress=(Hostname, PortNumber)",simpleTuple,283 Making Use of Python,"ServerAddress = (Hostname, PortNumber)",simpleTuple,286 Making Use of Python,"ServerAddress = (Hostname, PortNumber)",simpleTuple,288 Making Use of Python,"ServerAddress = (Hostname, PortNumber)",simpleTuple,307 Making Use of Python,"urltup=(‘http’, ‘www.python.org’, ‘/doc/lib/lib.html’)",simpleTuple,323 Making Use of Python,"xl.Range(“A3:D3”).Value=(‘How’,’are’,’you!’)",simpleTuple,372 Making Use of Python,"listvar=[‘abcd’,123,2.23,’efgh’]",simpleList,33 Making Use of Python,"listvar[1]=[888,’pqr’]",simpleList,33 Making Use of Python,listvar[0:2]=[],simpleList,34 Making Use of Python,"listvar[1:1]=[1234,’ddd’]",simpleList,34 Making Use of Python,"listvar[1:2]=[‘007’,’xyz’]",simpleList,34 Making Use of Python,"stud_name=[‘Ken’,’William’,’Catherine’,’Steve’,’Mark’]",simpleList,42 Making Use of Python,"stud_name=[‘Ken’,’William’,’Catherine’,’Steve’,’Mark’]",simpleList,43 Making Use of Python,"a=[31,’ddd’]",simpleList,56 Making Use of Python,"list=[23,23.1,23L,234e-1]",simpleList,57 Making Use of Python,"ls=[43,12.23]",simpleList,61 Making Use of Python,"ls=[astr,cstr]",simpleList,61 Making Use of Python,"listvar=[‘abcd’,123,2.23,’efgh’]",simpleList,66 Making Use of Python,"listvar=[‘abcd’,123,2.23,’efgh’]",simpleList,67 Making Use of Python,"stack=[‘a’,’b’,’c’,’d’]",simpleList,68 Making Use of Python,"queue=[‘a’,’b’,’c’,’d’]",simpleList,69 Making Use of Python,"names=[‘Laurie’,’James’,’Mark’,’John’,’William’]",simpleList,91 Making Use of Python,"names=[‘Laurie’,’James’,’Mark’,’John’,’William’]",simpleList,92 Making Use of Python,"choices=[‘y’,’Y’,’yes’,’Yes’,’YES’]",simpleList,95 Making Use of Python,list_yr=[],simpleList,114 Making Use of Python,list_yr=[],simpleList,115 Making Use of Python,"seq1=[4,7,3]",simpleList,116 Making Use of Python,"seq2=[2,6,8]",simpleList,116 Making Use of Python,"4+2,7+6,3+8] =[6,13,11]",simpleList,117 Making Use of Python,seq=[],simpleList,117 Making Use of Python,"list=[‘one’,’two’,’three’]",simpleList,145 Making Use of Python,"heading=[‘Code’,’Title’,’Duration’,’Fee’]",simpleList,154 Making Use of Python,"details=[course_code,course_title,course_dur,course_fee]",simpleList,155 Making Use of Python,studobjects=[],simpleList,195 Making Use of Python,Mylist=[‘abc’],simpleList,197 Making Use of Python,studobjects=[],simpleList,209 Making Use of Python,"h, —host=[Hostname]",simpleList,245 Making Use of Python,"P, —port=[portno]",simpleList,245 Making Use of Python,"u, —user=[user]",simpleList,245 Making Use of Python,"D, —database=[databasename]",simpleList,247 Making Use of Python,"h, —host=[Hostname]",simpleList,247 Making Use of Python,"P, —port=[portno]",simpleList,247 Making Use of Python,locks=[],simpleList,302 Making Use of Python,threadarray = [],simpleList,305 Making Use of Python,threadarray = [],simpleList,306 Making Use of Python,ServerData=[],simpleList,307 Making Use of Python,add=[],simpleList,307 Making Use of Python,"_public_methods_=[‘letters’,’words’]",simpleList,373 Making Use of Python,"_public_methods_=[‘letters’,’words’]",simpleList,373 Making Use of Python,for iterating_var in sequence:,forsimple,91 Making Use of Python,for x in names:,forsimple,91 Making Use of Python,for i in range(len(names)):,forsimple,92 Making Use of Python,"for num in range(10,20):",forsimple,93 Making Use of Python,"for i in range(2,num):",forsimple,93 Making Use of Python,for the problem statement in the beginning of the chapter is as follows:,forsimple,94 Making Use of Python,for clear in range(35):,forsimple,95 Making Use of Python,for y in range(10):,forsimple,95 Making Use of Python,for clear in range(40):,forsimple,95 Making Use of Python,for each in vartuple:,forsimple,106 Making Use of Python,for each in vardict:,forsimple,107 Making Use of Python,for eachk in vark:,forsimple,107 Making Use of Python,for eachnk in varnk:,forsimple,107 Making Use of Python,for this purpose in main_mod.py is as follows:,forsimple,139 Making Use of Python,for x in list:,forsimple,145 Making Use of Python,for the problem statement in the beginning of the chapter is as follows:,forsimple,154 Making Use of Python,for x in details:,forsimple,155 Making Use of Python,for x in heading:,forsimple,155 Making Use of Python,for i in range(seconds):,forsimple,302 Making Use of Python,for i in range(4):,forsimple,302 Making Use of Python,for mythread in threadarray:,forsimple,305 Making Use of Python,for mythread in threadarray:,forsimple,306 Making Use of Python,for i in range(len(ServerData)):,forsimple,308 Making Use of Python,for i in range(len(ServerList)):,forsimple,309 Making Use of Python,"for key, value in f.headers.items():",forsimple,325 Making Use of Python,for eachkey in initialvalues.keys():,forsimple,332 Making Use of Python,for eachCook in environ[‘HTTP_COOKIE’].split(‘;’):,forsimple,335 Making Use of Python,for eachCook in self.cookies.keys():,forsimple,336 Making Use of Python,for COM in Python is provided by two packages:,forsimple,370 Making Use of Python,a=a+3,assignwithSum,18 Making Use of Python,var=var+1,assignwithSum,20 Making Use of Python,x = y + z,assignwithSum,22 Making Use of Python,x = y + z,assignwithSum,23 Making Use of Python,x=7+3*6,assignwithSum,23 Making Use of Python,"expression x = 7 + 3 * 6, the part 3 * 6 is evaluated first and the result 18 is added",assignwithSum,24 Making Use of Python,z = 7 + ( 5 * (8 / 2) + (4 + 6)),assignwithSum,24 Making Use of Python,x = x + y.,assignwithSum,25 Making Use of Python,tupmain=tup+tup1,assignwithSum,35 Making Use of Python,"tup=tup+(‘c’,’d’)",assignwithSum,36 Making Use of Python,a=9+4j,assignwithSum,55 Making Use of Python,a=9+4j,assignwithSum,55 Making Use of Python,a=a+76,assignwithSum,55 Making Use of Python,num2=num1+num2,assignwithSum,88 Making Use of Python,num2 = num1+num2,assignwithSum,89 Making Use of Python,j=j+1,assignwithSum,95 Making Use of Python,tot_score=tot_score+ int(score) #Calculates total score,assignwithSum,95 Making Use of Python,i=i+1,assignwithSum,95 Making Use of Python,"ch=raw_input(‘Enter an operator, +/-/*: ‘)",assignwithSum,113 Making Use of Python,func=a+b,assignwithSum,116 Making Use of Python,bee=lambda b: a+b,assignwithSum,119 Making Use of Python,id=f+str(day)+str(month) #and evaluates second value,assignwithSum,119 Making Use of Python,age=age+1,assignwithSum,120 Making Use of Python,first=fname+lname[0] #Evaluates the first value,assignwithSum,121 Making Use of Python,third=lname[0]+fname+str(year)[2:],assignwithSum,121 Making Use of Python,fourth=fname[0]+lname+age_func(),assignwithSum,121 Making Use of Python,num2=num1+num2,assignwithSum,126 Making Use of Python,num2=num1+num2,assignwithSum,134 Making Use of Python,age=age+1,assignwithSum,138 Making Use of Python,i=i+1,assignwithSum,139 Making Use of Python,list[i]=x+’\n’,assignwithSum,145 Making Use of Python,i=i+1,assignwithSum,145 Making Use of Python,details[i]=x+’\t’,assignwithSum,155 Making Use of Python,i=i+1,assignwithSum,155 Making Use of Python,heading[j]=x+’\t’,assignwithSum,155 Making Use of Python,j=j+1,assignwithSum,155 Making Use of Python,My_Class.a=My_Class.a + My_Class.b,assignwithSum,164 Making Use of Python,ctr=ctr+1,assignwithSum,195 Making Use of Python,i=i+1,assignwithSum,263 Making Use of Python,i=i+1,assignwithSum,297 Making Use of Python,j=j+1,assignwithSum,297 Making Use of Python,i=i+1,assignwithSum,300 Making Use of Python,j=j+1,assignwithSum,300 Making Use of Python,number=number+1,assignwithSum,305 Making Use of Python,threadnumber=threadnumber+1,assignwithSum,305 Making Use of Python,number=number+1,assignwithSum,306 Making Use of Python,threadnumber=threadnumber+1,assignwithSum,306 Making Use of Python,ClientData=ClientData+’~~’,assignwithSum,308 Making Use of Python,cookie[‘counter’]=int(cookie[‘counter’].value)+1,assignwithSum,332 Making Use of Python,filedata = filedata + \,assignwithSum,336 Making Use of Python,directory containing the Python executable to the set path or PATH= directive.,simpleAssign,7 Making Use of Python,name=raw_input(‘Enter your name: ‘),simpleAssign,14 Making Use of Python,to assign values to variables. The operand to the left of the = operator is the name of the,simpleAssign,18 Making Use of Python,"variable, and the operand to the right of the = operator is the value stored in the vari-",simpleAssign,18 Making Use of Python,price=100,simpleAssign,18 Making Use of Python,discount=25,simpleAssign,18 Making Use of Python,a=2,simpleAssign,18 Making Use of Python,a=b=c=1,simpleAssign,18 Making Use of Python,"a,b,c=1,2,’learn types’",simpleAssign,19 Making Use of Python,"x,y)=10,20",simpleAssign,19 Making Use of Python,var=1,simpleAssign,20 Making Use of Python,var=2.76,simpleAssign,20 Making Use of Python,floatvar=6.4,simpleAssign,20 Making Use of Python,var=floatvar,simpleAssign,20 Making Use of Python,varlong=812386l,simpleAssign,21 Making Use of Python,complexobj=23.87-1.23j,simpleAssign,22 Making Use of Python,x = y - z,simpleAssign,23 Making Use of Python,x = y ** z,simpleAssign,23 Making Use of Python,x = y * z,simpleAssign,23 Making Use of Python,x = y / z,simpleAssign,23 Making Use of Python,x = y % z,simpleAssign,23 Making Use of Python,y=100/4*5,simpleAssign,23 Making Use of Python,"to 7. In the expression y = 100 / 4 * 5, the part 100/4 is evaluated first because",simpleAssign,24 Making Use of Python,y = 100 / (4 * 5),simpleAssign,24 Making Use of Python,You have learned how values are assigned to variables by using the = operator. Let’s,simpleAssign,25 Making Use of Python,x = y,simpleAssign,25 Making Use of Python,x + = y,simpleAssign,25 Making Use of Python,x - = y,simpleAssign,25 Making Use of Python,x * = y,simpleAssign,25 Making Use of Python,x = x - y.,simpleAssign,25 Making Use of Python,x = x * y.,simpleAssign,25 Making Use of Python,x / = y,simpleAssign,25 Making Use of Python,x = x / y.,simpleAssign,25 Making Use of Python,x % = y,simpleAssign,26 Making Use of Python,x = x % y.,simpleAssign,26 Making Use of Python,x <operator>= y,simpleAssign,26 Making Use of Python,x = x <operator> y,simpleAssign,26 Making Use of Python,x=15,simpleAssign,26 Making Use of Python,y=12,simpleAssign,26 Making Use of Python,"operation, the value of x becomes 27. Then, in the second operation, 12*2=24 is",simpleAssign,26 Making Use of Python,newstr=strvar*4,simpleAssign,28 Making Use of Python,strval*=4,simpleAssign,28 Making Use of Python,score1=70,simpleAssign,31 Making Use of Python,score2=85,simpleAssign,31 Making Use of Python,listvar[3]=8-4j,simpleAssign,33 Making Use of Python,listvar[:0]=listvar,simpleAssign,34 Making Use of Python,"anothertup=tup,(‘a’,’b’,’c’)",simpleAssign,35 Making Use of Python,atup[1]=999,simpleAssign,35 Making Use of Python,tuple[2][1]=5678,simpleAssign,36 Making Use of Python,ruf=bee,simpleAssign,41 Making Use of Python,ruf=beast,simpleAssign,41 Making Use of Python,a variable by using the = sign.,simpleAssign,45 Making Use of Python,string=raw_input(‘Enter a string ‘),simpleAssign,49 Making Use of Python,ls=raw_input(‘Enter a list ‘),simpleAssign,49 Making Use of Python,inp=input(‘Enter a list’),simpleAssign,50 Making Use of Python,s=r’Hello\n’,simpleAssign,54 Making Use of Python,astr=repr(76),simpleAssign,60 Making Use of Python,bstr=repr(ls),simpleAssign,61 Making Use of Python,ls_str=repr(ls),simpleAssign,61 Making Use of Python,b=78,simpleAssign,61 Making Use of Python,name=steve’,simpleAssign,66 Making Use of Python,tupvar=tuple(listvar),simpleAssign,66 Making Use of Python,list1=list(tup1),simpleAssign,67 Making Use of Python,course_code=raw_input(‘Enter course code:’),simpleAssign,71 Making Use of Python,course_title=raw_input(‘Enter course title:’),simpleAssign,71 Making Use of Python,course_dur=input(‘Enter course duration (in hrs.):’),simpleAssign,71 Making Use of Python,course_fee=float(input(‘Enter course fee (in $):’)),simpleAssign,71 Making Use of Python,start_date=raw_input(‘Enter course start date (mm/dd/yy):’),simpleAssign,71 Making Use of Python,end_date=raw_input(‘Enter course end date (mm/dd/yy):’),simpleAssign,71 Making Use of Python,no_of_seats=input(‘Enter no. of seats:’),simpleAssign,71 Making Use of Python,ls=end_date.split(‘/’),simpleAssign,71 Making Use of Python,x==y,simpleAssign,77 Making Use of Python,x!=y,simpleAssign,77 Making Use of Python,x>=y,simpleAssign,77 Making Use of Python,x<=y,simpleAssign,77 Making Use of Python,a=45,simpleAssign,77 Making Use of Python,b=15*3,simpleAssign,77 Making Use of Python,a==b,simpleAssign,77 Making Use of Python,a<=b,simpleAssign,77 Making Use of Python,a==b>50,simpleAssign,77 Making Use of Python,"x,y=45,65",simpleAssign,78 Making Use of Python,ps=p,simpleAssign,82 Making Use of Python,g=123,simpleAssign,82 Making Use of Python,f=123,simpleAssign,82 Making Use of Python,x=10,simpleAssign,84 Making Use of Python,in_chr=raw_input(“Enter a character:”),simpleAssign,85 Making Use of Python,inp=raw_input(‘Enter a character’),simpleAssign,86 Making Use of Python,n=input(‘Enter a number greater than 1 ‘),simpleAssign,88 Making Use of Python,num1=0,simpleAssign,88 Making Use of Python,num2=1,simpleAssign,88 Making Use of Python,num1=num2-num1,simpleAssign,88 Making Use of Python,i=1,simpleAssign,88 Making Use of Python,reg_no=raw_input(“Please enter your reg number “),simpleAssign,88 Making Use of Python,tot_score=score(reg_no),simpleAssign,88 Making Use of Python,i=1,simpleAssign,89 Making Use of Python,a=input(‘Enter an integer ‘),simpleAssign,89 Making Use of Python,num1=0,simpleAssign,89 Making Use of Python,num2=1,simpleAssign,89 Making Use of Python,num1 = num2 - num1,simpleAssign,89 Making Use of Python,if num2==89,simpleAssign,89 Making Use of Python,num=0,simpleAssign,90 Making Use of Python,num=int(raw_input(“Enter a number: “)),simpleAssign,90 Making Use of Python,reply=raw_input(“Do you want to enter another y/n “),simpleAssign,90 Making Use of Python,valid=0,simpleAssign,92 Making Use of Python,i=3,simpleAssign,92 Making Use of Python,if num%i==0: #to determine the first factor,simpleAssign,93 Making Use of Python,j=num/i #to calculate the second factor,simpleAssign,93 Making Use of Python,a=1,simpleAssign,93 Making Use of Python,i=1,simpleAssign,94 Making Use of Python,percent=tot_score/4,simpleAssign,95 Making Use of Python,elif percent>=60:,simpleAssign,95 Making Use of Python,elif percent>=40:,simpleAssign,95 Making Use of Python,choice=raw_input(“Do you want to enter details for \,simpleAssign,95 Making Use of Python,x=0,simpleAssign,101 Making Use of Python,x=num*num,simpleAssign,101 Making Use of Python,printx(x=32),simpleAssign,103 Making Use of Python,printx(x=y),simpleAssign,103 Making Use of Python,"stud_fn(score=86,reg_no=’S001’, name=’Laura’)",simpleAssign,103 Making Use of Python,"stud_fn(score=86,reg_no=’S001’)",simpleAssign,103 Making Use of Python,"shape(radius=3,’sphere’)",simpleAssign,105 Making Use of Python,shape(perimeter=30),simpleAssign,105 Making Use of Python,"shape(radius=12,type=’sphere’)",simpleAssign,105 Making Use of Python,"tuple_func(‘city’,’state’, num=20.2,count=30)",simpleAssign,107 Making Use of Python,another keyword argument count=30,simpleAssign,107 Making Use of Python,another keyword argument num=20.2,simpleAssign,107 Making Use of Python,"var_args_func(‘city’,30,’USA’,’2000’,reg=30,que=42)",simpleAssign,108 Making Use of Python,another non-keyword argument que=42,simpleAssign,108 Making Use of Python,another non-keyword argument reg=30,simpleAssign,108 Making Use of Python,"sum=add(14,24)",simpleAssign,108 Making Use of Python,"sum=add(a,b) #Return value of add stored in sum",simpleAssign,108 Making Use of Python,sq=square(sum),simpleAssign,108 Making Use of Python,"output=main_func(14,24)",simpleAssign,109 Making Use of Python,tup=func(),simpleAssign,109 Making Use of Python,"a,b,c)=func()",simpleAssign,109 Making Use of Python,"p,q,r=func()",simpleAssign,109 Making Use of Python,bee=ruf,simpleAssign,110 Making Use of Python,"x= lambda a,b: a*b",simpleAssign,111 Making Use of Python,"x=lambda a,b=6:a*b",simpleAssign,112 Making Use of Python,s= lambda *tup:tup,simpleAssign,112 Making Use of Python,"s((56,23),f=656,g=23,h=23)",simpleAssign,112 Making Use of Python,"ans=apply(ops[ch],nums)",simpleAssign,113 Making Use of Python,8*5=40,simpleAssign,113 Making Use of Python,ch=raw_input(‘Do you want to enter a year? ‘),simpleAssign,114 Making Use of Python,"leap_yrs=filter(leap,list_yr)",simpleAssign,114 Making Use of Python,ch=raw_input(‘Do you want to enter a year? ‘),simpleAssign,115 Making Use of Python,"leap_yrs=filter(lambda n:n%4==0,list_yr)",simpleAssign,115 Making Use of Python,ch=raw_input(‘Do you want to enter a number? ‘),simpleAssign,117 Making Use of Python,global_var=12,simpleAssign,118 Making Use of Python,local_var=34,simpleAssign,118 Making Use of Python,var=raw_input(“Enter a value: “),simpleAssign,119 Making Use of Python,age=cur_year-year-1,simpleAssign,120 Making Use of Python,t=time.localtime(time.time()) #Determines the current time in a list,simpleAssign,120 Making Use of Python,cur_year=t[0] #Extract the current year from the list,simpleAssign,120 Making Use of Python,cur_month=t[1],simpleAssign,120 Making Use of Python,cur_day=t[2],simpleAssign,120 Making Use of Python,fname=raw_input(“Enter your first name: “),simpleAssign,120 Making Use of Python,fname=isblank(fname) #Call isblank function for fname,simpleAssign,120 Making Use of Python,lname=raw_input(“Enter your last name: “),simpleAssign,120 Making Use of Python,lname=isblank(lname) #Call isblank function for lname,simpleAssign,120 Making Use of Python,month=int(dob[:2]) #Extract month from date of birth,simpleAssign,120 Making Use of Python,day=int(dob[3:5]) #Extract day from date of birth,simpleAssign,120 Making Use of Python,year=int(dob[6:10]) #Extract year from date of birth,simpleAssign,120 Making Use of Python,if dobvalid_func()==0: #Checks if dobvalid_func returns true,simpleAssign,121 Making Use of Python,num1=num2-num1,simpleAssign,126 Making Use of Python,c=casemod.case(‘H’),simpleAssign,128 Making Use of Python,fibo=fib.fibonacci,simpleAssign,133 Making Use of Python,num1=num2-num1,simpleAssign,134 Making Use of Python,"Bank.Account.fixed.interest(Principal,rate=.12,period=5)",simpleAssign,136 Making Use of Python,t=time.localtime(time.time()),simpleAssign,137 Making Use of Python,cur_year=t[0],simpleAssign,137 Making Use of Python,cur_month=t[1],simpleAssign,137 Making Use of Python,cur_day=t[2],simpleAssign,137 Making Use of Python,m=int(dob[:2]) #Extract month from date of birth,simpleAssign,138 Making Use of Python,d=int(dob[3:5]) #Extract day from date of birth,simpleAssign,138 Making Use of Python,y=int(dob[6:10]) #Extract year from date of birth,simpleAssign,138 Making Use of Python,"if dobvalid_func(m,d,y)==0:",simpleAssign,138 Making Use of Python,age=cur_year-y-1,simpleAssign,138 Making Use of Python,i=0,simpleAssign,138 Making Use of Python,i=0,simpleAssign,138 Making Use of Python,c=ord(cardno[i]),simpleAssign,139 Making Use of Python,fname=raw_input(“Enter your first name: “),simpleAssign,139 Making Use of Python,lname=raw_input(“Enter your last name: “),simpleAssign,139 Making Use of Python,"date=raw_input(“Enter your date of birth, mm-dd-yyyy: “)",simpleAssign,139 Making Use of Python,return_age=age_mod.age_cal(date),simpleAssign,139 Making Use of Python,qty_order=raw_input(“Enter quantity: “),simpleAssign,139 Making Use of Python,credit=raw_input(“Enter credit card no.: “),simpleAssign,139 Making Use of Python,i=0,simpleAssign,145 Making Use of Python,name=raw_input(‘Enter your name: ‘),simpleAssign,147 Making Use of Python,current_dir=os.getcwd(),simpleAssign,152 Making Use of Python,"join_dir=os.path.join(current_dir,’testfile’)",simpleAssign,152 Making Use of Python,course_code=raw_input(‘Enter the course code: ‘),simpleAssign,154 Making Use of Python,course_title=raw_input(‘Enter the course title: ‘),simpleAssign,154 Making Use of Python,course_dur=raw_input(‘Enter the course duration: ‘),simpleAssign,154 Making Use of Python,course_fee=raw_input(‘Enter the course fee: ‘),simpleAssign,154 Making Use of Python,i=0,simpleAssign,155 Making Use of Python,j=0,simpleAssign,155 Making Use of Python,if (os.path.getsize(‘course_details’)==0):,simpleAssign,155 Making Use of Python,ans=raw_input(‘Do you wish to add more records(y/n): ‘),simpleAssign,155 Making Use of Python,a=0,simpleAssign,164 Making Use of Python,b=1,simpleAssign,164 Making Use of Python,m = My_Class(),simpleAssign,166 Making Use of Python,m = My_Method_Class(),simpleAssign,167 Making Use of Python,"i = My_Init(1,2)",simpleAssign,168 Making Use of Python,b = My_Base_Class(),simpleAssign,171 Making Use of Python,s = My_Subclass(),simpleAssign,172 Making Use of Python,Aclass = My_Class_A(),simpleAssign,174 Making Use of Python,Bclass = My_Class_B(),simpleAssign,174 Making Use of Python,MyC=My_Class(),simpleAssign,175 Making Use of Python,MyChC=My_Child_Class(),simpleAssign,175 Making Use of Python,MyChC=My_Child_Class(),simpleAssign,175 Making Use of Python,classA = My_Class_A,simpleAssign,177 Making Use of Python,classB = My_Class_B,simpleAssign,177 Making Use of Python,a=0,simpleAssign,179 Making Use of Python,b=1,simpleAssign,179 Making Use of Python,ClearScreen = os.system(‘clear’) #Clears the screen as soon,simpleAssign,182 Making Use of Python,LibCode=Title=Price=’’ #Initializes the attributes,simpleAssign,182 Making Use of Python,LibCode=raw_input(‘Enter the library code: ‘),simpleAssign,182 Making Use of Python,Title=raw_input(‘Enter the title: ‘),simpleAssign,182 Making Use of Python,Price=raw_input(‘Enter the price (in $): ‘),simpleAssign,182 Making Use of Python,FileLen=File.tell() #Stores the length of file in,simpleAssign,182 Making Use of Python,if FileLen == 0L: #Checks if the length of file,simpleAssign,183 Making Use of Python,KeyInput=0,simpleAssign,183 Making Use of Python,ClearScreen = os.system(‘clear’),simpleAssign,183 Making Use of Python,KeyInput=1,simpleAssign,183 Making Use of Python,Author=Publisher=PageCount=ISBN=’’ #Initializes the,simpleAssign,184 Making Use of Python,libM=self.lib_method() #Calls the method of the,simpleAssign,184 Making Use of Python,Author=raw_input(‘Enter the name of the author: ‘),simpleAssign,184 Making Use of Python,Publisher=raw_input(‘Enter the name of the publisher: ‘),simpleAssign,184 Making Use of Python,ISBN=raw_input(‘Enter the ISBN: ‘),simpleAssign,184 Making Use of Python,PageCount=raw_input(‘Enter the page count: ‘),simpleAssign,184 Making Use of Python,BkFileLen=BkFile.tell(),simpleAssign,185 Making Use of Python,if BkFileLen == 0L: #Check if the length of the,simpleAssign,185 Making Use of Python,end=0,simpleAssign,185 Making Use of Python,record=1,simpleAssign,185 Making Use of Python,end=1,simpleAssign,185 Making Use of Python,ProductOf=Size=’’ #Initializes the attributes of,simpleAssign,185 Making Use of Python,libM=self.lib_method() #Calls the method of the,simpleAssign,186 Making Use of Python,ProductOf=raw_input(‘Enter the name of the software vendor: ‘),simpleAssign,186 Making Use of Python,Size=raw_input(‘Enter the size of the software (in MB): ‘),simpleAssign,186 Making Use of Python,SwFileLen=SwFile.tell(),simpleAssign,186 Making Use of Python,if SwFileLen == 0L: #Check if the length of the,simpleAssign,186 Making Use of Python,end=0,simpleAssign,187 Making Use of Python,record=1,simpleAssign,187 Making Use of Python,end=1,simpleAssign,187 Making Use of Python,done=0,simpleAssign,187 Making Use of Python,MenuChoice=raw_input(MenuItems) #Asks input for,simpleAssign,187 Making Use of Python,ClearScreen = os.system(‘clear’),simpleAssign,187 Making Use of Python,done=1,simpleAssign,188 Making Use of Python,bk=books() #Creates instance of the books class,simpleAssign,189 Making Use of Python,sw=software() #Creates instance of the software class,simpleAssign,189 Making Use of Python,scship=self.studfee-(self.studschrship*100/self.studfee),simpleAssign,195 Making Use of Python,r=os.system(“clear”),simpleAssign,195 Making Use of Python,ctr=0,simpleAssign,195 Making Use of Python,num1=input(‘Enter num1:’),simpleAssign,207 Making Use of Python,num2=input(‘Enter num2:’),simpleAssign,207 Making Use of Python,op=raw_input(‘Enter an operator’),simpleAssign,207 Making Use of Python,scship=self.studfee-(self.studschrship*100/self.studfee),simpleAssign,209 Making Use of Python,ctr=0,simpleAssign,209 Making Use of Python,r=os.system(“clear”),simpleAssign,209 Making Use of Python,http://www.URLAddress.com?login=yourLoginName,simpleAssign,221 Making Use of Python,font><FONT color=#ff6699 face=Arial size=4>Registration form for new,simpleAssign,222 Making Use of Python,Mr <INPUT CHECKED name=R1 type=radio value=V1> Mrs,simpleAssign,222 Making Use of Python,INPUT name=R1 type=radio value=V2>,simpleAssign,222 Making Use of Python,Ms <INPUT name=R1 type=radio value=V3> Dr <INPUT name=R1,simpleAssign,222 Making Use of Python,type=radio value=V4></font></P>,simpleAssign,222 Making Use of Python,name=T1 size=30> </font> ,simpleAssign,222 Making Use of Python,name=T2 size=30></font></P>,simpleAssign,222 Making Use of Python,font><INPUT name=T3,simpleAssign,222 Making Use of Python,size=30></font></P>,simpleAssign,222 Making Use of Python,INPUT name=T4 size=30></font>,simpleAssign,222 Making Use of Python,INPUT name=T5 size=30>,simpleAssign,222 Making Use of Python,INPUT name=T6,simpleAssign,223 Making Use of Python,size=30></font> ,simpleAssign,223 Making Use of Python,INPUT name=T7 size=14> ,simpleAssign,223 Making Use of Python,name=T8 size=13></font></P>,simpleAssign,223 Making Use of Python,name=T9,simpleAssign,223 Making Use of Python,size=30></font> ,simpleAssign,223 Making Use of Python,font><INPUT name=T10 size=30></P>,simpleAssign,223 Making Use of Python,name=T11></font> ,simpleAssign,223 Making Use of Python,Income: </font><SELECT name=D1,simpleAssign,223 Making Use of Python,size=1> <OPTION selected>Business</OPTION> <OPTION>Service</OPTION>,simpleAssign,223 Making Use of Python,name=D2 size=1> <OPTION selected>Savings account</OPTION> <OPTION>Loan,simpleAssign,223 Making Use of Python,INPUT name=B1 type=submit value=”Submit Form”> ,simpleAssign,224 Making Use of Python,INPUT name=B2 type=reset value=Reset></P></FORM>,simpleAssign,224 Making Use of Python,INPUT TYPE=radio NAME=studtitle VALUE=”Mr.” CHECKED> Mr,simpleAssign,231 Making Use of Python,INPUT TYPE=radio NAME=studtitle VALUE=”Mrs.”> Mrs.,simpleAssign,231 Making Use of Python,INPUT TYPE=radio NAME=studtitle VALUE=”Ms.”> Ms.,simpleAssign,231 Making Use of Python,INPUT TYPE=radio NAME=studtitle VALUE=”Dr.”> Dr.,simpleAssign,231 Making Use of Python,INPUT TYPE=text NAME=studname VALUE=”” SIZE=30></p>,simpleAssign,231 Making Use of Python,INPUT TYPE=text NAME=studdob VALUE=”” SIZE=30></p>,simpleAssign,231 Making Use of Python,textarea NAME=studadd rows=2 cols=30></textarea></p>,simpleAssign,231 Making Use of Python,INPUT TYPE=text NAME=studphone VALUE=”” SIZE=30></p>,simpleAssign,231 Making Use of Python,INPUT TYPE=text NAME=emailadd VALUE=”” SIZE=30></p>,simpleAssign,231 Making Use of Python,SELECT name=studcourse size=1> <OPTION selected>Project,simpleAssign,231 Making Use of Python,INPUT TYPE=submit>,simpleAssign,231 Making Use of Python,INPUT TYPE=RESET></FORM></BODY></HTML>,simpleAssign,231 Making Use of Python,fs = cgi.FieldStorage(),simpleAssign,233 Making Use of Python,title = fs[‘studtitle’].value,simpleAssign,233 Making Use of Python,name = fs[‘studname’].value,simpleAssign,233 Making Use of Python,dob=fs[‘studdob’].value,simpleAssign,233 Making Use of Python,add=fs[‘studadd’].value,simpleAssign,233 Making Use of Python,phone=fs[‘studphone’].value,simpleAssign,233 Making Use of Python,email=fs[‘emailadd’].value,simpleAssign,233 Making Use of Python,course=fs[‘studcourse’].value,simpleAssign,233 Making Use of Python,fs = cgi.FieldStorage(),simpleAssign,234 Making Use of Python,fpass=fs[‘password’].value,simpleAssign,234 Making Use of Python,fs = cgi.FieldStorage(),simpleAssign,236 Making Use of Python,Ch=0,simpleAssign,236 Making Use of Python,fpass=fs[‘password’].value,simpleAssign,236 Making Use of Python,"p[password], —password[=password] This option is used to specify the",simpleAssign,245 Making Use of Python,"p[password], —password[=password]",simpleAssign,247 Making Use of Python,INPUT TYPE=text NAME=studname VALUE=”” SIZE=30>,simpleAssign,253 Making Use of Python,textarea NAME=studadd rows=2 cols=30></textarea>,simpleAssign,253 Making Use of Python,INPUT TYPE=text NAME=studphone VALUE=”” SIZE=30>,simpleAssign,254 Making Use of Python,INPUT TYPE=text NAME=emailadd VALUE=”” SIZE=30></p>,simpleAssign,254 Making Use of Python,INPUT TYPE=submit>,simpleAssign,254 Making Use of Python,INPUT TYPE=RESET>,simpleAssign,254 Making Use of Python,"Connection = MySQLdb.connect(host=”localhost”,db=”Student”,\",simpleAssign,256 Making Use of Python,"port=8000, username=”laura”, passwd=”password”)",simpleAssign,256 Making Use of Python,con=connection.cursor(),simpleAssign,256 Making Use of Python,mysql> SET AUTOCOMMIT=0,simpleAssign,257 Making Use of Python,result=con.fetchone(),simpleAssign,258 Making Use of Python,result=con.fetchone(),simpleAssign,258 Making Use of Python,result=con.fetchall(),simpleAssign,258 Making Use of Python,"connection=MySQLdb.connect(host=”localhost”,db=”Registration”,\",simpleAssign,258 Making Use of Python,con=connection.cursor(),simpleAssign,259 Making Use of Python,fs = cgi.FieldStorage(),simpleAssign,259 Making Use of Python,name = fs[‘studname’].value,simpleAssign,259 Making Use of Python,dob=fs[‘studdob’].value,simpleAssign,259 Making Use of Python,add=fs[‘studadd’].value,simpleAssign,259 Making Use of Python,country=fs[‘studcountry’].value,simpleAssign,259 Making Use of Python,phone=fs[‘studphone’].value,simpleAssign,259 Making Use of Python,email=fs[‘emailadd’].value,simpleAssign,259 Making Use of Python,"connection=MySQLdb.connect(host=”localhost”,db=”Registration”,\",simpleAssign,259 Making Use of Python,con=connection.cursor(),simpleAssign,259 Making Use of Python,result_set=con.fetchall(),simpleAssign,259 Making Use of Python,"connection=MySQLdb.connect(host=”localhost”,db=”Registration”,\",simpleAssign,262 Making Use of Python,con=connection.cursor(),simpleAssign,262 Making Use of Python,count=con.rowcount,simpleAssign,262 Making Use of Python,i=0,simpleAssign,262 Making Use of Python,result_set=con.fetchone(),simpleAssign,262 Making Use of Python,"Connection = MySQLdb.connect(host=”localhost”,db=”Student”,\",simpleAssign,264 Making Use of Python,"port=8000, username=”laura”, passwd=”password”)",simpleAssign,264 Making Use of Python,con=connection.cursor(),simpleAssign,264 Making Use of Python,"TCP_Sock=socket(AF_INET, SOCK_STREAM)",simpleAssign,272 Making Use of Python,"TCP_Sock=socket(AF_INET, SOCK_DGRAM)",simpleAssign,272 Making Use of Python,4 PortNumber = 12345,simpleAssign,275 Making Use of Python,5 Buffer = 500,simpleAssign,275 Making Use of Python,"8 TCP_Server_Socket = socket(AF_INET, SOCK_STREAM)",simpleAssign,276 Making Use of Python,4 PortNumber = 12345,simpleAssign,277 Making Use of Python,5 Buffer = 500,simpleAssign,278 Making Use of Python,"8 TCP_Client_Socket = socket(AF_INET, SOCK_STREAM)",simpleAssign,278 Making Use of Python,4 PortNumber=12345,simpleAssign,281 Making Use of Python,5 Buffer=500,simpleAssign,281 Making Use of Python,"8 UDP_Server_Socket=socket(AF_INET, SOCK_DGRAM)",simpleAssign,281 Making Use of Python,"13 ClientData, ClientAddress = UDP_Server_Socket.recvfrom(Buffer)",simpleAssign,281 Making Use of Python,4 PortNumber=12345,simpleAssign,283 Making Use of Python,5 Buffer=500,simpleAssign,283 Making Use of Python,"8 UDP_Client_Socket=socket(AF_INET, SOCK_DGRAM)",simpleAssign,283 Making Use of Python,"Server_Socket=socket(AF_INET, SOCK_STREAM)",simpleAssign,285 Making Use of Python,"Client_Socket=socket(AF_INET, SOCK_STREAM)",simpleAssign,285 Making Use of Python,PortNumber = 22222 #Defines a dedicated port number for the server,simpleAssign,286 Making Use of Python,Buffer = 1024 #Defines the maximum size of data that can be,simpleAssign,286 Making Use of Python,"Server_Socket=socket(AF_INET, SOCK_STREAM) #Creates a stream",simpleAssign,286 Making Use of Python,"Temp_Socket, ClientAddress = Server_Socket.accept() #Accepts",simpleAssign,286 Making Use of Python,DataFromClient = Temp_Socket.recv(Buffer) #Receives data,simpleAssign,287 Making Use of Python,PortNumber = 22222 #Defines the dedicated port number of the server,simpleAssign,287 Making Use of Python,Buffer = 1024 #Defines the maximum size of data that can be,simpleAssign,288 Making Use of Python,"Client_Socket=socket(AF_INET, SOCK_STREAM) #Creates a stream",simpleAssign,288 Making Use of Python,i=0,simpleAssign,297 Making Use of Python,j=0,simpleAssign,297 Making Use of Python,i=0,simpleAssign,300 Making Use of Python,j=0,simpleAssign,300 Making Use of Python,myBank=Bank(),simpleAssign,302 Making Use of Python,lock=thread.allocate_lock(),simpleAssign,302 Making Use of Python,number =1,simpleAssign,304 Making Use of Python,while(number <= 10),simpleAssign,304 Making Use of Python,number =1,simpleAssign,304 Making Use of Python,while(number <= 10),simpleAssign,304 Making Use of Python,number =1,simpleAssign,305 Making Use of Python,while(number <= 5):,simpleAssign,305 Making Use of Python,threadnumber = 1,simpleAssign,305 Making Use of Python,number =1,simpleAssign,306 Making Use of Python,while(number <= 5):,simpleAssign,306 Making Use of Python,threadnumber = 1,simpleAssign,306 Making Use of Python,PortNumber = 12345,simpleAssign,307 Making Use of Python,Buffer = 500,simpleAssign,307 Making Use of Python,"TCP_Server_Socket = socket(AF_INET, SOCK_STREAM)",simpleAssign,307 Making Use of Python,ch=0,simpleAssign,308 Making Use of Python,ServerStr=str(ServerData),simpleAssign,308 Making Use of Python,ServerList=ServerStr.split(‘~~’),simpleAssign,308 Making Use of Python,DataStr = raw_input(‘Enter data to broadcast: ‘),simpleAssign,309 Making Use of Python,port=8888,simpleAssign,316 Making Use of Python,"srvsocket=SocketServer.TCPServer((“”,port),myR)",simpleAssign,316 Making Use of Python,content-length = 13432,simpleAssign,325 Making Use of Python,"keep-alive = timeout=15, max=100",simpleAssign,325 Making Use of Python,server = Apache/1.3.20 (Unix),simpleAssign,325 Making Use of Python,"last-modified = Fri, 11 Jan 2002 03:49:53 GMT",simpleAssign,325 Making Use of Python,connection = close,simpleAssign,325 Making Use of Python,"date = Fri, 11 Jan 2002 06:46:32 GMT",simpleAssign,325 Making Use of Python,content-type = text/html,simpleAssign,325 Making Use of Python,accept-ranges = bytes,simpleAssign,325 Making Use of Python,urllib.quote(‘http://search.python.org/query.html?qt=CGI&\,simpleAssign,326 Making Use of Python,col=ftp&col=python’),simpleAssign,326 Making Use of Python,qt=CGI COM&col=ftp&col=python’),simpleAssign,326 Making Use of Python,http://search.python.org/query.html?qt=CGI&col=ftp’,simpleAssign,326 Making Use of Python,http://search.python.org/query.html?qt=CGI COM&col=ftp&col=python’,simpleAssign,326 Making Use of Python,value pairs are first encoded in the “key=value” format with each key-value pair sep-,simpleAssign,326 Making Use of Python,name=Laura&studid=S001’,simpleAssign,327 Making Use of Python,form=FieldStorage(),simpleAssign,329 Making Use of Python,fileupload=form[“file_name”],simpleAssign,329 Making Use of Python,count=0,simpleAssign,329 Making Use of Python,cookie=Cookie.Cookie(),simpleAssign,331 Making Use of Python,cookie[‘studid’]=200,simpleAssign,332 Making Use of Python,C=Cookie.Cookie(os.environ[‘HTTP_COOKIE’]),simpleAssign,332 Making Use of Python,C=Cookie.Cookie(),simpleAssign,332 Making Use of Python,C[eachkey]=initialvalues[eachkey],simpleAssign,332 Making Use of Python,"cookie=getCookie({‘counter’:0,’studid’:”S01”})",simpleAssign,332 Making Use of Python,eachCook=eachCook.strip(),simpleAssign,335 Making Use of Python,tag = eachCook[2:6],simpleAssign,335 Making Use of Python,cookStatus = studidCook = ‘’,simpleAssign,335 Making Use of Python,studidCook = cookStatus = self.cookies[‘stid’],simpleAssign,336 Making Use of Python,FORM><INPUT TYPE=button VALUE=Back,simpleAssign,336 Making Use of Python,totbytes = 1024,simpleAssign,336 Making Use of Python,filename = self.f_name,simpleAssign,337 Making Use of Python,studidCook = cookStatus = self.cookies[‘stid’],simpleAssign,337 Making Use of Python,form = FieldStorage(),simpleAssign,337 Making Use of Python,val=form[‘Stud_Name’].value,simpleAssign,337 Making Use of Python,val=form[‘Course_ID’].value,simpleAssign,337 Making Use of Python,val=form[‘Assign_No’].value,simpleAssign,337 Making Use of Python,File_Upl = form[“File_Upl”],simpleAssign,337 Making Use of Python,page = myCGI(),simpleAssign,338 Making Use of Python,top = Tkinter.Tk(),simpleAssign,344 Making Use of Python,top = Tk(),simpleAssign,344 Making Use of Python,top = Tkinter.Tk(),simpleAssign,345 Making Use of Python,top = Tk(),simpleAssign,346 Making Use of Python,"L1 = Label(top, text=”Hello World”)",simpleAssign,348 Making Use of Python,"L1 = Label(top, text=”Hello World”, width = 20, height =5)",simpleAssign,348 Making Use of Python,top = Tk(),simpleAssign,348 Making Use of Python,"L1 = Label(top, text=”Hello World”, width = 20, height =5)",simpleAssign,348 Making Use of Python,E1 = Entry(top),simpleAssign,349 Making Use of Python,"E1 = Entry(top, bd =5, fg = “red”, relief = RAISED)",simpleAssign,349 Making Use of Python,top = Tk(),simpleAssign,350 Making Use of Python,"E1 = Entry(top, bd =5, fg = “red”, relief = RAISED)",simpleAssign,350 Making Use of Python,top = Tk(),simpleAssign,351 Making Use of Python,"L1 = Label(top, text=”User Name”)",simpleAssign,351 Making Use of Python,"E1 = Entry(top, bd =5)",simpleAssign,351 Making Use of Python,top = Tk(),simpleAssign,351 Making Use of Python,"L1 = Label(top, text=”User Name”)",simpleAssign,351 Making Use of Python,L1.pack(side=LEFT),simpleAssign,351 Making Use of Python,"E1 = Entry(top, bd =5)",simpleAssign,351 Making Use of Python,E1.pack(side=RIGHT),simpleAssign,351 Making Use of Python,top = Tk(),simpleAssign,352 Making Use of Python,"L1 = Label(top, text=”User Name”)",simpleAssign,352 Making Use of Python,"L1.grid(row=0, column=0)",simpleAssign,352 Making Use of Python,"E1 = Entry(top, bd =5)",simpleAssign,352 Making Use of Python,"E1.grid(row=0, column=1)",simpleAssign,352 Making Use of Python,top = Tk(),simpleAssign,352 Making Use of Python,"L1 = Label(top, text=”User Name”)",simpleAssign,352 Making Use of Python,"L1.place(relx=0.0, rely=0.0)",simpleAssign,352 Making Use of Python,"E1 = Entry(top, bd =5)",simpleAssign,352 Making Use of Python,"E1.place(relx=0.4, rely = 0.0)",simpleAssign,352 Making Use of Python,top = Tkinter.Tk(),simpleAssign,354 Making Use of Python,"B1 = Tkinter.Button(top, text = “Say Hello”, command = hello)",simpleAssign,354 Making Use of Python,Lb1 = Listbox(top),simpleAssign,355 Making Use of Python,top = Tk(),simpleAssign,355 Making Use of Python,Lb1 = Listbox(top),simpleAssign,355 Making Use of Python,CheckVar = IntVar(),simpleAssign,357 Making Use of Python,"C1 = Checkbutton(top, text = “Music”, variable = CheckVar)",simpleAssign,357 Making Use of Python,top = Tkinter.Tk(),simpleAssign,357 Making Use of Python,CheckVar = IntVar(),simpleAssign,357 Making Use of Python,"C1 = Checkbutton(top, text = “Music”, variable = CheckVar, \",simpleAssign,357 Making Use of Python,"onvalue = 1, offvalue = 0)",simpleAssign,357 Making Use of Python,top = Tkinter.Tk(),simpleAssign,358 Making Use of Python,RadioVar = IntVar(),simpleAssign,358 Making Use of Python,"R1 = Radiobutton(top, text = “Male”, variable = RadioVar, value = 1)",simpleAssign,358 Making Use of Python,"R2 = Radiobutton(top, text = “Female”, variable =RadioVar,value = 2)",simpleAssign,358 Making Use of Python,"F1 = Frame(top, width = 100, height = 100)",simpleAssign,358 Making Use of Python,"r1=Radiobutton(F1, text=”Male”, variable=v, value=1)",simpleAssign,358 Making Use of Python,"r2=Radiobutton(F1, text=”Female”, variable=v, value=2)",simpleAssign,358 Making Use of Python,"Label(master, text=”First Name”).grid(row=0)",simpleAssign,359 Making Use of Python,"Label(master, text=”Last Name”).grid(row=1)",simpleAssign,359 Making Use of Python,"Label(master, text=”Age”).grid(row=2)",simpleAssign,359 Making Use of Python,"Label(master, text=””, width=5).grid(row=0, column=3)",simpleAssign,359 Making Use of Python,"Label(master, text=”Gender”).grid(row=0, column=4)",simpleAssign,359 Making Use of Python,"variable=self.v, value=1).pack(anchor=W)",simpleAssign,359 Making Use of Python,"variable=self.v, value=2).pack(anchor=W)",simpleAssign,359 Making Use of Python,"Label(master, text=””).grid(row=3)",simpleAssign,359 Making Use of Python,wraplength=60).grid(row=4),simpleAssign,359 Making Use of Python,"width=10, command=self.Chk_Prereq, default=ACTIVE).pack()",simpleAssign,359 Making Use of Python,"width=10, command=self.Clear).pack()",simpleAssign,359 Making Use of Python,"width=10, command=self.Close).pack()",simpleAssign,360 Making Use of Python,"Label(master, text=””).grid(row=6)",simpleAssign,360 Making Use of Python,elif self.v.get()==2:,simpleAssign,360 Making Use of Python,elif self.var.get() == 1 and self.flag == 1:,simpleAssign,361 Making Use of Python,root = Tk(),simpleAssign,361 Making Use of Python,app = App(root),simpleAssign,361 Making Use of Python,id= GetIDsOfNames(“MethodCall”),simpleAssign,369 Making Use of Python,id= GetIDsOfNames(“Property”),simpleAssign,369 Making Use of Python,xl=win32com.client.Dispatch(“Excel.Application”),simpleAssign,370 Making Use of Python,xl.visible=1,simpleAssign,370 Making Use of Python,"xl.visible=1,",simpleAssign,371 Making Use of Python,xl=win32com.client.Dispatch(“Excel.Application”),simpleAssign,372 Making Use of Python,xl.visible=1,simpleAssign,372 Making Use of Python,"xl.Cells(1,2).Value=”=NOW()”",simpleAssign,372 Making Use of Python,"xl.Cells(2,2).Value=”=SUM(100,156)”",simpleAssign,372 Making Use of Python,arg1=arg1.strip(),simpleAssign,373 Making Use of Python,counter=arg1.count(‘ ‘),simpleAssign,373 Making Use of Python,l=len(arg1),simpleAssign,373 Making Use of Python,arg1=arg1.strip(),simpleAssign,373 Making Use of Python,counter=arg1.count(‘ ‘),simpleAssign,373 Making Use of Python,Set COMStringServer = CreateObject(“COMSTRINGSERVER”),simpleAssign,374 Making Use of Python,output = COMStringServer.letters(Text1.Text),simpleAssign,374 Making Use of Python,output1 = COMStringServer.words(Text1.Text),simpleAssign,374 Making Use of Python,Set COMStringServer = Nothing,simpleAssign,374 Making Use of Python,Set COMStringServer = CreateObject(“COMSTRINGSERVER”),simpleAssign,374 Python Crash Course,zip(),zip,490 Python Crash Course,"super().__init__(make, model, year)",superfunc,173 Python Crash Course,"super().__init__(make, model, year)",superfunc,174 Python Crash Course,"super().__init__(make, model, year)",superfunc,176 Python Crash Course,"super().__init__(make, model, year)",superfunc,181 Python Crash Course,super().__init__().,superfunc,258 Python Crash Course,"@login_required def",decaratorfunc,447 Python Crash Course,"@login_required def",decaratorfunc,448 Python Crash Course,"@login_required def",decaratorfunc,448 Python Crash Course,"@login_required def",decaratorfunc,448 Python Crash Course,"@login_required def",decaratorfunc,448 Python Crash Course,"@login_required def",decaratorfunc,448 Python Crash Course,"@login_required def",decaratorfunc,451 Python Crash Course,"@login_required def",decaratorfunc,452 Python Crash Course,"@login_required def",decaratorfunc,452 Python Crash Course,"@login_required def",decaratorfunc,453 Python Crash Course,"@login_required def",decaratorfunc,480 Python Crash Course,enumerate(),enumfunc,351 Python Crash Course,enumerate() int() ord() str(),enumfunc,490 Python Crash Course,"squares = [value**2 for value in range(1,11)]",simpleListComp,64 Python Crash Course,y_values = [x**2 for x in x_values],simpleListComp,328 Python Crash Course,y_values = [x**2 for x in x_values],simpleListComp,330 Python Crash Course,property() tuple(),classprop,490 Python Crash Course,classmethod() getattr() map() repr() xrange(),classmethod2,490 Python Crash Course,with open('pi_digits.txt') as file_object:,withfunc,190 Python Crash Course,with open('pi_digits.txt') as file_object:,withfunc,191 Python Crash Course,with open('text_files/filename.txt') as file_object:,withfunc,192 Python Crash Course,with open('text_files\filename.txt') as file_object:,withfunc,192 Python Crash Course,with open(file_path) as file_object:,withfunc,192 Python Crash Course,with open(file_path) as file_object:,withfunc,192 Python Crash Course,with open(filename) as file_object:,withfunc,193 Python Crash Course,with open(filename) as file_object:,withfunc,194 Python Crash Course,with open(filename) as file_object:,withfunc,194 Python Crash Course,with open(filename) as file_object:,withfunc,195 Python Crash Course,with open(filename) as file_object:,withfunc,195 Python Crash Course,with open(filename) as file_object:,withfunc,196 Python Crash Course,"with open(filename, 'w') as file_object:",withfunc,198 Python Crash Course,"with open(filename, 'w') as file_object:",withfunc,198 Python Crash Course,with open(filename) as f_obj:,withfunc,203 Python Crash Course,with open(filename) as f_obj:,withfunc,203 Python Crash Course,with open(filename) as f_obj:,withfunc,203 Python Crash Course,"with open(filename, 'w') as f_obj:",withfunc,210 Python Crash Course,with open(filename) as f_obj:,withfunc,210 Python Crash Course,"with open(filename, 'w') as f_obj:",withfunc,213 Python Crash Course,"with open(filename, 'w') as f_obj:",withfunc,213 Python Crash Course,with open(filename) as f:,withfunc,351 Python Crash Course,with open(filename) as f:,withfunc,352 Python Crash Course,with open(filename) as f:,withfunc,355 Python Crash Course,with open(filename) as f:,withfunc,356 Python Crash Course,with open(filename) as f:,withfunc,357 Python Crash Course,with open(filename) as f:,withfunc,359 Python Crash Course,with open(filename) as f:,withfunc,360 Python Crash Course,with open(filename) as f:,withfunc,363 Python Crash Course,"if alien_0['speed'] == 'medium': x_increment = 2 else:",ifelse,99 Python Crash Course,"if height >= 36: print(""\nYou're tall enough to ride!"") else:",ifelse,120 Python Crash Course,"if number % 2 == 0: print(""\nThe number "" + str(number) + "" is even."") else:",ifelse,121 Python Crash Course,"while statement needs to check only one condition: whether or not the flag is currently True. Then, all our other tests (to see if an event has occurred that should set the flag to False) can be neatly organized in the rest of the program. Let’s add a flag to parrot.py from the previous section. This flag, which we’ll call active (though you can call it anything), will monitor whether or not the program should continue running: prompt = ""\nTell me something, and I will repeat it back to you:"" prompt += ""\nEnter 'quit' to end the program. "" u active = True v while active: message = input(prompt) w if message == 'quit': active = False x else:",whileelse,124 Python Crash Course,"while True: city = input(prompt) if city == 'quit': break else:",whileelse,125 Python Crash Course,"while True: first_number = input(""\nFirst number: "") if first_number == 'q': break second_number = input(""Second number: "") u try: answer = int(first_number) / int(second_number) v except ZeroDivisionError: print(""You can't divide by 0!"") w else:",whileelse,202 Python Crash Course,"while True: u print(""\nPlease tell me your name:"") f_name = input(""First name: "") l_name = input(""Last name: "") formatted_name = get_formatted_name(f_name, l_name) print(""\nHello, "" + formatted_name + ""!"") For this example, we use a simple version of get_formatted_name() that doesn’t involve middle names. The while loop asks the user to enter their name, and we prompt for their first and last name separately u. But there’s one problem with this while loop: We haven’t defined a quit condition. Where do you put a quit condition when you ask for a series of inputs? We want the user to be able to quit as easily as possible, so each prompt should offer a way to quit. The break statement offers a straight- forward way to exit the loop at either prompt: def get_formatted_name(first_name, last_name): """"""Return a full name, neatly formatted."""""" full_name = first_name + ' ' + last_name return full_name.title() while True: print(""\nPlease tell me your name:"") print(""(enter 'q' at any time to quit)"") f_name = input(""First name: "") if f_name == 'q': break l_name = input(""Last name: "") if l_name == 'q': break",whilebreak,145 Python Crash Course,"while True: u first_number = input(""\nFirst number: "") if first_number == 'q': break v second_number = input(""Second number: "") if second_number == 'q': break",whilebreak,201 Python Crash Course,"while True: first = input(""\nPlease give me a first name: "") if first == 'q': break last = input(""Please give me a last name: "") if last == 'q': break formatted_name = get_formatted_name(first, last) print(""\tNeatly formatted name: "" + formatted_name + '.') This program imports get_formatted_name() from name_function.py. The user can enter a series of first and last names, and see the formatted full names that are generated: Enter 'q' at any time to quit. Please give me a first name: janis Please give me a last name: joplin Neatly formatted name: Janis Joplin. Please give me a first name: bob Please give me a last name: dylan Neatly formatted name: Bob Dylan. Please give me a first name: q We can see that the names generated here are correct. But let’s say we want to modify get_formatted_name() so it can also handle middle names. As we do so, we want to make sure we don’t break",whilebreak,216 Python Crash Course,"while True: response = input(""Language: "") if response == 'q': break",whilebreak,224 Python Crash Course,"while loop, like this: rw_visual.py import matplotlib.pyplot as plt from random_walk import RandomWalk # Keep making new walks, as long as the program is active. while True: # Make a random walk, and plot the points. rw = RandomWalk() rw.fill_walk() plt.scatter(rw.x_values, rw.y_values, s=15) plt.show() u keep_running = input(""Make another walk? (y/n): "") if keep_running == 'n': break",whilebreak,334 Python Crash Course,"while current_number < 10: u current_number += 1 if current_number % 2 == 0: continue print(current_number) First we set current_number to 0. Because it’s less than 10, Python enters the while loop. Once inside the loop, we increment the count by 1 at u, so current_number is 1. The if statement then checks the modulo of current_number and 2. If the modulo is 0 (which means current_number is divisible by 2), the continue statement tells Python to ignore the rest of the loop and return to the beginning. If the current number is not divis- ible by 2, the rest of the loop is executed and Python prints the current number: 1 3 5 7 9 Avoiding Infinite Loops Every while loop needs a way to stop running so it won’t continue",whilecontinue,126 Python Crash Course,"while True: gf.check_events(ai_settings, screen, ship, bullets) if stats.game_active: ship.update() gf.update_bullets(ai_settings, screen, ship, aliens, bullets) gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets) gf.update_screen(ai_settings, screen, ship, aliens, bullets) In the main loop, we always need to call check_events(), even if the game is inactive. For example, we still need to know if the user presses Q to quit the game or clicks the button to close the window. We also continue",whilecontinue,289 Python Crash Course,while loop counts from 1 to 5:,whilesimple,122 Python Crash Course,while current_number <= 5:,whilesimple,122 Python Crash Course,while message != 'quit':,whilesimple,123 Python Crash Course,while loop and the program ends:,whilesimple,123 Python Crash Course,while message != 'quit':,whilesimple,123 Python Crash Course,while x <= 5:,whilesimple,126 Python Crash Course,while x <= 5:,whilesimple,127 Python Crash Course,while unconfirmed_users:,whilesimple,128 Python Crash Course,while 'cat' in pets:,whilesimple,129 Python Crash Course,while polling_active:,whilesimple,130 Python Crash Course,while unprinted_designs:,whilesimple,147 Python Crash Course,while unprinted_designs:,whilesimple,148 Python Crash Course,while True:,whilesimple,241 Python Crash Course,while True:,whilesimple,242 Python Crash Course,while True:,whilesimple,243 Python Crash Course,while True:,whilesimple,246 Python Crash Course,while True:,whilesimple,248 Python Crash Course,while True:,whilesimple,249 Python Crash Course,while True:,whilesimple,250 Python Crash Course,while True:,whilesimple,251 Python Crash Course,while True:,whilesimple,259 Python Crash Course,while True:,whilesimple,262 Python Crash Course,while loop in alien_invasion.py looks simple again:,whilesimple,263 Python Crash Course,while True:,whilesimple,263 Python Crash Course,while True:,whilesimple,268 Python Crash Course,while True:,whilesimple,270 Python Crash Course,while True:,whilesimple,277 Python Crash Course,while True:,whilesimple,279 Python Crash Course,while True:,whilesimple,280 Python Crash Course,while True:,whilesimple,283 Python Crash Course,while True:,whilesimple,285 Python Crash Course,while True:,whilesimple,286 Python Crash Course,while True:,whilesimple,294 Python Crash Course,while True:,whilesimple,296 Python Crash Course,while True:,whilesimple,297 Python Crash Course,while True:,whilesimple,303 Python Crash Course,while loop:,whilesimple,305 Python Crash Course,while True:,whilesimple,305 Python Crash Course,while True:,whilesimple,312 Python Crash Course,while True:,whilesimple,316 Python Crash Course,while len(self.x_values) < self.num_points:,whilesimple,332 Python Crash Course,while True:,whilesimple,335 Python Crash Course,while True:,whilesimple,336 Python Crash Course,while True:,whilesimple,337 Python Crash Course,while True:,whilesimple,337 Python Crash Course,while True:,whilesimple,338 Python Crash Course,while logged out:,whilesimple,448 Python Crash Course,from . import views,fromrelative,413 Python Crash Course,from . import views,fromrelative,440 Python Crash Course,from pizza import *,fromstarstatements,157 Python Crash Course,from module_name import *,fromstarstatements,157 Python Crash Course,from module_name import *,fromstarstatements,159 Python Crash Course,from module_name import *,fromstarstatements,182 Python Crash Course,from pizza import make_pizza as mp,asextension,156 Python Crash Course,from module_name import function_name as fn,asextension,156 Python Crash Course,"Calling p.make_pizza() is more concise than calling pizza.make_pizza(): import pizza as p",asextension,157 Python Crash Course,"The general syntax for this approach is: import module_name as mn",asextension,157 Python Crash Course,"from module_name import function_name as fn import module_name as mn",asextension,159 Python Crash Course,"from ship import Ship import game_functions as gf",asextension,248 Python Crash Course,"from alien import Alien import game_functions as gf",asextension,268 Python Crash Course,"from ship import Ship import game_functions as gf",asextension,270 Python Crash Course,from matplotlib import pyplot as plt,asextension,353 Python Crash Course,from matplotlib import pyplot as plt,asextension,355 Python Crash Course,"def __init__(self, name, age)",__init__,162 Python Crash Course,The __init__(),__init__,163 Python Crash Course,The __init__(),__init__,163 Python Crash Course,the __init__(),__init__,163 Python Crash Course,this __init__(),__init__,163 Python Crash Course,the __init__() method from the Dog class. We’ll pass Dog(),__init__,163 Python Crash Course,the __init__(),__init__,164 Python Crash Course,The __init__(),__init__,164 Python Crash Course,The __init__(),__init__,164 Python Crash Course,The __init__(),__init__,166 Python Crash Course,"def __init__(self, make, model, year)",__init__,167 Python Crash Course,the __init__(),__init__,167 Python Crash Course,The __init__(),__init__,167 Python Crash Course,the __init__(),__init__,168 Python Crash Course,"def __init__(self, make, model, year)",__init__,168 Python Crash Course,the __init__(),__init__,168 Python Crash Course,The __init__(),__init__,172 Python Crash Course,the __init__(),__init__,172 Python Crash Course,"def __init__(self, make, model, year)",__init__,172 Python Crash Course,"def __init__(self, make, model, year)",__init__,173 Python Crash Course,The __init__(),__init__,173 Python Crash Course,the __init__(),__init__,173 Python Crash Course,the __init__(),__init__,173 Python Crash Course,the __init__(),__init__,173 Python Crash Course,from __init__(),__init__,173 Python Crash Course,"def __init__(self, make, model, year)",__init__,173 Python Crash Course,"def __init__(self, make, model, year)",__init__,173 Python Crash Course,"def __init__(self, make, model, year)",__init__,174 Python Crash Course,"def __init__(self, make, model, year)",__init__,176 Python Crash Course,The __init__(),__init__,176 Python Crash Course,the __init__(),__init__,176 Python Crash Course,"def __init__(self, make, model, year)",__init__,179 Python Crash Course,"def __init__(self, battery_size=60)",__init__,180 Python Crash Course,"def __init__(self, make, model, year)",__init__,181 Python Crash Course,write __init__(),__init__,187 Python Crash Course,"def __init__(self, question)",__init__,223 Python Crash Course,The __init__(),__init__,228 Python Crash Course,def __init__(self),__init__,243 Python Crash Course,"def __init__(self, screen)",__init__,245 Python Crash Course,The __init__(),__init__,245 Python Crash Course,"def __init__(self, screen)",__init__,251 Python Crash Course,the __init__(),__init__,251 Python Crash Course,to __init__() and update(),__init__,252 Python Crash Course,"def __init__(self, screen)",__init__,252 Python Crash Course,"In __init__(), we add a self.moving_left flag. In update()",__init__,252 Python Crash Course,def __init__(self),__init__,253 Python Crash Course,"def __init__(self, ai_settings, screen)",__init__,253 Python Crash Course,for __init__(),__init__,254 Python Crash Course,"an __init__()",__init__,256 Python Crash Course,an __init__(),__init__,257 Python Crash Course,the __init__(),__init__,257 Python Crash Course,def __init__(self),__init__,257 Python Crash Course,"def __init__(self, ai_settings, screen, ship)",__init__,258 Python Crash Course,"def __init__(self, ai_settings, screen)",__init__,267 Python Crash Course,def __init__(self),__init__,276 Python Crash Course,"def __init__(self, ai_settings)",__init__,285 Python Crash Course,in __init__(),__init__,286 Python Crash Course,"from __init__()",__init__,286 Python Crash Course,"def __init__(self, settings)",__init__,288 Python Crash Course,"def __init__(self, ai_settings)",__init__,292 Python Crash Course,"def __init__(self, ai_settings, screen, msg)",__init__,292 Python Crash Course,The __init__(),__init__,293 Python Crash Course,"the __init__()",__init__,299 Python Crash Course,def __init__(self),__init__,299 Python Crash Course,the __init__(),__init__,299 Python Crash Course,than __init__(),__init__,301 Python Crash Course,"def __init__(self, ai_settings, screen, stats)",__init__,301 Python Crash Course,give __init__(),__init__,302 Python Crash Course,def __init__(self),__init__,306 Python Crash Course,"def __init__(self, ai_settings)",__init__,308 Python Crash Course,"in __init__() rather than in reset_stats()",__init__,308 Python Crash Course,the __init__(),__init__,308 Python Crash Course,"def __init__(self, ai_settings, screen, stats)",__init__,308 Python Crash Course,from __init__(),__init__,310 Python Crash Course,"def __init__(self, ai_settings, screen, stats)",__init__,310 Python Crash Course,"def __init__(self, ai_settings, screen)",__init__,313 Python Crash Course,of __init__(),__init__,313 Python Crash Course,and __init__(),__init__,314 Python Crash Course,"def __init__(self, ai_settings, screen, stats)",__init__,314 Python Crash Course,the __init__(),__init__,317 Python Crash Course,shorten __init__(). The prep_images(),__init__,317 Python Crash Course,the __init__(),__init__,332 Python Crash Course,with __init__(),__init__,332 Python Crash Course,The __init__(),__init__,340 Python Crash Course,"try: with open(filename) as f_obj: username = json.load(f_obj) except FileNotFoundError: username = input(""What is your name? "") with open(filename, 'w') as f_obj: json.dump(username, f_obj) print(""We'll remember you when you come back, "" + username + ""!"") else: print(""Welcome back, "" + username + ""!"") greet_user() Because we’re using a function now, we update the comments with a docstring that reflects how the program currently works u. This file is a little cleaner, but the function greet_user() is doing more than just greeting the user—it’s also retrieving a stored username if one exists and prompting for a new username if one doesn’t exist. Let’s refactor greet_user() so it’s not doing so many different tasks. We’ll start by moving the code for retrieving a stored username to a sepa- rate function: import json def get_stored_username(): u """"""Get stored username if available."""""" filename = 'username.json' try: with open(filename) as f_obj: username = json.load(f_obj) except FileNotFoundError: v return None else: return username 212 Chapter 10 www.it-ebooks.info",trytry,212 Python Crash Course,"try: The opening is the first part of the game, roughly...>, <Entry: In the opening phase of the game, it's important t...>] To get data through a foreign key relationship, you use the lowercase name of the related model followed by an underscore and the word set u. For example, say you have the models Pizza and Topping, and Topping is related to Pizza through a foreign key. If your object is called my_pizza, representing a single pizza, you can get all of the pizza’s toppings using the code my_pizza.topping_set.all(). We’ll use this kind of syntax when we begin to code the pages users can request. The shell is very useful for making sure your code retrieves the data you want it to. If your code works as you expect it to in the shell, you can expect it to work properly in the files you write within your project. If your code generates errors or doesn’t retrieve the data you expect it to, it’s much easier to troubleshoot your code in the simple shell environment than it is within the files that generate web pages. We won’t refer to the shell much, but you should continue using it to practice working with Django’s syntax for accessing the data stored in the project. N O T E Each time you modify your models, you’ll need to restart the shell to see the effects of those changes. To exit a shell session, enter CTRL-D; on Windows enter CTRL-Z and then press ENTER. www.it-ebooks.info Getting Started with Django 411",trytry,411 Python Crash Course,"try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError: msg = ""Sorry, the file "" + filename + "" does not exist."" print(msg) else:",tryexceptelse,205 Python Crash Course,"try: --snip-- except FileNotFoundError: u pass else:",tryexceptelse,206 Python Crash Course,"try: u with open(filename) as f_obj: v username = json.load(f_obj) w except FileNotFoundError: x username = input(""What is your name? "") y with open(filename, 'w') as f_obj: json.dump(username, f_obj) print(""We'll remember you when you come back, "" + username + ""!"") else:",tryexceptelse,211 Python Crash Course,"try: current_date = datetime.strptime(row[0], ""%Y-%m-%d"") high = int(row[1]) low = int(row[3]) except ValueError: v print(current_date, 'missing data') else:",tryexceptelse,360 Python Crash Course,"try: print(5/0) except ZeroDivisionError:",tryexcept,200 Python Crash Course,"try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError:",tryexcept,204 Python Crash Course,"u cc_pops_1, cc_pops_2, cc_pops_3 = {}, {}, {}",nestedDict,371 Python Crash Course,"cc_pops_1, cc_pops_2, cc_pops_3 = {}, {}, {}",nestedDict,372 Python Crash Course,v widgets = {'text': forms.Textarea(attrs={'cols': 80})},nestedDict,432 Python Crash Course,"def build_profile(first, last, **user_info):",funcwith2star,153 Python Crash Course,def make_pizza(*toppings):,funcwithstar,151 Python Crash Course,def make_pizza(*toppings):,funcwithstar,151 Python Crash Course,"def make_pizza(size, *toppings):",funcwithstar,152 Python Crash Course,"def make_pizza(size, *toppings):",funcwithstar,155 Python Crash Course,class Dog():,simpleclass,162 Python Crash Course,class ClassName(object):,simpleclass,164 Python Crash Course,class Dog(object):,simpleclass,164 Python Crash Course,class Dog():,simpleclass,164 Python Crash Course,class Dog():,simpleclass,165 Python Crash Course,class Dog():,simpleclass,165 Python Crash Course,class Car():,simpleclass,167 Python Crash Course,class Car():,simpleclass,168 Python Crash Course,class Car():,simpleclass,169 Python Crash Course,class Car():,simpleclass,169 Python Crash Course,class Car():,simpleclass,170 Python Crash Course,class Car():,simpleclass,170 Python Crash Course,class Car():,simpleclass,172 Python Crash Course,class ElectricCar(Car):,simpleclass,172 Python Crash Course,class Car(object):,simpleclass,173 Python Crash Course,class ElectricCar(Car):,simpleclass,173 Python Crash Course,class Car():,simpleclass,174 Python Crash Course,class ElectricCar(Car):,simpleclass,174 Python Crash Course,class Car():,simpleclass,175 Python Crash Course,class Battery():,simpleclass,175 Python Crash Course,class ElectricCar(Car):,simpleclass,176 Python Crash Course,class Car():,simpleclass,177 Python Crash Course,class Battery():,simpleclass,177 Python Crash Course,class ElectricCar(Car):,simpleclass,177 Python Crash Course,class Car():,simpleclass,179 Python Crash Course,class Car():,simpleclass,180 Python Crash Course,class Battery():,simpleclass,180 Python Crash Course,class ElectricCar(Car):,simpleclass,181 Python Crash Course,class Battery():,simpleclass,183 Python Crash Course,class ElectricCar(Car):,simpleclass,183 Python Crash Course,class Car():,simpleclass,183 Python Crash Course,class AnonymousSurvey():,simpleclass,223 Python Crash Course,class Settings():,simpleclass,243 Python Crash Course,class Ship():,simpleclass,245 Python Crash Course,class Ship():,simpleclass,251 Python Crash Course,class Settings():,simpleclass,253 Python Crash Course,class Ship():,simpleclass,253 Python Crash Course,class Bullet(Sprite):,simpleclass,258 Python Crash Course,class Alien(Sprite):,simpleclass,267 Python Crash Course,class GameStats():,simpleclass,285 Python Crash Course,class Button():,simpleclass,292 Python Crash Course,class GameStats():,simpleclass,301 Python Crash Course,class Scoreboard():,simpleclass,301 Python Crash Course,class Settings():,simpleclass,306 Python Crash Course,class Ship(Sprite):,simpleclass,313 Python Crash Course,class Scoreboard():,simpleclass,314 Python Crash Course,class RandomWalk():,simpleclass,332 Python Crash Course,class Die():,simpleclass,340 Python Crash Course,"u dates, highs, lows = [], [], []",nestedList,357 Python Crash Course,"dates, highs, lows = [], [], []",nestedList,360 Python Crash Course,"for cat in cats: for dog in dogs:",fornested,55 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,96 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,96 Python Crash Course,alien_0 = {'color': 'green'},simpleDict,96 Python Crash Course,alien_0 = {'color': 'green'},simpleDict,97 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,97 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,97 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,98 Python Crash Course,alien_0 = {'color': 'green'},simpleDict,99 Python Crash Course,"alien_0 = {'x_position': 0, 'y_position': 25, 'speed': 'medium'}",simpleDict,99 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,100 Python Crash Course,"alien_0 = {'color': 'green', 'points': 5}",simpleDict,109 Python Crash Course,"alien_1 = {'color': 'yellow', 'points': 10}",simpleDict,109 Python Crash Course,"alien_2 = {'color': 'red', 'points': 15}",simpleDict,109 Python Crash Course,"v new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'}",simpleDict,109 Python Crash Course,"new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'}",simpleDict,110 Python Crash Course,"u person = {'first': first_name, 'last': last_name}",simpleDict,144 Python Crash Course,"person = {'first': first_name, 'last': last_name}",simpleDict,144 Python Crash Course,x context = {'topics': topics},simpleDict,419 Python Crash Course,"x context = {'topic': topic, 'entries': entries}",simpleDict,422 Python Crash Course,x labels = {'text': ''},simpleDict,428 Python Crash Course,context = {'form': form},simpleDict,429 Python Crash Course,u labels = {'text': ''},simpleDict,432 Python Crash Course,"context = {'topic': topic, 'form': form}",simpleDict,433 Python Crash Course,"context = {'entry': entry, 'topic': topic, 'form': form}",simpleDict,436 Python Crash Course,context = {'form': form},simpleDict,444 Python Crash Course,context = {'topics': topics},simpleDict,451 Python Crash Course,"context = {'topic': topic, 'entries': entries}",simpleDict,452 Python Crash Course,context = {'form': form},simpleDict,453 Python Crash Course,"BOOTSTRAP3 = { 'include_jquery': True, }",simpleDict,457 Python Crash Course,"BOOTSTRAP3 = { 'include_jquery': True, }",simpleDict,468 Python Crash Course,"DATABASES = { 'default': dj_database_url.config(default='postgres://localhost') }",simpleDict,469 Python Crash Course,at the open(),openfunc,190 Python Crash Course,"tents, you first need to open the file to access it. The open()",openfunc,190 Python Crash Course,for pi_digits.txt in the directory where file_reader.py is stored. The open(),openfunc,190 Python Crash Course,"function returns an object representing the file. Here, open('pi_digits.txt')",openfunc,190 Python Crash Course,Notice how we call open() in this program but not close(),openfunc,190 Python Crash Course,and close the file by calling open() and close(),openfunc,191 Python Crash Course,When you pass a simple filename like pi_digits.txt to the open(),openfunc,191 Python Crash Course,"is in python_work, just passing open()",openfunc,191 Python Crash Course,"python_work—say, a folder called other_files—then just passing open()",openfunc,192 Python Crash Course,store them in a variable and then pass that variable to open(),openfunc,192 Python Crash Course,v with open(filename),openfunc,193 Python Crash Course,for the name of another file you want to work with. After we call open(),openfunc,193 Python Crash Course,"When you use with, the file object returned by open()",openfunc,194 Python Crash Course,"To write text to a file, you need to call open()",openfunc,197 Python Crash Course,"u with open(filename, 'w')",openfunc,197 Python Crash Course,The call to open(),openfunc,197 Python Crash Course,The open(),openfunc,198 Python Crash Course,"u with open(filename, 'a')",openfunc,199 Python Crash Course,"this example, the open()",openfunc,203 Python Crash Course,block will begin just before the line that contains open(),openfunc,203 Python Crash Course,"v with open(filename, 'w')",openfunc,209 Python Crash Course,v with open(filename),openfunc,209 Python Crash Course,u with open(filename),openfunc,350 Python Crash Course,abs() divmod() input() open() staticmethod(),openfunc,490 Python Crash Course,"v file_object.write(""I love programming."")",write,197 Python Crash Course,At v we use the write(),write,198 Python Crash Course,The write(),write,198 Python Crash Course,"file_object.write(""I love programming."")",write,198 Python Crash Course,"file_object.write(""I love creating new games."")",write,198 Python Crash Course,Including newlines in your write(),write,198 Python Crash Course,"file_object.write(""I love programming.\n"")",write,198 Python Crash Course,"file_object.write(""I love creating new games.\n"")",write,198 Python Crash Course,"v file_object.write(""I also love finding meaning in large datasets.\n"")",write,199 Python Crash Course,"file_object.write(""I love creating apps that can run in a browser.\n"")",write,199 Python Crash Course,contents = file_object.read(),read,190 Python Crash Course,"Once we have a file object representing pi_digits.txt, we use the read()",read,191 Python Crash Course,contents = file_object.read(),read,191 Python Crash Course,contents = f_obj.read(),read,203 Python Crash Course,contents = f_obj.read(),read,203 Python Crash Course,import this,importfunc,34 Python Crash Course,import this,importfunc,35 Python Crash Course,import this,importfunc,36 Python Crash Course,import statement,importfunc,154 Python Crash Course,import functions,importfunc,154 Python Crash Course,import a,importfunc,154 Python Crash Course,import into,importfunc,154 Python Crash Course,import pizza,importfunc,155 Python Crash Course,import pizza,importfunc,155 Python Crash Course,import a,importfunc,155 Python Crash Course,import statement,importfunc,155 Python Crash Course,"import an",importfunc,155 Python Crash Course,import a,importfunc,156 Python Crash Course,import as,importfunc,156 Python Crash Course,"import just",importfunc,156 Python Crash Course,import the,importfunc,156 Python Crash Course,import statement,importfunc,156 Python Crash Course,import every,importfunc,157 Python Crash Course,import statement,importfunc,157 Python Crash Course,import the,importfunc,157 Python Crash Course,import the,importfunc,157 Python Crash Course,import statements,importfunc,157 Python Crash Course,import statements,importfunc,158 Python Crash Course,import statement,importfunc,159 Python Crash Course,import module_name,importfunc,159 Python Crash Course,import classes,importfunc,162 Python Crash Course,import the,importfunc,179 Python Crash Course,import the,importfunc,180 Python Crash Course,import statement,importfunc,180 Python Crash Course,import the,importfunc,180 Python Crash Course,import the,importfunc,180 Python Crash Course,import the,importfunc,181 Python Crash Course,import as,importfunc,181 Python Crash Course,import both,importfunc,181 Python Crash Course,import multiple,importfunc,182 Python Crash Course,import an,importfunc,182 Python Crash Course,import the,importfunc,182 Python Crash Course,import car,importfunc,182 Python Crash Course,import the,importfunc,182 Python Crash Course,import every,importfunc,182 Python Crash Course,import statements,importfunc,182 Python Crash Course,import a,importfunc,182 Python Crash Course,import many,importfunc,182 Python Crash Course,import every,importfunc,183 Python Crash Course,import the,importfunc,183 Python Crash Course,"import Car",importfunc,183 Python Crash Course,import from,importfunc,183 Python Crash Course,import Car,importfunc,184 Python Crash Course,import statement,importfunc,184 Python Crash Course,import statement,importfunc,184 Python Crash Course,import a,importfunc,186 Python Crash Course,import statement,importfunc,186 Python Crash Course,import statement,importfunc,187 Python Crash Course,import json,importfunc,209 Python Crash Course,import the,importfunc,209 Python Crash Course,import json,importfunc,209 Python Crash Course,import json,importfunc,210 Python Crash Course,import json,importfunc,210 Python Crash Course,import json,importfunc,211 Python Crash Course,import json,importfunc,212 Python Crash Course,import json,importfunc,213 Python Crash Course,import the,importfunc,217 Python Crash Course,import unittest,importfunc,217 Python Crash Course,import unittest,importfunc,217 Python Crash Course,import unittest,importfunc,221 Python Crash Course,import unittest,importfunc,222 Python Crash Course,import unittest,importfunc,225 Python Crash Course,import unittest,importfunc,226 Python Crash Course,import unittest,importfunc,227 Python Crash Course,import statements,importfunc,236 Python Crash Course,import pygame,importfunc,239 Python Crash Course,import Pygame,importfunc,239 Python Crash Course,import pygame,importfunc,239 Python Crash Course,import Pygame,importfunc,240 Python Crash Course,import pygame,importfunc,240 Python Crash Course,import statement,importfunc,240 Python Crash Course,import sys,importfunc,241 Python Crash Course,import pygame,importfunc,241 Python Crash Course,import the,importfunc,241 Python Crash Course,import pygame,importfunc,243 Python Crash Course,import Settings,importfunc,244 Python Crash Course,import pygame,importfunc,245 Python Crash Course,import the,importfunc,245 Python Crash Course,import Ship,importfunc,246 Python Crash Course,import sys,importfunc,247 Python Crash Course,import pygame,importfunc,247 Python Crash Course,import pygame,importfunc,248 Python Crash Course,import sys,importfunc,248 Python Crash Course,import pygame,importfunc,258 Python Crash Course,import pygame,importfunc,259 Python Crash Course,import Group,importfunc,260 Python Crash Course,import pygame,importfunc,267 Python Crash Course,import pygame,importfunc,270 Python Crash Course,import the,importfunc,270 Python Crash Course,import the,importfunc,271 Python Crash Course,import statement,importfunc,271 Python Crash Course,import the,importfunc,286 Python Crash Course,import sys,importfunc,286 Python Crash Course,import the,importfunc,287 Python Crash Course,import the,importfunc,293 Python Crash Course,import Button,importfunc,294 Python Crash Course,import the,importfunc,303 Python Crash Course,import pygame,importfunc,313 Python Crash Course,import statements,importfunc,314 Python Crash Course,import the,importfunc,314 Python Crash Course,import matplotlib,importfunc,323 Python Crash Course,import the,importfunc,324 Python Crash Course,import pygal,importfunc,342 Python Crash Course,import pygal,importfunc,343 Python Crash Course,import csv,importfunc,350 Python Crash Course,import csv,importfunc,352 Python Crash Course,import csv,importfunc,353 Python Crash Course,import the,importfunc,354 Python Crash Course,import csv,importfunc,355 Python Crash Course,import json,importfunc,363 Python Crash Course,import the,importfunc,363 Python Crash Course,"import the",importfunc,365 Python Crash Course,import it,importfunc,365 Python Crash Course,import json,importfunc,366 Python Crash Course,import pygal,importfunc,367 Python Crash Course,import pygal,importfunc,368 Python Crash Course,import json,importfunc,369 Python Crash Course,import pygal,importfunc,369 Python Crash Course,import json,importfunc,372 Python Crash Course,import pygal,importfunc,372 Python Crash Course,import the,importfunc,374 Python Crash Course,import requests,importfunc,379 Python Crash Course,import the,importfunc,380 Python Crash Course,import requests,importfunc,380 Python Crash Course,import requests,importfunc,384 Python Crash Course,import pygal,importfunc,384 Python Crash Course,import pygal,importfunc,387 Python Crash Course,import requests,importfunc,391 Python Crash Course,import the,importfunc,410 Python Crash Course,import the,importfunc,413 Python Crash Course,import the,importfunc,414 Python Crash Course,import the,importfunc,414 Python Crash Course,import views,importfunc,414 Python Crash Course,import Topic,importfunc,419 Python Crash Course,import the,importfunc,419 Python Crash Course,import Topic,importfunc,428 Python Crash Course,import the,importfunc,428 Python Crash Course,import Topic,importfunc,429 Python Crash Course,import TopicForm,importfunc,429 Python Crash Course,import the,importfunc,429 Python Crash Course,"import the",importfunc,429 Python Crash Course,import statement,importfunc,432 Python Crash Course,import Topic,importfunc,433 Python Crash Course,import statement,importfunc,434 Python Crash Course,import the,importfunc,436 Python Crash Course,import the,importfunc,440 Python Crash Course,import the,importfunc,443 Python Crash Course,import the,importfunc,445 Python Crash Course,import the,importfunc,445 Python Crash Course,import the,importfunc,445 Python Crash Course,import the,importfunc,447 Python Crash Course,import the,importfunc,449 Python Crash Course,import the,importfunc,449 Python Crash Course,import Topic,importfunc,451 Python Crash Course,import the,importfunc,452 Python Crash Course,import dj_database_url,importfunc,469 Python Crash Course,import os,importfunc,470 Python Crash Course,import this,importfunc,480 Python Crash Course,import pass,importfunc,489 Python Crash Course,from module_name import function_name,importfromsimple,156 Python Crash Course,from pizza import make_pizza,importfromsimple,156 Python Crash Course,from module_name import function_name,importfromsimple,159 Python Crash Course,from car import Car,importfromsimple,180 Python Crash Course,from car import ElectricCar,importfromsimple,181 Python Crash Course,from car import Car,importfromsimple,183 Python Crash Course,from car import Car,importfromsimple,183 Python Crash Course,from electric_car import ElectricCar,importfromsimple,183 Python Crash Course,from collections import OrderedDict,importfromsimple,185 Python Crash Course,from random import randint,importfromsimple,186 Python Crash Course,from name_function import get_formatted_name,importfromsimple,216 Python Crash Course,from name_function import get_formatted_name,importfromsimple,217 Python Crash Course,from name_function import get_formatted_name,importfromsimple,221 Python Crash Course,from survey import AnonymousSurvey,importfromsimple,224 Python Crash Course,from survey import AnonymousSurvey,importfromsimple,225 Python Crash Course,from survey import AnonymousSurvey,importfromsimple,226 Python Crash Course,from survey import AnonymousSurvey,importfromsimple,227 Python Crash Course,from settings import Settings,importfromsimple,243 Python Crash Course,from settings import Settings,importfromsimple,246 Python Crash Course,from ship import Ship,importfromsimple,246 Python Crash Course,from settings import Settings,importfromsimple,248 Python Crash Course,from pygame.sprite import Sprite,importfromsimple,258 Python Crash Course,"from Sprite, which we import from",importfromsimple,258 Python Crash Course,from pygame.sprite import Group,importfromsimple,259 Python Crash Course,from bullet import Bullet,importfromsimple,260 Python Crash Course,from pygame.sprite import Sprite,importfromsimple,267 Python Crash Course,from ship import Ship,importfromsimple,268 Python Crash Course,from pygame.sprite import Group,importfromsimple,270 Python Crash Course,from settings import Settings,importfromsimple,270 Python Crash Course,from bullet import Bullet,importfromsimple,271 Python Crash Course,from alien import Alien,importfromsimple,271 Python Crash Course,from random import randint,importfromsimple,276 Python Crash Course,from settings import Settings,importfromsimple,286 Python Crash Course,from game_stats import GameStats,importfromsimple,286 Python Crash Course,"from time import sleep import pygame",importfromsimple,286 Python Crash Course,from game_stats import GameStats,importfromsimple,294 Python Crash Course,from button import Button,importfromsimple,294 Python Crash Course,from game_stats import GameStats,importfromsimple,303 Python Crash Course,from scoreboard import Scoreboard,importfromsimple,303 Python Crash Course,from pygame.sprite import Sprite,importfromsimple,313 Python Crash Course,from pygame.sprite import Group,importfromsimple,314 Python Crash Course,from ship import Ship,importfromsimple,314 Python Crash Course,from random import choice,importfromsimple,332 Python Crash Course,from random_walk import RandomWalk,importfromsimple,333 Python Crash Course,from random import randint,importfromsimple,340 Python Crash Course,from die import Die,importfromsimple,341 Python Crash Course,from die import Die,importfromsimple,343 Python Crash Course,"from die import Die import pygal",importfromsimple,345 Python Crash Course,from datetime import datetime,importfromsimple,354 Python Crash Course,from datetime import datetime,importfromsimple,355 Python Crash Course,from pygal.i18n import COUNTRIES,importfromsimple,365 Python Crash Course,from pygal.i18n import COUNTRIES,importfromsimple,365 Python Crash Course,from country_codes import get_country_code,importfromsimple,366 Python Crash Course,from country_codes import get_country_code,importfromsimple,369 Python Crash Course,from pygal.style import RotateStyle,importfromsimple,372 Python Crash Course,from which we import the,importfromsimple,373 Python Crash Course,from pygal.style import LightColorizedStyle,importfromsimple,374 Python Crash Course,from pygal.style import LightColorizedStyle,importfromsimple,374 Python Crash Course,from pygal.style import LightColorizedStyle,importfromsimple,384 Python Crash Course,from pygal.style import LightColorizedStyle,importfromsimple,387 Python Crash Course,from operator import itemgetter,importfromsimple,391 Python Crash Course,from django.db import models,importfromsimple,403 Python Crash Course,from django.db import models,importfromsimple,403 Python Crash Course,from django.contrib import admin,importfromsimple,407 Python Crash Course,from django.contrib import admin,importfromsimple,407 Python Crash Course,from learning_logs.models import Topic,importfromsimple,407 Python Crash Course,from django.db import models,importfromsimple,408 Python Crash Course,from django.contrib import admin,importfromsimple,409 Python Crash Course,from learning_logs.models import Topic,importfromsimple,410 Python Crash Course,from django.contrib import admin,importfromsimple,413 Python Crash Course,from django.contrib import admin,importfromsimple,413 Python Crash Course,from django.conf.urls import url,importfromsimple,413 Python Crash Course,from django.shortcuts import render,importfromsimple,414 Python Crash Course,from django.shortcuts import render,importfromsimple,415 Python Crash Course,from django.shortcuts import render,importfromsimple,419 Python Crash Course,from django import forms,importfromsimple,428 Python Crash Course,from django.shortcuts import render,importfromsimple,429 Python Crash Course,from django.http import HttpResponseRedirect,importfromsimple,429 Python Crash Course,from django.core.urlresolvers import reverse,importfromsimple,429 Python Crash Course,from django import forms,importfromsimple,432 Python Crash Course,from django.shortcuts import render,importfromsimple,433 Python Crash Course,from django.shortcuts import render,importfromsimple,436 Python Crash Course,from django.contrib import admin,importfromsimple,439 Python Crash Course,from django.conf.urls import url,importfromsimple,440 Python Crash Course,from django.contrib.auth.views import login,importfromsimple,440 Python Crash Course,from django.http import HttpResponseRedirect,importfromsimple,443 Python Crash Course,from django.core.urlresolvers import reverse,importfromsimple,443 Python Crash Course,from django.contrib.auth import logout,importfromsimple,443 Python Crash Course,from django.shortcuts import render,importfromsimple,444 Python Crash Course,from django.http import HttpResponseRedirect,importfromsimple,444 Python Crash Course,from django.core.urlresolvers import reverse,importfromsimple,444 Python Crash Course,from django.contrib.auth.forms import UserCreationForm,importfromsimple,444 Python Crash Course,from django.core.urlresolvers import reverse,importfromsimple,447 Python Crash Course,from django.contrib.auth.decorators import login_required,importfromsimple,447 Python Crash Course,from django.db import models,importfromsimple,449 Python Crash Course,from django.contrib.auth.models import User,importfromsimple,449 Python Crash Course,from django.contrib.auth.models import User,importfromsimple,449 Python Crash Course,from learning_logs.models import Topic,importfromsimple,450 Python Crash Course,from django.shortcuts import render,importfromsimple,452 Python Crash Course,from django.core.urlresolvers import reverse,importfromsimple,452 Python Crash Course,from django.core.wsgi import get_wsgi_application,importfromsimple,470 Python Crash Course,from dj_static import Cling,importfromsimple,470 Python Crash Course,self.age = age,simpleattr,162 Python Crash Course,self.name = name takes the value stored in the parameter name and stores it,simpleattr,163 Python Crash Course,self.make = make,simpleattr,167 Python Crash Course,self.model = model,simpleattr,167 Python Crash Course,self.year = year,simpleattr,167 Python Crash Course,self.make = make,simpleattr,168 Python Crash Course,self.model = model,simpleattr,168 Python Crash Course,self.year = year,simpleattr,168 Python Crash Course,self.odometer_reading = mileage,simpleattr,169 Python Crash Course,self.odometer_reading = mileage,simpleattr,170 Python Crash Course,self.odometer_reading += miles,simpleattr,170 Python Crash Course,self.make = make,simpleattr,172 Python Crash Course,self.model = model,simpleattr,172 Python Crash Course,self.year = year,simpleattr,172 Python Crash Course,self.odometer_reading = 0,simpleattr,172 Python Crash Course,self.odometer_reading += miles,simpleattr,172 Python Crash Course,self.battery_size = battery_size,simpleattr,175 Python Crash Course,self.make = make,simpleattr,179 Python Crash Course,self.model = model,simpleattr,179 Python Crash Course,self.year = year,simpleattr,179 Python Crash Course,self.odometer_reading = 0,simpleattr,179 Python Crash Course,self.odometer_reading += miles,simpleattr,179 Python Crash Course,self.battery_size = battery_size,simpleattr,180 Python Crash Course,self.battery = Battery(),simpleattr,181 Python Crash Course,self.question = question,simpleattr,223 Python Crash Course,self.responses = [],simpleattr,223 Python Crash Course,self.screen_width = 1200,simpleattr,243 Python Crash Course,self.screen_height = 800,simpleattr,243 Python Crash Course,"self.bg_color = (230, 230, 230)",simpleattr,243 Python Crash Course,self.screen = screen,simpleattr,245 Python Crash Course,self.rect.bottom = self.screen_rect.bottom,simpleattr,245 Python Crash Course,self.rect.centerx = self.screen_rect.centerx,simpleattr,251 Python Crash Course,self.rect.bottom = self.screen_rect.bottom,simpleattr,251 Python Crash Course,self.moving_right = False,simpleattr,252 Python Crash Course,self.moving_left = False,simpleattr,252 Python Crash Course,self.ship_speed_factor = 1.5,simpleattr,253 Python Crash Course,self.screen = screen,simpleattr,253 Python Crash Course,self.moving_right = False,simpleattr,253 Python Crash Course,self.moving_left = False,simpleattr,253 Python Crash Course,self.center += self.ai_settings.ship_speed_factor,simpleattr,255 Python Crash Course,self.center -= self.ai_settings.ship_speed_factor,simpleattr,255 Python Crash Course,self.rect.centerx = self.center,simpleattr,255 Python Crash Course,self.bullet_speed_factor = 1,simpleattr,257 Python Crash Course,self.bullet_width = 3,simpleattr,257 Python Crash Course,self.bullet_height = 15,simpleattr,257 Python Crash Course,"self.bullet_color = 60, 60, 60",simpleattr,257 Python Crash Course,self.screen = screen,simpleattr,258 Python Crash Course,self.speed_factor = ai_settings.bullet_speed_factor,simpleattr,258 Python Crash Course,self.bullet_width = 3,simpleattr,262 Python Crash Course,self.bullet_height = 15,simpleattr,262 Python Crash Course,"self.bullet_color = 60, 60, 60",simpleattr,262 Python Crash Course,self.bullets_allowed = 3,simpleattr,262 Python Crash Course,self.screen = screen,simpleattr,267 Python Crash Course,self.ai_settings = ai_settings,simpleattr,267 Python Crash Course,self.image = pygame.image.load('images/alien.bmp'),simpleattr,267 Python Crash Course,self.rect = self.image.get_rect(),simpleattr,267 Python Crash Course,self.rect.y = self.rect.height,simpleattr,267 Python Crash Course,self.x = float(self.rect.x),simpleattr,267 Python Crash Course,self.alien_speed_factor = 1,simpleattr,276 Python Crash Course,self.alien_speed_factor = 1,simpleattr,277 Python Crash Course,self.fleet_drop_speed = 10,simpleattr,277 Python Crash Course,self.fleet_direction = 1,simpleattr,277 Python Crash Course,self.x += (self.ai_settings.alien_speed_factor *,simpleattr,278 Python Crash Course,self.rect.x = self.x,simpleattr,278 Python Crash Course,self.bullet_speed_factor = 3,simpleattr,283 Python Crash Course,self.bullet_width = 3,simpleattr,283 Python Crash Course,self.ai_settings = ai_settings,simpleattr,285 Python Crash Course,self.ships_left = self.ai_settings.ship_limit,simpleattr,285 Python Crash Course,self.ship_speed_factor = 1.5,simpleattr,286 Python Crash Course,self.ship_limit = 3,simpleattr,286 Python Crash Course,self.center = self.screen_rect.centerx,simpleattr,287 Python Crash Course,self.game_active = True,simpleattr,288 Python Crash Course,self.ai_settings = ai_settings,simpleattr,292 Python Crash Course,self.game_active = False,simpleattr,292 Python Crash Course,self.screen = screen,simpleattr,292 Python Crash Course,self.screen_rect = screen.get_rect(),simpleattr,292 Python Crash Course,"self.button_color = (0, 255, 0)",simpleattr,292 Python Crash Course,"self.text_color = (255, 255, 255)",simpleattr,292 Python Crash Course,self.rect.center = self.screen_rect.center,simpleattr,292 Python Crash Course,self.msg_image_rect.center = self.rect.center,simpleattr,293 Python Crash Course,self.screen_width = 1200,simpleattr,299 Python Crash Course,self.screen_height = 800,simpleattr,299 Python Crash Course,"self.bg_color = (230, 230, 230)",simpleattr,299 Python Crash Course,self.ship_limit = 3,simpleattr,299 Python Crash Course,self.bullet_width = 3,simpleattr,299 Python Crash Course,self.bullet_height = 15,simpleattr,299 Python Crash Course,"self.bullet_color = 60, 60, 60",simpleattr,299 Python Crash Course,self.bullets_allowed = 3,simpleattr,299 Python Crash Course,self.fleet_drop_speed = 10,simpleattr,299 Python Crash Course,self.ship_speed_factor = 1.5,simpleattr,299 Python Crash Course,self.bullet_speed_factor = 3,simpleattr,299 Python Crash Course,self.alien_speed_factor = 1,simpleattr,300 Python Crash Course,self.fleet_direction = 1,simpleattr,300 Python Crash Course,self.ship_speed_factor *= self.speedup_scale,simpleattr,300 Python Crash Course,self.bullet_speed_factor *= self.speedup_scale,simpleattr,300 Python Crash Course,self.alien_speed_factor *= self.speedup_scale,simpleattr,300 Python Crash Course,self.ships_left = self.ai_settings.ship_limit,simpleattr,301 Python Crash Course,self.score = 0,simpleattr,301 Python Crash Course,self.screen = screen,simpleattr,301 Python Crash Course,self.screen_rect = screen.get_rect(),simpleattr,302 Python Crash Course,self.ai_settings = ai_settings,simpleattr,302 Python Crash Course,self.stats = stats,simpleattr,302 Python Crash Course,self.alien_points = 50,simpleattr,304 Python Crash Course,self.speedup_scale = 1.1,simpleattr,306 Python Crash Course,self.ship_speed_factor *= self.speedup_scale,simpleattr,306 Python Crash Course,self.bullet_speed_factor *= self.speedup_scale,simpleattr,306 Python Crash Course,self.alien_speed_factor *= self.speedup_scale,simpleattr,306 Python Crash Course,self.alien_points = int(self.alien_points * self.score_scale),simpleattr,307 Python Crash Course,"self.score_image = self.font.render(score_str, True, self.text_color,",simpleattr,307 Python Crash Course,self.high_score = 0,simpleattr,308 Python Crash Course,self.high_score_rect = self.high_score_image.get_rect(),simpleattr,309 Python Crash Course,self.ships_left = self.ai_settings.ship_limit,simpleattr,310 Python Crash Course,self.score = 0,simpleattr,310 Python Crash Course,self.level = 1,simpleattr,310 Python Crash Course,self.level_rect = self.level_image.get_rect(),simpleattr,311 Python Crash Course,self.num_points = num_points,simpleattr,332 Python Crash Course,self.y_values = [0],simpleattr,332 Python Crash Course,self.num_sides = num_sides,simpleattr,340 Python Crash Course,the operator += takes the string that was stored in prompt and adds the new,assignIncrement,119 Python Crash Course,current_number += 1,assignIncrement,122 Python Crash Course,with current_number += 1. (The += operator is shorthand for current_number =,assignIncrement,122 Python Crash Course,x += 1,assignIncrement,126 Python Crash Course,"But if you accidentally omit the line x += 1 (as shown next), the loop",assignIncrement,127 Python Crash Course,pi_string += line.rstrip(),assignIncrement,194 Python Crash Course,pi_string += line.strip(),assignIncrement,195 Python Crash Course,pi_string += line.strip(),assignIncrement,196 Python Crash Course,pi_string += line.rstrip(),assignIncrement,196 Python Crash Course,w ship.rect.centerx += 1,assignIncrement,250 Python Crash Course,x self.center += self.ai_settings.ship_speed_factor,assignIncrement,254 Python Crash Course,u self.x += self.ai_settings.alien_speed_factor,assignIncrement,276 Python Crash Course,v alien.rect.y += ai_settings.fleet_drop_speed,assignIncrement,279 Python Crash Course,u stats.score += ai_settings.alien_points,assignIncrement,305 Python Crash Course,stats.score += ai_settings.alien_points * len(aliens),assignIncrement,306 Python Crash Course,stats.score += ai_settings.alien_points * len(aliens),assignIncrement,309 Python Crash Course,u stats.level += 1,assignIncrement,311 Python Crash Course,"not), 78 += operator, 119",assignIncrement,515 Python Crash Course,"def describe_pet(pet_name, animal_type='dog'):",funcdefault,138 Python Crash Course,"def describe_pet(pet_name, animal_type='dog'):",funcdefault,139 Python Crash Course,"def get_formatted_name(first_name, last_name, middle_name=''):",funcdefault,143 Python Crash Course,"def build_person(first_name, last_name, age=''):",funcdefault,144 Python Crash Course,"def get_formatted_name(first, last, middle=''):",funcdefault,220 Python Crash Course,range(),rangefunc,61 Python Crash Course,range(),rangefunc,61 Python Crash Course,range(),rangefunc,61 Python Crash Course,range(),rangefunc,61 Python Crash Course,range(),rangefunc,61 Python Crash Course,"range(1,6)",rangefunc,61 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,range(),rangefunc,62 Python Crash Course,"range(1,11)",rangefunc,64 Python Crash Course,range(),rangefunc,64 Python Crash Course,range(),rangefunc,65 Python Crash Course,range(),rangefunc,109 Python Crash Course,range(),rangefunc,110 Python Crash Course,range(),rangefunc,177 Python Crash Course,range(),rangefunc,177 Python Crash Course,range(),rangefunc,177 Python Crash Course,range(),rangefunc,177 Python Crash Course,range() to the ElectricCar class. The get_range(),rangefunc,177 Python Crash Course,range(),rangefunc,178 Python Crash Course,range(),rangefunc,178 Python Crash Course,range(),rangefunc,178 Python Crash Course,range(),rangefunc,178 Python Crash Course,range(),rangefunc,181 Python Crash Course,range(),rangefunc,271 Python Crash Course,range(),rangefunc,335 Python Crash Course,"range(2, 13)",rangefunc,344 Python Crash Course,range() type(),rangefunc,490 Python Crash Course,range(),rangefunc,521 Python Crash Course,range(),rangefunc,523 Python Crash Course,def greet_user():,simplefunc,134 Python Crash Course,def greet_user(username):,simplefunc,134 Python Crash Course,def greet_users(names):,simplefunc,147 Python Crash Course,def show_completed_models(completed_models):,simplefunc,148 Python Crash Course,def sit(self):,simplefunc,162 Python Crash Course,def roll_over(self):,simplefunc,162 Python Crash Course,def get_descriptive_name(self):,simplefunc,167 Python Crash Course,def get_descriptive_name(self):,simplefunc,168 Python Crash Course,def read_odometer(self):,simplefunc,168 Python Crash Course,def get_descriptive_name(self):,simplefunc,172 Python Crash Course,def read_odometer(self):,simplefunc,172 Python Crash Course,def describe_battery(self):,simplefunc,174 Python Crash Course,def ElectricCar(Car):,simplefunc,175 Python Crash Course,def fill_gas_tank():,simplefunc,175 Python Crash Course,def describe_battery(self):,simplefunc,176 Python Crash Course,def get_range(self):,simplefunc,177 Python Crash Course,def get_descriptive_name(self):,simplefunc,179 Python Crash Course,def read_odometer(self):,simplefunc,179 Python Crash Course,def describe_battery(self):,simplefunc,180 Python Crash Course,def get_range(self):,simplefunc,180 Python Crash Course,def count_words(filename):,simplefunc,205 Python Crash Course,def count_words(filename):,simplefunc,206 Python Crash Course,def count_words(filename):,simplefunc,206 Python Crash Course,def greet_user():,simplefunc,212 Python Crash Course,def greet_user():,simplefunc,213 Python Crash Course,def get_stored_username():,simplefunc,213 Python Crash Course,def get_new_username():,simplefunc,213 Python Crash Course,def greet_user():,simplefunc,213 Python Crash Course,def test_first_last_name(self):,simplefunc,217 Python Crash Course,def test_first_last_name(self):,simplefunc,221 Python Crash Course,def test_first_last_middle_name(self):,simplefunc,221 Python Crash Course,def show_question(self):,simplefunc,223 Python Crash Course,def show_results(self):,simplefunc,223 Python Crash Course,def test_store_single_response(self):,simplefunc,225 Python Crash Course,def test_store_single_response(self):,simplefunc,226 Python Crash Course,def test_store_three_responses(self):,simplefunc,226 Python Crash Course,def setUp(self):,simplefunc,227 Python Crash Course,def test_store_single_response(self):,simplefunc,227 Python Crash Course,def test_store_three_responses(self):,simplefunc,227 Python Crash Course,def run_game():,simplefunc,241 Python Crash Course,def run_game():,simplefunc,242 Python Crash Course,def run_game():,simplefunc,243 Python Crash Course,def blitme(self):,simplefunc,245 Python Crash Course,def run_game():,simplefunc,246 Python Crash Course,def check_events():,simplefunc,247 Python Crash Course,def run_game():,simplefunc,248 Python Crash Course,def check_events():,simplefunc,248 Python Crash Course,def check_events(ship):,simplefunc,250 Python Crash Course,def update(self):,simplefunc,251 Python Crash Course,def blitme(self):,simplefunc,251 Python Crash Course,def check_events(ship):,simplefunc,251 Python Crash Course,def update(self):,simplefunc,252 Python Crash Course,def check_events(ship):,simplefunc,252 Python Crash Course,def update(self):,simplefunc,254 Python Crash Course,def blitme(self):,simplefunc,254 Python Crash Course,def run_game():,simplefunc,254 Python Crash Course,def update(self):,simplefunc,255 Python Crash Course,def check_events(ship):,simplefunc,256 Python Crash Course,def update(self):,simplefunc,259 Python Crash Course,def draw_bullet(self):,simplefunc,259 Python Crash Course,def run_game():,simplefunc,259 Python Crash Course,def update_bullets(bullets):,simplefunc,263 Python Crash Course,def blitme(self):,simplefunc,267 Python Crash Course,def run_game():,simplefunc,268 Python Crash Course,def run_game():,simplefunc,270 Python Crash Course,def update(self):,simplefunc,276 Python Crash Course,def update_aliens(aliens):,simplefunc,277 Python Crash Course,def check_edges(self):,simplefunc,278 Python Crash Course,def update(self):,simplefunc,278 Python Crash Course,def reset_stats(self):,simplefunc,285 Python Crash Course,def run_game():,simplefunc,286 Python Crash Course,def center_ship(self):,simplefunc,287 Python Crash Course,def reset_stats(self):,simplefunc,292 Python Crash Course,def draw_button(self):,simplefunc,293 Python Crash Course,def run_game():,simplefunc,294 Python Crash Course,def initialize_dynamic_settings(self):,simplefunc,299 Python Crash Course,def increase_speed(self):,simplefunc,300 Python Crash Course,def reset_stats(self):,simplefunc,301 Python Crash Course,def prep_score(self):,simplefunc,302 Python Crash Course,def show_score(self):,simplefunc,302 Python Crash Course,def run_game():,simplefunc,303 Python Crash Course,def initialize_dynamic_settings(self):,simplefunc,304 Python Crash Course,def increase_speed(self):,simplefunc,306 Python Crash Course,def increase_speed(self):,simplefunc,307 Python Crash Course,def prep_score(self):,simplefunc,307 Python Crash Course,def prep_high_score(self):,simplefunc,308 Python Crash Course,def show_score(self):,simplefunc,309 Python Crash Course,def reset_stats(self):,simplefunc,310 Python Crash Course,def prep_level(self):,simplefunc,311 Python Crash Course,def show_score(self):,simplefunc,311 Python Crash Course,def prep_ships(self):,simplefunc,314 Python Crash Course,def show_score(self):,simplefunc,314 Python Crash Course,def fill_walk(self):,simplefunc,332 Python Crash Course,def roll(self):,simplefunc,340 Python Crash Course,def get_country_code(country_name):,simplefunc,365 Python Crash Course,def __str__(self):,simplefunc,404 Python Crash Course,def __str__(self):,simplefunc,408 Python Crash Course,def index(request):,simplefunc,415 Python Crash Course,def index(request):,simplefunc,419 Python Crash Course,def topics(request):,simplefunc,419 Python Crash Course,def new_topic(request):,simplefunc,429 Python Crash Course,def logout_view(request):,simplefunc,443 Python Crash Course,def logout_view(request):,simplefunc,444 Python Crash Course,def register(request):,simplefunc,444 Python Crash Course,def __str__(self):,simplefunc,449 Python Crash Course,return to a terminal,return,5 Python Crash Course,return to continue,return,7 Python Crash Course,return to a terminal,return,8 Python Crash Course,return to continue,return,14 Python Crash Course,"return to a project after some time away, you’ll likely have forgot-",return,33 Python Crash Course,return ele-,return,65 Python Crash Course,return True no matter how the value 'Audi' is formatted,return,77 Python Crash Course,return items in a certain order is to sort the keys as they’re,return,106 Python Crash Course,return a list of values without any keys.,return,107 Python Crash Course,return to the beginning of the,return,126 Python Crash Course,return a,return,133 Python Crash Course,return a value or set of values. The value the,return,141 Python Crash Course,return value. The return statement takes a value,return,141 Python Crash Course,return full_name.title(),return,142 Python Crash Course,"return value can be stored. In this case, the returned",return,142 Python Crash Course,return full_name.title(),return,142 Python Crash Course,return full_name.title(),return,143 Python Crash Course,"return any kind of value you need it to, including more com-",return,144 Python Crash Course,return person,return,144 Python Crash Course,"return value is printed at w with the original two pieces of textual information",return,144 Python Crash Course,return person,return,144 Python Crash Course,return full_name.title(),return,145 Python Crash Course,return a string formatted like this:,return,146 Python Crash Course,return a dictionary containing these two pieces of,return,146 Python Crash Course,return value to show that the dictionaries are storing the,return,146 Python Crash Course,return the new list and store it in a separate list.,return,150 Python Crash Course,return profile,return,153 Python Crash Course,return the profile dictionary to the function call line.,return,153 Python Crash Course,return values. You learned how to use functions,return,159 Python Crash Course,"return statement, but Python automatically returns an instance representing this",return,164 Python Crash Course,return long_name.title(),return,167 Python Crash Course,return long_name.title(),return,172 Python Crash Course,return long_name.title(),return,179 Python Crash Course,"return the value you’re expecting, or it should return None. This allows us to per-",return,213 Python Crash Course,return value of the function. At w we print a,return,213 Python Crash Course,return username,return,213 Python Crash Course,return full_name.title(),return,216 Python Crash Course,return value that we’re interested in testing. In,return,218 Python Crash Course,"return a capitalized, properly spaced full name, we expect",return,218 Python Crash Course,return full_name.title(),return,219 Python Crash Course,return full_name.title(),return,220 Python Crash Course,return a single string of the form,return,222 Python Crash Course,"return a single string of the form City, Country –",return,222 Python Crash Course,return number_aliens_x,return,273 Python Crash Course,return number_rows,return,274 Python Crash Course,return True,return,278 Python Crash Course,return True,return,278 Python Crash Course,return any changed settings to their initial values each time the,return,300 Python Crash Course,return the bullet width to normal.,return,306 Python Crash Course,"return randint(1, self.num_sides)",return,340 Python Crash Course,return a random num-,return,340 Python Crash Course,return the start-,return,340 Python Crash Course,return code,return,366 Python Crash Course,return None.,return,366 Python Crash Course,return None,return,366 Python Crash Course,return None if the country,return,366 Python Crash Course,return 'ye',return,375 Python Crash Course,return None state-,return,375 Python Crash Course,return to any previously working state. (To learn more about ver-,return,378 Python Crash Course,"return a complete set of results, so it’s pretty safe to ignore",return,380 Python Crash Course,return self.text,return,404 Python Crash Course,"return self.text[:50] + ""...""",return,408 Python Crash Course,return an error page if the URL,return,414 Python Crash Course,"return render(request, 'learning_logs/index.html')",return,415 Python Crash Course,return this page. Here’s how we modify learning_logs/urls.py:,return,419 Python Crash Course,"return render(request, 'learning_logs/topics.html', context)",return,419 Python Crash Course,"return render(request, 'learning_logs/topic.html', context)",return,422 Python Crash Course,return HttpResponseRedirect(reverse('learning_logs:topics')),return,429 Python Crash Course,"return render(request, 'learning_logs/new_topic.html', context)",return,429 Python Crash Course,"return a blank form (if it’s another kind of request, it’s still safe to return",return,430 Python Crash Course,"return HttpResponseRedirect(reverse('learning_logs:topic',",return,433 Python Crash Course,"return render(request, 'learning_logs/new_entry.html', context)",return,433 Python Crash Course,"return a form for editing the entry. When the page receives a POST request with",return,436 Python Crash Course,"return HttpResponseRedirect(reverse('learning_logs:topic',",return,436 Python Crash Course,"return render(request, 'learning_logs/edit_entry.html', context)",return,436 Python Crash Course,return HttpResponseRedirect(reverse('learning_logs:index')),return,443 Python Crash Course,return HttpResponseRedirect(reverse('learning_logs:index')),return,444 Python Crash Course,"return render(request, 'users/register.html', context)",return,444 Python Crash Course,return self.text,return,449 Python Crash Course,"return render(request, 'learning_logs/topics.html', context)",return,451 Python Crash Course,"return render(request, 'learning_logs/topic.html', context)",return,452 Python Crash Course,return HttpResponseRedirect(reverse('learning_logs:topics')),return,453 Python Crash Course,"return render(request, 'learning_logs/new_topic.html', context)",return,453 Python Crash Course,return to the last working snapshot of your project if anything goes wrong;,return,471 Python Crash Course,return to your local system’s terminal,return,475 Python Crash Course,return a 404 error if the user,return,478 Python Crash Course,"return None continue for lambda try",return,489 Python Crash Course,return to continue,return,493 Python Crash Course,"return to a previously saved state.",return,506 Python Crash Course,"return to your text editor, you’ll see that hello_world.py has",return,511 Python Crash Course,return to the latest commit or abandon your recent work and pick up devel-,return,512 Python Crash Course,"return values, 141–146",return,519 Python Crash Course,"return values, 141",return,524 Python Crash Course,"if you run this code, you’ll see that it generates an error:",simpleif,31 Python Crash Course,if car == 'bmw':,simpleif,76 Python Crash Course,if the person did not order anchovies:,simpleif,78 Python Crash Course,if requested_topping != 'anchovies':,simpleif,78 Python Crash Course,if the given answer is not correct:,simpleif,79 Python Crash Course,if user not in banned_users:,simpleif,81 Python Crash Course,if statement has one test and one action:,simpleif,82 Python Crash Course,"if conditional_test: do something",simpleif,82 Python Crash Course,if the individual has registered to vote yet:,simpleif,83 Python Crash Course,"if age >= 18: print(""You are old enough to vote!"")",simpleif,83 Python Crash Course,if age < 4:,simpleif,84 Python Crash Course,if age < 18:,simpleif,85 Python Crash Course,if age < 4:,simpleif,85 Python Crash Course,"if age < 18: v price = 5",simpleif,85 Python Crash Course,"if age < 4: price = 0",simpleif,86 Python Crash Course,"if age < 18: price = 5",simpleif,86 Python Crash Course,"if age < 65: price = 10",simpleif,86 Python Crash Course,if statement that catches the specific condition of interest:,simpleif,86 Python Crash Course,"if age < 4: price = 0",simpleif,86 Python Crash Course,"if age < 18: price = 5",simpleif,86 Python Crash Course,"if age < 65: price = 10",simpleif,86 Python Crash Course,if requested_topping == 'green peppers':,simpleif,90 Python Crash Course,if requested_toppings:,simpleif,91 Python Crash Course,if requested_topping in available_toppings:,simpleif,92 Python Crash Course,if age < 4:,simpleif,94 Python Crash Course,if age<4:,simpleif,94 Python Crash Course,if alien_0['speed'] == 'slow':,simpleif,99 Python Crash Course,"if you had used abbreviations for the variable names, like this:",simpleif,103 Python Crash Course,if name in friends:,simpleif,105 Python Crash Course,if Erin took the poll:,simpleif,106 Python Crash Course,"if alien['color'] == 'green': alien['color'] = 'yellow'",simpleif,110 Python Crash Course,"if alien['color'] == 'green': alien['color'] = 'yellow'",simpleif,111 Python Crash Course,"if alien['color'] == 'yellow': alien['color'] = 'red'",simpleif,111 Python Crash Course,"if you try to use the input as a number, you’ll get an error:",simpleif,119 Python Crash Course,if a number is even or odd:,simpleif,121 Python Crash Course,if test fixes this:,simpleif,123 Python Crash Course,"if message != 'quit': print(message)",simpleif,123 Python Crash Course,if it does not match the quit value:,simpleif,124 Python Crash Course,"if repeat == 'no': polling_active = False",simpleif,130 Python Crash Course,if middle_name:,simpleif,143 Python Crash Course,"if age: person['age'] = age",simpleif,144 Python Crash Course,if the function receives only one value:,simpleif,151 Python Crash Course,"if mileage >= self.odometer_reading: self.odometer_reading = mileage",simpleif,172 Python Crash Course,"if self.battery_size == 70: range = 240",simpleif,177 Python Crash Course,"if mileage >= self.odometer_reading: self.odometer_reading = mileage",simpleif,179 Python Crash Course,"if self.battery_size == 70: range = 240",simpleif,181 Python Crash Course,if birthday in pi_string:,simpleif,196 Python Crash Course,if username:,simpleif,213 Python Crash Course,"if username: print(""Welcome back, "" + username + ""!"")",simpleif,213 Python Crash Course,"if middle: full_name = first + ' ' + middle + ' ' + last",simpleif,220 Python Crash Course,if you’re running Python 2.7):,simpleif,240 Python Crash Course,"if event.type == pygame.QUIT: sys.exit()",simpleif,247 Python Crash Course,"if event.type == pygame.QUIT: sys.exit()",simpleif,250 Python Crash Course,"if self.moving_right: self.rect.centerx += 1",simpleif,251 Python Crash Course,if event.key == pygame.K_RIGHT:,simpleif,251 Python Crash Course,"if event.key == pygame.K_RIGHT: ship.moving_right = False",simpleif,251 Python Crash Course,"if self.moving_right: self.rect.centerx += 1",simpleif,252 Python Crash Course,"if self.moving_left: self.rect.centerx -= 1",simpleif,252 Python Crash Course,"if event.key == pygame.K_RIGHT: ship.moving_right = True",simpleif,252 Python Crash Course,"if event.key == pygame.K_RIGHT: ship.moving_right = False",simpleif,252 Python Crash Course,if self.moving_right:,simpleif,254 Python Crash Course,"if self.moving_left: self.center -= self.ai_settings.ship_speed_factor",simpleif,254 Python Crash Course,if self.moving_right and self.rect.right < self.screen_rect.right:,simpleif,255 Python Crash Course,if self.moving_left and self.rect.left > 0:,simpleif,255 Python Crash Course,"if event.key == pygame.K_RIGHT: ship.moving_right = True",simpleif,255 Python Crash Course,"if event.key == pygame.K_RIGHT: ship.moving_right = False",simpleif,255 Python Crash Course,"if event.type == pygame.QUIT: sys.exit()",simpleif,256 Python Crash Course,"if len(bullets) < ai_settings.bullets_allowed: new_bullet = Bullet(ai_settings, screen, ship)",simpleif,263 Python Crash Course,"if bullet.rect.bottom <= 0: bullets.remove(bullet)",simpleif,263 Python Crash Course,"if len(bullets) < ai_settings.bullets_allowed: new_bullet = Bullet(ai_settings, screen, ship)",simpleif,264 Python Crash Course,"if alien.check_edges(): change_fleet_direction(ai_settings, aliens)",simpleif,278 Python Crash Course,"if bullet.rect.bottom <= 0: bullets.remove(bullet)",simpleif,283 Python Crash Course,"if len(aliens) == 0: # Destroy existing bullets and create new fleet.",simpleif,284 Python Crash Course,"if pygame.sprite.spritecollideany(ship, aliens): v print(""Ship hit!!!"")",simpleif,284 Python Crash Course,"if pygame.sprite.spritecollideany(ship, aliens): ship_hit(ai_settings, stats, screen, ship, aliens, bullets)",simpleif,287 Python Crash Course,"if stats.ships_left > 0: # Decrement ships_left.",simpleif,289 Python Crash Course,"if not stats.game_active: play_button.draw_button()",simpleif,294 Python Crash Course,"if event.type == pygame.QUIT: --snip--",simpleif,295 Python Crash Course,"if play_button.rect.collidepoint(mouse_x, mouse_y):",simpleif,295 Python Crash Course,"if play_button.rect.collidepoint(mouse_x, mouse_y): # Reset the game statistics.",simpleif,296 Python Crash Course,"if event.type == pygame.QUIT: --snip--",simpleif,297 Python Crash Course,if button_clicked and not stats.game_active:,simpleif,297 Python Crash Course,"if button_clicked and not stats.game_active: # Hide the mouse cursor.",simpleif,298 Python Crash Course,"if stats.ships_left > 0: --snip--",simpleif,298 Python Crash Course,"if len(aliens) == 0: # Destroy existing bullets, speed up game, and create new fleet.",simpleif,300 Python Crash Course,"if button_clicked and not stats.game_active: # Reset the game settings.",simpleif,300 Python Crash Course,"if not stats.game_active: play_button.draw_button()",simpleif,303 Python Crash Course,if collisions:,simpleif,305 Python Crash Course,"if stats.game_active: ship.update()",simpleif,305 Python Crash Course,if collisions:,simpleif,306 Python Crash Course,"if stats.score > stats.high_score: stats.high_score = stats.score",simpleif,309 Python Crash Course,"if collisions: for aliens in collisions.values():",simpleif,309 Python Crash Course,"if len(aliens) == 0: # If the entire fleet is destroyed, start a new level.",simpleif,311 Python Crash Course,if button_clicked and not stats.game_active:,simpleif,311 Python Crash Course,"if event.type == pygame.QUIT: --snip--",simpleif,312 Python Crash Course,"if button_clicked and not stats.game_active: --snip--",simpleif,315 Python Crash Course,"if pygame.sprite.spritecollideany(ship, aliens):",simpleif,315 Python Crash Course,"if stats.ships_left > 0: # Decrement ships_left.",simpleif,315 Python Crash Course,"if alien.rect.bottom >= screen_rect.bottom: # Treat this the same as if a ship got hit.",simpleif,316 Python Crash Course,"if stats.game_active: ship.update()",simpleif,316 Python Crash Course,"if pop_dict['Year'] == '2010': x country_name = pop_dict['Country Name']",simpleif,363 Python Crash Course,"if pop_dict['Year'] == '2010': country_name = pop_dict['Country Name']",simpleif,364 Python Crash Course,"if pop_dict['Year'] == '2010': country = pop_dict['Country Name']",simpleif,364 Python Crash Course,"if pop_dict['Year'] == '2010': country_name = pop_dict['Country Name']",simpleif,366 Python Crash Course,if code:,simpleif,366 Python Crash Course,"if pop_dict['Year'] == '2010': country = pop_dict['Country Name']",simpleif,369 Python Crash Course,if code:,simpleif,370 Python Crash Course,"if pop_dict['Year'] == '2010': --snip--",simpleif,371 Python Crash Course,"if code: cc_populations[code] = population",simpleif,371 Python Crash Course,"if pop < 10000000: cc_pops_1[cc] = pop",simpleif,371 Python Crash Course,"if pop < 1000000000: cc_pops_2[cc] = pop",simpleif,371 Python Crash Course,"if pop < 10000000: --snip--",simpleif,373 Python Crash Course,if no entries have been made yet for this topic:,simpleif,423 Python Crash Course,if request.method != 'POST':,simpleif,429 Python Crash Course,"if form.is_valid(): y form.save()",simpleif,429 Python Crash Course,if request.method != 'POST':,simpleif,433 Python Crash Course,if form.is_valid():,simpleif,433 Python Crash Course,"if request.method != 'POST': # Initial request; pre-fill form with the current entry.",simpleif,436 Python Crash Course,if form.is_valid():,simpleif,436 Python Crash Course,"if request.method != 'POST': # Display blank registration form.",simpleif,444 Python Crash Course,"if form.is_valid(): x new_user = form.save()",simpleif,444 Python Crash Course,"if topic.owner != request.user: raise Http404",simpleif,452 Python Crash Course,"if request.method != 'POST': # Initial request; pre-fill form with the current entry.",simpleif,453 Python Crash Course,"if request.method != 'POST': # No data submitted; create a blank form.",simpleif,453 Python Crash Course,if form.is_valid():,simpleif,453 Python Crash Course,if it’s available:,simpleif,467 Python Crash Course,"if os.getcwd() == '/app': v import dj_database_url",simpleif,469 Python Crash Course,"if os.getcwd() == '/app': --snip--",simpleif,476 Python Crash Course,"print(""Hello Python interpreter!"")",printfunc,4 Python Crash Course,"print(""Hello world!"")",printfunc,4 Python Crash Course,"print(""Hello Python world!"")",printfunc,6 Python Crash Course,"print(""Hello Python interpreter!"")",printfunc,8 Python Crash Course,"print(""Hello Python interpreter!"")",printfunc,9 Python Crash Course,"print(""Hello Python world!"")",printfunc,10 Python Crash Course,"print(""Hello Python world!"")",printfunc,12 Python Crash Course,"print(""Hello Python world!"")",printfunc,13 Python Crash Course,"print(""Hello Python world!"")",printfunc,19 Python Crash Course,print(message),printfunc,20 Python Crash Course,print(message),printfunc,20 Python Crash Course,print(message),printfunc,20 Python Crash Course,print(mesage),printfunc,22 Python Crash Course,print(mesage),printfunc,22 Python Crash Course,print(mesage),printfunc,22 Python Crash Course,print(name.title()),printfunc,24 Python Crash Course,print(),printfunc,24 Python Crash Course,print(name.upper()),printfunc,24 Python Crash Course,print(name.lower()),printfunc,24 Python Crash Course,print(full_name),printfunc,25 Python Crash Course,"print(""Hello, "" + full_name.title() + ""!"")",printfunc,25 Python Crash Course,print(message),printfunc,25 Python Crash Course,"print(""Python"")",printfunc,26 Python Crash Course,"print(""\tPython"")",printfunc,26 Python Crash Course,"print(""Languages:\nPython\nC\nJavaScript"")",printfunc,26 Python Crash Course,"print(""Languages:\n\tPython\n\tC\n\tJavaScript"")",printfunc,26 Python Crash Course,print(message),printfunc,28 Python Crash Course,print(message),printfunc,28 Python Crash Course,print(message),printfunc,31 Python Crash Course,print(message),printfunc,32 Python Crash Course,print(5 + 3),printfunc,33 Python Crash Course,"print(""Hello Python people!"")",printfunc,33 Python Crash Course,print(bicycles),printfunc,38 Python Crash Course,print(bicycles[0]),printfunc,38 Python Crash Course,print(bicycles[0].title()),printfunc,38 Python Crash Course,print(bicycles[1]),printfunc,39 Python Crash Course,print(bicycles[3]),printfunc,39 Python Crash Course,print(bicycles[-1]),printfunc,39 Python Crash Course,print(message),printfunc,39 Python Crash Course,print(motorcycles),printfunc,41 Python Crash Course,print(motorcycles),printfunc,41 Python Crash Course,print(motorcycles),printfunc,41 Python Crash Course,print(motorcycles),printfunc,41 Python Crash Course,print(motorcycles),printfunc,42 Python Crash Course,print(motorcycles),printfunc,42 Python Crash Course,print(motorcycles),printfunc,43 Python Crash Course,print(motorcycles),printfunc,43 Python Crash Course,print(motorcycles),printfunc,43 Python Crash Course,print(motorcycles),printfunc,43 Python Crash Course,print(motorcycles),printfunc,44 Python Crash Course,print(motorcycles),printfunc,44 Python Crash Course,print(popped_motorcycle),printfunc,44 Python Crash Course,"print(""The last motorcycle I owned was a "" + last_owned.title() + ""."")",printfunc,44 Python Crash Course,print('The first motorcycle I owned was a ' + first_owned.title() + '.'),printfunc,44 Python Crash Course,print(motorcycles),printfunc,45 Python Crash Course,print(motorcycles),printfunc,45 Python Crash Course,print(motorcycles),printfunc,45 Python Crash Course,print(motorcycles),printfunc,45 Python Crash Course,"print(""\nA "" + too_expensive.title() + "" is too expensive for me."")",printfunc,45 Python Crash Course,print(cars),printfunc,47 Python Crash Course,print(cars),printfunc,48 Python Crash Course,"print(""Here is the original list:"")",printfunc,48 Python Crash Course,print(cars),printfunc,48 Python Crash Course,"print(""\nHere is the sorted list:"")",printfunc,48 Python Crash Course,print(sorted(cars)),printfunc,48 Python Crash Course,"print(""\nHere is the original list again:"")",printfunc,48 Python Crash Course,print(cars),printfunc,48 Python Crash Course,print(cars),printfunc,49 Python Crash Course,print(cars),printfunc,49 Python Crash Course,print(motorcycles[3]),printfunc,50 Python Crash Course,print(motorcycles[3]),printfunc,51 Python Crash Course,print(motorcycles[-1]),printfunc,51 Python Crash Course,print(motorcycles[-1]),printfunc,51 Python Crash Course,print(motorcycles[-1]),printfunc,51 Python Crash Course,print(magician),printfunc,54 Python Crash Course,print(magician),printfunc,54 Python Crash Course,print(magician),printfunc,54 Python Crash Course,"print(magician.title() + "", that was a great trick!"")",printfunc,55 Python Crash Course,"print(magician.title() + "", that was a great trick!"")",printfunc,56 Python Crash Course,"print(""I can't wait to see your next trick, "" + magician.title() + "".\n"")",printfunc,56 Python Crash Course,"print(magician.title() + "", that was a great trick!"")",printfunc,56 Python Crash Course,"print(""I can't wait to see your next trick, "" + magician.title() + "".\n"")",printfunc,56 Python Crash Course,"print(""Thank you, everyone. That was a great magic show!"")",printfunc,56 Python Crash Course,print(magician),printfunc,57 Python Crash Course,print(magician),printfunc,58 Python Crash Course,"print(magician.title() + "", that was a great trick!"")",printfunc,58 Python Crash Course,"print(""I can't wait to see your next trick, "" + magician.title() + "".\n"")",printfunc,58 Python Crash Course,print(message),printfunc,59 Python Crash Course,print(message),printfunc,59 Python Crash Course,"print(magician.title() + "", that was a great trick!"")",printfunc,59 Python Crash Course,"print(""I can't wait to see your next trick, "" + magician.title() + "".\n"")",printfunc,59 Python Crash Course,"print(""Thank you everyone, that was a great magic show!"")",printfunc,59 Python Crash Course,print(magician),printfunc,60 Python Crash Course,print(value),printfunc,61 Python Crash Course,print(value),printfunc,61 Python Crash Course,print(numbers),printfunc,62 Python Crash Course,print(even_numbers),printfunc,62 Python Crash Course,print(squares),printfunc,62 Python Crash Course,print(squares),printfunc,63 Python Crash Course,print(squares),printfunc,64 Python Crash Course,print(players[0:3]),printfunc,65 Python Crash Course,print(players[1:4]),printfunc,65 Python Crash Course,print(players[:4]),printfunc,65 Python Crash Course,print(players[2:]),printfunc,66 Python Crash Course,print(players[-3:]),printfunc,66 Python Crash Course,"print(""Here are the first three players on my team:"")",printfunc,66 Python Crash Course,print(player.title()),printfunc,66 Python Crash Course,"print(""My favorite foods are:"")",printfunc,67 Python Crash Course,print(my_foods),printfunc,67 Python Crash Course,"print(""\nMy friend's favorite foods are:"")",printfunc,67 Python Crash Course,print(friend_foods),printfunc,67 Python Crash Course,"print(""My favorite foods are:"")",printfunc,67 Python Crash Course,print(my_foods),printfunc,67 Python Crash Course,"print(""\nMy friend's favorite foods are:"")",printfunc,68 Python Crash Course,print(friend_foods),printfunc,68 Python Crash Course,"print(""My favorite foods are:"")",printfunc,68 Python Crash Course,print(my_foods),printfunc,68 Python Crash Course,"print(""\nMy friend's favorite foods are:"")",printfunc,68 Python Crash Course,print(friend_foods),printfunc,68 Python Crash Course,print(dimensions[0]),printfunc,70 Python Crash Course,print(dimensions[1]),printfunc,70 Python Crash Course,print(dimension),printfunc,70 Python Crash Course,"print(""Original dimensions:"")",printfunc,71 Python Crash Course,print(dimension),printfunc,71 Python Crash Course,"print(""\nModified dimensions:"")",printfunc,71 Python Crash Course,print(dimension),printfunc,71 Python Crash Course,print(car.upper()),printfunc,76 Python Crash Course,print(car.title()),printfunc,76 Python Crash Course,"print(""Hold the anchovies!"")",printfunc,78 Python Crash Course,"print(""That is not the correct answer. Please try again!"")",printfunc,79 Python Crash Course,"print(user.title() + "", you can post a response if you wish."")",printfunc,81 Python Crash Course,"print(""Is car == 'subaru'? I predict True."")",printfunc,82 Python Crash Course,print(car == 'subaru'),printfunc,82 Python Crash Course,"print(""\nIs car == 'audi'? I predict False."")",printfunc,82 Python Crash Course,print(car == 'audi'),printfunc,82 Python Crash Course,"print(""You are old enough to vote!"")",printfunc,83 Python Crash Course,"print(""Have you registered to vote yet?"")",printfunc,83 Python Crash Course,"print(""You are old enough to vote!"")",printfunc,84 Python Crash Course,"print(""Have you registered to vote yet?"")",printfunc,84 Python Crash Course,"print(""Sorry, you are too young to vote."")",printfunc,84 Python Crash Course,"print(""Please register to vote as soon as you turn 18!"")",printfunc,84 Python Crash Course,"print(""Your admission cost is $0."")",printfunc,84 Python Crash Course,"print(""Your admission cost is $5."")",printfunc,85 Python Crash Course,"print(""Your admission cost is $10."")",printfunc,85 Python Crash Course,"print(""Your admission cost is $"" + str(price) + ""."")",printfunc,85 Python Crash Course,"print(""Your admission cost is $"" + str(price) + ""."")",printfunc,86 Python Crash Course,"print(""Your admission cost is $"" + str(price) + ""."")",printfunc,86 Python Crash Course,"print(""Adding mushrooms."")",printfunc,87 Python Crash Course,"print(""Adding pepperoni."")",printfunc,87 Python Crash Course,"print(""Adding extra cheese."")",printfunc,87 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,87 Python Crash Course,"print(""Adding mushrooms."")",printfunc,88 Python Crash Course,"print(""Adding pepperoni."")",printfunc,88 Python Crash Course,"print(""Adding extra cheese."")",printfunc,88 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,88 Python Crash Course,"print(""Adding "" + requested_topping + ""."")",printfunc,90 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,90 Python Crash Course,"print(""Sorry, we are out of green peppers right now."")",printfunc,90 Python Crash Course,"print(""Adding "" + requested_topping + ""."")",printfunc,90 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,90 Python Crash Course,"print(""Adding "" + requested_topping + ""."")",printfunc,91 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,91 Python Crash Course,"print(""Are you sure you want a plain pizza?"")",printfunc,91 Python Crash Course,"print(""Adding "" + requested_topping + ""."")",printfunc,92 Python Crash Course,"print(""Sorry, we don't have "" + requested_topping + ""."")",printfunc,92 Python Crash Course,"print(""\nFinished making your pizza!"")",printfunc,92 Python Crash Course,print(alien_0['color']),printfunc,96 Python Crash Course,print(alien_0['points']),printfunc,96 Python Crash Course,print(alien_0['color']),printfunc,97 Python Crash Course,"print(""You just earned "" + str(new_points) + "" points!"")",printfunc,97 Python Crash Course,print(alien_0),printfunc,98 Python Crash Course,print(alien_0),printfunc,98 Python Crash Course,print(alien_0),printfunc,98 Python Crash Course,"print(""The alien is "" + alien_0['color'] + ""."")",printfunc,99 Python Crash Course,"print(""The alien is now "" + alien_0['color'] + ""."")",printfunc,99 Python Crash Course,"print(""Original x-position: "" + str(alien_0['x_position']))",printfunc,99 Python Crash Course,"print(""New x-position: "" + str(alien_0['x_position']))",printfunc,99 Python Crash Course,print(alien_0),printfunc,100 Python Crash Course,print(alien_0),printfunc,100 Python Crash Course,"print(""\nKey: "" + key)",printfunc,103 Python Crash Course,"print(""Value: "" + value)",printfunc,103 Python Crash Course,print(name.title(),printfunc,104 Python Crash Course,print(name.title()),printfunc,105 Python Crash Course,print(name.title()),printfunc,105 Python Crash Course,"print("" Hi "" + name.title()",printfunc,105 Python Crash Course,"print(""Erin, please take our poll!"")",printfunc,106 Python Crash Course,"print(name.title() + "", thank you for taking the poll."")",printfunc,106 Python Crash Course,"print(""The following languages have been mentioned:"")",printfunc,107 Python Crash Course,print(language.title()),printfunc,107 Python Crash Course,"print(""The following languages have been mentioned:"")",printfunc,108 Python Crash Course,print(language.title()),printfunc,108 Python Crash Course,print(alien),printfunc,109 Python Crash Course,print(alien),printfunc,109 Python Crash Course,"print(""..."")",printfunc,109 Python Crash Course,"print(""Total number of aliens: "" + str(len(aliens)))",printfunc,109 Python Crash Course,print(alien),printfunc,110 Python Crash Course,"print(""..."")",printfunc,110 Python Crash Course,"print(""\t"" + topping)",printfunc,112 Python Crash Course,"print(""\n"" + name.title() + ""'s favorite languages are:"")",printfunc,112 Python Crash Course,"print(""\t"" + language.title())",printfunc,112 Python Crash Course,"print(""\nUsername: "" + username)",printfunc,114 Python Crash Course,"print(""\tFull name: "" + full_name.title())",printfunc,114 Python Crash Course,"print(""\tLocation: "" + location.title())",printfunc,114 Python Crash Course,print(message),printfunc,118 Python Crash Course,print(message),printfunc,118 Python Crash Course,"print(""Hello, "" + name + ""!"")",printfunc,118 Python Crash Course,"print(""\nHello, "" + name + ""!"")",printfunc,119 Python Crash Course,"print(""\nYou'll be able to ride when you're a little older."")",printfunc,120 Python Crash Course,"print(""\nThe number "" + str(number) + "" is odd."")",printfunc,121 Python Crash Course,print(current_number),printfunc,122 Python Crash Course,print(message),printfunc,123 Python Crash Course,print(message),printfunc,124 Python Crash Course,"print(""I'd love to go to "" + city.title() + ""!"")",printfunc,125 Python Crash Course,print(x),printfunc,126 Python Crash Course,print(x),printfunc,127 Python Crash Course,"print(""Verifying user: "" + current_user.title())",printfunc,128 Python Crash Course,"print(""\nThe following users have been confirmed:"")",printfunc,129 Python Crash Course,print(confirmed_user.title()),printfunc,129 Python Crash Course,print(pets),printfunc,129 Python Crash Course,print(pets),printfunc,129 Python Crash Course,"print(""\n--- Poll Results ---"")",printfunc,130 Python Crash Course,"print(name + "" would like to climb "" + response + ""."")",printfunc,130 Python Crash Course,"print(""Hello!"")",printfunc,134 Python Crash Course,"print(""Hello!"")",printfunc,134 Python Crash Course,"print(""Hello!"")",printfunc,134 Python Crash Course,"print(""Hello, "" + username.title() + ""!"")",printfunc,134 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,136 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,136 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,136 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,136 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,137 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,137 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,138 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,138 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,138 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,138 Python Crash Course,"print(""\nI have a "" + animal_type + ""."")",printfunc,140 Python Crash Course,"print(""My "" + animal_type + ""'s name is "" + pet_name.title() + ""."")",printfunc,140 Python Crash Course,print(musician),printfunc,142 Python Crash Course,"print(""Jimi Hendrix"")",printfunc,142 Python Crash Course,print(musician),printfunc,142 Python Crash Course,print(musician),printfunc,143 Python Crash Course,print(musician),printfunc,143 Python Crash Course,print(musician),printfunc,144 Python Crash Course,print(musician),printfunc,144 Python Crash Course,"print(""\nHello, "" + formatted_name + ""!"")",printfunc,146 Python Crash Course,print(msg),printfunc,147 Python Crash Course,"print(""Printing model: "" + current_design)",printfunc,148 Python Crash Course,"print(""\nThe following models have been printed:"")",printfunc,148 Python Crash Course,print(completed_model),printfunc,148 Python Crash Course,"print(""Printing model: "" + current_design)",printfunc,148 Python Crash Course,"print(""\nThe following models have been printed:"")",printfunc,148 Python Crash Course,print(completed_model),printfunc,148 Python Crash Course,print(toppings),printfunc,151 Python Crash Course,"print(""\nMaking a pizza with the following toppings:"")",printfunc,151 Python Crash Course,"print(""- "" + topping)",printfunc,151 Python Crash Course,"print(""\nMaking a "" + str(size)",printfunc,152 Python Crash Course,"print(""- "" + topping)",printfunc,152 Python Crash Course,print(user_profile),printfunc,153 Python Crash Course,"print(""\nMaking a "" + str(size)",printfunc,155 Python Crash Course,"print(""- "" + topping)",printfunc,155 Python Crash Course,"print(self.name.title() + "" is now sitting."")",printfunc,162 Python Crash Course,"print(self.name.title() + "" rolled over!"")",printfunc,162 Python Crash Course,"print(""My dog's name is "" + my_dog.name.title() + ""."")",printfunc,164 Python Crash Course,"print(""My dog is "" + str(my_dog.age) + "" years old."")",printfunc,164 Python Crash Course,"print(""My dog's name is "" + my_dog.name.title() + ""."")",printfunc,165 Python Crash Course,"print(""My dog is "" + str(my_dog.age) + "" years old."")",printfunc,165 Python Crash Course,"print(""\nYour dog's name is "" + your_dog.name.title() + ""."")",printfunc,166 Python Crash Course,"print(""Your dog is "" + str(your_dog.age) + "" years old."")",printfunc,166 Python Crash Course,print(my_new_car.get_descriptive_name()),printfunc,167 Python Crash Course,"print(""This car has "" + str(self.odometer_reading) + "" miles on it."")",printfunc,168 Python Crash Course,print(my_new_car.get_descriptive_name()),printfunc,168 Python Crash Course,print(my_new_car.get_descriptive_name()),printfunc,169 Python Crash Course,print(my_new_car.get_descriptive_name()),printfunc,169 Python Crash Course,"print(""You can't roll back an odometer!"")",printfunc,170 Python Crash Course,print(my_used_car.get_descriptive_name()),printfunc,170 Python Crash Course,"print(""This car has "" + str(self.odometer_reading) + "" miles on it."")",printfunc,172 Python Crash Course,"print(""You can't roll back an odometer!"")",printfunc,172 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,173 Python Crash Course,"print(""This car has a "" + str(self.battery_size) + ""-kWh battery."")",printfunc,174 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,174 Python Crash Course,"print(""This car doesn't need a gas tank!"")",printfunc,175 Python Crash Course,"print(""This car has a "" + str(self.battery_size) + ""-kWh battery."")",printfunc,176 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,176 Python Crash Course,print(message),printfunc,177 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,177 Python Crash Course,"print(""This car has "" + str(self.odometer_reading) + "" miles on it."")",printfunc,179 Python Crash Course,"print(""You can't roll back an odometer!"")",printfunc,179 Python Crash Course,print(my_new_car.get_descriptive_name()),printfunc,180 Python Crash Course,"print(""This car has a "" + str(self.battery_size) + ""-kWh battery."")",printfunc,180 Python Crash Course,print(message),printfunc,181 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,181 Python Crash Course,print(my_beetle.get_descriptive_name()),printfunc,181 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,181 Python Crash Course,print(my_beetle.get_descriptive_name()),printfunc,182 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,182 Python Crash Course,print(my_beetle.get_descriptive_name()),printfunc,183 Python Crash Course,print(my_tesla.get_descriptive_name()),printfunc,183 Python Crash Course,print(name.title(),printfunc,185 Python Crash Course,print(contents),printfunc,190 Python Crash Course,print(contents.rstrip()),printfunc,191 Python Crash Course,print(line),printfunc,193 Python Crash Course,print(line.rstrip()),printfunc,193 Python Crash Course,print(line.rstrip()),printfunc,194 Python Crash Course,print(pi_string),printfunc,194 Python Crash Course,print(len(pi_string)),printfunc,194 Python Crash Course,print(pi_string),printfunc,195 Python Crash Course,print(len(pi_string)),printfunc,195 Python Crash Course,"print(pi_string[:52] + ""..."")",printfunc,196 Python Crash Course,print(len(pi_string)),printfunc,196 Python Crash Course,"print(""Your birthday appears in the first million digits of pi!"")",printfunc,196 Python Crash Course,"print(""Your birthday does not appear in the first million digits of pi."")",printfunc,196 Python Crash Course,print(5/0),printfunc,200 Python Crash Course,print(5/0),printfunc,200 Python Crash Course,"print(""You can't divide by zero!"")",printfunc,200 Python Crash Course,print(5/0),printfunc,201 Python Crash Course,"print(""Give me two numbers, and I'll divide them."")",printfunc,201 Python Crash Course,"print(""Enter 'q' to quit."")",printfunc,201 Python Crash Course,print(answer),printfunc,201 Python Crash Course,"print(""Give me two numbers, and I'll divide them."")",printfunc,202 Python Crash Course,"print(""Enter 'q' to quit."")",printfunc,202 Python Crash Course,print(answer),printfunc,202 Python Crash Course,print(msg),printfunc,204 Python Crash Course,print(msg),printfunc,204 Python Crash Course,"print(""The file "" + filename + "" has about "" + str(num_words) + "" words."")",printfunc,205 Python Crash Course,"print(""The file "" + filename + "" has about "" + str(num_words)",printfunc,205 Python Crash Course,print(numbers),printfunc,209 Python Crash Course,"print(""We'll remember you when you come back, "" + username + ""!"")",printfunc,210 Python Crash Course,"print(""Welcome back, "" + username + ""!"")",printfunc,210 Python Crash Course,"print(""Welcome back, "" + username + ""!"")",printfunc,211 Python Crash Course,"print(""Welcome back, "" + username + ""!"")",printfunc,213 Python Crash Course,"print(""We'll remember you when you come back, "" + username + ""!"")",printfunc,213 Python Crash Course,"print(""We'll remember you when you come back, "" + username + ""!"")",printfunc,213 Python Crash Course,"print(""Enter 'q' at any time to quit."")",printfunc,216 Python Crash Course,print(question),printfunc,223 Python Crash Course,"print(""Survey results:"")",printfunc,223 Python Crash Course,print('- ' + response),printfunc,223 Python Crash Course,"print(""Enter 'q' at any time to quit.\n"")",printfunc,224 Python Crash Course,"print(""\nThank you to everyone who participated in the survey!"")",printfunc,224 Python Crash Course,print(len(bullets)),printfunc,262 Python Crash Course,print(self.alien_points),printfunc,307 Python Crash Course,print(results),printfunc,341 Python Crash Course,print(frequencies),printfunc,341 Python Crash Course,print(header_row),printfunc,350 Python Crash Course,"print(index, column_header)",printfunc,351 Python Crash Course,print(header_row),printfunc,351 Python Crash Course,print(highs),printfunc,352 Python Crash Course,print(highs),printfunc,353 Python Crash Course,print(first_date),printfunc,354 Python Crash Course,"print(country_name + "": "" + population)",printfunc,363 Python Crash Course,"print(country_name + "": "" + str(population))",printfunc,364 Python Crash Course,"print(country + "": "" + str(population))",printfunc,364 Python Crash Course,"print(country_code, COUNTRIES[country_code])",printfunc,365 Python Crash Course,print(get_country_code('Andorra')),printfunc,366 Python Crash Course,print(get_country_code('United Arab Emirates')),printfunc,366 Python Crash Course,print(get_country_code('Afghanistan')),printfunc,366 Python Crash Course,"print(code + "": ""+ str(population))",printfunc,366 Python Crash Course,print('ERROR - ' + country_name),printfunc,366 Python Crash Course,"print(len(cc_pops_1), len(cc_pops_2), len(cc_pops_3))",printfunc,371 Python Crash Course,"print(""Status code:"", r.status_code)",printfunc,379 Python Crash Course,print(response_dict.keys()),printfunc,380 Python Crash Course,"print(""Status code:"", r.status_code)",printfunc,380 Python Crash Course,"print(""Total repositories:"", response_dict['total_count'])",printfunc,380 Python Crash Course,"print(""Repositories returned:"", len(repo_dicts))",printfunc,380 Python Crash Course,"print(""\nKeys:"", len(repo_dict))",printfunc,381 Python Crash Course,print(key),printfunc,381 Python Crash Course,"print(""Repositories returned:"", len(repo_dicts))",printfunc,381 Python Crash Course,"print(""\nSelected information about first repository:"")",printfunc,381 Python Crash Course,"print('Name:', repo_dict['name'])",printfunc,381 Python Crash Course,"print('Owner:', repo_dict['owner']['login'])",printfunc,381 Python Crash Course,"print('Stars:', repo_dict['stargazers_count'])",printfunc,382 Python Crash Course,"print('Repository:', repo_dict['html_url'])",printfunc,382 Python Crash Course,"print('Created:', repo_dict['created_at'])",printfunc,382 Python Crash Course,"print('Updated:', repo_dict['updated_at'])",printfunc,382 Python Crash Course,"print('Description:', repo_dict['description'])",printfunc,382 Python Crash Course,"print(""Repositories returned:"", len(repo_dicts))",printfunc,382 Python Crash Course,"print(""\nSelected information about each repository:"")",printfunc,383 Python Crash Course,"print('\nName:', repo_dict['name'])",printfunc,383 Python Crash Course,"print('Owner:', repo_dict['owner']['login'])",printfunc,383 Python Crash Course,"print('Stars:', repo_dict['stargazers_count'])",printfunc,383 Python Crash Course,"print('Repository:', repo_dict['html_url'])",printfunc,383 Python Crash Course,"print('Description:', repo_dict['description'])",printfunc,383 Python Crash Course,"print(""Status code:"", r.status_code)",printfunc,385 Python Crash Course,"print(""Total repositories:"", response_dict['total_count'])",printfunc,385 Python Crash Course,"print(""Number of items:"", len(repo_dicts))",printfunc,389 Python Crash Course,"print(""Status code:"", r.status_code)",printfunc,391 Python Crash Course,print(submission_r.status_code),printfunc,391 Python Crash Course,"print(""\nTitle:"", submission_dict['title'])",printfunc,391 Python Crash Course,"print(""Discussion link:"", submission_dict['link'])",printfunc,391 Python Crash Course,"print(""Comments:"", submission_dict['comments'])",printfunc,391 Python Crash Course,"print(topic.id, topic)",printfunc,411 Python Crash Course,"print(user.username, user.id)",printfunc,449 Python Crash Course,"print(topic, topic.owner)",printfunc,450 Python Crash Course,print() super(),printfunc,490 Python Crash Course,"print(""Hello Python world!"")",printfunc,492 Python Crash Course,"print(""Hello Python world!"")",printfunc,492 Python Crash Course,"print(""Hello Git world!"")",printfunc,507 Python Crash Course,"print(""Hello Git world!"")",printfunc,510 Python Crash Course,"print(""Hello everyone."")",printfunc,510 Python Crash Course,"print(""Hello Git world!"")",printfunc,511 Python Crash Course,"print(""Hello everyone."")",printfunc,511 Python Crash Course,"print(""Oh no, I broke the project!"")",printfunc,511 Python Crash Course,"print(""Hello Git world!"")",printfunc,511 Python Crash Course,"print(""Hello everyone."")",printfunc,511 Python Crash Course,"dimensions.py u dimensions = (200, 50)",simpleTuple,70 Python Crash Course,"dimensions = (200, 50)",simpleTuple,70 Python Crash Course,"dimensions = (200, 50)",simpleTuple,70 Python Crash Course,"u dimensions = (200, 50)",simpleTuple,71 Python Crash Course,"v dimensions = (400, 100)",simpleTuple,71 Python Crash Course,"u bg_color = (230, 230, 230)",simpleTuple,242 Python Crash Course,"v self.text_color = (30, 30, 30)",simpleTuple,302 Python Crash Course,"plt.scatter(x_values, y_values, c=(0, 0, 0.8), edgecolor='none', s=40)",simpleTuple,330 Python Crash Course,"plt.figure(figsize=(10, 6))",simpleTuple,338 Python Crash Course,"plt.figure(dpi=128, figsize=(10, 6))",simpleTuple,338 Python Crash Course,"fig = plt.figure(dpi=128, figsize=(10, 6))",simpleTuple,353 Python Crash Course,"fig = plt.figure(dpi=128, figsize=(10, 6))",simpleTuple,355 Python Crash Course,"fig = plt.figure(dpi=128, figsize=(10, 6))",simpleTuple,358 Python Crash Course,"fig = plt.figure(dpi=128, figsize=(10, 6))",simpleTuple,358 Python Crash Course,"w SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')",simpleTuple,469 Python Crash Course,"STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )",simpleTuple,469 Python Crash Course,"SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')",simpleTuple,476 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,38 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,38 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,38 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,39 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,39 Python Crash Course,"bicycles = ['trek', 'cannondale', 'redline', 'specialized']",simpleList,39 Python Crash Course,"motorcycles.py u motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,41 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,41 Python Crash Course,motorcycles = [],simpleList,42 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,42 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,43 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,43 Python Crash Course,"u motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,44 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,44 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,44 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki', 'ducati']",simpleList,45 Python Crash Course,"u motorcycles = ['honda', 'yamaha', 'suzuki', 'ducati']",simpleList,45 Python Crash Course,"cars = ['bmw', 'audi', 'toyota', 'subaru']",simpleList,47 Python Crash Course,"cars = ['bmw', 'audi', 'toyota', 'subaru']",simpleList,48 Python Crash Course,"cars = ['bmw', 'audi', 'toyota', 'subaru']",simpleList,48 Python Crash Course,"cars = ['bmw', 'audi', 'toyota', 'subaru']",simpleList,49 Python Crash Course,"cars = ['bmw', 'audi', 'toyota', 'subaru']",simpleList,49 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,50 Python Crash Course,"motorcycles = ['honda', 'yamaha', 'suzuki']",simpleList,51 Python Crash Course,motorcycles = [],simpleList,51 Python Crash Course,"magicians.py u magicians = ['alice', 'david', 'carolina']",simpleList,54 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,55 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,56 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,56 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,57 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,58 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,59 Python Crash Course,"magicians = ['alice', 'david', 'carolina']",simpleList,60 Python Crash Course,squares.py u squares = [],simpleList,62 Python Crash Course,squares = [],simpleList,63 Python Crash Course,"digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]",simpleList,63 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,65 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,65 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,65 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,66 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,66 Python Crash Course,"players = ['charles', 'martina', 'michael', 'florence', 'eli']",simpleList,66 Python Crash Course,"foods.py u my_foods = ['pizza', 'falafel', 'carrot cake']",simpleList,67 Python Crash Course,"my_foods = ['pizza', 'falafel', 'carrot cake']",simpleList,67 Python Crash Course,"my_foods = ['pizza', 'falafel', 'carrot cake']",simpleList,68 Python Crash Course,"cars = ['audi', 'bmw', 'subaru', 'toyota']",simpleList,76 Python Crash Course,"requested_toppings = ['mushrooms', 'onions', 'pineapple']",simpleList,81 Python Crash Course,"banned_users = ['andrew', 'carolina', 'david']",simpleList,81 Python Crash Course,"u requested_toppings = ['mushrooms', 'extra cheese']",simpleList,87 Python Crash Course,"requested_toppings = ['mushrooms', 'extra cheese']",simpleList,88 Python Crash Course,"requested_toppings = ['mushrooms', 'green peppers', 'extra cheese']",simpleList,90 Python Crash Course,"requested_toppings = ['mushrooms', 'green peppers', 'extra cheese']",simpleList,90 Python Crash Course,u requested_toppings = [],simpleList,91 Python Crash Course,"v requested_toppings = ['mushrooms', 'french fries', 'extra cheese']",simpleList,92 Python Crash Course,"u friends = ['phil', 'sarah']",simpleList,105 Python Crash Course,"u aliens = [alien_0, alien_1, alien_2]",simpleList,109 Python Crash Course,aliens = [],simpleList,109 Python Crash Course,aliens = [],simpleList,110 Python Crash Course,"u unconfirmed_users = ['alice', 'brian', 'candace']",simpleList,128 Python Crash Course,confirmed_users = [],simpleList,128 Python Crash Course,"pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']",simpleList,129 Python Crash Course,"u usernames = ['hannah', 'ty', 'margot']",simpleList,147 Python Crash Course,"unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']",simpleList,147 Python Crash Course,completed_models = [],simpleList,147 Python Crash Course,"unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']",simpleList,148 Python Crash Course,completed_models = [],simpleList,148 Python Crash Course,"unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']",simpleList,149 Python Crash Course,completed_models = [],simpleList,149 Python Crash Course,"filenames = ['alice.txt', 'siddhartha.txt', 'moby_dick.txt', 'little_women.txt']",simpleList,206 Python Crash Course,"filenames = ['alice.txt', 'siddhartha.txt', 'moby_dick.txt', 'little_women.txt']",simpleList,206 Python Crash Course,"numbers = [2, 3, 5, 7, 11, 13]",simpleList,209 Python Crash Course,"u responses = ['English', 'Spanish', 'Mandarin']",simpleList,226 Python Crash Course,"v self.responses = ['English', 'Spanish', 'Mandarin']",simpleList,227 Python Crash Course,"squares = [1, 4, 9, 16, 25]",simpleList,324 Python Crash Course,"squares = [1, 4, 9, 16, 25]",simpleList,325 Python Crash Course,"input_values = [1, 2, 3, 4, 5]",simpleList,326 Python Crash Course,"squares = [1, 4, 9, 16, 25]",simpleList,326 Python Crash Course,"x_values = [1, 2, 3, 4, 5]",simpleList,328 Python Crash Course,"y_values = [1, 4, 9, 16, 25]",simpleList,328 Python Crash Course,w self.x_values = [0],simpleList,332 Python Crash Course,results = [],simpleList,341 Python Crash Course,results = [],simpleList,341 Python Crash Course,frequencies = [],simpleList,341 Python Crash Course,frequencies = [],simpleList,342 Python Crash Course,"v hist.x_labels = ['1', '2', '3', '4', '5', '6']",simpleList,342 Python Crash Course,results = [],simpleList,343 Python Crash Course,frequencies = [],simpleList,343 Python Crash Course,"hist.x_labels = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']",simpleList,344 Python Crash Course,results = [],simpleList,345 Python Crash Course,u highs = [],simpleList,352 Python Crash Course,highs = [],simpleList,353 Python Crash Course,"u dates, highs = [], []",simpleList,355 Python Crash Course,"u names, stars = [], []",simpleList,385 Python Crash Course,"chart.x_labels = ['httpie', 'django', 'flask']",simpleList,388 Python Crash Course,"u names, plot_dicts = [], []",simpleList,389 Python Crash Course,"names, plot_dicts = [], []",simpleList,390 Python Crash Course,w submission_dicts = [],simpleList,391 Python Crash Course,"v urlpatterns = [ w url(r'^admin/', include(admin.site.urls)), ]",simpleList,413 Python Crash Course,w fields = ['text'],simpleList,428 Python Crash Course,fields = ['text'],simpleList,432 Python Crash Course,args=[topic_id],simpleList,433 Python Crash Course,args=[topic.id],simpleList,436 Python Crash Course,x ALLOWED_HOSTS = ['*'],simpleList,469 Python Crash Course,u ALLOWED_HOSTS = ['learning-log.herokuapp.com'],simpleList,476 Python Crash Course,ALLOWED_HOSTS = ['localhost'],simpleList,479 Python Crash Course,"for the item at index -1, Python always returns the last item in the list:",forsimple,39 Python Crash Course,for loop to print out each name in a list of magicians:,forsimple,54 Python Crash Course,for magician in magicians:,forsimple,54 Python Crash Course,for magician in magicians:,forsimple,54 Python Crash Course,for magician in magicians:,forsimple,54 Python Crash Course,for item in list_of_items:,forsimple,55 Python Crash Course,for magician in magicians:,forsimple,55 Python Crash Course,for each magician in the list:,forsimple,55 Python Crash Course,for magician in magicians:,forsimple,56 Python Crash Course,for each person in the list:,forsimple,56 Python Crash Course,for magician in magicians:,forsimple,56 Python Crash Course,for magician in magicians:,forsimple,57 Python Crash Course,for magician in magicians:,forsimple,58 Python Crash Course,for magician in magicians:,forsimple,59 Python Crash Course,"for each person in the list, as you can see at v:",forsimple,59 Python Crash Course,"for value in range(1,5):",forsimple,61 Python Crash Course,"for value in range(1,6):",forsimple,61 Python Crash Course,"for value in range(1,11):",forsimple,62 Python Crash Course,"for value in range(1,11):",forsimple,63 Python Crash Course,for player in players[:3]:,forsimple,66 Python Crash Course,for dimension in dimensions:,forsimple,70 Python Crash Course,for dimension in dimensions:,forsimple,71 Python Crash Course,for dimension in dimensions:,forsimple,71 Python Crash Course,"for the value 'bmw'. Whenever the value is 'bmw', it’s printed in uppercase instead of title case:",forsimple,76 Python Crash Course,for car in cars:,forsimple,76 Python Crash Course,for requested_topping in requested_toppings:,forsimple,90 Python Crash Course,for requested_topping in requested_toppings:,forsimple,90 Python Crash Course,for requested_topping in requested_toppings:,forsimple,91 Python Crash Course,for requested_topping in requested_toppings:,forsimple,92 Python Crash Course,"for key, value in user_0.items():",forsimple,103 Python Crash Course,"for name, language in favorite_languages.items():",forsimple,104 Python Crash Course,for name in favorite_languages.keys():,forsimple,105 Python Crash Course,for name in favorite_languages:,forsimple,105 Python Crash Course,for name in favorite_languages.keys():,forsimple,105 Python Crash Course,for name in favorite_languages.keys():,forsimple,105 Python Crash Course,for name in sorted(favorite_languages.keys()):,forsimple,106 Python Crash Course,for language in favorite_languages.values():,forsimple,107 Python Crash Course,for language in set(favorite_languages.values()):,forsimple,108 Python Crash Course,for alien in aliens:,forsimple,109 Python Crash Course,for alien_number in range(30):,forsimple,109 Python Crash Course,for alien in aliens[:5]:,forsimple,109 Python Crash Course,"for alien_number in range (0,30):",forsimple,110 Python Crash Course,for alien in aliens[0:3]:,forsimple,110 Python Crash Course,for alien in aliens[0:5]:,forsimple,110 Python Crash Course,for alien in aliens[0:3]:,forsimple,111 Python Crash Course,for topping in pizza['toppings']:,forsimple,112 Python Crash Course,"for name, languages in favorite_languages.items():",forsimple,112 Python Crash Course,for language in languages:,forsimple,112 Python Crash Course,"for username, user_info in users.items():",forsimple,114 Python Crash Course,for confirmed_user in confirmed_users:,forsimple,129 Python Crash Course,"for name, response in responses.items():",forsimple,130 Python Crash Course,for name in names:,forsimple,147 Python Crash Course,for completed_model in completed_models:,forsimple,148 Python Crash Course,for completed_model in completed_models:,forsimple,148 Python Crash Course,for topping in toppings:,forsimple,151 Python Crash Course,for topping in toppings:,forsimple,152 Python Crash Course,"for key, value in user_info.items():",forsimple,153 Python Crash Course,for topping in toppings:,forsimple,155 Python Crash Course,"for name, language in favorite_languages.items():",forsimple,185 Python Crash Course,for line in file_object:,forsimple,193 Python Crash Course,for line in file_object:,forsimple,193 Python Crash Course,for line in lines:,forsimple,194 Python Crash Course,for line in lines:,forsimple,194 Python Crash Course,for line in lines:,forsimple,195 Python Crash Course,for line in lines:,forsimple,196 Python Crash Course,for line in lines:,forsimple,196 Python Crash Course,for filename in filenames:,forsimple,206 Python Crash Course,for filename in filenames:,forsimple,206 Python Crash Course,for a username and store it in username.json for next time:,forsimple,211 Python Crash Course,for response in responses:,forsimple,223 Python Crash Course,for response in responses:,forsimple,226 Python Crash Course,for response in responses:,forsimple,226 Python Crash Course,for response in self.responses:,forsimple,227 Python Crash Course,for response in self.responses:,forsimple,227 Python Crash Course,for event in pygame.event.get():,forsimple,241 Python Crash Course,for event in pygame.event.get():,forsimple,247 Python Crash Course,for event in pygame.event.get():,forsimple,250 Python Crash Course,for event in pygame.event.get():,forsimple,251 Python Crash Course,for event in pygame.event.get():,forsimple,252 Python Crash Course,for event in pygame.event.get():,forsimple,256 Python Crash Course,for event in pygame.event.get():,forsimple,260 Python Crash Course,for bullet in bullets.sprites():,forsimple,260 Python Crash Course,for bullet in bullets.copy():,forsimple,262 Python Crash Course,for bullet in bullets.copy():,forsimple,263 Python Crash Course,for bullet in bullets:,forsimple,268 Python Crash Course,for alien_number in range(number_aliens_x):,forsimple,271 Python Crash Course,for alien_number in range(number_aliens_x):,forsimple,273 Python Crash Course,for row_number in range(number_rows):,forsimple,274 Python Crash Course,for alien_number in range(number_aliens_x):,forsimple,274 Python Crash Course,for alien in aliens.sprites():,forsimple,278 Python Crash Course,for alien in aliens.sprites():,forsimple,279 Python Crash Course,for collisions in the update_bullets() function:,forsimple,280 Python Crash Course,for bullet in bullets.copy():,forsimple,283 Python Crash Course,for alien in aliens.sprites():,forsimple,288 Python Crash Course,for event in pygame.event.get():,forsimple,295 Python Crash Course,for event in pygame.event.get():,forsimple,297 Python Crash Course,for aliens in collisions.values():,forsimple,306 Python Crash Course,"for high scores, we’ll write a new function, check_high_score(), in game_functions.py:",forsimple,309 Python Crash Course,for event in pygame.event.get():,forsimple,312 Python Crash Course,for ship_number in range(self.stats.ships_left):,forsimple,314 Python Crash Course,for alien in aliens.sprites():,forsimple,316 Python Crash Course,for roll_num in range(100):,forsimple,341 Python Crash Course,for roll_num in range(1000):,forsimple,341 Python Crash Course,"for value in range(1, die.num_sides+1):",forsimple,341 Python Crash Course,"for value in range(1, die.num_sides+1):",forsimple,342 Python Crash Course,for roll_num in range(1000):,forsimple,343 Python Crash Course,"for value in range(2, max_result+1):",forsimple,344 Python Crash Course,for roll_num in range(50000):,forsimple,345 Python Crash Course,"for index, column_header in enumerate(header_row):",forsimple,351 Python Crash Course,for row in reader:,forsimple,352 Python Crash Course,for row in reader:,forsimple,353 Python Crash Course,for row in reader:,forsimple,355 Python Crash Course,for row in reader:,forsimple,357 Python Crash Course,for row in reader:,forsimple,360 Python Crash Course,for pop_dict in pop_data:,forsimple,363 Python Crash Course,for pop_dict in pop_data:,forsimple,364 Python Crash Course,for pop_dict in pop_data:,forsimple,364 Python Crash Course,for country_code in sorted(COUNTRIES.keys()):,forsimple,365 Python Crash Course,"for code, name in COUNTRIES.items():",forsimple,366 Python Crash Course,for pop_dict in pop_data:,forsimple,366 Python Crash Course,for pop_dict in pop_data:,forsimple,369 Python Crash Course,for pop_dict in pop_data:,forsimple,371 Python Crash Course,"for cc, pop in cc_populations.items():",forsimple,371 Python Crash Course,"for cc, pop in cc_populations.items():",forsimple,373 Python Crash Course,for key in sorted(repo_dict.keys()):,forsimple,381 Python Crash Course,for some of the keys in repo_dict:,forsimple,381 Python Crash Course,for repo_dict in repo_dicts:,forsimple,383 Python Crash Course,for repo_dict in repo_dicts:,forsimple,385 Python Crash Course,for repo_dict in repo_dicts:,forsimple,389 Python Crash Course,for repo_dict in repo_dicts:,forsimple,390 Python Crash Course,for submission_id in submission_ids[:30]:,forsimple,391 Python Crash Course,for submission_dict in submission_dicts:,forsimple,391 Python Crash Course,"for ll_env in parentheses), enter the following commands to create a new project:",forsimple,400 Python Crash Course,for topic in topics:,forsimple,410 Python Crash Course,for user in User.objects.all():,forsimple,449 Python Crash Course,for topic in Topic.objects.all():,forsimple,450 Python Crash Course,"for getting help in Appendix C. Don’t be shy about asking for help:",forsimple,481 Python Crash Course,"for that project will often appear in searches—for example, http:",forsimple,502 Python Crash Course,"u full_name = first_name + "" "" + last_name",assignwithSum,25 Python Crash Course,"full_name = first_name + "" "" + last_name",assignwithSum,25 Python Crash Course,"full_name = first_name + "" "" + last_name",assignwithSum,25 Python Crash Course,v alien_0['x_position'] = alien_0['x_position'] + x_increment,assignwithSum,99 Python Crash Course,"w full_name = user_info['first'] + "" "" + user_info['last']",assignwithSum,114 Python Crash Course,v full_name = first_name + ' ' + last_name,assignwithSum,142 Python Crash Course,full_name = first_name + ' ' + middle_name + ' ' + last_name,assignwithSum,142 Python Crash Course,full_name = first_name + ' ' + middle_name + ' ' + last_name,assignwithSum,143 Python Crash Course,full_name = first_name + ' ' + last_name,assignwithSum,143 Python Crash Course,full_name = first_name + ' ' + last_name,assignwithSum,145 Python Crash Course,long_name = str(self.year) + ' ' + self.make + ' ' + self.model,assignwithSum,167 Python Crash Course,long_name = str(self.year) + ' ' + self.make + ' ' + self.model,assignwithSum,172 Python Crash Course,long_name = str(self.year) + ' ' + self.make + ' ' + self.model,assignwithSum,179 Python Crash Course,full_name = first + ' ' + last,assignwithSum,216 Python Crash Course,full_name = first + ' ' + middle + ' ' + last,assignwithSum,219 Python Crash Course,full_name = first + ' ' + last,assignwithSum,220 Python Crash Course,alien.x = alien_width + 2 * alien_width * alien_number,assignwithSum,271 Python Crash Course,alien.x = alien_width + 2 * alien_width * alien_number,assignwithSum,273 Python Crash Course,alien.x = alien_width + 2 * alien_width * alien_number,assignwithSum,274 Python Crash Course,w alien.rect.y = alien.rect.height + 2 * alien.rect.height * row_number,assignwithSum,274 Python Crash Course,w self.level_rect.top = self.score_rect.bottom + 10,assignwithSum,311 Python Crash Course,w ship.rect.x = 10 + ship_number * ship.rect.width,assignwithSum,314 Python Crash Course,z next_x = self.x_values[-1] + x_step,assignwithSum,333 Python Crash Course,next_y = self.y_values[-1] + y_step,assignwithSum,333 Python Crash Course,u result = die_1.roll() + die_2.roll(),assignwithSum,343 Python Crash Course,v max_result = die_1.num_sides + die_2.num_sides,assignwithSum,343 Python Crash Course,result = die_1.roll() + die_2.roll(),assignwithSum,345 Python Crash Course,u >>> favorite_language = favorite_language.rstrip(),simpleAssign,27 Python Crash Course,age = 23,simpleAssign,31 Python Crash Course,age = 23,simpleAssign,32 Python Crash Course,v popped_motorcycle = motorcycles.pop(),simpleAssign,44 Python Crash Course,last_owned = motorcycles.pop(),simpleAssign,44 Python Crash Course,u first_owned = motorcycles.pop(0),simpleAssign,44 Python Crash Course,argument reverse=True to the sort() method. The following example sorts,simpleAssign,48 Python Crash Course,cars.sort(reverse=True),simpleAssign,48 Python Crash Course,function has been used. The sorted() function can also accept a reverse=True,simpleAssign,48 Python Crash Course,"numbers = list(range(1,6))",simpleAssign,62 Python Crash Course,"even_numbers.py even_numbers = list(range(2,11,2))",simpleAssign,62 Python Crash Course,w square = value**2,simpleAssign,62 Python Crash Course,v friend_foods = my_foods[:],simpleAssign,67 Python Crash Course,u friend_foods = my_foods[:],simpleAssign,67 Python Crash Course,u friend_foods = my_foods,simpleAssign,68 Python Crash Course,u dimensions[0] = 250,simpleAssign,70 Python Crash Course,dimensions[0] = 250,simpleAssign,70 Python Crash Course,age = 18,simpleAssign,78 Python Crash Course,age == 18,simpleAssign,78 Python Crash Course,answer = 17,simpleAssign,79 Python Crash Course,u if answer != 42:,simpleAssign,79 Python Crash Course,age = 19,simpleAssign,79 Python Crash Course,age <= 21,simpleAssign,79 Python Crash Course,age >= 21,simpleAssign,79 Python Crash Course,u >>> age_0 = 22,simpleAssign,79 Python Crash Course,age_1 = 18,simpleAssign,79 Python Crash Course,v >>> age_0 >= 21 and age_1 >= 21,simpleAssign,79 Python Crash Course,w >>> age_1 = 22,simpleAssign,80 Python Crash Course,age_0 >= 21 and age_1 >= 21,simpleAssign,80 Python Crash Course,age_0 >= 21) and (age_1 >= 21),simpleAssign,80 Python Crash Course,u >>> age_0 = 22,simpleAssign,80 Python Crash Course,age_1 = 18,simpleAssign,80 Python Crash Course,v >>> age_0 >= 21 or age_1 >= 21,simpleAssign,80 Python Crash Course,w >>> age_0 = 18,simpleAssign,80 Python Crash Course,age_0 >= 21 or age_1 >= 21,simpleAssign,80 Python Crash Course,game_active = True,simpleAssign,81 Python Crash Course,can_edit = False,simpleAssign,81 Python Crash Course,age = 19,simpleAssign,83 Python Crash Course,u if age >= 18:,simpleAssign,83 Python Crash Course,age = 19,simpleAssign,83 Python Crash Course,age = 17,simpleAssign,84 Python Crash Course,u if age >= 18:,simpleAssign,84 Python Crash Course,age = 12,simpleAssign,84 Python Crash Course,age = 12,simpleAssign,85 Python Crash Course,u price = 0,simpleAssign,85 Python Crash Course,w price = 10,simpleAssign,85 Python Crash Course,age = 12,simpleAssign,86 Python Crash Course,price = 5,simpleAssign,86 Python Crash Course,age = 12,simpleAssign,86 Python Crash Course,u elif age >= 65:,simpleAssign,86 Python Crash Course,price = 5,simpleAssign,86 Python Crash Course,u new_points = alien_0['points'],simpleAssign,97 Python Crash Course,u alien_0['x_position'] = 0,simpleAssign,98 Python Crash Course,v alien_0['y_position'] = 25,simpleAssign,98 Python Crash Course,alien_0['points'] = 5,simpleAssign,98 Python Crash Course,x_increment = 1,simpleAssign,99 Python Crash Course,x_increment = 3,simpleAssign,99 Python Crash Course,alien_0['speed'] = fast,simpleAssign,100 Python Crash Course,alien['points'] = 10,simpleAssign,110 Python Crash Course,alien['points'] = 10,simpleAssign,111 Python Crash Course,alien['points'] = 15,simpleAssign,111 Python Crash Course,location = user_info['location'],simpleAssign,114 Python Crash Course,"message = input(""Tell me something, and I will repeat it back to you: "")",simpleAssign,118 Python Crash Course,"name = input(""Please enter your name: "")",simpleAssign,118 Python Crash Course,name = input(prompt),simpleAssign,119 Python Crash Course,"age = input(""How old are you? "")",simpleAssign,119 Python Crash Course,"age = input(""How old are you? "")",simpleAssign,119 Python Crash Course,u >>> age >= 18,simpleAssign,119 Python Crash Course,v TypeError: unorderable types: str() >= int(),simpleAssign,119 Python Crash Course,"age = input(""How old are you? "")",simpleAssign,120 Python Crash Course,u >>> age = int(age),simpleAssign,120 Python Crash Course,age >= 18,simpleAssign,120 Python Crash Course,"height = input(""How tall are you, in inches? "")",simpleAssign,120 Python Crash Course,height = int(height),simpleAssign,120 Python Crash Course,The program can compare height to 36 because height = int(height),simpleAssign,120 Python Crash Course,"number = input(""Enter a number, and I'll tell you if it's even or odd: "")",simpleAssign,121 Python Crash Course,number = int(number),simpleAssign,121 Python Crash Course,"and two is zero (here, if number % 2 == 0) the number is even. Otherwise,",simpleAssign,121 Python Crash Course,current_number = 1,simpleAssign,122 Python Crash Course,Python repeats the loop as long as the condition current_number <= 5,simpleAssign,122 Python Crash Course,message = input(prompt),simpleAssign,123 Python Crash Course,"enters the loop. At message = input(prompt), Python displays the prompt and",simpleAssign,123 Python Crash Course,message = input(prompt),simpleAssign,123 Python Crash Course,current_number = 0,simpleAssign,126 Python Crash Course,x = 1,simpleAssign,126 Python Crash Course,x = 1,simpleAssign,127 Python Crash Course,ditional test x <= 5 will always evaluate to True and the while loop will run,simpleAssign,127 Python Crash Course,w current_user = unconfirmed_users.pop(),simpleAssign,128 Python Crash Course,polling_active = True,simpleAssign,130 Python Crash Course,"u name = input(""\nWhat is your name? "")",simpleAssign,130 Python Crash Course,"response = input(""Which mountain would you like to climb someday? "")",simpleAssign,130 Python Crash Course,v responses[name] = response,simpleAssign,130 Python Crash Course,"w repeat = input(""Would you like to let another person respond? (yes/ no) "")",simpleAssign,130 Python Crash Course,"x musician = get_formatted_name('jimi', 'hendrix')",simpleAssign,142 Python Crash Course,"musician = get_formatted_name('john', 'lee', 'hooker')",simpleAssign,142 Python Crash Course,"musician = get_formatted_name('jimi', 'hendrix')",simpleAssign,143 Python Crash Course,"x musician = get_formatted_name('john', 'hooker', 'lee')",simpleAssign,143 Python Crash Course,"musician = build_person('jimi', 'hendrix')",simpleAssign,144 Python Crash Course,"musician = build_person('jimi', 'hendrix', age=27)",simpleAssign,144 Python Crash Course,"formatted_name = get_formatted_name(f_name, l_name)",simpleAssign,146 Python Crash Course,current_design = unprinted_designs.pop(),simpleAssign,147 Python Crash Course,current_design = unprinted_designs.pop(),simpleAssign,148 Python Crash Course,u profile['first_name'] = first,simpleAssign,153 Python Crash Course,profile['last_name'] = last,simpleAssign,153 Python Crash Course,profile[key] = value,simpleAssign,153 Python Crash Course,"user_profile = build_profile('albert', 'einstein',",simpleAssign,153 Python Crash Course,"car = make_car('subaru', 'outback', color='blue', tow_package=True)",simpleAssign,154 Python Crash Course,x self.name = name,simpleAssign,162 Python Crash Course,The same process happens with self.age = age. Variables that are accessible,simpleAssign,163 Python Crash Course,"u my_dog = Dog('willie', 6)",simpleAssign,164 Python Crash Course,"my_dog = Dog('willie', 6)",simpleAssign,165 Python Crash Course,"my_dog = Dog('willie', 6)",simpleAssign,165 Python Crash Course,"your_dog = Dog('lucy', 3)",simpleAssign,165 Python Crash Course,"w my_new_car = Car('audi', 'a4', 2016)",simpleAssign,167 Python Crash Course,u self.odometer_reading = 0,simpleAssign,168 Python Crash Course,"my_new_car = Car('audi', 'a4', 2016)",simpleAssign,168 Python Crash Course,"my_new_car = Car('audi', 'a4', 2016)",simpleAssign,169 Python Crash Course,u my_new_car.odometer_reading = 23,simpleAssign,169 Python Crash Course,"my_new_car = Car('audi', 'a4', 2016)",simpleAssign,169 Python Crash Course,u if mileage >= self.odometer_reading:,simpleAssign,170 Python Crash Course,"v my_used_car = Car('subaru', 'outback', 2013)",simpleAssign,170 Python Crash Course,"y my_tesla = ElectricCar('tesla', 'model s', 2016)",simpleAssign,173 Python Crash Course,u self.battery_size = 70,simpleAssign,174 Python Crash Course,"my_tesla = ElectricCar('tesla', 'model s', 2016)",simpleAssign,174 Python Crash Course,"v def __init__(self, battery_size=70):",simpleAssign,175 Python Crash Course,x self.battery = Battery(),simpleAssign,176 Python Crash Course,"my_tesla = ElectricCar('tesla', 'model s', 2016)",simpleAssign,176 Python Crash Course,elif self.battery_size == 85:,simpleAssign,177 Python Crash Course,range = 270,simpleAssign,177 Python Crash Course,"my_tesla = ElectricCar('tesla', 'model s', 2016)",simpleAssign,177 Python Crash Course,"my_new_car = Car('audi', 'a4', 2016)",simpleAssign,180 Python Crash Course,my_new_car.odometer_reading = 23,simpleAssign,180 Python Crash Course,elif self.battery_size == 85:,simpleAssign,181 Python Crash Course,range = 270,simpleAssign,181 Python Crash Course,"my_tesla = ElectricCar('tesla', 'model s', 2016)",simpleAssign,181 Python Crash Course,"v my_beetle = Car('volkswagen', 'beetle', 2016)",simpleAssign,181 Python Crash Course,"w my_tesla = ElectricCar('tesla', 'roadster', 2016)",simpleAssign,181 Python Crash Course,"v my_beetle = car.Car('volkswagen', 'beetle', 2016)",simpleAssign,182 Python Crash Course,"w my_tesla = car.ElectricCar('tesla', 'roadster', 2016)",simpleAssign,182 Python Crash Course,"my_beetle = Car('volkswagen', 'beetle', 2016)",simpleAssign,183 Python Crash Course,"my_tesla = ElectricCar('tesla', 'roadster', 2016)",simpleAssign,183 Python Crash Course,v favorite_languages = OrderedDict(),simpleAssign,185 Python Crash Course,"x = randint(1, 6)",simpleAssign,186 Python Crash Course,u lines = file_object.readlines(),simpleAssign,194 Python Crash Course,lines = file_object.readlines(),simpleAssign,194 Python Crash Course,lines = file_object.readlines(),simpleAssign,195 Python Crash Course,lines = file_object.readlines(),simpleAssign,195 Python Crash Course,lines = file_object.readlines(),simpleAssign,196 Python Crash Course,"u birthday = input(""Enter your birthday, in the form mmddyy: "")",simpleAssign,196 Python Crash Course,w answer = int(first_number) / int(second_number),simpleAssign,201 Python Crash Course,answer = int(first_number) / int(second_number),simpleAssign,201 Python Crash Course,u words = contents.split(),simpleAssign,205 Python Crash Course,v num_words = len(words),simpleAssign,205 Python Crash Course,words = contents.split(),simpleAssign,205 Python Crash Course,num_words = len(words),simpleAssign,205 Python Crash Course,w numbers = json.load(f_obj),simpleAssign,209 Python Crash Course,"u username = input(""What is your name? "")",simpleAssign,210 Python Crash Course,u username = json.load(f_obj),simpleAssign,210 Python Crash Course,username = get_stored_username(),simpleAssign,213 Python Crash Course,"username = input(""What is your name? "")",simpleAssign,213 Python Crash Course,"username = input(""What is your name? "")",simpleAssign,213 Python Crash Course,username = get_stored_username(),simpleAssign,213 Python Crash Course,username = get_new_username(),simpleAssign,213 Python Crash Course,"v formatted_name = get_formatted_name('janis', 'joplin')",simpleAssign,217 Python Crash Course,"formatted_name = get_formatted_name('janis', 'joplin')",simpleAssign,219 Python Crash Course,y FAILED (errors=1),simpleAssign,219 Python Crash Course,"formatted_name = get_formatted_name('janis', 'joplin')",simpleAssign,221 Python Crash Course,u formatted_name = get_formatted_name(,simpleAssign,221 Python Crash Course,"population=5000000'. Run test_cities.py again, and make sure this new test",simpleAssign,222 Python Crash Course,Verify that a == b,simpleAssign,223 Python Crash Course,Verify that a != b,simpleAssign,223 Python Crash Course,my_survey = AnonymousSurvey(question),simpleAssign,224 Python Crash Course,w my_survey = AnonymousSurvey(question),simpleAssign,225 Python Crash Course,my_survey = AnonymousSurvey(question),simpleAssign,226 Python Crash Course,u self.my_survey = AnonymousSurvey(question),simpleAssign,227 Python Crash Course,"v screen = pygame.display.set_mode((1200, 800))",simpleAssign,241 Python Crash Course,y if event.type == pygame.QUIT:,simpleAssign,241 Python Crash Course,u ai_settings = Settings(),simpleAssign,243 Python Crash Course,v screen = pygame.display.set_mode(,simpleAssign,243 Python Crash Course,u self.image = pygame.image.load('images/ship.bmp'),simpleAssign,245 Python Crash Course,v self.rect = self.image.get_rect(),simpleAssign,245 Python Crash Course,w self.screen_rect = screen.get_rect(),simpleAssign,245 Python Crash Course,x self.rect.centerx = self.screen_rect.centerx,simpleAssign,245 Python Crash Course,u ship = Ship(screen),simpleAssign,246 Python Crash Course,u elif event.type == pygame.KEYDOWN:,simpleAssign,250 Python Crash Course,v if event.key == pygame.K_RIGHT:,simpleAssign,250 Python Crash Course,u self.moving_right = False,simpleAssign,251 Python Crash Course,elif event.type == pygame.KEYDOWN:,simpleAssign,251 Python Crash Course,u ship.moving_right = True,simpleAssign,251 Python Crash Course,v elif event.type == pygame.KEYUP:,simpleAssign,251 Python Crash Course,elif event.type == pygame.KEYDOWN:,simpleAssign,252 Python Crash Course,elif event.key == pygame.K_LEFT:,simpleAssign,252 Python Crash Course,ship.moving_left = True,simpleAssign,252 Python Crash Course,elif event.type == pygame.KEYUP:,simpleAssign,252 Python Crash Course,elif event.key == pygame.K_LEFT:,simpleAssign,252 Python Crash Course,ship.moving_left = False,simpleAssign,252 Python Crash Course,v self.ai_settings = ai_settings,simpleAssign,253 Python Crash Course,w self.center = float(self.rect.centerx),simpleAssign,253 Python Crash Course,y self.rect.centerx = self.center,simpleAssign,254 Python Crash Course,"ship = Ship(ai_settings, screen)",simpleAssign,254 Python Crash Course,elif event.key == pygame.K_LEFT:,simpleAssign,255 Python Crash Course,ship.moving_left = True,simpleAssign,255 Python Crash Course,elif event.key == pygame.K_LEFT:,simpleAssign,255 Python Crash Course,ship.moving_left = False,simpleAssign,255 Python Crash Course,elif event.type == pygame.KEYDOWN:,simpleAssign,256 Python Crash Course,elif event.type == pygame.KEYUP:,simpleAssign,256 Python Crash Course,"u self.rect = pygame.Rect(0, 0, ai_settings.bullet_width,",simpleAssign,258 Python Crash Course,v self.rect.centerx = ship.rect.centerx,simpleAssign,258 Python Crash Course,w self.rect.top = ship.rect.top,simpleAssign,258 Python Crash Course,x self.y = float(self.rect.y),simpleAssign,258 Python Crash Course,y self.color = ai_settings.bullet_color,simpleAssign,258 Python Crash Course,u self.y -= self.speed_factor,simpleAssign,259 Python Crash Course,v self.rect.y = self.y,simpleAssign,259 Python Crash Course,"ship = Ship(ai_settings, screen)",simpleAssign,259 Python Crash Course,u bullets = Group(),simpleAssign,259 Python Crash Course,v elif event.key == pygame.K_SPACE:,simpleAssign,260 Python Crash Course,"new_bullet = Bullet(ai_settings, screen, ship)",simpleAssign,260 Python Crash Course,elif event.type == pygame.KEYDOWN:,simpleAssign,260 Python Crash Course,v if bullet.rect.bottom <= 0:,simpleAssign,262 Python Crash Course,elif event.key == pygame.K_SPACE:,simpleAssign,263 Python Crash Course,elif event.key == pygame.K_SPACE:,simpleAssign,264 Python Crash Course,elif event.key == pygame.K_q:,simpleAssign,266 Python Crash Course,u self.rect.x = self.rect.width,simpleAssign,267 Python Crash Course,"alien = Alien(ai_settings, screen)",simpleAssign,268 Python Crash Course,available_space_x = ai_settings.screen_width – (2 * alien_width),simpleAssign,269 Python Crash Course,number_aliens_x = available_space_x / (2 * alien_width),simpleAssign,270 Python Crash Course,"ship = Ship(ai_settings, screen)",simpleAssign,270 Python Crash Course,bullets = Group(),simpleAssign,270 Python Crash Course,u aliens = Group(),simpleAssign,270 Python Crash Course,"u alien = Alien(ai_settings, screen)",simpleAssign,271 Python Crash Course,v alien_width = alien.rect.width,simpleAssign,271 Python Crash Course,w available_space_x = ai_settings.screen_width - 2 * alien_width,simpleAssign,271 Python Crash Course,x number_aliens_x = int(available_space_x / (2 * alien_width)),simpleAssign,271 Python Crash Course,"z alien = Alien(ai_settings, screen)",simpleAssign,271 Python Crash Course,alien.rect.x = alien.x,simpleAssign,271 Python Crash Course,available_space_x = ai_settings.screen_width - 2 * alien_width,simpleAssign,273 Python Crash Course,number_aliens_x = int(available_space_x / (2 * alien_width)),simpleAssign,273 Python Crash Course,"alien = Alien(ai_settings, screen)",simpleAssign,273 Python Crash Course,v alien_width = alien.rect.width,simpleAssign,273 Python Crash Course,alien.rect.x = alien.x,simpleAssign,273 Python Crash Course,"alien = Alien(ai_settings, screen)",simpleAssign,273 Python Crash Course,"w number_aliens_x = get_number_aliens_x(ai_settings, alien.rect.width)",simpleAssign,273 Python Crash Course,available_space_y = ai_settings.screen_height – 3 * alien_height – ship_height,simpleAssign,273 Python Crash Course,number_rows = available_height_y / (2 * alien_height),simpleAssign,274 Python Crash Course,number_rows = int(available_space_y / (2 * alien_height)),simpleAssign,274 Python Crash Course,alien.rect.x = alien.x,simpleAssign,274 Python Crash Course,"number_aliens_x = get_number_aliens_x(ai_settings, alien.rect.width)",simpleAssign,274 Python Crash Course,"number_rows = get_number_rows(ai_settings, ship.rect.height,",simpleAssign,274 Python Crash Course,"random_number = randint(-10,10)",simpleAssign,276 Python Crash Course,v self.rect.x = self.x,simpleAssign,276 Python Crash Course,screen_rect = self.screen.get_rect(),simpleAssign,278 Python Crash Course,u if self.rect.right >= screen_rect.right:,simpleAssign,278 Python Crash Course,v elif self.rect.left <= 0:,simpleAssign,278 Python Crash Course,"collisions = pygame.sprite.groupcollide(bullets, aliens, True, True)",simpleAssign,280 Python Crash Course,"collisions = pygame.sprite.groupcollide(bullets, aliens, True, True)",simpleAssign,282 Python Crash Course,u if len(aliens) == 0:,simpleAssign,282 Python Crash Course,"collisions = pygame.sprite.groupcollide(bullets, aliens, True, True)",simpleAssign,283 Python Crash Course,v stats = GameStats(ai_settings),simpleAssign,286 Python Crash Course,v stats.ships_left -= 1,simpleAssign,287 Python Crash Course,screen_rect = screen.get_rect(),simpleAssign,288 Python Crash Course,u if alien.rect.bottom >= screen_rect.bottom:,simpleAssign,288 Python Crash Course,stats.ships_left -= 1,simpleAssign,289 Python Crash Course,stats.game_active = False,simpleAssign,289 Python Crash Course,"v self.width, self.height = 200, 50",simpleAssign,292 Python Crash Course,"w self.font = pygame.font.SysFont(None, 48)",simpleAssign,292 Python Crash Course,"x self.rect = pygame.Rect(0, 0, self.width, self.height)",simpleAssign,292 Python Crash Course,"u self.msg_image = self.font.render(msg, True, self.text_color,",simpleAssign,293 Python Crash Course,v self.msg_image_rect = self.msg_image.get_rect(),simpleAssign,293 Python Crash Course,"u play_button = Button(ai_settings, screen, ""Play"")",simpleAssign,294 Python Crash Course,u elif event.type == pygame.MOUSEBUTTONDOWN:,simpleAssign,295 Python Crash Course,"v mouse_x, mouse_y = pygame.mouse.get_pos()",simpleAssign,295 Python Crash Course,stats.game_active = True,simpleAssign,295 Python Crash Course,stats.game_active = True,simpleAssign,296 Python Crash Course,elif event.type == pygame.MOUSEBUTTONDOWN:,simpleAssign,297 Python Crash Course,"mouse_x, mouse_y = pygame.mouse.get_pos()",simpleAssign,297 Python Crash Course,"u button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,297 Python Crash Course,"button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,298 Python Crash Course,stats.game_active = False,simpleAssign,298 Python Crash Course,u self.speedup_scale = 1.1,simpleAssign,299 Python Crash Course,"button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,300 Python Crash Course,"w self.font = pygame.font.SysFont(None, 48)",simpleAssign,302 Python Crash Course,u score_str = str(self.stats.score),simpleAssign,302 Python Crash Course,"v self.score_image = self.font.render(score_str, True, self.text_color,",simpleAssign,302 Python Crash Course,w self.score_rect = self.score_image.get_rect(),simpleAssign,302 Python Crash Course,x self.score_rect.right = self.screen_rect.right - 20,simpleAssign,302 Python Crash Course,y self.score_rect.top = 20,simpleAssign,302 Python Crash Course,stats = GameStats(ai_settings),simpleAssign,303 Python Crash Course,"u sb = Scoreboard(ai_settings, screen, stats)",simpleAssign,303 Python Crash Course,"collisions = pygame.sprite.groupcollide(bullets, aliens, True, True)",simpleAssign,304 Python Crash Course,u self.score_scale = 1.5,simpleAssign,306 Python Crash Course,v self.alien_points = int(self.alien_points * self.score_scale),simpleAssign,306 Python Crash Course,"u rounded_score = int(round(self.stats.score, -1))",simpleAssign,307 Python Crash Course,"u high_score = int(round(self.stats.high_score, -1))",simpleAssign,308 Python Crash Course,"w self.high_score_image = self.font.render(high_score_str, True,",simpleAssign,309 Python Crash Course,x self.high_score_rect.centerx = self.screen_rect.centerx,simpleAssign,309 Python Crash Course,y self.high_score_rect.top = self.score_rect.top,simpleAssign,309 Python Crash Course,"u self.level_image = self.font.render(str(self.stats.level), True,",simpleAssign,311 Python Crash Course,v self.level_rect.right = self.score_rect.right,simpleAssign,311 Python Crash Course,"button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,311 Python Crash Course,stats.game_active = True,simpleAssign,312 Python Crash Course,elif event.type == pygame.MOUSEBUTTONDOWN:,simpleAssign,312 Python Crash Course,"mouse_x, mouse_y = pygame.mouse.get_pos()",simpleAssign,312 Python Crash Course,u self.ships = Group(),simpleAssign,314 Python Crash Course,"ship = Ship(self.ai_settings, self.screen)",simpleAssign,314 Python Crash Course,x ship.rect.y = 10,simpleAssign,314 Python Crash Course,"button_clicked = play_button.rect.collidepoint(mouse_x, mouse_y)",simpleAssign,315 Python Crash Course,stats.ships_left -= 1,simpleAssign,315 Python Crash Course,screen_rect = screen.get_rect(),simpleAssign,316 Python Crash Course,"u plt.plot(squares, linewidth=5)",simpleAssign,325 Python Crash Course,"v plt.title(""Square Numbers"", fontsize=24)",simpleAssign,325 Python Crash Course,"w plt.xlabel(""Value"", fontsize=14)",simpleAssign,325 Python Crash Course,"plt.ylabel(""Square of Value"", fontsize=14)",simpleAssign,325 Python Crash Course,"x plt.tick_params(axis='both', labelsize=14)",simpleAssign,325 Python Crash Course,set the font size of the tick mark labels to 14 (labelsize=14).,simpleAssign,325 Python Crash Course,"plt.plot(input_values, squares, linewidth=5)",simpleAssign,326 Python Crash Course,"u plt.scatter(2, 4, s=200)",simpleAssign,327 Python Crash Course,"plt.title(""Square Numbers"", fontsize=24)",simpleAssign,327 Python Crash Course,"plt.xlabel(""Value"", fontsize=14)",simpleAssign,327 Python Crash Course,"plt.ylabel(""Square of Value"", fontsize=14)",simpleAssign,327 Python Crash Course,"plt.tick_params(axis='both', which='major', labelsize=14)",simpleAssign,327 Python Crash Course,"plt.scatter(x_values, y_values, s=100)",simpleAssign,328 Python Crash Course,"u x_values = list(range(1, 1001))",simpleAssign,328 Python Crash Course,"v plt.scatter(x_values, y_values, s=40)",simpleAssign,328 Python Crash Course,"plt.scatter(x_values, y_values, edgecolor='none', s=40)",simpleAssign,329 Python Crash Course,"plt.scatter(x_values, y_values, c='red', edgecolor='none', s=40)",simpleAssign,330 Python Crash Course,x_values = list(range(1001)),simpleAssign,330 Python Crash Course,"plt.scatter(x_values, y_values, c=y_values, cmap=plt.cm.Blues,",simpleAssign,330 Python Crash Course,"edgecolor='none', s=40)",simpleAssign,330 Python Crash Course,"v def __init__(self, num_points=5000):",simpleAssign,332 Python Crash Course,"v x_direction = choice([1, -1])",simpleAssign,333 Python Crash Course,"x_distance = choice([0, 1, 2, 3, 4])",simpleAssign,333 Python Crash Course,w x_step = x_direction * x_distance,simpleAssign,333 Python Crash Course,"y_direction = choice([1, -1])",simpleAssign,333 Python Crash Course,"y_distance = choice([0, 1, 2, 3, 4])",simpleAssign,333 Python Crash Course,x y_step = y_direction * y_distance,simpleAssign,333 Python Crash Course,y if x_step == 0 and y_step == 0:,simpleAssign,333 Python Crash Course,u rw = RandomWalk(),simpleAssign,333 Python Crash Course,"v plt.scatter(rw.x_values, rw.y_values, s=15)",simpleAssign,334 Python Crash Course,rw = RandomWalk(),simpleAssign,335 Python Crash Course,u point_numbers = list(range(rw.num_points)),simpleAssign,335 Python Crash Course,"plt.scatter(rw.x_values, rw.y_values, c=point_numbers, cmap=plt.cm.Blues,",simpleAssign,335 Python Crash Course,"edgecolor='none', s=15)",simpleAssign,335 Python Crash Course,"keep_running = input(""Make another walk? (y/n): "")",simpleAssign,335 Python Crash Course,"the c argument, use the Blues colormap, and then pass edgecolor=none to get",simpleAssign,335 Python Crash Course,"plt.scatter(rw.x_values, rw.y_values, c=point_numbers, cmap=plt.cm.Blues,",simpleAssign,336 Python Crash Course,"edgecolor='none', s=15)",simpleAssign,336 Python Crash Course,"plt.scatter(0, 0, c='green', edgecolors='none', s=100)",simpleAssign,336 Python Crash Course,s=100),simpleAssign,336 Python Crash Course,"s=100) than the rest of the points. To mark the end point, we plot the last",simpleAssign,336 Python Crash Course,s=100),simpleAssign,337 Python Crash Course,rw = RandomWalk(50000),simpleAssign,337 Python Crash Course,point_numbers = list(range(rw.num_points)),simpleAssign,337 Python Crash Course,"plt.scatter(rw.x_values, rw.y_values, c=point_numbers, cmap=plt.cm.Blues,",simpleAssign,337 Python Crash Course,"edgecolor='none', s=1)",simpleAssign,337 Python Crash Course,world data) and plots each point at size s=1. The resulting walk is wispy and,simpleAssign,337 Python Crash Course,rw = RandomWalk(),simpleAssign,338 Python Crash Course,x_step = get_step(),simpleAssign,339 Python Crash Course,y_step = get_step(),simpleAssign,339 Python Crash Course,"u def __init__(self, num_sides=6):",simpleAssign,340 Python Crash Course,u die = Die(),simpleAssign,341 Python Crash Course,result = die.roll(),simpleAssign,341 Python Crash Course,result = die.roll(),simpleAssign,341 Python Crash Course,w frequency = results.count(value),simpleAssign,341 Python Crash Course,frequency = results.count(value),simpleAssign,342 Python Crash Course,u hist = pygal.Bar(),simpleAssign,342 Python Crash Course,die_1 = Die(),simpleAssign,343 Python Crash Course,die_2 = Die(),simpleAssign,343 Python Crash Course,frequency = results.count(value),simpleAssign,344 Python Crash Course,hist = pygal.Bar(),simpleAssign,344 Python Crash Course,die_1 = Die(),simpleAssign,345 Python Crash Course,u die_2 = Die(10),simpleAssign,345 Python Crash Course,hist = pygal.Bar(),simpleAssign,345 Python Crash Course,v reader = csv.reader(f),simpleAssign,350 Python Crash Course,w header_row = next(reader),simpleAssign,350 Python Crash Course,reader = csv.reader(f),simpleAssign,351 Python Crash Course,header_row = next(reader),simpleAssign,351 Python Crash Course,reader = csv.reader(f),simpleAssign,352 Python Crash Course,header_row = next(reader),simpleAssign,352 Python Crash Course,u high = int(row[1]),simpleAssign,353 Python Crash Course,"v plt.title(""Daily high temperatures, July 2014"", fontsize=24)",simpleAssign,353 Python Crash Course,"w plt.xlabel('', fontsize=16)",simpleAssign,353 Python Crash Course,"plt.ylabel(""Temperature (F)"", fontsize=16)",simpleAssign,353 Python Crash Course,"plt.tick_params(axis='both', which='major', labelsize=16)",simpleAssign,353 Python Crash Course,"first_date = datetime.strptime('2014-7-1', '%Y-%m-%d')",simpleAssign,354 Python Crash Course,reader = csv.reader(f),simpleAssign,355 Python Crash Course,header_row = next(reader),simpleAssign,355 Python Crash Course,"v current_date = datetime.strptime(row[0], ""%Y-%m-%d"")",simpleAssign,355 Python Crash Course,high = int(row[1]),simpleAssign,355 Python Crash Course,"plt.title(""Daily high temperatures, July 2014"", fontsize=24)",simpleAssign,355 Python Crash Course,"plt.xlabel('', fontsize=16)",simpleAssign,355 Python Crash Course,"plt.ylabel(""Temperature (F)"", fontsize=16)",simpleAssign,356 Python Crash Course,"plt.tick_params(axis='both', which='major', labelsize=16)",simpleAssign,356 Python Crash Course,"v plt.title(""Daily high temperatures - 2014"", fontsize=24)",simpleAssign,356 Python Crash Course,"plt.xlabel('', fontsize=16)",simpleAssign,356 Python Crash Course,reader = csv.reader(f),simpleAssign,357 Python Crash Course,header_row = next(reader),simpleAssign,357 Python Crash Course,"current_date = datetime.strptime(row[0], ""%Y-%m-%d"")",simpleAssign,357 Python Crash Course,high = int(row[1]),simpleAssign,357 Python Crash Course,v low = int(row[3]),simpleAssign,357 Python Crash Course,"x plt.title(""Daily high and low temperatures - 2014"", fontsize=24)",simpleAssign,358 Python Crash Course,"u plt.plot(dates, highs, c='red', alpha=0.5)",simpleAssign,358 Python Crash Course,"plt.plot(dates, lows, c='blue', alpha=0.5)",simpleAssign,358 Python Crash Course,"v plt.fill_between(dates, highs, lows, facecolor='blue', alpha=0.1)",simpleAssign,358 Python Crash Course,high = int(row[1]),simpleAssign,360 Python Crash Course,reader = csv.reader(f),simpleAssign,360 Python Crash Course,header_row = next(reader),simpleAssign,360 Python Crash Course,"plt.title(title, fontsize=20)",simpleAssign,360 Python Crash Course,u pop_data = json.load(f),simpleAssign,363 Python Crash Course,population = pop_dict['Value'],simpleAssign,363 Python Crash Course,u population = int(pop_dict['Value']),simpleAssign,364 Python Crash Course,population = int(pop_dict['Value']),simpleAssign,364 Python Crash Course,population = int(float(pop_dict['Value'])),simpleAssign,364 Python Crash Course,w if name == country_name:,simpleAssign,366 Python Crash Course,population = int(float(pop_dict['Value'])),simpleAssign,366 Python Crash Course,u code = get_country_code(country_name),simpleAssign,366 Python Crash Course,u wm = pygal.Worldmap(),simpleAssign,367 Python Crash Course,wm = pygal.Worldmap(),simpleAssign,368 Python Crash Course,population = int(float(pop_dict['Value'])),simpleAssign,369 Python Crash Course,code = get_country_code(country),simpleAssign,369 Python Crash Course,v cc_populations[code] = population,simpleAssign,370 Python Crash Course,w wm = pygal.Worldmap(),simpleAssign,370 Python Crash Course,cc_pops_3[cc] = pop,simpleAssign,371 Python Crash Course,wm = pygal.Worldmap(),simpleAssign,371 Python Crash Course,v wm_style = RotateStyle('#336699'),simpleAssign,373 Python Crash Course,w wm = pygal.Worldmap(style=wm_style),simpleAssign,373 Python Crash Course,wm_style = LightColorizedStyle,simpleAssign,374 Python Crash Course,"wm_style = RotateStyle('#336699', base_style=LightColorizedStyle)",simpleAssign,374 Python Crash Course,"wm_style = RS('#336699', base_style=LCS)",simpleAssign,374 Python Crash Course,https://api.github.com/search/repositories?q=language:python&sort=stars,simpleAssign,378 Python Crash Course,"The final part, &sort=stars, sorts the projects by the number of stars they’ve",simpleAssign,379 Python Crash Course,v url = 'https://api.github.com/search/repositories?q=language:python&sort=stars',simpleAssign,379 Python Crash Course,w r = requests.get(url),simpleAssign,379 Python Crash Course,y response_dict = r.json(),simpleAssign,380 Python Crash Course,url = 'https://api.github.com/search/repositories?q=language:python&sort=stars',simpleAssign,380 Python Crash Course,r = requests.get(url),simpleAssign,380 Python Crash Course,response_dict = r.json(),simpleAssign,380 Python Crash Course,v repo_dicts = response_dict['items'],simpleAssign,380 Python Crash Course,w repo_dict = repo_dicts[0],simpleAssign,381 Python Crash Course,repo_dicts = response_dict['items'],simpleAssign,381 Python Crash Course,repo_dict = repo_dicts[0],simpleAssign,381 Python Crash Course,repo_dicts = response_dict['items'],simpleAssign,382 Python Crash Course,URL = 'https://api.github.com/search/repositories?q=language:python&sort=star',simpleAssign,385 Python Crash Course,r = requests.get(URL),simpleAssign,385 Python Crash Course,response_dict = r.json(),simpleAssign,385 Python Crash Course,repo_dicts = response_dict['items'],simpleAssign,385 Python Crash Course,"w my_style = LS('#333366', base_style=LCS)",simpleAssign,385 Python Crash Course,"x chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)",simpleAssign,385 Python Crash Course,chart.x_labels = names,simpleAssign,385 Python Crash Course,"rotation of the labels along the x-axis to 45 degrees (x_label_rotation=45),",simpleAssign,385 Python Crash Course,show_legend=False). We then give the chart a title and set the x_labels attri-,simpleAssign,385 Python Crash Course,"my_style = LS('#333366', base_style=LCS)",simpleAssign,386 Python Crash Course,u my_config = pygal.Config(),simpleAssign,386 Python Crash Course,v my_config.x_label_rotation = 45,simpleAssign,386 Python Crash Course,my_config.show_legend = False,simpleAssign,386 Python Crash Course,w my_config.title_font_size = 24,simpleAssign,386 Python Crash Course,my_config.label_font_size = 14,simpleAssign,386 Python Crash Course,my_config.major_label_font_size = 18,simpleAssign,386 Python Crash Course,x my_config.truncate_label = 15,simpleAssign,386 Python Crash Course,y my_config.show_y_guides = False,simpleAssign,386 Python Crash Course,z my_config.width = 1000,simpleAssign,386 Python Crash Course,"chart = pygal.Bar(my_config, style=my_style)",simpleAssign,386 Python Crash Course,chart.x_labels = names,simpleAssign,386 Python Crash Course,"my_style = LS('#333366', base_style=LCS)",simpleAssign,387 Python Crash Course,"chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)",simpleAssign,387 Python Crash Course,repo_dicts = response_dict['items'],simpleAssign,389 Python Crash Course,"my_style = LS('#333366', base_style=LCS)",simpleAssign,389 Python Crash Course,r = requests.get(url),simpleAssign,391 Python Crash Course,v submission_ids = r.json(),simpleAssign,391 Python Crash Course,submission_r = requests.get(url),simpleAssign,391 Python Crash Course,response_dict = submission_r.json(),simpleAssign,391 Python Crash Course,"submission_dicts = sorted(submission_dicts, key=itemgetter('comments'),",simpleAssign,391 Python Crash Course,reverse=True),simpleAssign,391 Python Crash Course,Discussion link: http://news.ycombinator.com/item?id=9883246,simpleAssign,392 Python Crash Course,Discussion link: http://news.ycombinator.com/item?id=9884165,simpleAssign,392 Python Crash Course,Discussion link: http://news.ycombinator.com/item?id=9884005,simpleAssign,392 Python Crash Course,Discussion link: http://news.ycombinator.com/item?id=9884417,simpleAssign,393 Python Crash Course,Discussion link: http://news.ycombinator.com/item?id=9885625,simpleAssign,393 Python Crash Course,ll_env --python=python3 will create a virtual environment that uses Python 3.,simpleAssign,399 Python Crash Course,u text = models.CharField(max_length=200),simpleAssign,403 Python Crash Course,v date_added = models.DateTimeField(auto_now_add=True),simpleAssign,403 Python Crash Course,"record a date and time v. We pass the argument auto_add_now=True, which",simpleAssign,404 Python Crash Course,v topic = models.ForeignKey(Topic),simpleAssign,408 Python Crash Course,w text = models.TextField(),simpleAssign,408 Python Crash Course,date_added = models.DateTimeField(auto_now_add=True),simpleAssign,408 Python Crash Course,topics = Topic.objects.all(),simpleAssign,410 Python Crash Course,t = Topic.objects.get(id=1),simpleAssign,411 Python Crash Course,w topics = Topic.objects.order_by('date_added'),simpleAssign,419 Python Crash Course,v topic = Topic.objects.get(id=topic_id),simpleAssign,422 Python Crash Course,w entries = topic.entry_set.order_by('-date_added'),simpleAssign,422 Python Crash Course,v model = Topic,simpleAssign,428 Python Crash Course,v form = TopicForm(),simpleAssign,429 Python Crash Course,w form = TopicForm(request.POST),simpleAssign,429 Python Crash Course,model = Entry,simpleAssign,432 Python Crash Course,u topic = Topic.objects.get(id=topic_id),simpleAssign,433 Python Crash Course,w form = EntryForm(),simpleAssign,433 Python Crash Course,x form = EntryForm(data=request.POST),simpleAssign,433 Python Crash Course,y new_entry = form.save(commit=False),simpleAssign,433 Python Crash Course,z new_entry.topic = topic,simpleAssign,433 Python Crash Course,"When we call save(), we include the argument commit=False y to tell",simpleAssign,434 Python Crash Course,u entry = Entry.objects.get(id=entry_id),simpleAssign,436 Python Crash Course,topic = entry.topic,simpleAssign,436 Python Crash Course,v form = EntryForm(instance=entry),simpleAssign,436 Python Crash Course,"w form = EntryForm(instance=entry, data=request.POST)",simpleAssign,436 Python Crash Course,the argument instance=entry v. This argument tells Django to create the,simpleAssign,437 Python Crash Course,"When processing a POST request, we pass the instance=entry argu-",simpleAssign,437 Python Crash Course,ment and the data=request.POST argument w to tell Django to create a form,simpleAssign,437 Python Crash Course,u form = UserCreationForm(),simpleAssign,444 Python Crash Course,v form = UserCreationForm(data=request.POST),simpleAssign,444 Python Crash Course,"y authenticated_user = authenticate(username=new_user.username,",simpleAssign,444 Python Crash Course,password=request.POST['password1']),simpleAssign,444 Python Crash Course,text = models.CharField(max_length=200),simpleAssign,449 Python Crash Course,date_added = models.DateTimeField(auto_now_add=True),simpleAssign,449 Python Crash Course,owner = models.ForeignKey(User),simpleAssign,449 Python Crash Course,topics = Topic.objects.filter(owner=request.user).order_by('date_added'),simpleAssign,451 Python Crash Course,filter(owner=request.user) tells Django to retrieve only the Topic objects,simpleAssign,451 Python Crash Course,topic = Topic.objects.get(id=topic_id),simpleAssign,452 Python Crash Course,v if topic.owner != request.user:,simpleAssign,452 Python Crash Course,entries = topic.entry_set.order_by('-date_added'),simpleAssign,452 Python Crash Course,entry = Entry.objects.get(id=entry_id),simpleAssign,452 Python Crash Course,topic = entry.topic,simpleAssign,452 Python Crash Course,form = TopicForm(),simpleAssign,453 Python Crash Course,form = TopicForm(request.POST),simpleAssign,453 Python Crash Course,u new_topic = form.save(commit=False),simpleAssign,453 Python Crash Course,v new_topic.owner = request.user,simpleAssign,453 Python Crash Course,"When we first call form.save(), we pass the commit=False argument",simpleAssign,453 Python Crash Course,"meta http-equiv=""X-UA-Compatible"" content=""IE=edge"">",simpleAssign,458 Python Crash Course,"meta name=""viewport"" content=""width=device-width, initial-scale=1"">",simpleAssign,458 Python Crash Course,Django==1.8.4,simpleAssign,467 Python Crash Course,dj-database-url==0.3.0,simpleAssign,467 Python Crash Course,dj-static==0.0.6,simpleAssign,467 Python Crash Course,django-bootstrap3==6.2.2,simpleAssign,467 Python Crash Course,gunicorn==19.3.0,simpleAssign,467 Python Crash Course,static3==0.6.1,simpleAssign,467 Python Crash Course,"psycopg2>=2.6.1. This will install version 2.6.1 of psycopg2, or a newer version",simpleAssign,467 Python Crash Course,Django==1.8.4,simpleAssign,467 Python Crash Course,dj-database-url==0.3.0,simpleAssign,467 Python Crash Course,dj-static==0.0.6,simpleAssign,467 Python Crash Course,django-bootstrap3==6.2.2,simpleAssign,467 Python Crash Course,gunicorn==19.3.0,simpleAssign,467 Python Crash Course,static3==0.6.1,simpleAssign,468 Python Crash Course,psycopg2>=2.6.1,simpleAssign,468 Python Crash Course,y BASE_DIR = os.path.dirname(os.path.abspath(__file__)),simpleAssign,469 Python Crash Course,application = Cling(get_wsgi_application()),simpleAssign,470 Python Crash Course,v === web (Free): `gunicorn learning_log.wsgi __log-file -`,simpleAssign,473 Python Crash Course,"the setting DEBUG=True in settings.py, which provides debug messages when",simpleAssign,476 Python Crash Course,v DEBUG = False,simpleAssign,476 Python Crash Course,"u (ll_env)learning_log$ git commit -am ""Set DEBUG=False for Heroku.""",simpleAssign,477 Python Crash Course,master 081f635] Set DEBUG=False for Heroku.,simpleAssign,477 Python Crash Course,"pushing them to Heroku, you’ll first need to set Debug=False on your local",simpleAssign,479 Python Crash Course,DEBUG = False,simpleAssign,479 Python Crash Course,"topic = get_object_or_404(Topic, id=topic_id)",simpleAssign,480 Python Crash Course,DEBUG=False on the live server.,simpleAssign,482 Python Crash Course,git_practice$ git log --pretty=oneline,simpleAssign,509 Python Crash Course,The --pretty=oneline flag provides the two most important pieces of,simpleAssign,510 Python Crash Course,w git_practice$ git log --pretty=oneline,simpleAssign,510 Python Crash Course,git_practice$ git log --pretty=oneline,simpleAssign,512 Python Crash Course,v git_practice$ git log --pretty=oneline,simpleAssign,513 Python Crash Course,y git_practice$ git log --pretty=oneline,simpleAssign,513 "Learning Python, 5th Edition","res = [x + y for x in [0, 1, 2] for y in [100, 200, 300]]",listCompNested,584 "Learning Python, 5th Edition","zip(keyslist, valueslist)) # Zipped key/value tuples form (ahead)",zip,262 "Learning Python, 5th Edition","zip(['a', 'b', 'c'], [1, 2, 3]))",zip,265 "Learning Python, 5th Edition","zip(L1, L2)",zip,407 "Learning Python, 5th Edition","zip(L1, L2)) # list()",zip,407 "Learning Python, 5th Edition","zip(T1, T2, T3))",zip,408 "Learning Python, 5th Edition","zip(S1, S2)) # Truncates at len(shortest)",zip,408 "Learning Python, 5th Edition","zip(keys, vals))",zip,410 "Learning Python, 5th Edition","zip(keys, vals)",zip,410 "Learning Python, 5th Edition","zip(X, Y))",zip,433 "Learning Python, 5th Edition","zip('abc', 'xyz') # An iterable in Python 3.X (a list in 2.X)",zip,434 "Learning Python, 5th Edition","zip('abc', 'xyz'))",zip,434 "Learning Python, 5th Edition","zip(row1, row2)] for (row1, row2) in zip(M, N)",zip,588 "Learning Python, 5th Edition","zip(S1, S2))",zip,617 "Learning Python, 5th Edition","zip([−2, −1, 0, 1, 2]))",zip,617 "Learning Python, 5th Edition","zip([1, 2, 3], [2, 3, 4, 5]))",zip,617 "Learning Python, 5th Edition","zip(...) and map(None, ...)",zip,619 "Learning Python, 5th Edition","zip(seqs...) and 2.X map(None, seqs...)",zip,619 "Learning Python, 5th Edition","zip('abc', 'lmnop'))",zip,622 "Learning Python, 5th Edition","zip(keys, vals)} works like the form dict(zip(keys, vals))",zip,622 "Learning Python, 5th Edition","map(sum, M))",map,113 "Learning Python, 5th Edition","map(ord, S)",map,192 "Learning Python, 5th Edition","map(ord, 'spam'))",map,241 "Learning Python, 5th Edition","map(abs, [−1, −2, 0, 1, 2]))",map,243 "Learning Python, 5th Edition","map(None, S1, S2) # 2.X only: pads to len(longest)",map,408 "Learning Python, 5th Edition","map(ord, 'spam'))",map,409 "Learning Python, 5th Edition","map(str.upper, open('script2.py'))",map,430 "Learning Python, 5th Edition","map(abs, (-1, 0, 1)))",map,437 "Learning Python, 5th Edition","map(func, *iterables)",map,449 "Learning Python, 5th Edition","map(ord, S)",map,467 "Learning Python, 5th Edition","map(function, list)",map,468 "Learning Python, 5th Edition","map(lambda x: 2 ** x, range(7))",map,468 "Learning Python, 5th Edition","map(inc, counters))",map,574 "Learning Python, 5th Edition","map((lambda x: x + 3), counters))",map,575 "Learning Python, 5th Edition","map(func, seq)",map,575 "Learning Python, 5th Edition","map(inc, [1, 2, 3]))",map,575 "Learning Python, 5th Edition","map(inc, [1, 2, 3]) # Ours builds a list (see generators)",map,575 "Learning Python, 5th Edition","map(pow, [1, 2, 3], [2, 3, 4]))",map,575 "Learning Python, 5th Edition","map(inc, [1, 2, 3, 4]))",map,575 "Learning Python, 5th Edition","map((lambda x: x ** 2), range(10)))",map,583 "Learning Python, 5th Edition","map((lambda row: row[1]), listoftuple))",map,591 "Learning Python, 5th Edition","map((lambda (name, age, job): age), listoftuple))",map,591 "Learning Python, 5th Edition","map(abs, (−1, −2, 3, 4)))",map,599 "Learning Python, 5th Edition","map(lambda x: x * 2, (1, 2, 3, 4)))",map,600 "Learning Python, 5th Edition","map(str.upper, line.split(',')))",map,600 "Learning Python, 5th Edition","map(lambda x: x * 2, line.split(',')))",map,600 "Learning Python, 5th Edition","map(lambda x: x * 2, map(abs, (−1, −2, 3, 4))))",map,600 "Learning Python, 5th Edition","map(math.sqrt, (x ** 2 for x in range(4))))",map,600 "Learning Python, 5th Edition","map(abs, map(abs, map(abs, (−1, 0, 1)))))",map,601 "Learning Python, 5th Edition","map(str.upper, filter(lambda x: len(x) > 1, line.split())))",map,601 "Learning Python, 5th Edition","map(abs, [−2, −1, 0, 1, 2]))",map,617 "Learning Python, 5th Edition","map(pow, [1, 2, 3], [2, 3, 4, 5]))",map,617 "Learning Python, 5th Edition","map(lambda x, y: x + y, open('script2.py'), open('script2.py'))",map,617 "Learning Python, 5th Edition","map(func, ...)",map,617 "Learning Python, 5th Edition","map(func, seqs...)",map,617 "Learning Python, 5th Edition","map(None, [1, 2, 3], [2, 3, 4, 5])",map,619 "Learning Python, 5th Edition","map(None, 'abc', 'xyz123')",map,619 "Learning Python, 5th Edition","map(lambda x: x ** 2, range(1000)))",map,649 "Learning Python, 5th Edition","map(lambda x: x ** 2, range(1000)))",map,649 "Learning Python, 5th Edition","map(lambda x: x ** 2, range(1000)))",map,650 "Learning Python, 5th Edition","map(lambda x: x ** 2, range(1000)))",map,650 "Learning Python, 5th Edition","map(ord, 'spam' * 2500))"")",map,652 "Learning Python, 5th Edition","map(ord, 'spam' * 2500))",map,652 "Learning Python, 5th Edition","map(lambda x: x ** 2, range(1000)))",map,654 "Learning Python, 5th Edition","map(F,X)",map,889 "Learning Python, 5th Edition","map(str.upper, X)) # map calls (use list() in 3.X)",map,895 "Learning Python, 5th Edition","map(str, Squares(1, 5)))",map,898 "Learning Python, 5th Edition","map(lambda act: act(5), actions))",map,952 "Learning Python, 5th Edition","map(), range()",map,1461 "Learning Python, 5th Edition","map(None, ...)",map,1461 "Learning Python, 5th Edition","map()), list(range())",map,1461 "Learning Python, 5th Edition","map(ord, S)) # list()",map,1473 "Learning Python, 5th Edition","map(math.sqrt, values))",map,1480 "Learning Python, 5th Edition",def __init__(...): ... # On iter(),privatemethod,608 "Learning Python, 5th Edition",def __next__(...): ... # On next(),privatemethod,608 "Learning Python, 5th Edition","def __init__(self, value): # On ""ThirdClass(value)",privatemethod,806 "Learning Python, 5th Edition","def __str__(self): # On ""print(self)"", ""str()",privatemethod,806 "Learning Python, 5th Edition","def __init__(self, start): # On Number(start)",privatemethod,888 "Learning Python, 5th Edition","def __add__(self, other): # __add__ fallback: x = (x + y)",privatemethod,921 "Learning Python, 5th Edition",def __method(self),privatemethod,947 "Learning Python, 5th Edition",def __attrnames(self),privatemethod,959 "Learning Python, 5th Edition",def __attrnames(self),privatemethod,959 "Learning Python, 5th Edition",def __attrnames(self),privatemethod,964 "Learning Python, 5th Edition","def __attrnames(self, indent=' '*4)",privatemethod,965 "Learning Python, 5th Edition","def __attrnames(self, obj, indent)",privatemethod,967 "Learning Python, 5th Edition","def __listclass(self, aClass, indent)",privatemethod,967 "Learning Python, 5th Edition",def __len__(self): return len(self.data) # len(self),privatemethod,980 "Learning Python, 5th Edition","def __and__(self, other): return self.intersect(other)",privatemethod,980 "Learning Python, 5th Edition","def __or__(self, other): return self.union(other)",privatemethod,980 "Learning Python, 5th Edition",def __repr__(self): return 'Set:' + repr(self.data) # print(self),privatemethod,981 "Learning Python, 5th Edition",def __iter__(self): return iter(self.data),privatemethod,981 "Learning Python, 5th Edition","def __and__(self, other): return self.intersect(other)",privatemethod,983 "Learning Python, 5th Edition","def __or__(self, other): return self.union(other)",privatemethod,983 "Learning Python, 5th Edition","def __getattr__(self, name): print(name)",privatemethod,989 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'),privatemethod,1051 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'),privatemethod,1051 "Learning Python, 5th Edition",def __init__(self): print('A.__init__'),privatemethod,1051 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'); A.__init__(self),privatemethod,1051 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'); A.__init__(self),privatemethod,1051 "Learning Python, 5th Edition",def __init__(self): print('A.__init__'),privatemethod,1052 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'); super().__init__(),privatemethod,1052 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'); super().__init__(),privatemethod,1052 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'); super().__init__(),privatemethod,1053 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'); super().__init__(),privatemethod,1053 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'),privatemethod,1054 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'),privatemethod,1054 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'); super().__init__(),privatemethod,1054 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'); super().__init__(),privatemethod,1054 "Learning Python, 5th Edition",def __init__(self): print('D.__init__'); super().__init__(),privatemethod,1054 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'),privatemethod,1055 "Learning Python, 5th Edition",def __init__(self): print('D.__init__'); super().__init__(),privatemethod,1055 "Learning Python, 5th Edition",def __init__(self): print('B.__init__'); super().__init__(),privatemethod,1055 "Learning Python, 5th Edition",def __init__(self): print('C.__init__'); super().__init__(),privatemethod,1055 "Learning Python, 5th Edition",def __init__(self): print('D.__init__'); C.__init__(self); B.__init__(self),privatemethod,1055 "Learning Python, 5th Edition","def __init__(self, name): super().__init__(name, 70000)",privatemethod,1061 "Learning Python, 5th Edition","def __set__(self, instance, value): ... # Return nothing (None)",privatemethod,1227 "Learning Python, 5th Edition","def __delete__(self, instance): ... # Return nothing (None)",privatemethod,1227 "Learning Python, 5th Edition",def __get__(*args): print('get'),privatemethod,1228 "Learning Python, 5th Edition",def __get__(*args): print('get'),privatemethod,1229 "Learning Python, 5th Edition",def __set__(*args): raise AttributeError('cannot set'),privatemethod,1229 "Learning Python, 5th Edition","def __init__(self, name): # On [Person()",privatemethod,1241 "Learning Python, 5th Edition","def __get__(self, instance, owner): print('__get__')",privatemethod,1385 "Learning Python, 5th Edition","def __set__(self, instance, value): print('__set__')",privatemethod,1385 "Learning Python, 5th Edition","def __get__(self, instance, owner): print('__get__')",privatemethod,1385 "Learning Python, 5th Edition",def __str__(self): return('class'),privatemethod,1387 "Learning Python, 5th Edition",def __str__(self): return('D class'),privatemethod,1387 "Learning Python, 5th Edition",def __str__(self): return('C class'),privatemethod,1387 "Learning Python, 5th Edition",def __str__(self): return('C class'),privatemethod,1387 "Learning Python, 5th Edition","def __init__(self, name, pay): # Person = decorateAll(..)(Person)",privatemethod,1405 "Learning Python, 5th Edition",def __attrnames(self),privatemethod,1495 "Learning Python, 5th Edition",def __supers(self),privatemethod,1495 "Learning Python, 5th Edition","class Meta(type): def __new__(meta, classname, supers, classdict):",metaclass3,1039 "Learning Python, 5th Edition","class Meta(type): def __new__(meta, classname, supers, classdict): # Run by inherited type.__call__ return type.__new__(meta, classname, supers, classdict) This metaclass doesn’t really do anything (we might as well let the default type class create the class), but it demonstrates the way a metaclass taps into the metaclass hook to customize—because the metaclass is called at the end of a class statement, and because the type object’s __call__ dispatches to the __new__ and __init__ methods, code we provide in these methods can manage all the classes created from the metaclass. Here’s our example in action again, with prints added to the metaclass and the file at large to trace (again, some filenames are implied by later command-lines in this chap- ter): class MetaOne(type): def __new__(meta, classname, supers, classdict):",metaclass3,1371 "Learning Python, 5th Edition","class Eggs(object): # One of the ""object"" optional class Spam(Eggs, object): __metaclass__ = MetaOne Customizing Construction and Initialization Metaclasses can also tap into the __init__ protocol invoked by the type object’s __call__. In general, __new__ creates and returns the class object, and __init__ initial- izes the already created class passed in as an argument. Metaclasses can use either or both hooks to manage the class at creation time: class MetaTwo(type): def __new__(meta, classname, supers, classdict):",metaclass3,1372 "Learning Python, 5th Edition","class SuperMeta(type): def __call__(meta, classname, supers, classdict): print('In SuperMeta.call: ', classname, supers, classdict, sep='\n...') return type.__call__(meta, classname, supers, classdict) def __init__(Class, classname, supers, classdict): print('In SuperMeta init:', classname, supers, classdict, sep='\n...') print('...init class object:', list(Class.__dict__.keys())) print('making metaclass') class SubMeta(type, metaclass=SuperMeta): def __new__(meta, classname, supers, classdict):",metaclass3,1376 "Learning Python, 5th Edition","class MetaOne(type): def __new__(meta, classname, supers, classdict):",metaclass3,1379 "Learning Python, 5th Edition","class Extender(type): def __new__(meta, classname, supers, classdict):",metaclass3,1393 "Learning Python, 5th Edition","class MetaExtend(type): def __new__(meta, classname, supers, classdict):",metaclass3,1394 "Learning Python, 5th Edition","class Metaclass(type): def __new__(meta, clsname, supers, attrdict):",metaclass3,1398 "Learning Python, 5th Edition","class MetaTrace(type): def __new__(meta, classname, supers, classdict):",metaclass3,1402 "Learning Python, 5th Edition","class MetaDecorate(type): def __new__(meta, classname, supers, classdict):",metaclass3,1403 "Learning Python, 5th Edition",__metaclass__ = ABCMeta,metaclass2,871 "Learning Python, 5th Edition",__metaclass__ = Meta,metaclass2,1040 "Learning Python, 5th Edition",__metaclass__ = Meta,metaclass2,1369 "Learning Python, 5th Edition",__metaclass__ = Meta,metaclass2,1369 "Learning Python, 5th Edition",__metaclass__ = M,metaclass2,1462 "Learning Python, 5th Edition",class Super(metaclass=ABCMeta):,metaclassheader,870 "Learning Python, 5th Edition",class Super(metaclass=ABCMeta):,metaclassheader,871 "Learning Python, 5th Edition",class C(metaclass=Meta):,metaclassheader,1040 "Learning Python, 5th Edition",class Client1(metaclass=Extras):,metaclassheader,1361 "Learning Python, 5th Edition",class Client2(metaclass=Extras):,metaclassheader,1361 "Learning Python, 5th Edition",class Client3(metaclass=Extras):,metaclassheader,1361 "Learning Python, 5th Edition",class Spam(metaclass=Meta):,metaclassheader,1369 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=Meta):",metaclassheader,1369 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=Meta):",metaclassheader,1370 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=MetaOne):",metaclassheader,1371 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=MetaTwo):",metaclassheader,1372 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=MetaFunc):",metaclassheader,1373 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=MetaObj()):",metaclassheader,1374 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=SubMetaObj()):",metaclassheader,1375 "Learning Python, 5th Edition","class Spam(Eggs, metaclass=SubMeta):",metaclassheader,1376 "Learning Python, 5th Edition",class Super(metaclass=MetaOne):,metaclassheader,1380 "Learning Python, 5th Edition",class B(metaclass=A):,metaclassheader,1381 "Learning Python, 5th Edition","class B(A, metaclass=M):",metaclassheader,1381 "Learning Python, 5th Edition","class C(B, metaclass=M):",metaclassheader,1382 "Learning Python, 5th Edition","class C2(C1,metaclass=M2):",metaclassheader,1382 "Learning Python, 5th Edition",class C(metaclass=D):,metaclassheader,1387 "Learning Python, 5th Edition",class B(metaclass=A):,metaclassheader,1388 "Learning Python, 5th Edition",class B(metaclass=A):,metaclassheader,1389 "Learning Python, 5th Edition",class B(metaclass=A):,metaclassheader,1390 "Learning Python, 5th Edition",class B(metaclass=A):,metaclassheader,1390 "Learning Python, 5th Edition",class Client1(metaclass=Extender):,metaclassheader,1393 "Learning Python, 5th Edition",class Client2(metaclass=Extender):,metaclassheader,1393 "Learning Python, 5th Edition",class Person(metaclass=Tracer):,metaclassheader,1397 "Learning Python, 5th Edition","class B(A, metaclass=Metaclass):",metaclassheader,1398 "Learning Python, 5th Edition","class B(A, metaclass=Metaclass):",metaclassheader,1399 "Learning Python, 5th Edition",class C(metaclass=func):,metaclassheader,1399 "Learning Python, 5th Edition",class Person(metaclass=MetaTrace):,metaclassheader,1402 "Learning Python, 5th Edition",class Person(metaclass=decorateAll(tracer)):,metaclassheader,1403 "Learning Python, 5th Edition",class Person(metaclass=decorateAll(tracer)):,metaclassheader,1404 "Learning Python, 5th Edition",class Person(metaclass=decorateAll(timer())):,metaclassheader,1404 "Learning Python, 5th Edition",class Person(metaclass=decorateAll(timer(label='**'))):,metaclassheader,1404 "Learning Python, 5th Edition",class C(metaclass=M):,metaclassheader,1462 "Learning Python, 5th Edition","super().act() # Reference superclass generically, omit self",superfunc,1043 "Learning Python, 5th Edition",super().act() # super applied to a single-inheritance tree,superfunc,1045 "Learning Python, 5th Edition","super().act() # Doesn't fail on multi-inher, but picks just one!",superfunc,1045 "Learning Python, 5th Edition","super().act() # If B is listed first, A.act() is no longer run!",superfunc,1045 "Learning Python, 5th Edition","super().__init__() here would run only one constructor, and adding super throughout",superfunc,1046 "Learning Python, 5th Edition",super().__getitem__(ix) # Direct name calls work too,superfunc,1047 "Learning Python, 5th Edition",super().act() # Simpler 3.X call format fails in 2.X,superfunc,1048 "Learning Python, 5th Edition",super().m() # Can't hardcode class name here,superfunc,1050 "Learning Python, 5th Edition","super().__init__(name, 50000) # Dispatch by super()",superfunc,1060 "Learning Python, 5th Edition","super().__init__(name, 40000)",superfunc,1060 "Learning Python, 5th Edition","@rangetest(percent=(0.0, 1.0)) # Use decorator to validate def",decaratorfunc,826 "Learning Python, 5th Edition","@abstractmethod def",decaratorfunc,870 "Learning Python, 5th Edition","@abstractmethod def",decaratorfunc,871 "Learning Python, 5th Edition","@abstractmethod def",decaratorfunc,871 "Learning Python, 5th Edition","@property # Coding properties with decorators: ahead def",decaratorfunc,1022 "Learning Python, 5th Edition","@staticmethod # Function decoration syntax def",decaratorfunc,1035 "Learning Python, 5th Edition","@staticmethod def",decaratorfunc,1036 "Learning Python, 5th Edition","@staticmethod def",decaratorfunc,1036 "Learning Python, 5th Edition","@classmethod def",decaratorfunc,1036 "Learning Python, 5th Edition","@property # Property: computed on fetch def",decaratorfunc,1036 "Learning Python, 5th Edition","@tracer # Same as spam = tracer(spam) def",decaratorfunc,1037 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1038 "Learning Python, 5th Edition","@count def",decaratorfunc,1039 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1224 "Learning Python, 5th Edition","@property def",decaratorfunc,1225 "Learning Python, 5th Edition","@property def",decaratorfunc,1225 "Learning Python, 5th Edition","@name.setter def",decaratorfunc,1225 "Learning Python, 5th Edition","@name.deleter def",decaratorfunc,1225 "Learning Python, 5th Edition","@decorator # Decorate function def",decaratorfunc,1273 "Learning Python, 5th Edition","@staticmethod def",decaratorfunc,1274 "Learning Python, 5th Edition","@property def",decaratorfunc,1274 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1274 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1274 "Learning Python, 5th Edition","@decorator # func = decorator(func) def",decaratorfunc,1275 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1275 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1276 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1276 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1276 "Learning Python, 5th Edition","@C def",decaratorfunc,1280 "Learning Python, 5th Edition","@d3 def",decaratorfunc,1281 "Learning Python, 5th Edition","@d3 def",decaratorfunc,1281 "Learning Python, 5th Edition","@decorator(A, B) def",decaratorfunc,1281 "Learning Python, 5th Edition","@decorator def",decaratorfunc,1282 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1283 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1285 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1285 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1286 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1286 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1287 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1287 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1288 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1288 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1289 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1290 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1290 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1291 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1291 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1292 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1292 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1293 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1293 "Learning Python, 5th Edition","@tracer # Applies to class methods def",decaratorfunc,1295 "Learning Python, 5th Edition","@tracer # But fails for simple functions def",decaratorfunc,1295 "Learning Python, 5th Edition","@timer def",decaratorfunc,1296 "Learning Python, 5th Edition","@timer def",decaratorfunc,1296 "Learning Python, 5th Edition","@timer('==>') # Like listcomp = timer('==>')(listcomp) def",decaratorfunc,1298 "Learning Python, 5th Edition","@timer(label='[CCC]==>') def",decaratorfunc,1299 "Learning Python, 5th Edition","@timer(trace=True, label='[MMM]==>') def",decaratorfunc,1300 "Learning Python, 5th Edition","@timer(trace=False) # No tracing, collect total time ... def",decaratorfunc,1300 "Learning Python, 5th Edition","@timer(trace=True, label='\t=>') # Turn on tracing, custom label ... def",decaratorfunc,1300 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1310 "Learning Python, 5th Edition","@register def",decaratorfunc,1312 "Learning Python, 5th Edition","@register def",decaratorfunc,1312 "Learning Python, 5th Edition","@decorate def",decaratorfunc,1313 "Learning Python, 5th Edition","@annotate('spam data') def",decaratorfunc,1314 "Learning Python, 5th Edition","@rangetest(percent=(0.0, 1.0)) # Use decorator to validate def",decaratorfunc,1331 "Learning Python, 5th Edition","@rangetest((1, 0, 120)) # persinfo = rangetest(...)(persinfo) def",decaratorfunc,1332 "Learning Python, 5th Edition","@rangetest([0, 1, 12], [1, 1, 31], [2, 0, 2009]) def",decaratorfunc,1332 "Learning Python, 5th Edition","@rangetest([1, 0.0, 1.0]) # giveRaise = rangetest(...)(giveRaise) def",decaratorfunc,1332 "Learning Python, 5th Edition","@rangetest(age=(0, 120)) # persinfo = rangetest(...)(persinfo) def",decaratorfunc,1334 "Learning Python, 5th Edition","@rangetest(M=(1, 12), D=(1, 31), Y=(0, 2013)) def",decaratorfunc,1334 "Learning Python, 5th Edition","@rangetest(percent=(0.0, 1.0)) # percent passed by name or position def",decaratorfunc,1335 "Learning Python, 5th Edition","@rangetest(a=(1, 10), b=(1, 10), c=(1, 10), d=(1, 10)) def",decaratorfunc,1335 "Learning Python, 5th Edition","@rangetest(a=(1, 5), c=(0.0, 1.0)) def",decaratorfunc,1340 "Learning Python, 5th Edition","@rangetest def",decaratorfunc,1341 "Learning Python, 5th Edition","@rangetest(a=(1, 5), c=(0.0, 1.0)) def",decaratorfunc,1341 "Learning Python, 5th Edition","@rangetest def",decaratorfunc,1341 "Learning Python, 5th Edition","@typetest(a=int, c=float) def",decaratorfunc,1343 "Learning Python, 5th Edition","@typetest def",decaratorfunc,1343 "Learning Python, 5th Edition","@timer(trace=True, label='[CCC]==>') def",decaratorfunc,1346 "Learning Python, 5th Edition","@timer('[MMM]==>') def",decaratorfunc,1346 "Learning Python, 5th Edition","@timer() def",decaratorfunc,1346 "Learning Python, 5th Edition","@timer(label='**') def",decaratorfunc,1346 "Learning Python, 5th Edition","@rangetest(m=(1, 12), d=(1, 31), y=(1900, 2013)) def",decaratorfunc,1351 "Learning Python, 5th Edition","@typetest(a=int, c=float) def",decaratorfunc,1351 "Learning Python, 5th Edition","@valuetest(word1=str.islower, word2=(lambda x: x[0].isupper())) def",decaratorfunc,1352 "Learning Python, 5th Edition","@valuetest(A=lambda x: isinstance(x, int), B=lambda x: x > 0 and x < 10) def",decaratorfunc,1352 "Learning Python, 5th Edition","@typetest(Z=str) # Only innermost validates positional args def",decaratorfunc,1352 "Learning Python, 5th Edition","@rangetest(a=(1, 10)) def",decaratorfunc,1353 "Learning Python, 5th Edition","@typetest(a=int) def",decaratorfunc,1353 "Learning Python, 5th Edition","@classmethod # Class method: gets class def",decaratorfunc,1389 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1401 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1401 "Learning Python, 5th Edition","@tracer def",decaratorfunc,1401 "Learning Python, 5th Edition","@decorateAll(tracer) # Decorate all with tracer @decorateAll(timer()) # Decorate all with timer, def",decaratorfunc,1406 "Learning Python, 5th Edition","@safe def",decaratorfunc,1499 "Learning Python, 5th Edition","@decorator # Class decoration syntax class",decaratorclass,1038 "Learning Python, 5th Edition","@count class",decaratorclass,1039 "Learning Python, 5th Edition","@count class",decaratorclass,1039 "Learning Python, 5th Edition","@count class",decaratorclass,1039 "Learning Python, 5th Edition","@count class",decaratorclass,1039 "Learning Python, 5th Edition","@decorator class",decaratorclass,1039 "Learning Python, 5th Edition","@decorator # Decorate class class",decaratorclass,1277 "Learning Python, 5th Edition","@decorator class",decaratorclass,1278 "Learning Python, 5th Edition","@decorator class",decaratorclass,1278 "Learning Python, 5th Edition","@decorator class",decaratorclass,1278 "Learning Python, 5th Edition","@Decorator class",decaratorclass,1279 "Learning Python, 5th Edition","@eggs class",decaratorclass,1280 "Learning Python, 5th Edition","@decorator class",decaratorclass,1283 "Learning Python, 5th Edition","@singleton # Person = singleton(Person) class",decaratorclass,1302 "Learning Python, 5th Edition","@singleton # Spam = singleton(Spam) class",decaratorclass,1302 "Learning Python, 5th Edition","@Tracer class",decaratorclass,1305 "Learning Python, 5th Edition","@Tracer class",decaratorclass,1305 "Learning Python, 5th Edition","@Tracer ... class",decaratorclass,1306 "Learning Python, 5th Edition","@Tracer # Decorator approach class",decaratorclass,1307 "Learning Python, 5th Edition","@Tracer # Triggers __init__ class",decaratorclass,1308 "Learning Python, 5th Edition","@Tracer class",decaratorclass,1308 "Learning Python, 5th Edition","@Tracer class",decaratorclass,1309 "Learning Python, 5th Edition","@register class",decaratorclass,1312 "Learning Python, 5th Edition","@Private('data', 'size') # Doubler = Private(...)(Doubler) class",decaratorclass,1315 "Learning Python, 5th Edition","@Private('age') # Person = Private('age')(Person) class",decaratorclass,1320 "Learning Python, 5th Edition","@Public('name') class",decaratorclass,1320 "Learning Python, 5th Edition","@Private('age') class",decaratorclass,1323 "Learning Python, 5th Edition","@Private('age') class",decaratorclass,1323 "Learning Python, 5th Edition","@Private('age') # Person = Private('age')(Person) class",decaratorclass,1348 "Learning Python, 5th Edition","@callable syntax for decorators allows us to add logic to be automatically run when a function is called or a class",decaratorclass,1358 "Learning Python, 5th Edition","@extras class",decaratorclass,1362 "Learning Python, 5th Edition","@extras class Client2: ... # Rebinds class",decaratorclass,1362 "Learning Python, 5th Edition","@extras class",decaratorclass,1362 "Learning Python, 5th Edition","@Extender class",decaratorclass,1395 "Learning Python, 5th Edition","@Extender class",decaratorclass,1395 "Learning Python, 5th Edition","@Tracer class",decaratorclass,1396 "Learning Python, 5th Edition","@decorator class",decaratorclass,1398 "Learning Python, 5th Edition","@func class C: # A class",decaratorclass,1399 "Learning Python, 5th Edition","@decorateAll(tracer) # Use a class decorator class",decaratorclass,1405 "Learning Python, 5th Edition","@decorateAll(tracer(timer(label='@@'))) # Traces applying the timer class",decaratorclass,1406 "Learning Python, 5th Edition","@decorateAll(timer(label='@@')) class",decaratorclass,1406 "Learning Python, 5th Edition","@decorateAll(timer(label='@@')) 1406 | Chapter 40: Metaclass",decaratorclass,1406 "Learning Python, 5th Edition","@decorateAll(tracer) # Times onCall wrapper, traces methods class",decaratorclass,1407 "Learning Python, 5th Edition",enumerate(S),enumfunc,411 "Learning Python, 5th Edition",enumerate('spam')),enumfunc,424 "Learning Python, 5th Edition","enumerate(ups('aaa,bbb,ccc'))",enumfunc,596 "Learning Python, 5th Edition",col2 = [row[1] for row in M],simpleListComp,111 "Learning Python, 5th Edition",L = [x**2 for x in range(5)],simpleListComp,241 "Learning Python, 5th Edition",L = [x + 20 for x in T],simpleListComp,279 "Learning Python, 5th Edition",numbers = [int(P) for P in parts],simpleListComp,289 "Learning Python, 5th Edition",objects = [eval(P) for P in parts],simpleListComp,289 "Learning Python, 5th Edition",Y = [list(L) for i in range(4)],simpleListComp,310 "Learning Python, 5th Edition",L = [x + 10 for x in L],simpleListComp,424 "Learning Python, 5th Edition",L = [x + 10 for x in L],simpleListComp,425 "Learning Python, 5th Edition",lines = [line.rstrip() for line in lines],simpleListComp,426 "Learning Python, 5th Edition",lines = [line.rstrip() for line in open('script2.py')],simpleListComp,426 "Learning Python, 5th Edition",lines = [line.rstrip() for line in open('script2.py') if line[0] == 'p'],simpleListComp,427 "Learning Python, 5th Edition",uppers = [line.upper() for line in open('script2.py')],simpleListComp,430 "Learning Python, 5th Edition",seqs = [list(S) for S in seqs],simpleListComp,619 "Learning Python, 5th Edition",seqs = [list(S) for S in seqs],simpleListComp,620 "Learning Python, 5th Edition",res = [next(i) for i in iters],simpleListComp,622 "Learning Python, 5th Edition","stmt=""L = [1, 2, 3, 4, 5]\nM = [x + 1 for x in L]",simpleListComp,645 "Learning Python, 5th Edition","c:\code> py −3 -m timeit -n 1000 -r 3 ""L = [1,2,3,4,5]"" ""M = [x + 1 for x in L]",simpleListComp,646 "Learning Python, 5th Edition","c:\code> python -m timeit -n 1000 -r 3 ""L = [1,2,3,4,5]"" ""M = [x + 1 for x in L]",simpleListComp,646 "Learning Python, 5th Edition","c:\code> python -m timeit -n 1000 -r 3 -s ""L = [1,2,3,4,5]"" ""M = [x + 1 for x in L]",simpleListComp,646 "Learning Python, 5th Edition",import random\nvals=[random.random() for i in range(1000)],simpleListComp,646 "Learning Python, 5th Edition",y = [x ** 2 for x in range(1000)],simpleListComp,647 "Learning Python, 5th Edition","0, 0, ""s = 'spam' * 2500\nx = [s[i] for i in range(10000)]",simpleListComp,649 "Learning Python, 5th Edition","0.8746 [""s = 'spam' * 2500\nx = [s[i] for i in range(10000)]""]",simpleListComp,649 "Learning Python, 5th Edition","0.6143 [""s = 'spam' * 2500\nx = [s[i] for i in range(10000)]""]",simpleListComp,649 "Learning Python, 5th Edition","0.1298 [""s = 'spam' * 2500\nx = [s[i] for i in range(10000)]""]",simpleListComp,650 "Learning Python, 5th Edition","s = 'spam' * 2500\nx = [s[i] for i in range(10000)]""]",simpleListComp,650 "Learning Python, 5th Edition","0.8711 [""s = 'spam' * 2500\nx = [s[i] for i in range(10000)]""]",simpleListComp,654 "Learning Python, 5th Edition","c:\code> python -m timeit -n 1000 -r 3 -s ""L = [1,2,3,4,5]"" ""M = [x + 1 for x in L]",simpleListComp,1434 "Learning Python, 5th Edition","t = [print(i, end=' ') for i in range(5, 0, −1)]",simpleListComp,1483 "Learning Python, 5th Edition",nums = [int(col) for col in cols],simpleListComp,1501 "Learning Python, 5th Edition",nums = [int(x) for x in cols],simpleListComp,1501 "Learning Python, 5th Edition",colnames = [desc[0] for desc in curs.description],simpleListComp,1505 "Learning Python, 5th Edition","unders = [] for attr in dir(self): # Instance dir() if attr[:2] == '__' and attr[-2:]",listCompIf,965 "Learning Python, 5th Edition",D = {x: x*2 for x in range(10)},simpleDictComp,252 "Learning Python, 5th Edition","D = {k: v for (k, v) in zip(['a', 'b', 'c'], [1, 2, 3])}",simpleDictComp,265 "Learning Python, 5th Edition","D = {x: x ** 2 for x in [1, 2, 3, 4]}",simpleDictComp,265 "Learning Python, 5th Edition",D = {c: c * 4 for c in 'SPAM'},simpleDictComp,265 "Learning Python, 5th Edition","D = {c.lower(): c + '!' for c in ['SPAM', 'EGGS', 'HAM']}",simpleDictComp,266 "Learning Python, 5th Edition","D = {k:0 for k in ['a', 'b', 'c']}",simpleDictComp,266 "Learning Python, 5th Edition",D = {k: None for k in 'spam'},simpleDictComp,266 "Learning Python, 5th Edition",table = {act(5): act for act in actions},simpleDictComp,953 "Learning Python, 5th Edition",G = (sum(row) for row in M),generatorExpression,112 "Learning Python, 5th Edition",G = (x ** 2 for x in range(4)),generatorExpression,598 "Learning Python, 5th Edition",G = (S[i:] + S[:i] for i in range(len(S))),generatorExpression,611 "Learning Python, 5th Edition","genabove = (self.__listclass(c, indent+4) for c in aClass.__bases__)",generatorExpression,968 "Learning Python, 5th Edition","struct.unpack('>i4sh', data)",struct,124 "Learning Python, 5th Edition","pickle.dump(D, F)",pickle,290 "Learning Python, 5th Edition","pickle.dump(object, file)",pickle,941 "Learning Python, 5th Edition","pickle.dump(shop, open('shopfile.pkl', 'wb'))",pickle,941 "Learning Python, 5th Edition","pickle.dumps([1, 2, 3])",pickle,1210 "Learning Python, 5th Edition","pickle.dumps([1, 2, 3], protocol=0)",pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'w'))",pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'w'), protocol=0)",pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'wb'))",pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'wb'))",pickle,1210 "Learning Python, 5th Edition","pickle.load(open('temp', 'rb'))",pickle,1210 "Learning Python, 5th Edition","pickle.dumps([1, 2, 3])",pickle,1210 "Learning Python, 5th Edition","pickle.dumps([1, 2, 3], protocol=1)",pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'w'))",pickle,1210 "Learning Python, 5th Edition",pickle.load(open('temp')),pickle,1210 "Learning Python, 5th Edition","pickle.dump([1, 2, 3], open('temp', 'wb'))",pickle,1211 "Learning Python, 5th Edition","pickle.load(open('temp', 'rb'))",pickle,1211 "Learning Python, 5th Edition",import dbm,importdbm,271 "Learning Python, 5th Edition","re.split('[/:]', '/usr/home/lumberjack')",re,108 "Learning Python, 5th Edition","re.match('sp(.*)am', line)",re,192 "Learning Python, 5th Edition",re.compile(),re,308 "Learning Python, 5th Edition","re.match('(.*) down (.*) on (.*)', S).groups()",re,1206 "Learning Python, 5th Edition","re.match(b'(.*) down (.*) on (.*)', B).groups()",re,1207 "Learning Python, 5th Edition","re.match('(.*) down (.*) on (.*)', S).groups()",re,1207 "Learning Python, 5th Edition","re.match('(.*) down (.*) on (.*)', U).groups()",re,1207 "Learning Python, 5th Edition","re.match('(.*) down (.*) on (.*)', B).groups()",re,1207 "Learning Python, 5th Edition","re.match(b'(.*) down (.*) on (.*)', S).groups()",re,1207 "Learning Python, 5th Edition","re.match(b'(.*) down (.*) on (.*)', bytearray(B)).groups()",re,1207 "Learning Python, 5th Edition","re.match('(.*) down (.*) on (.*)', bytearray(B)).groups()",re,1207 "Learning Python, 5th Edition",import re,importre,108 "Learning Python, 5th Edition",import re,importre,308 "Learning Python, 5th Edition",import re,importre,1206 "Learning Python, 5th Edition",import re,importre,1207 "Learning Python, 5th Edition",import re,importre,1207 "Learning Python, 5th Edition",import re,importre,1212 "Learning Python, 5th Edition","def gen(n): for i in n: yield",generatorYield,320 "Learning Python, 5th Edition","def squares(x): for i in range(x): yield",generatorYield,474 "Learning Python, 5th Edition","def both(N): for i in range(N): yield",generatorYield,605 "Learning Python, 5th Edition","def both(N): yield",generatorYield,606 "Learning Python, 5th Edition","def gen(x): for i in range(x): yield",generatorYield,902 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1023 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1227 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1228 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1230 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1231 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1232 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1233 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1234 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1235 "Learning Python, 5th Edition","def __get__(self, instance, instancetype=None):",descriptorGet,1236 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1247 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1247 "Learning Python, 5th Edition","def __get__(self, instance, owner): # Class names:",descriptorGet,1260 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1260 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1260 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1260 "Learning Python, 5th Edition","def __get__(self, instance, owner): # Class names:",descriptorGet,1262 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1262 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1262 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1262 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1292 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1293 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1294 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1295 "Learning Python, 5th Edition","def __get__(self, instance, owner):",descriptorGet,1326 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1023 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1230 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1231 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1232 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1233 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1234 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1235 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1236 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1247 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1260 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1260 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1260 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1260 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1262 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1262 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1262 "Learning Python, 5th Edition","def __set__(self, instance, value):",descriptorSet,1262 "Learning Python, 5th Edition","def __delete__(self, instance):",descriptorDelete,1230 "Learning Python, 5th Edition","def __delete__(self, instance):",descriptorDelete,1231 "Learning Python, 5th Edition","def __delete__(self, instance):",descriptorDelete,1236 "Learning Python, 5th Edition","__slots__=['data1'] in Super and __slots__=['data3'] in Sub, only the data2 at-",__slots__,976 "Learning Python, 5th Edition","__slots__ = ['a', 'b']; x = 1; y = 2",__slots__,1009 "Learning Python, 5th Edition","__slots__ = ['b', 'c']",__slots__,1009 "Learning Python, 5th Edition","__slots__ = ['age', 'name', 'job']",__slots__,1010 "Learning Python, 5th Edition","__slots__ = ['a', 'b'] # __slots__ means no __dict__ by default",__slots__,1012 "Learning Python, 5th Edition","__slots__ = ['a', 'b']",__slots__,1012 "Learning Python, 5th Edition","__slots__ = ['a', 'b', '__dict__'] # Name __dict__ to include one too",__slots__,1013 "Learning Python, 5th Edition","__slots__ = ['c', 'd'] # Superclass has slots",__slots__,1014 "Learning Python, 5th Edition","__slots__ = ['a', '__dict__'] # But so does its subclass",__slots__,1014 "Learning Python, 5th Edition","__slots__ = ['a', 'b', '__dict__']",__slots__,1015 "Learning Python, 5th Edition",__slots__ = ['a'] # Makes instance dict for nonslots,__slots__,1016 "Learning Python, 5th Edition",__slots__ = ['a'],__slots__,1017 "Learning Python, 5th Edition",__slots__ = ['b'],__slots__,1017 "Learning Python, 5th Edition","__slots__ = ['a', 'b', 'c', 'd']",__slots__,1019 "Learning Python, 5th Edition",import importlib,importlib,763 "Learning Python, 5th Edition",import importlib,importlib,962 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,732 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,749 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,751 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,752 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,760 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,765 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,767 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,768 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,821 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,823 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,824 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,827 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,831 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,832 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,835 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,837 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,838 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,842 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,846 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,868 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,874 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,880 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,900 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,907 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,913 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,920 "Learning Python, 5th Edition","if __name__ == ""__main__"":",__name__,936 "Learning Python, 5th Edition","if __name__ == ""__main__"":",__name__,938 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,939 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,959 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,961 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,962 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,964 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,967 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,981 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,983 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1006 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1089 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1117 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1138 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1254 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1258 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1291 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1305 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1315 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1351 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1487 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1487 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1487 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1491 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1492 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1496 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1497 "Learning Python, 5th Edition",if __name__ == '__main__':,__name__,1499 "Learning Python, 5th Edition","__add__', '__class__",__class__,104 "Learning Python, 5th Edition",we must compare instance __class__,__class__,308 "Learning Python, 5th Edition","__add__', '__class__",__class__,445 "Learning Python, 5th Edition","__add__', '__class__",__class__,445 "Learning Python, 5th Edition","__annotations__', '__call__', '__class__",__class__,563 "Learning Python, 5th Edition","__annotations__', '__call__', '__class__",__class__,564 "Learning Python, 5th Edition",that Python creates for us—it’s called __class__,__class__,811 "Learning Python, 5th Edition",x.__class__,__class__,811 "Learning Python, 5th Edition",The built-in instance.__class__,__class__,840 "Learning Python, 5th Edition",bob.__class__,__class__,841 "Learning Python, 5th Edition",bob.__class__,__class__,841 "Learning Python, 5th Edition",return '[%s: %s]' % (self.__class__,__class__,842 "Learning Python, 5th Edition","If you ever do wish to include inherited attributes too, you can climb the __class__",__class__,843 "Learning Python, 5th Edition","stored attributes, and sets the instance’s __class__",__class__,856 "Learning Python, 5th Edition",you can inspect. Instances have a __class__,__class__,878 "Learning Python, 5th Edition",X.__class__,__class__,878 "Learning Python, 5th Edition",The prior section demonstrated the special __class__,__class__,880 "Learning Python, 5th Edition",classtree(inst.__class__,__class__,880 "Learning Python, 5th Edition",self.__class__,__class__,959 "Learning Python, 5th Edition",Each instance has a built-in __class__,__class__,959 "Learning Python, 5th Edition","the header, so the expression self.__class__",__class__,959 "Learning Python, 5th Edition",self.__class__,__class__,964 "Learning Python, 5th Edition",above = self.__listclass(self.__class__,__class__,967 "Learning Python, 5th Edition",self.__class__,__class__,967 "Learning Python, 5th Edition","from, instead of a generic instance type, and is normally the same as I.__class__",__class__,986 "Learning Python, 5th Edition","type(I), I.__class__",__class__,993 "Learning Python, 5th Edition",C.__class__,__class__,993 "Learning Python, 5th Edition",AttributeError: class C has no attribute '__class__,__class__,993 "Learning Python, 5th Edition","type([1, 2, 3]), [1, 2, 3].__class__",__class__,993 "Learning Python, 5th Edition","type(list), list.__class__",__class__,993 "Learning Python, 5th Edition",Classes have a __class__,__class__,993 "Learning Python, 5th Edition","type(I), I.__class__",__class__,993 "Learning Python, 5th Edition","type(C), C.__class__",__class__,993 "Learning Python, 5th Edition","type(I), I.__class__",__class__,993 "Learning Python, 5th Edition","type(C), C.__class__",__class__,993 "Learning Python, 5th Edition","type([1, 2, 3]), [1, 2, 3].__class__",__class__,993 "Learning Python, 5th Edition","type(list), list.__class__",__class__,994 "Learning Python, 5th Edition","c.__class__, d.__class__",__class__,994 "Learning Python, 5th Edition",c.__class__ == d.__class__,__class__,994 "Learning Python, 5th Edition","c.__class__, d.__class__",__class__,994 "Learning Python, 5th Edition","c.__class__, d.__class__",__class__,995 "Learning Python, 5th Edition",if hasattr(instance.__class__,__class__,1005 "Learning Python, 5th Edition","return (instance,) + instance.__class__",__class__,1005 "Learning Python, 5th Edition",return [instance] + dflr(instance.__class__,__class__,1005 "Learning Python, 5th Edition",trace(dflr(I.__class__,__class__,1007 "Learning Python, 5th Edition",class 'object'>: ['__class__,__class__,1008 "Learning Python, 5th Edition",self.count() # Passes self.__class__,__class__,1033 "Learning Python, 5th Edition",return 'Bob ' + self.__class__,__class__,1036 "Learning Python, 5th Edition",self.__class__,__class__,1044 "Learning Python, 5th Edition",changing an instance’s __class__,__class__,1050 "Learning Python, 5th Edition",the instance’s __class__,__class__,1127 "Learning Python, 5th Edition","specific subclasses. Because of this, the __class__",__class__,1127 "Learning Python, 5th Edition",print('caught: %s' % X.__class__,__class__,1127 "Learning Python, 5th Edition",Because __class__,__class__,1127 "Learning Python, 5th Edition",large if you’ve forgotten what __class__,__class__,1128 "Learning Python, 5th Edition",instance.__class__,__class__,1151 "Learning Python, 5th Edition",itance rules. The inherited descriptor for name __class__,__class__,1227 "Learning Python, 5th Edition",aClass = object.__class__,__class__,1309 "Learning Python, 5th Edition",original decorated class—if you test their type with X.__class__,__class__,1321 "Learning Python, 5th Edition",return self.__class__,__class__,1325 "Learning Python, 5th Edition",return self.__class__,__class__,1325 "Learning Python, 5th Edition",return self.__class__,__class__,1325 "Learning Python, 5th Edition",return self.__class__,__class__,1325 "Learning Python, 5th Edition",return self.__class__,__class__,1326 "Learning Python, 5th Edition",return self.__class__,__class__,1348 "Learning Python, 5th Edition",Special attributes like __class__,__class__,1357 "Learning Python, 5th Edition","have a __class__ that links to type, just as an instance has a __class__",__class__,1365 "Learning Python, 5th Edition",X.__class__,__class__,1365 "Learning Python, 5th Edition",C.__class__,__class__,1366 "Learning Python, 5th Edition",X.__class__,__class__,1366 "Learning Python, 5th Edition",C.__class__,__class__,1366 "Learning Python, 5th Edition","model in older Pythons, they do not have a __class__",__class__,1366 "Learning Python, 5th Edition",X.__class__,__class__,1366 "Learning Python, 5th Edition",C.__class__,__class__,1366 "Learning Python, 5th Edition",AttributeError: class C has no attribute '__class__,__class__,1366 "Learning Python, 5th Edition","in the metaclass’s class, available in its __class__",__class__,1377 "Learning Python, 5th Edition",print(SubMeta.__class__,__class__,1378 "Learning Python, 5th Edition",used instead of that on a metaclass (instance). The class’s __class__,__class__,1379 "Learning Python, 5th Edition","In fact, classes acquire metaclass attributes through their __class__",__class__,1382 "Learning Python, 5th Edition",way that normal instances inherit from classes through their __class__,__class__,1382 "Learning Python, 5th Edition",instance inheritance does not follow a class’s __class__,__class__,1382 "Learning Python, 5th Edition","only, and using only the instance’s __class__",__class__,1382 "Learning Python, 5th Edition",I.__class__,__class__,1382 "Learning Python, 5th Edition",C.__class__,__class__,1382 "Learning Python, 5th Edition",C.__class__,__class__,1382 "Learning Python, 5th Edition","class M2(M1): attr2 = 2 # Gets __bases__, __class__",__class__,1382 "Learning Python, 5th Edition","attr4 = 4 # Gets __bases__, __class__",__class__,1382 "Learning Python, 5th Edition",I = C2() # I gets __class__,__class__,1382 "Learning Python, 5th Edition",I.__class__,__class__,1383 "Learning Python, 5th Edition",C2.__class__,__class__,1383 "Learning Python, 5th Edition",I.__class__,__class__,1383 "Learning Python, 5th Edition",I.attr1 # Though class's __class__,__class__,1383 "Learning Python, 5th Edition",M2.__class__,__class__,1383 "Learning Python, 5th Edition",x.__name__ for x in C2.__mro__] # __bases__ tree from I.__class__,__class__,1383 "Learning Python, 5th Edition",x.__name__ for x in M2.__mro__] # __bases__ tree from C2.__class__,__class__,1383 "Learning Python, 5th Edition",b. The __dict__ of all classes on the __mro__ found at I’s __class__,__class__,1383 "Learning Python, 5th Edition",b. The __dict__ of all metaclasses on the __mro__ found at C’s __class__,__class__,1384 "Learning Python, 5th Edition",special __class__,__class__,1384 "Learning Python, 5th Edition",I.__class__,__class__,1384 "Learning Python, 5th Edition",I.__dict__['__class__,__class__,1384 "Learning Python, 5th Edition",bob' # But I.__class__,__class__,1384 "Learning Python, 5th Edition",I.__class__,__class__,1384 "Learning Python, 5th Edition","class '__main__.C'>, {'__class__",__class__,1384 "Learning Python, 5th Edition",a. Search the __dict__ of all classes on the __mro__ found at I’s __class__,__class__,1385 "Learning Python, 5th Edition",a. Search the __dict__ of all metaclasses on the __mro__ found at C’s __class__,__class__,1386 "Learning Python, 5th Edition","for k in (C, C.__class__",__class__,1388 "Learning Python, 5th Edition",self.__class__,__class__,1495 "Learning Python, 5th Edition",for super in self.__class__,__class__,1495 "Learning Python, 5th Edition","Or: ', '.join(super.__name__ for super in self.__class__",__class__,1495 "Learning Python, 5th Edition",a loop through a module’s __dict__,__dict__,690 "Learning Python, 5th Edition",Module namespaces can be accessed via the attribute__dict__,__dict__,695 "Learning Python, 5th Edition",through the built-in __dict__,__dict__,695 "Learning Python, 5th Edition",keys list of an object’s __dict__,__dict__,695 "Learning Python, 5th Edition",Namespace Dictionaries: __dict__,__dict__,696 "Learning Python, 5th Edition",module’s namespace dictionary through the module’s __dict__,__dict__,696 "Learning Python, 5th Edition",list(module2.__dict__,__dict__,696 "Learning Python, 5th Edition",list(name for name in module2.__dict__,__dict__,697 "Learning Python, 5th Edition",list(name for name in module2.__dict__,__dict__,697 "Learning Python, 5th Edition",the effect is the same. We’ll see similar __dict__,__dict__,697 "Learning Python, 5th Edition","module2.name, module2.__dict__",__dict__,697 "Learning Python, 5th Edition",M.__dict__,__dict__,759 "Learning Python, 5th Edition",for attr in sorted(module.__dict__,__dict__,760 "Learning Python, 5th Edition","print(getattr(module, attr)) # Same as .__dict__",__dict__,760 "Learning Python, 5th Edition","__name__, __file__, and __dict__",__dict__,761 "Learning Python, 5th Edition",scanning modules’ __dict__,__dict__,764 "Learning Python, 5th Edition",navigate arbitrarily shaped and deep import dependency chains. Module __dict__,__dict__,764 "Learning Python, 5th Edition",for attrobj in module.__dict__,__dict__,764 "Learning Python, 5th Edition",transitive_reload(obj.__dict__,__dict__,767 "Learning Python, 5th Edition",modules.extend(x for x in next.__dict__,__dict__,768 "Learning Python, 5th Edition",myclient and test interactively by importing myclient and inspecting its __dict__,__dict__,779 "Learning Python, 5th Edition","For example, the __dict__",__dict__,810 "Learning Python, 5th Edition","Chapter 31 and Chapter 32. Normally, __dict__",__dict__,810 "Learning Python, 5th Edition",list(rec.__dict__,__dict__,810 "Learning Python, 5th Edition","age', '__module__', '__qualname__', '__weakref__', 'name', '__dict__",__dict__,810 "Learning Python, 5th Edition",list(name for name in rec.__dict__,__dict__,810 "Learning Python, 5th Edition",list(x.__dict__,__dict__,810 "Learning Python, 5th Edition",list(y.__dict__,__dict__,810 "Learning Python, 5th Edition","x.name, x.__dict__",__dict__,810 "Learning Python, 5th Edition",x.__dict__,__dict__,811 "Learning Python, 5th Edition",The built-in object.__dict__,__dict__,841 "Learning Python, 5th Edition",list(bob.__dict__,__dict__,841 "Learning Python, 5th Edition",for key in bob.__dict__,__dict__,841 "Learning Python, 5th Edition","print(key, '=>', bob.__dict__",__dict__,841 "Learning Python, 5th Edition",for key in bob.__dict__,__dict__,841 "Learning Python, 5th Edition",not be stored in the __dict__,__dict__,841 "Learning Python, 5th Edition",a missing __dict__,__dict__,842 "Learning Python, 5th Edition",class with slots (its lack of them is enough to guarantee a __dict__,__dict__,842 "Learning Python, 5th Edition",for key in sorted(self.__dict__,__dict__,842 "Learning Python, 5th Edition",inheritance tree; that’s what self’s __dict__,__dict__,843 "Learning Python, 5th Edition","to the instance’s class, use the __dict__",__dict__,843 "Learning Python, 5th Edition",instead of using __dict__,__dict__,843 "Learning Python, 5th Edition",bob.__dict__,__dict__,844 "Learning Python, 5th Edition",list(bob.__dict__,__dict__,844 "Learning Python, 5th Edition","__class__', '__delattr__', '__dict__",__dict__,844 "Learning Python, 5th Edition",6. Why is it better to use tools like __dict__,__dict__,855 "Learning Python, 5th Edition","dictionaries, exposed with the built-in __dict__",__dict__,878 "Learning Python, 5th Edition",X.__dict__,__dict__,878 "Learning Python, 5th Edition",X.__dict__,__dict__,879 "Learning Python, 5th Edition",X.__dict__,__dict__,879 "Learning Python, 5th Edition",list(Sub.__dict__,__dict__,879 "Learning Python, 5th Edition",list(Super.__dict__,__dict__,879 "Learning Python, 5th Edition","__module__', 'hello', '__dict__",__dict__,879 "Learning Python, 5th Edition",Y.__dict__,__dict__,879 "Learning Python, 5th Edition","X.data1, X.__dict__",__dict__,879 "Learning Python, 5th Edition",X.__dict__,__dict__,879 "Learning Python, 5th Edition",X.__dict__,__dict__,879 "Learning Python, 5th Edition","X.hello, for instance, cannot be accessed by X.__dict__",__dict__,879 "Learning Python, 5th Edition",X.__dict__,__dict__,879 "Learning Python, 5th Edition","per-instance values. As we’ll see, though, slots may prevent a __dict__",__dict__,880 "Learning Python, 5th Edition",self.__dict__,__dict__,910 "Learning Python, 5th Edition",If you change the __dict__,__dict__,911 "Learning Python, 5th Edition",in __dict__,__dict__,911 "Learning Python, 5th Edition",self.__dict__,__dict__,911 "Learning Python, 5th Edition",instance’s __dict__,__dict__,911 "Learning Python, 5th Edition","object.__setattr__ scheme shown here, not by self.__dict__",__dict__,911 "Learning Python, 5th Edition",self.__dict__,__dict__,912 "Learning Python, 5th Edition",self.__dict__,__dict__,912 "Learning Python, 5th Edition",having to go through __dict__,__dict__,913 "Learning Python, 5th Edition","to a string at runtime, not a variable. In fact, getattr(X,N) is similar to X.__dict__",__dict__,942 "Learning Python, 5th Edition",see Chapter 22 and Chapter 29 for more on the __dict__,__dict__,943 "Learning Python, 5th Edition",print(I.__dict__,__dict__,946 "Learning Python, 5th Edition",Listing instance attributes with __dict__,__dict__,959 "Learning Python, 5th Edition",for attr in sorted(self.__dict__,__dict__,959 "Learning Python, 5th Edition","result += '\t%s=%s\n' % (attr, self.__dict__",__dict__,959 "Learning Python, 5th Edition","return ''.join('\t%s=%s\n' % (attr, self.__dict__",__dict__,959 "Learning Python, 5th Edition",for attr in sorted(self.__dict__,__dict__,959 "Learning Python, 5th Edition","tionary (remember, it’s exported in __dict__",__dict__,960 "Learning Python, 5th Edition",fetches inherited names not in self.__dict__,__dict__,964 "Learning Python, 5th Edition","__class__, __delattr__, __dict__",__dict__,966 "Learning Python, 5th Edition",for attr in sorted(obj.__dict__,__dict__,967 "Learning Python, 5th Edition",scanning each object’s attribute __dict__,__dict__,967 "Learning Python, 5th Edition",sion indexed the instance __dict__,__dict__,969 "Learning Python, 5th Edition",for attr in sorted(obj.__dict__,__dict__,971 "Learning Python, 5th Edition",Because they scan instance __dict__,__dict__,975 "Learning Python, 5th Edition","a __slots__ class attribute, and not physically stored in an instance’s __dict__",__dict__,976 "Learning Python, 5th Edition","fact, slots may suppress a __dict__",__dict__,976 "Learning Python, 5th Edition",fetch values from their inheritance source via __dict__,__dict__,976 "Learning Python, 5th Edition","results set, which include both __dict__",__dict__,976 "Learning Python, 5th Edition","too, because slots-based names appear in class’s __dict__",__dict__,976 "Learning Python, 5th Edition","slot management tools, though not in the instance __dict__",__dict__,976 "Learning Python, 5th Edition",Supports classes with slots that preclude __dict__,__dict__,1005 "Learning Python, 5th Edition","if hasattr(obj, '__dict__') and attr in obj.__dict__",__dict__,1005 "Learning Python, 5th Edition","order for classic classes, searching each object’s namespace __dict__",__dict__,1006 "Learning Python, 5th Edition",class '__main__.A'>: ['__dict__,__dict__,1007 "Learning Python, 5th Edition",class 'testmixin0.Super'>: ['__dict__,__dict__,1008 "Learning Python, 5th Edition",class 'testmixin0.Super'>: ['__dict__,__dict__,1008 "Learning Python, 5th Edition",attributes too. Because a class’s __dict__,__dict__,1008 "Learning Python, 5th Edition",instance’s __dict__,__dict__,1009 "Learning Python, 5th Edition",class '__main__.D'>: ['__dict__,__dict__,1009 "Learning Python, 5th Edition",mapattrs must be careful to check to see if a __dict__,__dict__,1009 "Learning Python, 5th Edition",current physical __dict__,__dict__,1009 "Learning Python, 5th Edition","with a key-sharing dictionary model, where the __dict__",__dict__,1011 "Learning Python, 5th Edition","it—substantially. In fact, some instances with slots may not have a __dict__",__dict__,1011 "Learning Python, 5th Edition",to use more storage-neutral interfaces than __dict__,__dict__,1012 "Learning Python, 5th Edition",X.__dict__,__dict__,1012 "Learning Python, 5th Edition",AttributeError: 'C' object has no attribute '__dict__,__dict__,1012 "Learning Python, 5th Edition",neutral tools such as getattr and setattr (which look beyond the instance __dict__,__dict__,1012 "Learning Python, 5th Edition",self.d = 4 # Cannot add new names if no __dict__,__dict__,1012 "Learning Python, 5th Edition","We can still accommodate extra attributes, though, by including __dict__",__dict__,1013 "Learning Python, 5th Edition",self.d = 4 # d stored in __dict__,__dict__,1013 "Learning Python, 5th Edition","In this case, both storage mechanisms are used. This renders __dict__",__dict__,1013 "Learning Python, 5th Edition",X.__dict__ # Some objects have both __dict__,__dict__,1013 "Learning Python, 5th Edition","a', 'b', '__dict__",__dict__,1013 "Learning Python, 5th Edition",for attr in list(X.__dict__,__dict__,1013 "Learning Python, 5th Edition","for attr in list(getattr(X, '__dict__",__dict__,1013 "Learning Python, 5th Edition","a', '__dict__",__dict__,1014 "Learning Python, 5th Edition","a', '__dict__",__dict__,1014 "Learning Python, 5th Edition",X.__dict__,__dict__,1014 "Learning Python, 5th Edition","for attr in list(getattr(X, '__dict__",__dict__,1014 "Learning Python, 5th Edition",I.__dict__ # Both __dict__,__dict__,1015 "Learning Python, 5th Edition",I.__dict__['c'] # __dict__,__dict__,1015 "Learning Python, 5th Edition","getattr(I, 'c'), getattr(I, 'a') # dir+getattr is broader than __dict__",__dict__,1015 "Learning Python, 5th Edition",instance __dict__,__dict__,1016 "Learning Python, 5th Edition","perclass without a __slots__, the instance __dict__",__dict__,1016 "Learning Python, 5th Edition",produce an instance __dict__,__dict__,1016 "Learning Python, 5th Edition",Slots and __dict__,__dict__,1016 "Learning Python, 5th Edition","__dict__ and assigning names not listed, unless __dict__",__dict__,1016 "Learning Python, 5th Edition",X.__dict__,__dict__,1016 "Learning Python, 5th Edition",D.__dict__,__dict__,1016 "Learning Python, 5th Edition",X.__dict__,__dict__,1017 "Learning Python, 5th Edition",C.__dict__,__dict__,1017 "Learning Python, 5th Edition",X.__dict__,__dict__,1017 "Learning Python, 5th Edition",AttributeError: 'D' object has no attribute '__dict__,__dict__,1017 "Learning Python, 5th Edition","C.__dict__.keys(), D.__dict__",__dict__,1017 "Learning Python, 5th Edition",lack of slots is enough to ensure that the instance will still have a __dict__,__dict__,1017 "Learning Python, 5th Edition","class C(ListTree): __slots__ = ['a', 'b'] # OK: superclass produces __dict__",__dict__,1018 "Learning Python, 5th Edition",ates an instance __dict__,__dict__,1018 "Learning Python, 5th Edition",need to catch exceptions when __dict__,__dict__,1018 "Learning Python, 5th Edition",earlier in this chapter must check for the presence of a __dict__,__dict__,1018 "Learning Python, 5th Edition",if attr in obj.__dict__,__dict__,1018 "Learning Python, 5th Edition",AttributeError: 'C' object has no attribute '__dict__,__dict__,1018 "Learning Python, 5th Edition","if attr in getattr(obj, '__dict__",__dict__,1018 "Learning Python, 5th Edition","if hasattr(obj, '__dict__') and attr in obj.__dict__",__dict__,1018 "Learning Python, 5th Edition","the MRO this way, instead of scanning an instance __dict__",__dict__,1018 "Learning Python, 5th Edition",allowing for a missing __dict__,__dict__,1018 "Learning Python, 5th Edition",tributes based on both __slots__ and __dict__,__dict__,1019 "Learning Python, 5th Edition",self.__dict__,__dict__,1022 "Learning Python, 5th Edition",list(X.__dict__,__dict__,1229 "Learning Python, 5th Edition",I.__dict__,__dict__,1235 "Learning Python, 5th Edition",a key in the instance’s __dict__,__dict__,1240 "Learning Python, 5th Edition",self.__dict__,__dict__,1240 "Learning Python, 5th Edition","By contrast, though, we cannot use the __dict__",__dict__,1241 "Learning Python, 5th Edition",x = self.__dict__,__dict__,1241 "Learning Python, 5th Edition",Fetching the __dict__,__dict__,1241 "Learning Python, 5th Edition",stance’s __dict__,__dict__,1241 "Learning Python, 5th Edition","object.__setattr__ scheme shown here, not by self.__dict__",__dict__,1241 "Learning Python, 5th Edition",ing. Namespace __dict__,__dict__,1241 "Learning Python, 5th Edition",self.__dict__,__dict__,1242 "Learning Python, 5th Edition",del self.__dict__,__dict__,1242 "Learning Python, 5th Edition",get: __dict__,__dict__,1243 "Learning Python, 5th Edition",get: __dict__,__dict__,1243 "Learning Python, 5th Edition",get: __dict__,__dict__,1243 "Learning Python, 5th Edition",get: __dict__,__dict__,1243 "Learning Python, 5th Edition",self.__dict__,__dict__,1244 "Learning Python, 5th Edition",calls instead of __dict__,__dict__,1244 "Learning Python, 5th Edition",self.__dict__,__dict__,1248 "Learning Python, 5th Edition",self.__dict__,__dict__,1248 "Learning Python, 5th Edition",self.__dict__,__dict__,1265 "Learning Python, 5th Edition",self.__dict__,__dict__,1266 "Learning Python, 5th Edition",self.__dict__,__dict__,1315 "Learning Python, 5th Edition",return onInstance # Or use __dict__,__dict__,1315 "Learning Python, 5th Edition",Using __dict__,__dict__,1318 "Learning Python, 5th Edition",The __setattr__ method in this code relies on an instance object’s __dict__,__dict__,1318 "Learning Python, 5th Edition","However, it uses the setattr built-in instead of __dict__",__dict__,1318 "Learning Python, 5th Edition",may not store attributes in a __dict__,__dict__,1318 "Learning Python, 5th Edition","all). However, because we rely on a __dict__",__dict__,1318 "Learning Python, 5th Edition",getattr apply to attributes based on both __dict__,__dict__,1318 "Learning Python, 5th Edition",and __dict__,__dict__,1357 "Learning Python, 5th Edition","a, v) for (a, v) in x.__dict__",__dict__,1368 "Learning Python, 5th Edition","print('...init class object:', list(Class.__dict__",__dict__,1372 "Learning Python, 5th Edition","print('...init class object:', list(Class.__dict__",__dict__,1374 "Learning Python, 5th Edition","print('...init class object:', list(Class.__dict__",__dict__,1375 "Learning Python, 5th Edition","print('...init class object:', list(Class.__dict__",__dict__,1376 "Learning Python, 5th Edition",ally searches only the __dict__,__dict__,1379 "Learning Python, 5th Edition",itance via __dict__,__dict__,1379 "Learning Python, 5th Edition","attr' in B.__dict__, 'attr' in A.__dict__",__dict__,1381 "Learning Python, 5th Edition","space dictionaries in classes in the tree—that is, by checking the __dict__",__dict__,1381 "Learning Python, 5th Edition","attr' in B.__dict__, 'attr' in A.__dict__",__dict__,1381 "Learning Python, 5th Edition","attr' in B.__dict__, 'attr' in A.__dict__, 'attr' in M.__dict__",__dict__,1381 "Learning Python, 5th Edition",Python checks the __dict__,__dict__,1381 "Learning Python, 5th Edition",to the __dict__,__dict__,1382 "Learning Python, 5th Edition",a. The __dict__,__dict__,1383 "Learning Python, 5th Edition",a. The __dict__,__dict__,1384 "Learning Python, 5th Edition",and __dict__,__dict__,1384 "Learning Python, 5th Edition",instance’s own __dict__,__dict__,1384 "Learning Python, 5th Edition",I.__dict__,__dict__,1384 "Learning Python, 5th Edition",I.__dict__,__dict__,1384 "Learning Python, 5th Edition",I.__dict__['__dict__,__dict__,1384 "Learning Python, 5th Edition",I.name # I.name comes from I.__dict__,__dict__,1384 "Learning Python, 5th Edition",and I.__dict__,__dict__,1384 "Learning Python, 5th Edition",I.__dict__,__dict__,1384 "Learning Python, 5th Edition","spam', '__dict__",__dict__,1384 "Learning Python, 5th Edition",I.__dict__,__dict__,1385 "Learning Python, 5th Edition",I.__dict__,__dict__,1385 "Learning Python, 5th Edition","c. Else, return a value in the __dict__",__dict__,1386 "Learning Python, 5th Edition","c. Else, call a descriptor or return a value in the __dict__",__dict__,1386 "Learning Python, 5th Edition","return Metaclass(cls.__name__, cls.__bases__, dict(cls.__dict__",__dict__,1398 "Learning Python, 5th Edition","for attr, attrval in aClass.__dict__",__dict__,1405 "Learning Python, 5th Edition",listing with __dict__,__dict__,1521 "Learning Python, 5th Edition","try: # Merged form main-action except Exception1: handler1 except Exception2: # Catch exceptions handler2 ... else: # No-exception handler else-block finally:",tryexceptelsefinally,1103 "Learning Python, 5th Edition","try: x = 'spam'[99] except IndexError: print('except run') finally: print('finally run') print('after run') print(sep + 'NO EXCEPTION RAISED') try: x = 'spam'[3] except IndexError: print('except run') finally:",tryexceptfinally,1105 "Learning Python, 5th Edition","try: x = 1 / 0 except IndexError: print('except run') finally:",tryexceptfinally,1106 "Learning Python, 5th Edition","try: ... try: ... raise IndexError ... finally: ... print('spam') ... finally: ... print('SPAM') ... spam SPAM Traceback (most recent call last): File ""<stdin>"", line 3, in <module> IndexError See Figure 36-2 for a graphic illustration of this code’s operation; the effect is the same, but the function logic has been inlined as nested statements here. For a more useful example of syntactic nesting at work, consider the following file, except-finally.py: def raise1(): raise IndexError def noraise(): return def raise2(): raise SyntaxError for func in (raise1, noraise, raise2): print('<%s>' % func.__name__) try: try: func() except IndexError: print('caught IndexError') finally:",tryexceptfinally,1144 "Learning Python, 5th Edition","try: for line in myfile: ...use line here... finally:",tryfinally,294 "Learning Python, 5th Edition","try: ... fetcher(x, 3) ... finally: # Termination actions ... print('after fetch') ... 'm' after fetch >>> Here, if the try block finishes without an exception, the finally block will run, and the program will resume after the entire try. In this case, this statement seems a bit silly —we might as well have simply typed the print right after a call to the function, and skipped the try altogether: fetcher(x, 3) print('after fetch') There is a problem with coding this way, though: if the function call raises an exception, the print will never be reached. The try/finally combination avoids this pitfall—when an exception does occur in a try block, finally blocks are executed while the program is being unwound: >>> def after(): try: fetcher(x, 4) finally:",tryfinally,1087 "Learning Python, 5th Edition","try: >>> def after(): try: fetcher(x, 3) finally:",tryfinally,1088 "Learning Python, 5th Edition","try: statements # Run this action first finally:",tryfinally,1101 "Learning Python, 5th Edition","try: stuff(file) # Raises exception finally:",tryfinally,1102 "Learning Python, 5th Edition","try: # Format 1 statements except [type [as value]]: # [type [, value]] in Python 2.X statements [except [type [as value]]: statements]* [else: statements] [finally: statements] try: # Format 2 statements finally:",tryfinally,1104 "Learning Python, 5th Edition","try: for line in myfile: print(line) ...more code here... finally:",tryfinally,1115 "Learning Python, 5th Edition","try: # Same effect but explicit close on error for line in fin: fout.write(line.upper()) finally:",tryfinally,1119 "Learning Python, 5th Edition","try: ...process myfile... finally:",tryfinally,1148 "Learning Python, 5th Edition","first={0[0]}, third={0[2]}",dictwithList,224 "Learning Python, 5th Edition",0.platform:>10} = {1[kind]:<10},dictwithList,225 "Learning Python, 5th Edition",platform:>10} = {[kind]:<10},dictwithList,226 "Learning Python, 5th Edition","D = {'name': 'Bob', 'age': 40.5, 'jobs': ['dev', 'mgr']}",dictwithList,263 "Learning Python, 5th Edition","bob = {'name': 'Bob', 'age': 40.5, 'jobs': ['dev', 'mgr']}",dictwithList,282 "Learning Python, 5th Edition","D = {'x':X[:], 'y':2}",dictwithList,300 "Learning Python, 5th Edition","rec = {'name': 'Bob', 'age': 40.5, 'jobs': ['dev', 'mgr']}",dictwithList,814 "Learning Python, 5th Edition",with open(r'C:\code\data.txt') as myfile:,withfunc,294 "Learning Python, 5th Edition",with open('data') as myfile:,withfunc,321 "Learning Python, 5th Edition","with open('lumberjack.txt', 'w') as file:",withfunc,1088 "Learning Python, 5th Edition",with open(r'C:\misc\data') as myfile:,withfunc,1115 "Learning Python, 5th Edition","with open('data') as fin, open('res', 'w') as fout:",withfunc,1118 "Learning Python, 5th Edition","with open('script1.py') as f1, open('script2.py') as f2:",withfunc,1118 "Learning Python, 5th Edition","with open('script1.py') as f1, open('script2.py') as f2:",withfunc,1118 "Learning Python, 5th Edition","with open('script2.py') as fin, open('upper.py', 'w') as fout:",withfunc,1119 "Learning Python, 5th Edition","with open(r'C:\code\textdata', 'w') as myfile:",withfunc,1148 "Learning Python, 5th Edition",with open(filename) as myfile:,withfunc,1148 "Learning Python, 5th Edition","L = [123, 'abc', 1.23, {}]",listwithdict,240 "Learning Python, 5th Edition","if X: A = Y else:",ifelse,382 "Learning Python, 5th Edition","if found: print('at index', i) else:",ifelse,468 "Learning Python, 5th Edition","if sometest: action, args = func1, (1,) # Call func1 with one arg in this case else:",ifelse,537 "Learning Python, 5th Edition","if a: b else:",ifelse,571 "Learning Python, 5th Edition","if sys.version_info[0] >= 3 and sys.version_info[1] >= 3: timer = time.perf_counter # or process_time else:",ifelse,633 "Learning Python, 5th Edition","if sys.platform[:3] == 'win': dirname = r'C:\Python33\Lib' else:",ifelse,1500 "Learning Python, 5th Edition","if not 'user' in form: print(""<h1>Who are you?</h1>"") else:",ifelse,1504 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break elif not reply.isdigit(): print('Bad!' * 8) else:",whileelse,332 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break try: num = int(reply) except: print('Bad!' * 8) else:",whileelse,333 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break elif not reply.isdigit(): print('Bad!' * 8) else: num = int(reply) if num < 20: print('low') else:",whileelse,335 "Learning Python, 5th Edition","while test: # Loop test statements # Loop body else:",whileelse,388 "Learning Python, 5th Edition","while True: ...loop body... if exitTest(): break To fully understand how this structure works, we need to move on to the next section and learn more about the break statement. break, continue, pass, and the Loop else Now that we’ve seen a few Python loops in action, it’s time to take a look at two simple statements that have a purpose only when nested inside loops—the break and con tinue statements. While we’re looking at oddballs, we will also study the loop else clause here because it is intertwined with break, and Python’s empty placeholder state- ment, pass (which is not tied to loops per se, but falls into the general category of simple one-word statements). In Python: break Jumps out of the closest enclosing loop (past the entire loop statement) continue Jumps to the top of the closest enclosing loop (to the loop’s header line) pass Does nothing at all: it’s an empty statement placeholder Loop else block Runs if and only if the loop is exited normally (i.e., without hitting a break) General Loop Format Factoring in break and continue statements, the general format of the while loop looks like this: while test: statements if test: break # Exit loop now, skip else if present if test: continue # Go to top of loop now, to test1 else:",whileelse,389 "Learning Python, 5th Edition","while True: ... name = input('Enter name:') # Use raw_input() in 2.X ... if name == 'stop': break ... age = input('Enter age: ') ... print('Hello', name, '=>', int(age) ** 2) ... Enter name:bob Enter age: 40 Hello bob => 1600 Enter name:sue Enter age: 30 Hello sue => 900 Enter name:stop Notice how this code converts the age input to an integer with int before raising it to the second power; as you’ll recall, this is necessary because input returns user input as a string. In Chapter 36, you’ll see that input also raises an exception at end-of-file (e.g., if the user types Ctrl-Z on Windows or Ctrl-D on Unix); if this matters, wrap input in try statements. Loop else When combined with the loop else clause, the break statement can often eliminate the need for the search status flags used in other languages. For instance, the following piece of code determines whether a positive integer y is prime by searching for factors greater than 1: x = y // 2 # For some y > 1 while x > 1: if y % x == 0: # Remainder print(y, 'has factor', x) break # Skip else x -= 1 else:",whileelse,392 "Learning Python, 5th Edition","while x and not found: if match(x[0]): # Value at front? print('Ni') found = True else: x = x[1:] # Slice off front and repeat if not found: print('not found') Here, we initialize, set, and later test a flag to determine whether the search succeeded or not. This is valid Python code, and it does work; however, this is exactly the sort of structure that the loop else clause is there to handle. Here’s an else equivalent: while x: # Exit when x empty if match(x[0]): print('Ni') break # Exit, go around else x = x[1:] else:",whileelse,393 "Learning Python, 5th Edition","while items: front = items.pop(0) # Fetch/delete front item if not isinstance(front, list): tot += front # Add numbers directly else: items.extend(front) # <== Append all in nested list return tot Technically, this code traverses the list in breadth-first fashion by levels, because it adds nested lists’ contents to the end of the list, forming a first-in-first-out queue. To emulate the traversal of the recursive call version more closely, we can change it to perform depth-first traversal simply by adding the content of nested lists to the front of the list, forming a last-in-first-out stack: def sumtree(L): # Depth-first, explicit stack tot = 0 items = list(L) # Start with copy of top level while items: front = items.pop(0) # Fetch/delete front item if not isinstance(front, list): tot += front # Add numbers directly else:",whileelse,559 "Learning Python, 5th Edition","while x > 1: if y % x == 0: # Remainder print(y, 'has factor', x) break # Skip else x -= 1 else:",whileelse,664 "Learning Python, 5th Edition","while True: try: line = input() # Read line from stdin (raw_input in 2.X) except EOFError: break # Exit loop at end-of-file else:",whileelse,1146 "Learning Python, 5th Edition","while i < len(L): if 2 ** X == L[i]: print('at index', i) break i += 1 else: print(X, 'not found') # b L = [1, 2, 4, 8, 16, 32, 64] X = 5 for p in L: if (2 ** X) == p: print((2 ** X), 'was found at', L.index(p)) break else:",whileelse,1474 "Learning Python, 5th Edition","while x > 1: if y % x == 0: # No remainder? print(y, 'has factor', x) break # Skip else x -= 1 else:",whileelse,1479 "Learning Python, 5th Edition","while True: print('-' * 30) row = curs.fetchone() if not row: break for (name, value) in zip(colnames, row): print('%s => %s' % (name, value)) conn.commit() # Save inserted records # Fetch and open/play a file by FTP import webbrowser, sys from ftplib import FTP # Socket-based FTP tools from getpass import getpass # Hidden password input if sys.version[0] == '2': input = raw_input # 2.X compatibility nonpassive = False # Force active mode FTP for server? filename = input('File?') # File to be downloaded dirname = input('Dir? ') or '.' # Remote directory to fetch from sitename = input('Site?') # FTP site to contact user = input('User?') # Use () for anonymous if not user: userinofo = () else:",whileelse,1505 "Learning Python, 5th Edition","while X > Y: print('hello') while True: pass while True: if exittest(): break",whilebreak,320 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break print(reply.upper()) This code makes use of a few new ideas and some we’ve already seen: • The code leverages the Python while loop, Python’s most general looping state- ment. We’ll study the while statement in more detail later, but in short, it consists of the word while, followed by an expression that is interpreted as a true or false result, followed by a nested block of code that is repeated while the test at the top is true (the word True here is considered always true). • The input built-in function we met earlier in the book is used here for general console input—it prints its optional argument string as a prompt and returns the user’s typed reply as a string. Use raw_input in 2.X instead, per the upcoming note. • A single-line if statement that makes use of the special rule for nested blocks also appears here: the body of the if appears on the header line after the colon instead of being indented on a new line underneath it. This would work either way, but as it’s coded, we’ve saved an extra line. • Finally, the Python break",whilebreak,330 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break",whilebreak,331 "Learning Python, 5th Edition","while True: reply = input('Enter text:') if reply == 'stop': break try: print(int(reply) ** 2) except: print('Bad!' * 8) print('Bye') And if we wanted to support input of floating-point numbers instead of just integers, for example, using try would be much easier than manual error testing—we could simply run a float call and catch its exceptions: while True: reply = input('Enter text:') if reply == 'stop': break",whilebreak,334 "Learning Python, 5th Edition","while x: x = x−1 # Or, x -= 1 if x % 2 != 0: continue # Odd? -- skip print print(x, end=' ') Because continue jumps to the top of the loop, you don’t need to nest the print state- ment here inside an if test; the print is only reached if the continue is not run. If this sounds similar to a “go to” in other languages, it should. Python has no “go to” state- ment, but because continue lets you jump about in a program, many of the warnings about readability and maintainability you may have heard about “go to” apply. con tinue should probably be used sparingly, especially when you’re first getting started with Python. For instance, the last example might be clearer if the print were nested under the if: x = 10 while x: x = x−1 if x % 2 == 0: # Even? -- print print(x, end=' ') Later in this book, we’ll also learn that raised and caught exceptions can also emulate “go to” statements in limited and structured ways; stay tuned for more on this technique in Chapter 36 where we will learn how to use it to break out of multiple nested loops, a feat not possible with the next section’s topic alone. break The break statement causes an immediate exit from a loop. Because the code that fol- lows it in the loop is not executed if the break is reached, you can also sometimes avoid nesting by including a break. For example, here is a simple interactive loop (a variant break",whilebreak,391 "Learning Python, 5th Edition","while True: x = next(obj) if not x: break",whilebreak,394 "Learning Python, 5th Edition","while True: char = file.read(1) # Read by character if not char: break # Empty string means end-of-file print(char) for char in open('test.txt').read(): print(char) The for loop here also processes each character, but it loads the file into memory all at once (and assumes it fits!). To read by lines or blocks instead, you can use while loop code like this: file = open('test.txt') while True: line = file.readline() # Read line by line if not line: break print(line.rstrip()) # Line already has a \n file = open('test.txt', 'rb') while True: chunk = file.read(10) # Read byte chunks: up to 10 bytes if not chunk: break",whilebreak,401 "Learning Python, 5th Edition","while loop: >>> f = open('script2.py') >>> while True: ... line = f.readline() ... if not line: break",whilebreak,418 "Learning Python, 5th Edition","while True: data = reader.read() if not data: break",whilebreak,938 "Learning Python, 5th Edition","while True: data = self.reader.readline() if not data: break",whilebreak,939 "Learning Python, 5th Edition","while True: if skiptest(): continue",whilecontinue,320 "Learning Python, 5th Edition","while clients that use from get copies of the file’s names:",whilesimple,70 "Learning Python, 5th Edition",while x > 0:,whilesimple,119 "Learning Python, 5th Edition",while True:,whilesimple,171 "Learning Python, 5th Edition","while 1:",whilesimple,171 "Learning Python, 5th Edition",while B != '':,whilesimple,207 "Learning Python, 5th Edition",while slicing a list always returns a new list:,whilesimple,243 "Learning Python, 5th Edition",while L:,whilesimple,344 "Learning Python, 5th Edition",while L:,whilesimple,346 "Learning Python, 5th Edition",while True:,whilesimple,388 "Learning Python, 5th Edition",while x != '':,whilesimple,388 "Learning Python, 5th Edition",while x:,whilesimple,388 "Learning Python, 5th Edition",while a < b:,whilesimple,388 "Learning Python, 5th Edition",while True:,whilesimple,390 "Learning Python, 5th Edition",while x:,whilesimple,394 "Learning Python, 5th Edition",while x:,whilesimple,394 "Learning Python, 5th Edition",while loop:,whilesimple,404 "Learning Python, 5th Edition",while i < len(X):,whilesimple,404 "Learning Python, 5th Edition",while i < len(L):,whilesimple,407 "Learning Python, 5th Edition",while True:,whilesimple,422 "Learning Python, 5th Edition",while or range. Another reminder:,whilesimple,464 "Learning Python, 5th Edition",while not found and i < len(L):,whilesimple,467 "Learning Python, 5th Edition",while L:,whilesimple,557 "Learning Python, 5th Edition",while all(seqs):,whilesimple,619 "Learning Python, 5th Edition",while all(seqs):,whilesimple,620 "Learning Python, 5th Edition",while iters:,whilesimple,621 "Learning Python, 5th Edition",while iters:,whilesimple,622 "Learning Python, 5th Edition",while digits:,whilesimple,752 "Learning Python, 5th Edition",while modules:,whilesimple,768 "Learning Python, 5th Edition",while True:,whilesimple,793 "Learning Python, 5th Edition",while offset < len(self.wrapped):,whilesimple,906 "Learning Python, 5th Edition",while True:,whilesimple,907 "Learning Python, 5th Edition",while the try block was running or not. Its general form is:,whilesimple,1100 "Learning Python, 5th Edition",while its instance.data can vary per client instance:,whilesimple,1234 "Learning Python, 5th Edition",from . import spam,fromrelative,719 "Learning Python, 5th Edition",from . import string,fromrelative,719 "Learning Python, 5th Edition",from . import string,fromrelative,720 "Learning Python, 5th Edition",from . import string,fromrelative,721 "Learning Python, 5th Edition",from . import D,fromrelative,721 "Learning Python, 5th Edition",from . import string,fromrelative,722 "Learning Python, 5th Edition",from . import m,fromrelative,723 "Learning Python, 5th Edition",from . import string,fromrelative,724 "Learning Python, 5th Edition",from . import string,fromrelative,724 "Learning Python, 5th Edition",from . import eggs,fromrelative,725 "Learning Python, 5th Edition",from . import eggs,fromrelative,726 "Learning Python, 5th Edition",from . import string,fromrelative,727 "Learning Python, 5th Edition",from . import string,fromrelative,727 "Learning Python, 5th Edition",from . import string,fromrelative,728 "Learning Python, 5th Edition",from . import mod,fromrelative,729 "Learning Python, 5th Edition",from . import eggs,fromrelative,730 "Learning Python, 5th Edition",from . import eggs,fromrelative,731 "Learning Python, 5th Edition",from . import m1,fromrelative,732 "Learning Python, 5th Edition",from . import mod,fromrelative,734 "Learning Python, 5th Edition",from . import mod2,fromrelative,738 "Learning Python, 5th Edition","from module import *",fromstarstatements,354 "Learning Python, 5th Edition",from tkinter import *,fromstarstatements,550 "Learning Python, 5th Edition",from module1 import *,fromstarstatements,689 "Learning Python, 5th Edition",from module import *,fromstarstatements,692 "Learning Python, 5th Edition",from module import *,fromstarstatements,693 "Learning Python, 5th Edition",from unders import *,fromstarstatements,747 "Learning Python, 5th Edition",from alls import *,fromstarstatements,748 "Learning Python, 5th Edition",from module import *,fromstarstatements,773 "Learning Python, 5th Edition",from module1 import *,fromstarstatements,773 "Learning Python, 5th Edition",from module2 import *,fromstarstatements,773 "Learning Python, 5th Edition",from module3 import *,fromstarstatements,773 "Learning Python, 5th Edition",from metainstance import *,fromstarstatements,1380 "Learning Python, 5th Edition",from dicts import *,fromstarstatements,1478 "Learning Python, 5th Edition",from mymod import *,fromstarstatements,1486 "Learning Python, 5th Edition",from mod1 import *,fromstarstatements,1488 "Learning Python, 5th Edition",from mod2 import *,fromstarstatements,1488 "Learning Python, 5th Edition",from mod3 import *,fromstarstatements,1488 "Learning Python, 5th Edition",from adder import *,fromstarstatements,1489 "Learning Python, 5th Edition",from multiset import *,fromstarstatements,1494 "Learning Python, 5th Edition",from tkinter import *,fromstarstatements,1501 "Learning Python, 5th Edition",from tkinter import *,fromstarstatements,1502 "Learning Python, 5th Edition",from M import func as mfunc,asextension,694 "Learning Python, 5th Edition",from N import func as nfunc,asextension,694 "Learning Python, 5th Edition",from dir1.dir2.mod import z as modz,asextension,713 "Learning Python, 5th Edition","here are some additional details: the following import statement: import modulename as name",asextension,758 "Learning Python, 5th Edition",from modulename import attrname as name,asextension,758 "Learning Python, 5th Edition",from module1 import utility as util1,asextension,758 "Learning Python, 5th Edition",from module2 import utility as util2,asextension,758 "Learning Python, 5th Edition",from dir1.dir2.mod import func as modfunc,asextension,758 "Learning Python, 5th Edition","breaking your code: import newname as oldname",asextension,759 "Learning Python, 5th Edition",from library import newname as oldname,asextension,759 "Learning Python, 5th Edition","string that is generated at runtime. The most general approach is to construct an import statement as a",asextension,762 "Learning Python, 5th Edition",from lister import ListInstance as Lister,asextension,974 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,129 "Learning Python, 5th Edition","def __init__(self, start)",__init__,514 "Learning Python, 5th Edition","def __init__(self, start)",__init__,514 "Learning Python, 5th Edition","def __init__(self, id)",__init__,518 "Learning Python, 5th Edition","def __init__(self, who)",__init__,791 "Learning Python, 5th Edition","def __init__(self, name, jobs, age=None)",__init__,813 "Learning Python, 5th Edition","def __init__(self, name, job, pay)",__init__,818 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,819 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,820 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,821 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,823 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,824 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,827 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,830 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,834 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,835 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,837 "Learning Python, 5th Edition","def __init__(self, *args)",__init__,838 "Learning Python, 5th Edition",def __init__(self),__init__,842 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,845 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,846 "Learning Python, 5th Edition","def __init__(self, value)",__init__,861 "Learning Python, 5th Edition","def __init__(self, x)",__init__,864 "Learning Python, 5th Edition","def __init__(self, x, y)",__init__,864 "Learning Python, 5th Edition","def __init__(self, start, stop)",__init__,896 "Learning Python, 5th Edition","def __init__(self, wrapped)",__init__,900 "Learning Python, 5th Edition","def __init__(self, wrapped)",__init__,900 "Learning Python, 5th Edition","def __init__(self, start, stop)",__init__,902 "Learning Python, 5th Edition",def __init__(...),__init__,903 "Learning Python, 5th Edition","def __init__(self, start, stop)",__init__,905 "Learning Python, 5th Edition","def __init__(self, start, stop)",__init__,905 "Learning Python, 5th Edition","def __init__(self, wrapped)",__init__,906 "Learning Python, 5th Edition","def __init__(self, value)",__init__,907 "Learning Python, 5th Edition","def __init__(self, value)",__init__,908 "Learning Python, 5th Edition",def __init__(self),__init__,912 "Learning Python, 5th Edition","def __init__(self, value=0)",__init__,913 "Learning Python, 5th Edition","def __init__(self, val)",__init__,916 "Learning Python, 5th Edition","def __init__(self, val)",__init__,916 "Learning Python, 5th Edition","def __init__(self, value=0)",__init__,917 "Learning Python, 5th Edition","def __init__(self, val)",__init__,917 "Learning Python, 5th Edition","def __init__(self, val)",__init__,918 "Learning Python, 5th Edition","def __init__(self, val)",__init__,918 "Learning Python, 5th Edition","def __init__(self, val)",__init__,919 "Learning Python, 5th Edition","def __init__(self, val)",__init__,919 "Learning Python, 5th Edition","def __init__(self, val)",__init__,921 "Learning Python, 5th Edition","def __init__(self, val)",__init__,921 "Learning Python, 5th Edition","def __init__(self, value)",__init__,922 "Learning Python, 5th Edition","def __init__(self, value)",__init__,923 "Learning Python, 5th Edition","def __init__(self, color)",__init__,923 "Learning Python, 5th Edition","def __init__(self, color)",__init__,925 "Learning Python, 5th Edition","def __init__(self, name='unknown')",__init__,929 "Learning Python, 5th Edition","def __init__(self, name, salary=0)",__init__,935 "Learning Python, 5th Edition","def __init__(self, name)",__init__,936 "Learning Python, 5th Edition","def __init__(self, name)",__init__,936 "Learning Python, 5th Edition","def __init__(self, name)",__init__,936 "Learning Python, 5th Edition","def __init__(self, name)",__init__,937 "Learning Python, 5th Edition",def __init__(self),__init__,937 "Learning Python, 5th Edition","def __init__(self, reader, writer)",__init__,939 "Learning Python, 5th Edition","def __init__(self, object)",__init__,942 "Learning Python, 5th Edition",def __init__(self),__init__,947 "Learning Python, 5th Edition","def __init__(self, data)",__init__,950 "Learning Python, 5th Edition","def __init__(self, base)",__init__,951 "Learning Python, 5th Edition","def __init__(self, val)",__init__,952 "Learning Python, 5th Edition","def __init__(self, val)",__init__,952 "Learning Python, 5th Edition","def __init__(self, val)",__init__,953 "Learning Python, 5th Edition","def __init__(self, name, job=None)",__init__,955 "Learning Python, 5th Edition",def __init__(self),__init__,958 "Learning Python, 5th Edition",def __init__(self),__init__,960 "Learning Python, 5th Edition",def __init__(self),__init__,961 "Learning Python, 5th Edition",def __init__(self),__init__,961 "Learning Python, 5th Edition",def __init__(self),__init__,962 "Learning Python, 5th Edition",def __init__(self),__init__,962 "Learning Python, 5th Edition","def __init__(self, value = [])",__init__,980 "Learning Python, 5th Edition","def __init__(self, value = [])",__init__,982 "Learning Python, 5th Edition",def __init__(self),__init__,1009 "Learning Python, 5th Edition",def __init__(self),__init__,1012 "Learning Python, 5th Edition",def __init__(self),__init__,1013 "Learning Python, 5th Edition","def __init__(self, data)",__init__,1015 "Learning Python, 5th Edition",def __init__(self),__init__,1026 "Learning Python, 5th Edition",def __init__(self),__init__,1027 "Learning Python, 5th Edition",def __init__(self),__init__,1028 "Learning Python, 5th Edition",def __init__(self),__init__,1030 "Learning Python, 5th Edition",def __init__(self),__init__,1032 "Learning Python, 5th Edition",def __init__(self),__init__,1032 "Learning Python, 5th Edition",def __init__(self),__init__,1033 "Learning Python, 5th Edition",def __init__(self),__init__,1033 "Learning Python, 5th Edition",def __init__(self),__init__,1036 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1037 "Learning Python, 5th Edition","def __init__(self, *args)",__init__,1039 "Learning Python, 5th Edition",def __init__(self),__init__,1046 "Learning Python, 5th Edition","def __init__(self, filename)",__init__,1046 "Learning Python, 5th Edition",def __init__(self),__init__,1051 "Learning Python, 5th Edition",def __init__(self),__init__,1052 "Learning Python, 5th Edition",def __init__(self): B.__init__(self); C.__init__(self),__init__,1054 "Learning Python, 5th Edition","def __init__(self, name, salary)",__init__,1060 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1060 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1060 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1060 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1060 "Learning Python, 5th Edition","def __init__(self, name): Employee.__init__(self, name, 70000)",__init__,1061 "Learning Python, 5th Edition",def __init__(self),__init__,1066 "Learning Python, 5th Edition",def __init__(self),__init__,1067 "Learning Python, 5th Edition",def __init__(self),__init__,1074 "Learning Python, 5th Edition",def __init__(self),__init__,1075 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1075 "Learning Python, 5th Edition","def __init__(self, line, file)",__init__,1137 "Learning Python, 5th Edition","def __init__(self, line, file)",__init__,1138 "Learning Python, 5th Edition",def __init__(self),__init__,1212 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1222 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1224 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1225 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1230 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1231 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1231 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1232 "Learning Python, 5th Edition","def __init__(self, value)",__init__,1233 "Learning Python, 5th Edition",def __init__(self),__init__,1233 "Learning Python, 5th Edition",def __init__(self),__init__,1234 "Learning Python, 5th Edition","def __init__(self, data)",__init__,1235 "Learning Python, 5th Edition","def __init__(self, data)",__init__,1235 "Learning Python, 5th Edition","def __init__(self, fget=None, fset=None, fdel=None, doc=None)",__init__,1236 "Learning Python, 5th Edition","def __init__(self, object)",__init__,1239 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1243 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1244 "Learning Python, 5th Edition",def __init__(self),__init__,1245 "Learning Python, 5th Edition",def __init__(self),__init__,1245 "Learning Python, 5th Edition","def __init__(self, square, cube)",__init__,1246 "Learning Python, 5th Edition","def __init__(self, square, cube)",__init__,1247 "Learning Python, 5th Edition","def __init__(self, square, cube)",__init__,1247 "Learning Python, 5th Edition","def __init__(self, square, cube)",__init__,1248 "Learning Python, 5th Edition",def __init__(self),__init__,1250 "Learning Python, 5th Edition",def __init__(self),__init__,1250 "Learning Python, 5th Edition","def __init__(self, name, job=None, pay=0)",__init__,1253 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1253 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1254 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1255 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1255 "Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1257 "Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1260 "Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1262 "Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1264 "Learning Python, 5th Edition","def __init__(self, acct, name, age, addr)",__init__,1265 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1275 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1275 "Learning Python, 5th Edition","def __init__(self, *args)",__init__,1278 "Learning Python, 5th Edition","def __init__(self, x, y)",__init__,1278 "Learning Python, 5th Edition","def __init__(self, C)",__init__,1279 "Learning Python, 5th Edition","def __init__(self, *args)",__init__,1279 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1283 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1285 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1289 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1290 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1291 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1293 "Learning Python, 5th Edition","def __init__(self, desc, subj)",__init__,1293 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1294 "Learning Python, 5th Edition","def __init__(self, meth)",__init__,1294 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1295 "Learning Python, 5th Edition","def __init__(self, func)",__init__,1299 "Learning Python, 5th Edition","def __init__(self, name, hours, rate)",__init__,1302 "Learning Python, 5th Edition","def __init__(self, val)",__init__,1302 "Learning Python, 5th Edition","def __init__(self, aClass)",__init__,1303 "Learning Python, 5th Edition","def __init__(self, object)",__init__,1304 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1304 "Learning Python, 5th Edition","def __init__(self, name, hours, rate)",__init__,1305 "Learning Python, 5th Edition","def __init__(self, aClass)",__init__,1308 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1308 "Learning Python, 5th Edition","def __init__(self, x)",__init__,1312 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1315 "Learning Python, 5th Edition","def __init__(self, label, start)",__init__,1316 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1319 "Learning Python, 5th Edition","def __init__(self, name, age)",__init__,1320 "Learning Python, 5th Edition","def __init__(self, name, age)",__init__,1320 "Learning Python, 5th Edition",def __init__(self),__init__,1323 "Learning Python, 5th Edition",def __init__(self),__init__,1323 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1324 "Learning Python, 5th Edition","def __init__(self, attrname)",__init__,1326 "Learning Python, 5th Edition","def __init__(self, name, job, pay)",__init__,1332 "Learning Python, 5th Edition","def __init__(self, name, job, pay)",__init__,1335 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1346 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1347 "Learning Python, 5th Edition","def __init__(self, name, age)",__init__,1349 "Learning Python, 5th Edition","def __init__(Class, classname, superclasses, attributedict)",__init__,1361 "Learning Python, 5th Edition","def __init__(Class, classname, supers, classdict)",__init__,1372 "Learning Python, 5th Edition","def __init__(Class, classname, supers, classdict)",__init__,1376 "Learning Python, 5th Edition","def __init__(Class, classname, supers, classdict)",__init__,1378 "Learning Python, 5th Edition","def __init__(self, value)",__init__,1392 "Learning Python, 5th Edition","def __init__(self, value)",__init__,1393 "Learning Python, 5th Edition","def __init__(self, value)",__init__,1395 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1396 "Learning Python, 5th Edition","def __init__(self, name, hours, rate)",__init__,1396 "Learning Python, 5th Edition","def __init__(self, *args, **kargs)",__init__,1397 "Learning Python, 5th Edition","def __init__(self, name, hours, rate)",__init__,1397 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1402 "Learning Python, 5th Edition","def __init__(self, name, pay)",__init__,1403 "Learning Python, 5th Edition","def __init__(self, start=[])",__init__,1489 "Learning Python, 5th Edition","def __init__(self, start=[])",__init__,1490 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1491 "Learning Python, 5th Edition","def __init__(self, start)",__init__,1492 "Learning Python, 5th Edition",def __init__(self),__init__,1495 "Learning Python, 5th Edition",def __init__(self),__init__,1495 "Learning Python, 5th Edition","def __init__(self, name)",__init__,1496 "Learning Python, 5th Edition",def __init__(self),__init__,1497 "Learning Python, 5th Edition","def __init__(self, parent, title='popup')",__init__,1502 "Learning Python, 5th Edition","try: ... raise IndexError # Trigger exception manually ... except IndexError: ... print('got exception') ... got exception As usual, if they’re not caught, user-triggered exceptions are propagated up to the top- level default exception handler and terminate the program with a standard error mes- sage: >>> raise IndexError Traceback (most recent call last): File ""<stdin>"", line 1, in <module> IndexError As we’ll see in the next chapter, the assert statement can be used to trigger exceptions, too—it’s a conditional raise, used mostly for debugging purposes during development: >>> assert False, 'Nobody expects the Spanish Inquisition!' Traceback (most recent call last): File ""<stdin>"", line 1, in <module> AssertionError: Nobody expects the Spanish Inquisition! User-Defined Exceptions The raise statement introduced in the prior section raises a built-in exception defined in Python’s built-in scope. As you’ll learn later in this part of the book, you can also define new exceptions of your own that are specific to your programs. User-defined exceptions are coded with classes, which inherit from a built-in exception class: usually the class named Exception: >>> class AlreadyGotOne(Exception): pass # User-defined exception >>> def grail(): raise AlreadyGotOne() # Raise an instance >>> try: ... grail() ... except AlreadyGotOne: # Catch class name ... print('got exception') ... got exception >>> As we’ll see in the next chapter, an as clause on an except can gain access to the ex- ception object itself. Class-based exceptions allow scripts to build exception categories, which can inherit behavior, and have attached state information and methods. They can also customize their error message text displayed if they’re not caught: 1086 | Chapter 33: Exception Basics www.it-ebooks.info",trytry,1086 "Learning Python, 5th Edition","try: action() except NameError: ... except IndexError: ... except KeyError: ... except (AttributeError, TypeError, SyntaxError): ... else: ... In this example, if an exception is raised while the call to the action function is running, Python returns to the try and searches for the first except that names the exception raised. It inspects the except clauses from top to bottom and left to right, and runs the statements under the first one that matches. If none match, the exception is propagated past this try. Note that the else runs only when no exception occurs in action—it does not run when an exception without a matching except is raised. Catching all: The empty except and Exception If you really want a general “catchall” clause, an empty except does the trick: try: action() except NameError: ... # Handle NameError except IndexError: ... # Handle IndexError except: ... # Handle all other exceptions 1096 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1096 "Learning Python, 5th Edition","try: action() except: ... # Catch all possible exceptions Empty excepts also raise some design issues, though. Although convenient, they may catch unexpected system exceptions unrelated to your code, and they may inadver- tently intercept exceptions meant for another handler. For example, even system exit calls and Ctrl-C key combinations in Python trigger exceptions, and you usually want these to pass. Even worse, the empty except may also catch genuine programming mistakes for which you probably want to see an error message. We’ll revisit this as a gotcha at the end of this part of the book. For now, I’ll just say, “use with care.” Python 3.X more strongly supports an alternative that solves one of these problems— catching an exception named Exception has almost the same effect as an empty except, but ignores exceptions related to system exits: try: action() except Exception: ... # Catch all possible exceptions, except exits We’ll explore how this form works its voodoo formally in the next chapter when we study exception classes. In short, it works because exceptions match if they are a sub- class of one named in an except clause, and Exception is a superclass of all the exceptions you should generally catch this way. This form has most of the same convenience of the empty except, without the risk of catching exit events. Though better, it also has some of the same dangers—especially with regard to masking programming errors. Version skew note: See also the raise statement ahead for more on the as portion of except clauses in try. Syntactically, Python 3.X requires the except E as V: handler clause form listed in Table 34-1 and used in this book, rather than the older except E, V: form. The latter form is still available (but not recommended) in Python 2.6 and 2.7: if used, it’s converted to the former. The change was made to eliminate confusion regarding the dual role of commas in the older form. In this form, two alternate exceptions are properly coded as except (E1, E2):. Because 3.X supports the as form only, commas in a handler clause are always taken to mean a tuple, regardless of whether parentheses are used or not, and the values are interpreted as alternative exceptions to be caught. The try/except/else Statement | 1097 www.it-ebooks.info",trytry,1097 "Learning Python, 5th Edition","try: try: ...run code... except IndexError: ...handle exception... # Did we get here because the try failed or not? Much like the way else clauses in loops make the exit cause more apparent, the else clause provides syntax in a try that makes what has happened obvious and unambig- uous: try: ...run code... except IndexError: ...handle exception... else: ...no exception occurred... You can almost emulate an else clause by moving its code into the try block: try: ...run code... ...no exception occurred... except IndexError: ...handle exception... This can lead to incorrect exception classifications, though. If the “no exception oc- curred” action triggers an IndexError, it will register as a failure of the try block and erroneously trigger the exception handler below the try (subtle, but true!). By using an explicit else clause instead, you make the logic more obvious and guarantee that except handlers will run only for real failures in the code you’re wrapping in a try, not for failures in the else no-exception case’s action. Example: Default Behavior Because the control flow through a program is easier to capture in Python than in English, let’s run some examples that further illustrate exception basics in the context of larger code samples in files. 1098 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1098 "Learning Python, 5th Edition","try: # Nested equivalent to merged form try: main-action except Exception1: handler1 except Exception2: handler2 1104 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1104 "Learning Python, 5th Edition","try: ... except IndexError as X: # X assigned the raised instance object ... The as is optional in a try handler (if it’s omitted, the instance is simply not assigned to a name), but including it allows the handler to access both data in the instance and methods in the exception class. This model works the same for user-defined exceptions we code with classes—the following, for example, passes to the exception class constructor arguments that be- come available in the handler through the assigned instance: class MyExc(Exception): pass ... raise MyExc('spam') # Exception class with constructor args ... try: ... except MyExc as X: # Instance attributes available in handler print(X.args) Because this encroaches on the next chapter’s topic, though, I’ll defer further details until then. Regardless of how you name them, exceptions are always identified by class instance objects, and at most one is active at any given time. Once caught by an except clause anywhere in the program, an exception dies (i.e., won’t propagate to another try), unless it’s reraised by another raise statement or error. Scopes and try except Variables We’ll study exception objects in more detail in the next chapter. Now that we’ve seen the as variable in action, though, we can finally clarify the related version-specific scope issue summarized in Chapter 17. In Python 2.X, the exception reference variable name in an except clause is not localized to the clause itself, and is available after the associated block runs: c:\code> py −2 >>> try: ... 1 / 0 ... except Exception as X: # 2.X does not localize X either way ... print X ... integer division or modulo by zero >>> X ZeroDivisionError('integer division or modulo by zero',) This is true in 2.X whether we use the 3.X-style as or the earlier comma syntax: >>> try: ... 1 / 0 ... except Exception, X: 1108 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1108 "Learning Python, 5th Edition","try: ... 1 / 0 ... except Exception, X: SyntaxError: invalid syntax >>> try: ... 1 / 0 ... except Exception as X: # 3.X localizes 'as' names to except block ... print(X) ... division by zero >>> X NameError: name 'X' is not defined Unlike compression loop variables, though, this variable is removed after the except block exits in 3.X. It does so because it would otherwise retain a reference to the runtime call stack, which would defer garbage collection and thus retain excess memory space. This removal occurs, though, even if you’re using the name elsewhere, and is more extreme policy than that used for comprehensions: >>> X = 99 >>> try: ... 1 / 0 ... except Exception as X: # 3.X localizes _and_ removes on exit! ... print(X) ... division by zero >>> X NameError: name 'X' is not defined >>> X = 99 >>> {X for X in 'spam'} # 2.X/3.X localizes only: not removed {'s', 'a', 'p', 'm'} >>> X 99 Because of this, you should generally use unique variable names in your try statement’s except clauses, even if they are localized by scope. If you do need to reference the exception instance after the try statement, simply assign it to another name that won’t be automatically removed: The raise Statement | 1109 www.it-ebooks.info",trytry,1109 "Learning Python, 5th Edition","try: ... 1 / 0 ... except Exception as X: # Python removes this reference ... print(X) ... Saveit = X # Assign exc to retain exc if needed ... division by zero >>> X NameError: name 'X' is not defined >>> Saveit ZeroDivisionError('division by zero',) Propagating Exceptions with raise The raise statement is a bit more feature-rich than we’ve seen thus far. For example, a raise that does not include an exception name or extra data value simply reraises the current exception. This form is typically used if you need to catch and handle an ex- ception but don’t want the exception to die in your code: >>> try: ... raise IndexError('spam') # Exceptions remember arguments ... except IndexError: ... print('propagating') ... raise # Reraise most recent exception ... propagating Traceback (most recent call last): File ""<stdin>"", line 2, in <module> IndexError: spam Running a raise this way reraises the exception and propagates it to a higher handler (or the default handler at the top, which stops the program with a standard error mes- sage). Notice how the argument we passed to the exception class shows up in the error messages; you’ll learn why this happens in the next chapter. Python 3.X Exception Chaining: raise from Exceptions can sometimes be triggered in response to other exceptions—both delib- erately and by new program errors. To support full disclosure in such cases, Python 3.X (but not 2.X) also allows raise statements to have an optional from clause: raise newexception from otherexception When the from is used in an explicit raise request, the expression following from speci- fies another exception class or instance to attach to the __cause__ attribute of the new exception being raised. If the raised exception is not caught, Python prints both ex- ceptions as part of the standard error message: >>> try: ... 1 / 0 ... except Exception as E: ... raise TypeError('Bad') from E # Explicitly chained exceptions 1110 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1110 "Learning Python, 5th Edition","try: ... 1 / 0 ... except: ... badname # Implicitly chained exceptions ... Traceback (most recent call last): File ""<stdin>"", line 2, in <module> ZeroDivisionError: division by zero During handling of the above exception, another exception occurred: Traceback (most recent call last): File ""<stdin>"", line 4, in <module> NameError: name 'badname' is not defined In both cases, because the original exception objects thus attached to new exception objects may themselves have attached causes, the causality chain can be arbitrary long, and is displayed in full in error messages. That is, error messages might give more than two exceptions. The net effect in both explicit and implicit contexts is to allow programmers to know all exceptions involved, when one exception triggers another: >>> try: ... try: ... raise IndexError() ... except Exception as E: ... raise TypeError() from E ... except Exception as E: ... raise SyntaxError() from E ... Traceback (most recent call last): File ""<stdin>"", line 3, in <module> IndexError The above exception was the direct cause of the following exception: Traceback (most recent call last): File ""<stdin>"", line 5, in <module> TypeError The raise Statement | 1111 www.it-ebooks.info",trytry,1111 "Learning Python, 5th Edition","try: try: 1 / 0 except: badname except: open('nonesuch') Like the unified try, chained exceptions are similar to utility in other languages (in- cluding Java and C#) though it’s not clear which languages were borrowers. In Python, it’s a still somewhat obscure extension, so we’ll defer to Python’s manuals for more details. In fact, Python 3.3 adds a way to stop exceptions from chaining, per the fol- lowing note. Python 3.3 chained exception suppression: raise from None. Python 3.3 introduces a new syntax form—using None as the exception name in the raise from statement: raise newexception from None This allows the display of the chained exception context described in the preceding section to be disabled. This makes for less cluttered error messages in applications that convert between exception types while processing exception chains. The assert Statement As a somewhat special case for debugging purposes, Python includes the assert state- ment. It is mostly just syntactic shorthand for a common raise usage pattern, and an assert can be thought of as a conditional raise statement. A statement of the form: assert test, data # The data part is optional works like the following code: if __debug__: if not test: raise AssertionError(data) In other words, if the test evaluates to false, Python raises an exception: the data item (if it’s provided) is used as the exception’s constructor argument. Like all exceptions, the AssertionError exception will kill your program if it’s not caught with a try, in which case the data item shows up as part of the standard error message. 1112 | Chapter 34: Exception Coding Details www.it-ebooks.info",trytry,1112 "Learning Python, 5th Edition","try: func() except (General, Specific1, Specific2): # Catch any of these ... This approach worked for the defunct string exception model too. For large or high exception hierarchies, however, it may be easier to catch categories using class-based categories than to list every member of a category in a single except clause. Perhaps more importantly, you can extend exception hierarchies as software needs evolve by adding new subclasses without breaking existing code. Suppose, for example, you code a numeric programming library in Python, to be used by a large number of people. While you are writing your library, you identify two things that can go wrong with numbers in your code—division by zero, and numeric overflow. You document these as the two standalone exceptions that your library may raise: # mathlib.py class Divzero(Exception): pass class Oflow(Exception): pass def func(): ... raise Divzero() ...and so on... Now, when people use your library, they typically wrap calls to your functions or classes in try statements that catch your two exceptions; after all, if they do not catch your exceptions, exceptions from your library will kill their code: # client.py import mathlib try: mathlib.func(...) except (mathlib.Divzero, mathlib.Oflow): ...handle and recover... 1128 | Chapter 35: Exception Objects www.it-ebooks.info",trytry,1128 "Learning Python, 5th Edition","try: mathlib.func(...) except (mathlib.Divzero, mathlib.Oflow, mathlib.Uflow): ...handle and recover... This may not be the end of the world. If your library is used only in-house, you can make the changes yourself. You might also ship a Python script that tries to fix such code automatically (it would probably be only a few dozen lines, and it would guess right at least some of the time). If many people have to change all their try statements each time you alter your exception set, though, this is not exactly the most polite of upgrade policies. Your users might try to avoid this pitfall by coding empty except clauses to catch all possible exceptions: # client.py try: mathlib.func(...) except: # Catch everything here (or catch Exception super) ...handle and recover... But this workaround might catch more than they bargained for—things like running out of memory, keyboard interrupts (Ctrl-C), system exits, and even typos in their own try block’s code will all trigger exceptions, and such things should pass, not be caught and erroneously classified as library errors. Catching the Exception super class improves on this, but still intercepts—and thus may mask—program errors. And really, in this scenario users want to catch and recover from only the specific ex- ceptions the library is defined and documented to raise. If any other exception occurs during a library call, it’s likely a genuine bug in the library (and probably time to contact the vendor!). As a rule of thumb, it’s usually better to be specific than general in ex- ception handlers—an idea we’ll revisit as a “gotcha” in the next chapter.1 Why Exception Hierarchies? | 1129 www.it-ebooks.info",trytry,1129 "Learning Python, 5th Edition","try: ... f = open('nonesuch.txt') ... except IOError as V: ... if V.errno == 2: # Or errno.N, V.args[0] ... print('No such file') ... else: ... raise # Propagate others ... No such file This code still works in 3.3, but with the new classes, programs in 3.3 and later can be more specific about the exceptions they mean to pro- cess, and ignore others: c:\temp> py −3.3 >>> try: ... f = open('nonesuch.txt') ... except FileNotFoundError: ... print('No such file') ... No such file For full details on this extension and its classes, see the other resources listed earlier. Default Printing and State Built-in exceptions also provide default print displays and state retention, which is often as much logic as user-defined classes require. Unless you redefine the constructors your classes inherit from them, any constructor arguments you pass to these classes are automatically saved in the instance’s args tuple attribute, and are automatically dis- played when the instance is printed. An empty tuple and display string are used if no constructor arguments are passed, and a single argument displays as itself (not as a tuple). Built-in Exception Classes | 1133 www.it-ebooks.info",trytry,1133 "Learning Python, 5th Edition","try: # Multiple arguments save/display a tuple ... raise E('spam', 'eggs', 'ham') ... except E as X: ... print('%s %s' % (X, X.args)) ... ('spam', 'eggs', 'ham') ('spam', 'eggs', 'ham') Note that exception instance objects are not strings themselves, but use the __str__ operator overloading protocol we studied in Chapter 30 to provide display strings when printed; to concatenate with real strings, perform manual conversions: str(X) + 'as tr', '%s' % X, and the like. Although this automatic state and display support is useful by itself, for more specific display and state retention needs you can always redefine inherited methods such as __str__ and __init__ in Exception subclasses—as the next section shows. Custom Print Displays As we saw in the preceding section, by default, instances of class-based exceptions display whatever you passed to the class constructor when they are caught and printed: >>> class MyBad(Exception): pass ... >>> try: ... raise MyBad('Sorry--my mistake!') ... except MyBad as X: ... print(X) ... Sorry--my mistake! This inherited default display model is also used if the exception is displayed as part of an error message when the exception is not caught: >>> raise MyBad('Sorry--my mistake!') Traceback (most recent call last): File ""<stdin>"", line 1, in <module> __main__.MyBad: Sorry--my mistake! For many roles, this is sufficient. To provide a more custom display, though, you can define one of two string-representation overloading methods in your class (__repr__ or __str__) to return the string you want to display for your exception. The string the method returns will be displayed if the exception either is caught and printed or reaches the default handler: >>> class MyBad(Exception): ... def __str__(self): ... return 'Always look on the bright side of life...' ... >>> try: ... raise MyBad() ... except MyBad as X: ... print(X) Custom Print Displays | 1135 www.it-ebooks.info",trytry,1135 "Learning Python, 5th Edition","try: ... parser() ... except FormatError as X: ... print('Error at: %s %s' % (X.file, X.line)) ... Error at: spam.txt 42 In the except clause here, the variable X is assigned a reference to the instance that was generated when the exception was raised. This gives access to the attributes attached to the instance by the custom constructor. Although we could rely on the default state retention of built-in superclasses, it’s less relevant to our application (and doesn’t sup- port the keyword arguments used in the prior example): >>> class FormatError(Exception): pass # Inherited constructor >>> def parser(): raise FormatError(42, 'spam.txt') # No keywords allowed! >>> try: ... parser() ... except FormatError as X: ... print('Error at:', X.args[0], X.args[1]) # Not specific to this app ... Error at: 42 spam.txt Providing Exception Methods Besides enabling application-specific state information, custom constructors also better support extra behavior for exception objects. That is, the exception class can also define methods to be called in the handler. The following code in excparse.py, for example, adds a method that uses exception state information to log errors to a file automatically: Custom Data and Behavior | 1137 www.it-ebooks.info",trytry,1137 "Learning Python, 5th Edition","try: action2() except TypeError: # Most recent matching try print('inner try') try: action1() except TypeError: # Here, only if action1 re-raises print('outer try') % python nestexc.py inner try Notice, though, that the top-level module code at the bottom of the file wraps a call to action1 in a try handler, too. When action2 triggers the TypeError exception, there will be two active try statements—the one in action1, and the one at the top level of the module file. Python picks and runs just the most recent try with a matching except— which in this case is the try inside action1. Again, the place where an exception winds up jumping to depends on the control flow through the program at runtime. Because of this, to know where you will go, you need to know where you’ve been. In this case, where exceptions are handled is more a func- tion of control flow than of statement syntax. However, we can also nest exception handlers syntactically—an equivalent case we turn to next. Example: Syntactic Nesting As I mentioned when we looked at the new unified try/except/finally statement in Chapter 34, it is possible to nest try statements syntactically by their position in your source code: try: try: action2() except TypeError: # Most recent matching try print('inner try') except TypeError: # Here, only if nested handler re-raises print('outer try') Nesting Exception Handlers | 1143 www.it-ebooks.info",trytry,1143 "Learning Python, 5th Edition","try: ...run program... except: # All uncaught exceptions come here import sys print('uncaught!', sys.exc_info()[0], sys.exc_info()[1]) This structure is commonly used during development, to keep programs active even after errors occur—within a loop, it allows you to run additional tests without having to restart. It’s also used when testing other program code, as described in the next section. On a related note, for more about handling program shutdowns without recovery from them, see also Python’s atexit standard library module. It’s also possible to customize what the top-level exception handler does with sys.excepthook. These and other related tools are described in Python’s library manual. Running In-Process Tests Some of the coding patterns we’ve just looked at can be combined in a test-driver application that tests other code within the same process. The following partial code sketches the general model: import sys log = open('testlog', 'a') from testapi import moreTests, runNextTest, testName def testdriver(): while moreTests(): try: runNextTest() except: print('FAILED', testName(), sys.exc_info()[:2], file=log) else: print('PASSED', testName(), file=log) testdriver() Exception Idioms | 1149 www.it-ebooks.info",trytry,1149 "Learning Python, 5th Edition","try: ... except: # sys.exc_info()[0:2] are the exception class and instance If no exception is being handled, this call returns a tuple containing three None values. Otherwise, the values returned are (type, value, traceback), where: • type is the exception class of the exception being handled. • value is the exception class instance that was raised. • traceback is a traceback object that represents the call stack at the point where the exception originally occurred, and used by the traceback module to generate error messages. As we saw in the prior chapter, sys.exc_info can also sometimes be useful to determine the specific exception type when catching exception category superclasses. As we’ve also learned, though, because in this case you can also get the exception type by fetching the __class__ attribute of the instance obtained with the as clause, sys.exc_info is often redundant apart from the empty except: try: ... 1150 | Chapter 36: Designing with Exceptions www.it-ebooks.info",trytry,1150 "Learning Python, 5th Edition","try: ... except General as instance: # instance.method() does the right thing for this instance As usual, being too specific in Python can limit your code’s flexibility. A polymorphic approach like the last example here generally supports future evolution better than explicitly type-specific tests or actions. Displaying Errors and Tracebacks Finally, the exception traceback object available in the prior section’s sys.exc_info result is also used by the standard library’s traceback module to generate the standard error message and stack display manually. This file has a handful of interfaces that support wide customization, which we don’t have space to cover usefully here, but the basics are simple. Consider the following aptly named file, badly.py: import traceback def inverse(x): return 1 / x try: inverse(0) except Exception: traceback.print_exc(file=open('badly.exc', 'w')) print('Bye') This code uses the print_exc convenience function in the traceback module, which uses sys.exc_info data by default; when run, the script prints the error message to a file—handy in testing programs that need to catch errors but still record them in full: c:\code> python badly.py Bye c:\code> type badly.exc Traceback (most recent call last): File ""badly.py"", line 7, in <module> inverse(0) File ""badly.py"", line 4, in inverse return 1 / x ZeroDivisionError: division by zero Exception Idioms | 1151 www.it-ebooks.info",trytry,1151 "Learning Python, 5th Edition","try: ... # IndexError is raised in here except: ... # But everything comes here and dies! try: func() except IndexError: # Exception should be processed here ... Perhaps worse, such code might also catch unrelated system exceptions. Even things like memory errors, genuine programming mistakes, iteration stops, keyboard inter- rupts, and system exits raise exceptions in Python. Unless you’re writing a debugger or similar tool, such exceptions should not usually be intercepted in your code. For example, scripts normally exit when control falls off the end of the top-level file. However, Python also provides a built-in sys.exit(statuscode) call to allow early ter- minations. This actually works by raising a built-in SystemExit exception to end the program, so that try/finally handlers run on the way out and special types of programs can intercept the event.1 Because of this, a try with an empty except might unknowingly prevent a crucial exit, as in the following file (exiter.py): 1. A related call, os._exit, also ends a program, but via an immediate termination—it skips cleanup actions, including any registered with the atexit module noted earlier, and cannot be intercepted with try/ except or try/finally blocks. It is usually used only in spawned child processes, a topic beyond this book’s scope. See the library manual or follow-up texts for details. Exception Design Tips and Gotchas | 1153 www.it-ebooks.info",trytry,1153 "Learning Python, 5th Edition","try: bye() except: print('got it') # Oops--we ignored the exit print('continuing...') % python exiter.py got it continuing... You simply might not expect all the kinds of exceptions that could occur during an operation. Using the built-in exception classes of the prior chapter can help in this particular case, because the Exception superclass is not a superclass of SystemExit: try: bye() except Exception: # Won't catch exits, but _will_ catch many others ... In other cases, though, this scheme is no better than an empty except clause—because Exception is a superclass above all built-in exceptions except system-exit events, it still has the potential to catch exceptions meant for elsewhere in the program. Probably worst of all, both using an empty except and catching the Exception superclass will also catch genuine programming errors, which should be allowed to pass most of the time. In fact, these two techniques can effectively turn off Python’s error-reporting machinery, making it difficult to notice mistakes in your code. Consider this code, for example: mydictionary = {...} ... try: x = myditctionary['spam'] # Oops: misspelled except: x = None # Assume we got KeyError ...continue here with x... The coder here assumes that the only sort of error that can happen when indexing a dictionary is a missing key error. But because the name myditctionary is misspelled (it should say mydictionary), Python raises a NameError instead for the undefined name reference, which the handler will silently catch and ignore. The event handler will in- correctly fill in a None default for the dictionary access, masking the program error. Moreover, catching Exception here will not help—it would have the exact same effect as an empty except, happily and silently filling in a default and masking a genuine program error you will probably want to know about. If this happens in code that is far removed from the place where the fetched values are used, it might make for a very interesting debugging task! 1154 | Chapter 36: Designing with Exceptions www.it-ebooks.info",trytry,1154 "Learning Python, 5th Edition","try: ... except (MyExcept1, MyExcept2): # Breaks if you add a MyExcept3 later ... # Nonerrors else: ... # Assumed to be an error Luckily, careful use of the class-based exceptions we discussed in Chapter 34 can make this code maintenance trap go away completely. As we saw, if you catch a general superclass, you can add and raise more specific subclasses in the future without having to extend except clause lists manually—the superclass becomes an extendible excep- tions category: try: ... except SuccessCategoryName: # OK if you add a MyExcept3 subclass later ... # Nonerrors else: ... # Assumed to be an error In other words, a little design goes a long way. The moral of the story is to be careful to be neither too general nor too specific in exception handlers, and to pick the gran- ularity of your try statement wrappings wisely. Especially in larger systems, exception policies should be a part of the overall design. Core Language Summary Congratulations! This concludes your look at the fundamentals of the Python pro- gramming language. If you’ve gotten this far, you’ve become a fully operational Python Core Language Summary | 1155 www.it-ebooks.info",trytry,1155 "Learning Python, 5th Edition","try: X[0] # __getitem__? except: print('fail []') try: X + 99 # __add__? except: print('fail +') try: X() # __call__? (implicit via built-in) except: print('fail ()') X.__call__() # __call__? (explicit, not inherited) print(X.__str__()) # __str__? (explicit, inherited from type) print(X) # __str__? (implicit via built-in) When run under Python 2.X as coded, __getattr__ does receive a variety of implicit attribute fetches for built-in operations, because Python looks up such attributes in instances normally. Conversely, __getattribute__ is not run for any of the operator overloading names invoked by built-in operations, because such names are looked up in classes only in the new-style class model: c:\code> py −2 getattr-builtins.py GetAttr=========================================== getattr: other __len__: 42 getattr: __getitem__ getattr: __coerce__ getattr: __add__ getattr: __call__ getattr: __call__ getattr: __str__ [Getattr str] getattr: __str__ [Getattr str] GetAttribute====================================== getattribute: eggs getattribute: spam getattribute: other __len__: 42 fail [] fail + fail () getattribute: __call__ getattribute: __str__ [GetAttribute str] <__main__.GetAttribute object at 0x02287898> Note how __getattr__ intercepts both implicit and explicit fetches of __call__ and __str__ in 2.X here. By contrast, __getattribute__ fails to catch implicit fetches of either attribute name for built-in operations. __getattr__ and __getattribute__ | 1251 www.it-ebooks.info",trytry,1251 "Learning Python, 5th Edition","try: sue.remain = 5 except: print(""Can't set sue.remain"") try: sue.acct = '1234567' except: print('Bad acct for Sue') Here is the output of our self-test code on both Python 3.X and 2.X; again, this is the same for all versions of this example, except for the tested class’s name. Trace through this code to see how the class’s methods are invoked; accounts are displayed with some digits hidden, names are converted to a standard format, and time remaining until retirement is computed when fetched using a class attribute cutoff: c:\code> py −3 validate_tester.py validate_properties [Using: <class 'validate_properties.CardHolder'>] 12345*** / bob_smith / 40 / 19.5 / 123 main st 23456*** / bob_q._smith / 50 / 9.5 / 123 main st 56781*** / sue_jones / 35 / 24.5 / 124 main st Bad age for Sue Can't set sue.remain Bad acct for Sue Using Descriptors to Validate Now, let’s recode our example using descriptors instead of properties. As we’ve seen, descriptors are very similar to properties in terms of functionality and roles; in fact, properties are basically a restricted form of descriptor. Like properties, descriptors are designed to handle specific attributes, not generic attribute access. Unlike properties, descriptors can also have their own state, and are a more general scheme. Option 1: Validating with shared descriptor instance state To understand the following code, it’s again important to notice that the attribute assignments inside the __init__ constructor method trigger descriptor __set__ meth- ods. When the constructor method assigns to self.name, for example, it automatically invokes the Name.__set__() method, which transforms the value and assigns it to a descriptor attribute called name. In the end, this class implements the same attributes as the prior version: it manages attributes called name, age, and acct; allows the attribute addr to be accessed directly; and provides a read-only attribute called remain that is entirely virtual and computed on demand. Notice how we must catch assignments to the remain name in its descriptor and raise an exception; as we learned earlier, if we did not do this, assigning to this attribute of an instance would silently create an instance attribute that hides the class attribute descriptor. Example: Attribute Validations | 1259 www.it-ebooks.info",trytry,1259 "Learning Python, 5th Edition","try: t = X.age # FAILS unless ""python -O"" except: print(sys.exc_info()[1]) try: X.age = 999 # ditto except: print(sys.exc_info()[1]) print('---------------------------------------------------------') # Test 2: names are private if not public # Operators must be non-Private or Public in BuiltinMixin used @Public('name', '__add__', '__str__', '__coerce__') class Person: def __init__(self, name, age): self.name = name self.age = age def __add__(self, N): self.age += N # Built-ins caught by mix-in in 3.X def __str__(self): return '%s: %s' % (self.name, self.age) X = Person('bob', 40) # X is an onInstance print(X.name) # onInstance embeds Person X.name = 'sue' print(X.name) X + 10 print(X) try: t = X.age # FAILS unless ""python -O"" except: print(sys.exc_info()[1]) try: X.age = 999 # ditto except: print(sys.exc_info()[1]) Finally, if all works as expected, this test’s output is as follows in both Python 3.X and 2.X—the same code applied to the same class decorated with Private and then with Public: c:\code> py −3 access-test.py --------------------------------------------------------- Bob Sue Sue: 50 Test Your Knowledge: Answers | 1349 www.it-ebooks.info",trytry,1349 "Learning Python, 5th Edition","try: oops() except IndexError: print('caught an index error!') except MyError as data: print('caught error:', MyError, data) else: print('no error caught...') if __name__ == '__main__': doomed() % python oops2.py caught error: <class '__main__.MyError'> Spam! Like all class exceptions, the instance is accessible via the as variable data; the error message shows both the class (<...>) and its instance (Spam!). The instance must be inheriting both an __init__ and a __repr__ or __str__ from Python’s Excep tion class, or it would print much like the class does. See Chapter 35 for details on how this works in built-in exception classes. 3. Error handling. Here’s one way to solve this one (file exctools.py). I did my tests in a file, rather than interactively, but the results are similar enough for full credit. Notice that the empty except and sys.exc_info approach used here will catch exit- related exceptions that listing Exception with an as variable won’t; that’s probably not ideal in most applications code, but might be useful in a tool like this designed to work as a sort of exceptions firewall. import sys, traceback def safe(callee, *pargs, **kargs): try: callee(*pargs, **kargs) # Catch everything else except: # Or ""except Exception as E:"" traceback.print_exc() print('Got %s %s' % (sys.exc_info()[0], sys.exc_info()[1])) if __name__ == '__main__': import oops2 safe(oops2.oops) 1498 | Appendix D: Solutions to End-of-Part Exercises www.it-ebooks.info",trytry,1498 "Learning Python, 5th Edition","try: statements # Run this main action first except name1: statements # Run if name1 is raised during try block except (name2, name3): statements # Run if any of these exceptions occur except name4 as var: statements # Run if name4 is raised, assign instance raised to var except: statements # Run for all other exceptions raised else:",tryexceptelse,1094 "Learning Python, 5th Edition","try: x = 'spam'[3] except IndexError: print('except run') else:",tryexceptelse,1105 "Learning Python, 5th Edition","try: action() except Exception: # Exits not caught here ...handle all application exceptions... else:",tryexceptelse,1132 "Learning Python, 5th Edition","try: item = searcher() except Failure: ...not found... else:",tryexceptelse,1147 "Learning Python, 5th Edition","try: oops() except IndexError: print('caught an index error!') else:",tryexceptelse,1497 "Learning Python, 5th Edition","try: ... print(Matrix[(2, 3, 6)]) # Try to index ... except KeyError:",tryexcept,260 "Learning Python, 5th Edition","try: ... print(branch[choice]) ... except KeyError:",tryexcept,374 "Learning Python, 5th Edition","try: # try statement catches exceptions ... X = next(I) # Or call I.__next__ in 3.X ... except StopIteration:",tryexcept,422 "Learning Python, 5th Edition","try: timer = time.perf_counter # or process_time except AttributeError:",tryexcept,634 "Learning Python, 5th Edition","try: print(next(I), end=' @ ') except StopIteration:",tryexcept,907 "Learning Python, 5th Edition","try: ... fetcher(x, 4) ... except IndexError:",tryexcept,1084 "Learning Python, 5th Edition","try: fetcher(x, 4) except IndexError:",tryexcept,1085 "Learning Python, 5th Edition","try: kaboom([0, 1, 2], 'spam') except TypeError:",tryexcept,1100 "Learning Python, 5th Edition","try: ... raise myexc ... except myexc:",tryexcept,1124 "Learning Python, 5th Edition","try: func() except General:",tryexcept,1126 "Learning Python, 5th Edition","try: func() except General as X:",tryexcept,1127 "Learning Python, 5th Edition","try: mathlib.func(...) except mathlib.NumErr:",tryexcept,1130 "Learning Python, 5th Edition","try: ... raise E('spam') ... except E as X:",tryexcept,1134 "Learning Python, 5th Edition","try: parser() except FormatError as exc:",tryexcept,1138 "Learning Python, 5th Edition","try: ... while True: ... while True: ... for i in range(10): ... if i > 3: raise Exitloop # break exits just one level ... print('loop3: %s' % i) ... print('loop2') ... print('loop1') ... except Exitloop:",tryexcept,1145 "Learning Python, 5th Edition","first={0}, last={1}, middle={2}'.format(*parts) # Or '{}",nestedDict,224 "Learning Python, 5th Edition","E = {'cto': {'name': 'Bob', 'age': 40}}",nestedDict,252 "Learning Python, 5th Edition",print('birthday = {0}/{1}/{2},nestedDict,1332 "Learning Python, 5th Edition",print('birthday = {0}/{1}/{2},nestedDict,1334 "Learning Python, 5th Edition",lambda args: expression,lambda,137 "Learning Python, 5th Edition",lambda would serve in place of a def in our example:,lambda,502 "Learning Python, 5th Edition",lambda n: x ** n) # x remembered from enclosing def,lambda,505 "Learning Python, 5th Edition",lambda x: i ** x) # But all remember same last i!,lambda,506 "Learning Python, 5th Edition","lambda function argument lists: see the Chapter 20 sidebar “Why You Will",lambda,528 "Learning Python, 5th Edition","lambda argument1, argument2,... argumentN : expression using arguments",lambda,568 "Learning Python, 5th Edition","lambda arguments, just like in a def:",lambda,568 "Learning Python, 5th Edition",lambda x: title + ' ' + x) # Title in enclosing def scope,lambda,569 "Learning Python, 5th Edition","lambda x: x ** 2, # Inline function definition",lambda,569 "Learning Python, 5th Edition","lambda x: x ** 3,",lambda,569 "Learning Python, 5th Edition",lambda x: x ** 4] # A list of three callable functions,lambda,569 "Learning Python, 5th Edition",lambda function:,lambda,571 "Learning Python, 5th Edition",lambda x: (lambda y: x + y)),lambda,573 "Learning Python, 5th Edition",lambda x: (lambda y: x + y))(99))(4),lambda,573 "Learning Python, 5th Edition",lambda defers execution of the handler until the event occurs: the write,lambda,573 "Learning Python, 5th Edition",lambda commonly appears:,lambda,575 "Learning Python, 5th Edition","lambda x: x > 0), range(−5, 5))) # An iterable in 3.X",lambda,576 "Learning Python, 5th Edition","lambda x, y: x + y), [1, 2, 3, 4])",lambda,577 "Learning Python, 5th Edition","lambda x, y: x * y), [1, 2, 3, 4])",lambda,577 "Learning Python, 5th Edition","lambda x, y: x + y), [1, 2, 3, 4, 5])",lambda,577 "Learning Python, 5th Edition","lambda x, y: x * y), [1, 2, 3, 4, 5])",lambda,577 "Learning Python, 5th Edition","lambda x, y: x + y), [2, 4, 6])",lambda,577 "Learning Python, 5th Edition","lambda x: len(x) > 1, line.split())) # Similar to filter",lambda,601 "Learning Python, 5th Edition",lambda and def—expression conciseness versus statement power:,lambda,603 "Learning Python, 5th Edition",lambda functions:,lambda,924 "Learning Python, 5th Edition",lambda color='red': 'turn ' + color) # Defaults retain state too,lambda,924 "Learning Python, 5th Edition","def f(a, *pargs, **kargs): print(a, pargs, kargs) >>> f(1, 2, 3, x=1, y=2) 1 (2, 3) {'y': 2, 'x':",funcwithkeywordonly,535 "Learning Python, 5th Edition","def echo(*args, **kwargs): print(args, kwargs) >>> echo(1, 2, a=3, b=4) (1, 2) {'a': 3, 'b': 4} In Python 2.X, we can call it generically with apply, or with the call syntax that is now required in 3.X: >>> pargs = (1, 2) >>> kargs = {'a':3, 'b':4} >>> apply(echo, pargs, kargs) (1, 2) {'a': 3, 'b':",funcwithkeywordonly,538 "Learning Python, 5th Edition","def kwonly(a, *b, c): print(a, b, c) >>> kwonly(1, 2, c=3) 1 (2,) 3 >>> kwonly(a=1, c=3) 1 () 3 >>> kwonly(1, 2, 3) TypeError: kwonly() missing 1 required keyword-only argument:",funcwithkeywordonly,539 "Learning Python, 5th Edition","def kwonly(a, *, b, c): print(a, b, c) >>> kwonly(1, c=3, b=2) 1 2 3 >>> kwonly(c=3, b=2, a=1) 1 2 3 >>> kwonly(1, 2, 3) TypeError: kwonly() takes 1 positional argument but 3 were given >>> kwonly(1) TypeError: kwonly() missing 2 required keyword-only arguments:",funcwithkeywordonly,539 "Learning Python, 5th Edition","def kwonly(a, *, b='spam', c='ham'):",funcwithkeywordonly,539 "Learning Python, 5th Edition","def kwonly(a, *, b, c='spam'): print(a, b, c) >>> kwonly(1, b='eggs') 1 eggs spam >>> kwonly(1, c='eggs') TypeError: kwonly() missing 1 required keyword-only argument:",funcwithkeywordonly,540 "Learning Python, 5th Edition","def kwonly(a, *, b=1, c, d=2): print(a, b, c, d) >>> kwonly(3, c=4) 3 1 4 2 >>> kwonly(3, c=4, b=5) 3 5 4 2 >>> kwonly(3) TypeError: kwonly() missing 1 required keyword-only argument:",funcwithkeywordonly,540 "Learning Python, 5th Edition","def kwonly(a, **pargs, b, c):",funcwithkeywordonly,540 "Learning Python, 5th Edition","def kwonly(a, **, b, c):",funcwithkeywordonly,540 "Learning Python, 5th Edition","def f(a, *b, **d, c=6):",funcwithkeywordonly,540 "Learning Python, 5th Edition","def f(a, *b, c=6, **d): print(a, b, c, d) # Collect args in header >>> f(1, 2, 3, x=4, y=5) # Default used 1 (2, 3) 6 {'y': 5, 'x': 4} >>> f(1, 2, 3, x=4, y=5, c=7) # Override default 1 (2, 3) 7 {'y': 5, 'x':",funcwithkeywordonly,540 "Learning Python, 5th Edition","def f(a, c=6, *b, **d): print(a, b, c, d) # c is not keyword-only here! >>> f(1, 2, 3, x=4) 1 (3,) 2 {'x':",funcwithkeywordonly,541 "Learning Python, 5th Edition","def process(*args, notify=False):",funcwithkeywordonly,542 "Learning Python, 5th Edition","def print3(*args, sep=' ', end='\n', file=sys.stdout):",funcwithkeywordonly,548 "Learning Python, 5th Edition","def mysum(first, *rest), although similar to the third var- iant, wouldn’t work at all, because it expects individual arguments, not a single iterable. Keep in mind that recursion can be direct, as in the examples so far, or indirect, as in the following (a function that calls another function, which calls back to its caller). The net effect is the same, though there are two function calls at each level instead of one: >>> def mysum(L): if not L: return 0 return nonempty(L) # Call a function that calls me >>> def nonempty(L):",funcwithkeywordonly,557 "Learning Python, 5th Edition","def mymapPad(*seqs, pad=None): seqs = [list(S) for S in seqs] res = [] while any(seqs):",funcwithkeywordonly,619 "Learning Python, 5th Edition","def mymapPad(*seqs, pad=None): seqs = [list(S) for S in seqs] while any(seqs):",funcwithkeywordonly,620 "Learning Python, 5th Edition","def mymapPad(*seqs, pad=None):",funcwithkeywordonly,620 "Learning Python, 5th Edition","def f(x): return x\n$listif3(map(f, 'spam' * 2500))""), (0, 0, ""def f(x):",funcwithkeywordonly,653 "Learning Python, 5th Edition","def f4(a, *b, **c): print(a, b, c) # Mixed modes def f5(a, b=2, c=3):",funcwithkeywordonly,664 "Learning Python, 5th Edition","def catcher(*pargs, **kargs): print('%s, %s' % (pargs, kargs)) >>> catcher(1, 2, 3, 4, 5) (1, 2, 3, 4, 5), {} >>> catcher(1, 2, c=3, d=4, e=5) # Arguments at calls (1, 2), {'d': 4, 'e': 5, 'c': 3} The function object’s API is available in older Pythons, but the func.__code__ attribute is named func.func_code in 2.5 and earlier; the newer __code__ attribute is also redun- dantly available in 2.6 and later for portability. Run a dir call on function and code objects for more details. Code like the following would support 2.5 and earlier, though the sys.version_info result itself is similarly nonportable—it’s a named tuple in recent Pythons, but we can use offsets on newer and older Pythons alike: >>> import sys # For backward compatibility >>> tuple(sys.version_info) # [0] is major release number (3, 3, 0, 'final', 0) >>> code = func.__code__ if sys.version_info[0] == 3 else func.func_code Argument assumptions Given the decorated function’s set of expected argument names, the solution relies upon two constraints on argument passing order imposed by Python (these still hold true in both 2.X and 3.X current releases):",funcwithkeywordonly,1337 "Learning Python, 5th Edition","def f6(a, b=2, *c): print(a, b, c) # Defaults and positional varargs % python >>> f1(1, 2) # Matched by position (order matters) 1 2 >>> f1(b=2, a=1) # Matched by name (order doesn't matter) 1 2 >>> f2(1, 2, 3) # Extra positionals collected in a tuple 1 (2, 3) >>> f3(1, x=2, y=3) # Extra keywords collected in a dictionary 1 {'x': 2, 'y': 3} >>> f4(1, 2, 3, x=2, y=3) # Extra of both kinds 1 (2, 3) {'x': 2, 'y': 3} >>> f5(1) # Both defaults kick in 1 2 3 >>> f5(1, 4) # Only one default used 1 4 3 >>> f6(1) # One argument: matches ""a"" 1 2 () >>> f6(1, 3, 4) # Extra positional collected 1 3 (4,) 8. Primes revisited. Here is the primes example, wrapped up in a function and a mod- ule (file primes.py) so it can be run multiple times. I added an if test to trap neg- atives, 0, and 1. I also changed / to // in this edition to make this solution immune to the Python 3.X / true division changes we studied in Chapter 5, and to enable it to support floating-point numbers (uncomment the from statement and change // to / to see the differences in 2.X): #from __future__ import division def prime(y):",funcwithkeywordonly,1479 "Learning Python, 5th Edition","def custom(*kargs, **pargs):",funcwith2star,518 "Learning Python, 5th Edition","def __call__(self, *kargs, **pargs):",funcwith2star,518 "Learning Python, 5th Edition",def f(**args):,funcwith2star,535 "Learning Python, 5th Edition","def tracer(func, *pargs, **kargs):",funcwith2star,537 "Learning Python, 5th Edition","def f(a, *b, c=6, **d):",funcwith2star,541 "Learning Python, 5th Edition","def print3(*args, **kargs):",funcwith2star,547 "Learning Python, 5th Edition","def print3(*args, **kargs):",funcwith2star,549 "Learning Python, 5th Edition","def func(a, **kargs):",funcwith2star,551 "Learning Python, 5th Edition","def total(reps, func, *pargs, **kargs):",funcwith2star,631 "Learning Python, 5th Edition","def bestof(reps, func, *pargs, **kargs):",funcwith2star,631 "Learning Python, 5th Edition","def bestoftotal(reps1, reps2, func, *pargs, **kargs):",funcwith2star,631 "Learning Python, 5th Edition","def total(func, *pargs, **kargs):",funcwith2star,639 "Learning Python, 5th Edition","def bestof(func, *pargs, **kargs):",funcwith2star,639 "Learning Python, 5th Edition","def bestoftotal(func, *pargs, **kargs):",funcwith2star,639 "Learning Python, 5th Edition","def total(func, *pargs, _reps=1000, **kargs):",funcwith2star,641 "Learning Python, 5th Edition","def bestof(func, *pargs, _reps=5, **kargs):",funcwith2star,641 "Learning Python, 5th Edition","def bestoftotal(func, *pargs, _reps1=5, **kargs):",funcwith2star,641 "Learning Python, 5th Edition","def f3(a, **b):",funcwith2star,664 "Learning Python, 5th Edition","def __call__(self, *pargs, **kargs):",funcwith2star,922 "Learning Python, 5th Edition","def __call__(self, *pargs, **kargs):",funcwith2star,922 "Learning Python, 5th Edition","def __call__(self, *pargs, d=6, **kargs):",funcwith2star,922 "Learning Python, 5th Edition","def factory(aClass, *pargs, **kargs):",funcwith2star,954 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1285 "Learning Python, 5th Edition","def wrapper(*args, **kwargs):",funcwith2star,1286 "Learning Python, 5th Edition","def wrapper(*args, **kwargs):",funcwith2star,1287 "Learning Python, 5th Edition","def wrapper(*args, **kwargs):",funcwith2star,1288 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1289 "Learning Python, 5th Edition","def onCall(*args, **kwargs): # Or in 2.X+3.X:",funcwith2star,1291 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1293 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1293 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1294 "Learning Python, 5th Edition","def wrapper(*args, **kwargs):",funcwith2star,1294 "Learning Python, 5th Edition","def wrapper(*args, **kwargs): # On method call:",funcwith2star,1295 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1295 "Learning Python, 5th Edition","def __call__(self, *args, **kargs): # On calls:",funcwith2star,1299 "Learning Python, 5th Edition","def onCall(*args, **kwargs):",funcwith2star,1302 "Learning Python, 5th Edition","def onCall(*args, **kwargs):",funcwith2star,1303 "Learning Python, 5th Edition","def onCall(*args, **kwargs):",funcwith2star,1303 "Learning Python, 5th Edition","def __call__(self, *args, **kwargs):",funcwith2star,1303 "Learning Python, 5th Edition","def getInstance(aClass, *args, **kwargs):",funcwith2star,1309 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1324 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1325 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1326 "Learning Python, 5th Edition","def reroute(self, attr, *args, **kargs):",funcwith2star,1326 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1326 "Learning Python, 5th Edition",def rangetest(**argchecks):,funcwith2star,1333 "Learning Python, 5th Edition","def onCall(*pargs, **kargs):",funcwith2star,1334 "Learning Python, 5th Edition","def func(a, b, *kargs, **pargs):",funcwith2star,1339 "Learning Python, 5th Edition",def rangetest(**argchecks):,funcwith2star,1341 "Learning Python, 5th Edition","def onCall(*pargs, **kargs):",funcwith2star,1341 "Learning Python, 5th Edition","def onCall(*pargs, **kargs):",funcwith2star,1341 "Learning Python, 5th Edition",def typetest(**argchecks):,funcwith2star,1342 "Learning Python, 5th Edition","def onCall(*pargs, **kargs):",funcwith2star,1342 "Learning Python, 5th Edition","def onCall(*args, **kargs): # On calls:",funcwith2star,1345 "Learning Python, 5th Edition","def reroute(self, attr, *args, **kargs):",funcwith2star,1348 "Learning Python, 5th Edition","def __call__(self, *args, **kargs):",funcwith2star,1348 "Learning Python, 5th Edition",def rangetest(**argchecks):,funcwith2star,1350 "Learning Python, 5th Edition",def typetest(**argchecks):,funcwith2star,1350 "Learning Python, 5th Edition",def valuetest(**argchecks):,funcwith2star,1350 "Learning Python, 5th Edition","def onCall(*pargs, **kargs):",funcwith2star,1351 "Learning Python, 5th Edition","def onCall(*args, **kwargs):",funcwith2star,1400 "Learning Python, 5th Edition","def onCall(*args, **kargs): # On calls:",funcwith2star,1400 "Learning Python, 5th Edition",def adder2(**args):,funcwith2star,1477 "Learning Python, 5th Edition",def adder3(**args):,funcwith2star,1477 "Learning Python, 5th Edition",def adder4(**args):,funcwith2star,1477 "Learning Python, 5th Edition","def f3(a, **b):",funcwith2star,1478 "Learning Python, 5th Edition","def f4(a, *b, **c):",funcwith2star,1478 "Learning Python, 5th Edition","def callproxy(*pargs, **kargs):",funcwith2star,1499 "Learning Python, 5th Edition","def f(a, b, c=1, *d):",funcwithstar,320 "Learning Python, 5th Edition","def f(a, b, c=1, *d):",funcwithstar,320 "Learning Python, 5th Edition","def adder(a, b=1, *c):",funcwithstar,473 "Learning Python, 5th Edition",def f(*args):,funcwithstar,534 "Learning Python, 5th Edition",def min1(*args):,funcwithstar,543 "Learning Python, 5th Edition","def min2(first, *rest):",funcwithstar,543 "Learning Python, 5th Edition",def min3(*args):,funcwithstar,543 "Learning Python, 5th Edition","def minmax(test, *args):",funcwithstar,544 "Learning Python, 5th Edition",def intersect(*args):,funcwithstar,545 "Learning Python, 5th Edition",def union(*args):,funcwithstar,545 "Learning Python, 5th Edition","def func(a, *pargs):",funcwithstar,551 "Learning Python, 5th Edition","def mymap(func, *seqs):",funcwithstar,617 "Learning Python, 5th Edition","def mymap(func, *seqs):",funcwithstar,618 "Learning Python, 5th Edition","def mymap(func, *seqs):",funcwithstar,618 "Learning Python, 5th Edition","def mymap(func, *seqs):",funcwithstar,618 "Learning Python, 5th Edition",def myzip(*seqs):,funcwithstar,619 "Learning Python, 5th Edition",def myzip(*seqs):,funcwithstar,620 "Learning Python, 5th Edition",def myzip(*seqs):,funcwithstar,620 "Learning Python, 5th Edition",def myzip(*seqs):,funcwithstar,621 "Learning Python, 5th Edition",def myzip(*args):,funcwithstar,621 "Learning Python, 5th Edition",def myzip(*args):,funcwithstar,622 "Learning Python, 5th Edition","def timer(func, *args):",funcwithstar,630 "Learning Python, 5th Edition","def f2(a, *b):",funcwithstar,664 "Learning Python, 5th Edition","def f6(a, b=2, *c):",funcwithstar,664 "Learning Python, 5th Edition","def minmax(test, *args):",funcwithstar,750 "Learning Python, 5th Edition","def minmax(test, *args):",funcwithstar,750 "Learning Python, 5th Edition",def reload_all(*args):,funcwithstar,764 "Learning Python, 5th Edition",def reload_all(*args):,funcwithstar,767 "Learning Python, 5th Edition",def reload_all(*modules):,funcwithstar,768 "Learning Python, 5th Edition","def meth(self, *args):",funcwithstar,934 "Learning Python, 5th Edition","def __call__(self, *args): # On later calls:",funcwithstar,1037 "Learning Python, 5th Edition",def oncall(*args):,funcwithstar,1038 "Learning Python, 5th Edition",def wrapper(*args):,funcwithstar,1275 "Learning Python, 5th Edition","def __call__(self, *args):",funcwithstar,1275 "Learning Python, 5th Edition","def __call__(self, *args):",funcwithstar,1275 "Learning Python, 5th Edition",def wrapper(*args):,funcwithstar,1276 "Learning Python, 5th Edition","def __call__(self, *args):",funcwithstar,1279 "Learning Python, 5th Edition",def onCall(*args): # On instance creation:,funcwithstar,1279 "Learning Python, 5th Edition","def __call__(self, *args): # On later calls:",funcwithstar,1283 "Learning Python, 5th Edition","def tracer(func, *args):",funcwithstar,1284 "Learning Python, 5th Edition","def __call__(self, *args):",funcwithstar,1308 "Learning Python, 5th Edition",def trace(*args):,funcwithstar,1315 "Learning Python, 5th Edition",def Private(*privates):,funcwithstar,1315 "Learning Python, 5th Edition",def trace(*args):,funcwithstar,1319 "Learning Python, 5th Edition",def Private(*attributes):,funcwithstar,1319 "Learning Python, 5th Edition",def Public(*attributes):,funcwithstar,1320 "Learning Python, 5th Edition",def rangetest(*argchecks):,funcwithstar,1331 "Learning Python, 5th Edition",def onCall(*args):,funcwithstar,1331 "Learning Python, 5th Edition",def trace(*args):,funcwithstar,1347 "Learning Python, 5th Edition",def Private(*attributes):,funcwithstar,1348 "Learning Python, 5th Edition",def Public(*attributes):,funcwithstar,1348 "Learning Python, 5th Edition",def adder1(*args):,funcwithstar,1476 "Learning Python, 5th Edition",def adder2(*args):,funcwithstar,1476 "Learning Python, 5th Edition",def adder1(*args):,funcwithstar,1477 "Learning Python, 5th Edition","def f2(a, *b):",funcwithstar,1478 "Learning Python, 5th Edition","def intersect(self, *others):",funcwithstar,1494 "Learning Python, 5th Edition",def union(*args):,funcwithstar,1494 "Learning Python, 5th Edition",class Subclass(Superclass):,simpleclass,321 "Learning Python, 5th Edition","class def computeSalary(self):",simpleclass,792 "Learning Python, 5th Edition",class Engineer(Employee):,simpleclass,793 "Learning Python, 5th Edition","class def computeSalary(self):",simpleclass,793 "Learning Python, 5th Edition",class FileReader(Reader):,simpleclass,794 "Learning Python, 5th Edition",class SocketReader(Reader):,simpleclass,794 "Learning Python, 5th Edition",class SecondClass(FirstClass):,simpleclass,802 "Learning Python, 5th Edition",class SecondClass(FirstClass):,simpleclass,804 "Learning Python, 5th Edition",class ThirdClass(SecondClass):,simpleclass,806 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,828 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,829 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,829 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,829 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,830 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,833 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,835 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,838 "Learning Python, 5th Edition",class TopTest(AttrDisplay):,simpleclass,842 "Learning Python, 5th Edition",class SubTest(TopTest):,simpleclass,843 "Learning Python, 5th Edition",class TopTest(AttrDisplay):,simpleclass,845 "Learning Python, 5th Edition",class Person(AttrDisplay):,simpleclass,845 "Learning Python, 5th Edition",class Manager(Person):,simpleclass,846 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,864 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,867 "Learning Python, 5th Edition",class Inheritor(Super):,simpleclass,868 "Learning Python, 5th Edition",class Replacer(Super):,simpleclass,868 "Learning Python, 5th Edition",class Extender(Super):,simpleclass,868 "Learning Python, 5th Edition",class Provider(Super):,simpleclass,868 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,870 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,870 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,871 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,871 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,878 "Learning Python, 5th Edition","class def selftest():",simpleclass,880 "Learning Python, 5th Edition",class B(A):,simpleclass,880 "Learning Python, 5th Edition",class C(A):,simpleclass,880 "Learning Python, 5th Edition",class Person(Emp):,simpleclass,881 "Learning Python, 5th Edition",class PrivateExc(Exception):,simpleclass,912 "Learning Python, 5th Edition",class Test1(Privacy):,simpleclass,912 "Learning Python, 5th Edition",class Test2(Privacy):,simpleclass,912 "Learning Python, 5th Edition",class addrepr(adder):,simpleclass,914 "Learning Python, 5th Edition",class addstr(adder):,simpleclass,915 "Learning Python, 5th Edition",class addboth(adder):,simpleclass,915 "Learning Python, 5th Edition",class Chef(Employee):,simpleclass,935 "Learning Python, 5th Edition",class Server(Employee):,simpleclass,936 "Learning Python, 5th Edition",class PizzaRobot(Chef):,simpleclass,936 "Learning Python, 5th Edition",class Uppercase(Processor):,simpleclass,939 "Learning Python, 5th Edition",class Sub2(Tool):,simpleclass,947 "Learning Python, 5th Edition",class Spam(ListInstance):,simpleclass,960 "Learning Python, 5th Edition",class B(C):,simpleclass,971 "Learning Python, 5th Edition",class MyList(list):,simpleclass,981 "Learning Python, 5th Edition",class Set(list):,simpleclass,982 "Learning Python, 5th Edition",class newstyle(object):,simpleclass,984 "Learning Python, 5th Edition",class C(object):,simpleclass,989 "Learning Python, 5th Edition",class C(object):,simpleclass,989 "Learning Python, 5th Edition",class C(object):,simpleclass,989 "Learning Python, 5th Edition",class C(object):,simpleclass,990 "Learning Python, 5th Edition",class C(object):,simpleclass,990 "Learning Python, 5th Edition",class C(object):,simpleclass,993 "Learning Python, 5th Edition",class C(object):,simpleclass,995 "Learning Python, 5th Edition",class D(object):,simpleclass,995 "Learning Python, 5th Edition",class C(object):,simpleclass,996 "Learning Python, 5th Edition",class B(A):,simpleclass,998 "Learning Python, 5th Edition",class C(A):,simpleclass,998 "Learning Python, 5th Edition",class A(object):,simpleclass,998 "Learning Python, 5th Edition",class B(A):,simpleclass,998 "Learning Python, 5th Edition",class C(A):,simpleclass,998 "Learning Python, 5th Edition",class B(A):,simpleclass,999 "Learning Python, 5th Edition",class C(A):,simpleclass,999 "Learning Python, 5th Edition",class A(object):,simpleclass,999 "Learning Python, 5th Edition",class B(A):,simpleclass,999 "Learning Python, 5th Edition",class C(A):,simpleclass,999 "Learning Python, 5th Edition",class C(A):,simpleclass,999 "Learning Python, 5th Edition",class B(A):,simpleclass,999 "Learning Python, 5th Edition",class B(A):,simpleclass,1002 "Learning Python, 5th Edition",class C(A):,simpleclass,1002 "Learning Python, 5th Edition",class B(A):,simpleclass,1003 "Learning Python, 5th Edition",class C(A):,simpleclass,1003 "Learning Python, 5th Edition",class A(X):,simpleclass,1003 "Learning Python, 5th Edition",class B(Y):,simpleclass,1003 "Learning Python, 5th Edition",class B(A):,simpleclass,1006 "Learning Python, 5th Edition",class C(A):,simpleclass,1006 "Learning Python, 5th Edition",class A(object):,simpleclass,1006 "Learning Python, 5th Edition",class B(A):,simpleclass,1006 "Learning Python, 5th Edition",class C(A):,simpleclass,1006 "Learning Python, 5th Edition",class A(object):,simpleclass,1009 "Learning Python, 5th Edition",class B(A):,simpleclass,1009 "Learning Python, 5th Edition",class C(A):,simpleclass,1009 "Learning Python, 5th Edition",class limiter(object):,simpleclass,1010 "Learning Python, 5th Edition",class D(E):,simpleclass,1014 "Learning Python, 5th Edition",class D(C):,simpleclass,1016 "Learning Python, 5th Edition",class D(C):,simpleclass,1017 "Learning Python, 5th Edition",class D(C):,simpleclass,1017 "Learning Python, 5th Edition",class D(C):,simpleclass,1017 "Learning Python, 5th Edition",class C(ListTree):,simpleclass,1017 "Learning Python, 5th Edition",class properties(object):,simpleclass,1021 "Learning Python, 5th Edition",class properties(object):,simpleclass,1021 "Learning Python, 5th Edition",class properties(object):,simpleclass,1022 "Learning Python, 5th Edition",class AgeDesc(object):,simpleclass,1023 "Learning Python, 5th Edition",class descriptors(object):,simpleclass,1023 "Learning Python, 5th Edition",class Sub(Spam):,simpleclass,1031 "Learning Python, 5th Edition",class Other(Spam):,simpleclass,1031 "Learning Python, 5th Edition",class Sub(Spam):,simpleclass,1032 "Learning Python, 5th Edition",class Other(Spam):,simpleclass,1032 "Learning Python, 5th Edition",class Sub(Spam):,simpleclass,1033 "Learning Python, 5th Edition",class Other(Spam):,simpleclass,1033 "Learning Python, 5th Edition",class Methods(object):,simpleclass,1036 "Learning Python, 5th Edition",class D(C):,simpleclass,1043 "Learning Python, 5th Edition",class D(C):,simpleclass,1043 "Learning Python, 5th Edition",class E(C):,simpleclass,1044 "Learning Python, 5th Edition",class C(A):,simpleclass,1045 "Learning Python, 5th Edition",class D(C):,simpleclass,1047 "Learning Python, 5th Edition",class C(object):,simpleclass,1048 "Learning Python, 5th Edition",class D(C):,simpleclass,1048 "Learning Python, 5th Edition",class D(C):,simpleclass,1048 "Learning Python, 5th Edition",class D(C):,simpleclass,1048 "Learning Python, 5th Edition",class C(X):,simpleclass,1050 "Learning Python, 5th Edition",class C(X):,simpleclass,1050 "Learning Python, 5th Edition",class B(A):,simpleclass,1051 "Learning Python, 5th Edition",class C(A):,simpleclass,1051 "Learning Python, 5th Edition",class B(A):,simpleclass,1052 "Learning Python, 5th Edition",class C(A):,simpleclass,1052 "Learning Python, 5th Edition",class B(A):,simpleclass,1056 "Learning Python, 5th Edition",class B(A):,simpleclass,1056 "Learning Python, 5th Edition",class Mixin(A):,simpleclass,1057 "Learning Python, 5th Edition",class Mixin(A):,simpleclass,1058 "Learning Python, 5th Edition",class B(A):,simpleclass,1058 "Learning Python, 5th Edition",class Mixin(A):,simpleclass,1059 "Learning Python, 5th Edition",class B(A):,simpleclass,1059 "Learning Python, 5th Edition",class Mixin(A):,simpleclass,1059 "Learning Python, 5th Edition",class Chef1(Employee):,simpleclass,1060 "Learning Python, 5th Edition",class Server1(Employee):,simpleclass,1060 "Learning Python, 5th Edition",class Chef2(Employee):,simpleclass,1060 "Learning Python, 5th Edition",class Server2(Employee):,simpleclass,1060 "Learning Python, 5th Edition",class Career(Exception):,simpleclass,1087 "Learning Python, 5th Edition",class MyError(Exception):,simpleclass,1101 "Learning Python, 5th Edition",class General(Exception):,simpleclass,1126 "Learning Python, 5th Edition",class Specific1(General):,simpleclass,1126 "Learning Python, 5th Edition",class Specific2(General):,simpleclass,1126 "Learning Python, 5th Edition",class General(Exception):,simpleclass,1127 "Learning Python, 5th Edition",class Specific1(General):,simpleclass,1127 "Learning Python, 5th Edition",class Specific2(General):,simpleclass,1127 "Learning Python, 5th Edition",class Divzero(Exception):,simpleclass,1129 "Learning Python, 5th Edition",class Oflow(Exception):,simpleclass,1129 "Learning Python, 5th Edition",class Uflow(Exception):,simpleclass,1129 "Learning Python, 5th Edition",class NumErr(Exception):,simpleclass,1130 "Learning Python, 5th Edition",class Divzero(NumErr):,simpleclass,1130 "Learning Python, 5th Edition",class Oflow(NumErr):,simpleclass,1130 "Learning Python, 5th Edition",class Uflow(NumErr):,simpleclass,1130 "Learning Python, 5th Edition",class E(Exception):,simpleclass,1134 "Learning Python, 5th Edition",class E(Exception):,simpleclass,1136 "Learning Python, 5th Edition",class E(Exception):,simpleclass,1136 "Learning Python, 5th Edition",class FormatError(Exception):,simpleclass,1137 "Learning Python, 5th Edition",class FormatError(Exception):,simpleclass,1138 "Learning Python, 5th Edition",class CustomFormatError(FormatError):,simpleclass,1138 "Learning Python, 5th Edition",class Exitloop(Exception):,simpleclass,1145 "Learning Python, 5th Edition",class Found(Exception):,simpleclass,1147 "Learning Python, 5th Edition",class Failure(Exception):,simpleclass,1147 "Learning Python, 5th Edition",class Person(Super):,simpleclass,1223 "Learning Python, 5th Edition",class Person(Super):,simpleclass,1231 "Learning Python, 5th Edition",class Catcher(object):,simpleclass,1239 "Learning Python, 5th Edition",class GetAttribute(object):,simpleclass,1245 "Learning Python, 5th Edition",class Powers(object):,simpleclass,1246 "Learning Python, 5th Edition",class DescSquare(object):,simpleclass,1247 "Learning Python, 5th Edition",class DescCube(object):,simpleclass,1247 "Learning Python, 5th Edition",class Powers(object):,simpleclass,1247 "Learning Python, 5th Edition",class Powers(object):,simpleclass,1248 "Learning Python, 5th Edition",class GetAttribute(object):,simpleclass,1250 "Learning Python, 5th Edition",class Manager(object):,simpleclass,1255 "Learning Python, 5th Edition",class CardHolder(object):,simpleclass,1257 "Learning Python, 5th Edition",class CardHolder(object):,simpleclass,1260 "Learning Python, 5th Edition",class Name(object):,simpleclass,1260 "Learning Python, 5th Edition",class Age(object):,simpleclass,1260 "Learning Python, 5th Edition",class Acct(object):,simpleclass,1260 "Learning Python, 5th Edition",class Remain(object):,simpleclass,1260 "Learning Python, 5th Edition",class CardHolder(object):,simpleclass,1262 "Learning Python, 5th Edition",class Name(object):,simpleclass,1262 "Learning Python, 5th Edition",class Age(object):,simpleclass,1262 "Learning Python, 5th Edition",class Acct(object):,simpleclass,1262 "Learning Python, 5th Edition",class Remain(object):,simpleclass,1262 "Learning Python, 5th Edition",class CardHolder(object):,simpleclass,1265 "Learning Python, 5th Edition",class Descriptor(object):,simpleclass,1292 "Learning Python, 5th Edition",class tracer(object):,simpleclass,1293 "Learning Python, 5th Edition",class tracer(object):,simpleclass,1294 "Learning Python, 5th Edition",class tracer(object):,simpleclass,1294 "Learning Python, 5th Edition",class onInstance(BuiltinsMixin):,simpleclass,1325 "Learning Python, 5th Edition",class onInstance(BuiltinsMixin):,simpleclass,1326 "Learning Python, 5th Edition",class ProxyDesc(object):,simpleclass,1326 "Learning Python, 5th Edition",class onInstance(BuiltinsMixin):,simpleclass,1347 "Learning Python, 5th Edition",class Client1(Extras):,simpleclass,1359 "Learning Python, 5th Edition",class Client2(Extras):,simpleclass,1359 "Learning Python, 5th Edition",class Client3(Extras):,simpleclass,1359 "Learning Python, 5th Edition",class Extras(type):,simpleclass,1361 "Learning Python, 5th Edition",class C(object):,simpleclass,1366 "Learning Python, 5th Edition",class Spam(Eggs):,simpleclass,1368 "Learning Python, 5th Edition",class Spam(object):,simpleclass,1369 "Learning Python, 5th Edition",class SubMetaObj(SuperMetaObj):,simpleclass,1375 "Learning Python, 5th Edition",class SuperMeta(type):,simpleclass,1378 "Learning Python, 5th Edition",class SubMeta(SuperMeta):,simpleclass,1378 "Learning Python, 5th Edition",class Sub(Super):,simpleclass,1380 "Learning Python, 5th Edition",class A(type):,simpleclass,1381 "Learning Python, 5th Edition",class B(A):,simpleclass,1381 "Learning Python, 5th Edition",class M(type):,simpleclass,1381 "Learning Python, 5th Edition",class acquisition (instance):,simpleclass,1381 "Learning Python, 5th Edition",class M(type):,simpleclass,1381 "Learning Python, 5th Edition",class B(A):,simpleclass,1382 "Learning Python, 5th Edition",class M1(type):,simpleclass,1382 "Learning Python, 5th Edition",class D(type):,simpleclass,1387 "Learning Python, 5th Edition",class C(D):,simpleclass,1387 "Learning Python, 5th Edition",class A(type):,simpleclass,1388 "Learning Python, 5th Edition",class A(type):,simpleclass,1389 "Learning Python, 5th Edition",class A(type):,simpleclass,1390 "Learning Python, 5th Edition",class A(type):,simpleclass,1390 "Learning Python, 5th Edition","class def eggsfunc(obj):",simpleclass,1395 "Learning Python, 5th Edition",class ListAdder(Adder):,simpleclass,1489 "Learning Python, 5th Edition",class DictAdder(Adder):,simpleclass,1489 "Learning Python, 5th Edition",class ListAdder(Adder):,simpleclass,1490 "Learning Python, 5th Edition",class DictAdder(Adder):,simpleclass,1490 "Learning Python, 5th Edition",class MyListSub(MyList):,simpleclass,1492 "Learning Python, 5th Edition",class MultiSet(Set):,simpleclass,1494 "Learning Python, 5th Edition","class def speak(self):",simpleclass,1496 "Learning Python, 5th Edition",class Mammal(Animal):,simpleclass,1496 "Learning Python, 5th Edition",class Cat(Mammal):,simpleclass,1496 "Learning Python, 5th Edition",class Dog(Mammal):,simpleclass,1496 "Learning Python, 5th Edition",class Primate(Mammal):,simpleclass,1496 "Learning Python, 5th Edition",class Hacker(Primate):,simpleclass,1496 "Learning Python, 5th Edition",class Customer(Actor):,simpleclass,1497 "Learning Python, 5th Edition",class Clerk(Actor):,simpleclass,1497 "Learning Python, 5th Edition",class Parrot(Actor):,simpleclass,1497 "Learning Python, 5th Edition",class MyError(Exception):,simpleclass,1498 "Learning Python, 5th Edition",class MySubGui(MyGui):,simpleclass,1503 "Learning Python, 5th Edition",raise EndSearch(location),raise,321 "Learning Python, 5th Edition",raise TypeError('extra keywords: %s' % kargs),raise,549 "Learning Python, 5th Edition",raise NotImplementedError('action must be defined!'),raise,870 "Learning Python, 5th Edition",raise AttributeError(attrname),raise,910 "Learning Python, 5th Edition",raise AttributeError(attr + ' not allowed'),raise,911 "Learning Python, 5th Edition","raise print(bob); print()",raise,936 "Learning Python, 5th Edition",raise AttributeError(name),raise,1021 "Learning Python, 5th Edition",raise AttributeError(name),raise,1022 "Learning Python, 5th Edition",raise Career(),raise,1087 "Learning Python, 5th Edition",raise MyError(),raise,1101 "Learning Python, 5th Edition","raise Exc(Args)",raise,1107 "Learning Python, 5th Edition",raise Exc(),raise,1107 "Learning Python, 5th Edition",raise IndexError # Class (instance created),raise,1107 "Learning Python, 5th Edition",raise IndexError() # Instance (created in statement),raise,1107 "Learning Python, 5th Edition",raise statement raises (triggers),raise,1120 "Learning Python, 5th Edition",raise General(),raise,1127 "Learning Python, 5th Edition",raise Specific1(),raise,1127 "Learning Python, 5th Edition",raise Specific2(),raise,1127 "Learning Python, 5th Edition",raise DivZero(),raise,1130 "Learning Python, 5th Edition",raise IndexError # Same as IndexError(),raise,1134 "Learning Python, 5th Edition",raise IndexError('spam'),raise,1134 "Learning Python, 5th Edition",raise E('spam'),raise,1134 "Learning Python, 5th Edition",raise MyBad(),raise,1136 "Learning Python, 5th Edition",raise E('spam'),raise,1136 "Learning Python, 5th Edition",raise E('spam'),raise,1136 "Learning Python, 5th Edition","raise FormatError(42, file='spam.txt')",raise,1137 "Learning Python, 5th Edition","raise FormatError(40, 'spam.txt')",raise,1138 "Learning Python, 5th Edition",raise CustomFormatError(...),raise,1138 "Learning Python, 5th Edition",raise Found(),raise,1147 "Learning Python, 5th Edition",raise Failure(),raise,1147 "Learning Python, 5th Edition",raise AttributeError(attr),raise,1242 "Learning Python, 5th Edition",raise AttributeError(attr),raise,1244 "Learning Python, 5th Edition",raise AttributeError(attr),raise,1245 "Learning Python, 5th Edition",raise TypeError('unknown attr:' + name),raise,1247 "Learning Python, 5th Edition",raise TypeError('invald acct number'),raise,1260 "Learning Python, 5th Edition",raise TypeError('cannot set remain'),raise,1260 "Learning Python, 5th Edition",raise TypeError('invald acct number'),raise,1262 "Learning Python, 5th Edition",raise TypeError('cannot set remain'),raise,1262 "Learning Python, 5th Edition",raise AttributeError(name),raise,1264 "Learning Python, 5th Edition",raise ValueError('invalid age'),raise,1266 "Learning Python, 5th Edition",raise TypeError(errmsg),raise,1331 "Learning Python, 5th Edition",raise TypeError(errmsg),raise,1334 "Learning Python, 5th Edition",raise TypeError(errmsg),raise,1334 "Learning Python, 5th Edition",raise TypeError(errmsg),raise,1342 "Learning Python, 5th Edition",raise TypeError(errmsg),raise,1343 "Learning Python, 5th Edition","raise TypeError(errfmt % (func.__name__, argname, criteria))",raise,1351 "Learning Python, 5th Edition",raise E(V),raise,1461 "Learning Python, 5th Edition",raise IndexError(),raise,1497 "Learning Python, 5th Edition",raise MyError('Spam!'),raise,1498 "Learning Python, 5th Edition",raise MyError('Spam!'),raise,1499 "Learning Python, 5th Edition","assert X > Y, 'X too small'",assert,321 "Learning Python, 5th Edition","assert False, 'action must be defined!' # If this version is called >>> X = Super()",assert,869 "Learning Python, 5th Edition","assert x < 0, 'x must be negative'",assert,1113 "Learning Python, 5th Edition","assert x < 0, 'x must be negative'",assert,1113 "Learning Python, 5th Edition",assert x != 0 # A generally useless assert!,assert,1113 "Learning Python, 5th Edition","assert percent >= 0.0 and percent <= 1.0, 'percent invalid'",assert,1330 "Learning Python, 5th Edition","def func1(): pass",pass,390 "Learning Python, 5th Edition","def func2(): pass",pass,390 "Learning Python, 5th Edition","def func1(): ... # Alternative to pass",pass,390 "Learning Python, 5th Edition","when the nested functions are later called, they all effectively remember the same value: the value the loop variable had on the last loop iteration. That is, when we pass",pass,506 "Learning Python, 5th Edition",">>> def indirect(func, arg): func(arg) # Call the pass",pass,562 "Learning Python, 5th Edition",">>> def saver(x=None): if x is None: # No argument pass",pass,659 "Learning Python, 5th Edition","argument to the screen and call it interactively, passing a variety of object types: string, integer, list, dictionary. Then, try calling it without pass",pass,663 "Learning Python, 5th Edition","method(self, ...): pass",pass,870 "Learning Python, 5th Edition","method(self, ...): pass",pass,871 "Learning Python, 5th Edition","action(self): pass",pass,871 "Learning Python, 5th Edition",">>> class Truth: pass",pass,928 "Learning Python, 5th Edition","def ham(self): pass",pass,961 "Learning Python, 5th Edition","passed in to the tester is a mix-in class instead of a function, but the principle is similar: everything qualifies as a pass",pass,961 "Learning Python, 5th Edition","def ham(self): pass",pass,962 "Learning Python, 5th Edition","class C: pass",pass,1019 "Learning Python, 5th Edition","class Methods: def imeth(self, x): # Normal instance method: pass",pass,1029 "Learning Python, 5th Edition","class Spam: numInstances = 0 # Trace class pass",pass,1032 "Learning Python, 5th Edition","def act(self): C.act(self) # Name superclass explicitly, pass",pass,1043 "Learning Python, 5th Edition","f. How would you go about emulating other list operations in the set class? (Hint: __add__ can catch concatenation, and __getattr__ can pass",pass,1074 "Learning Python, 5th Edition","def onCall(*args): # Multilevel state retention: ... # args pass",pass,1298 "Learning Python, 5th Edition","if argname in kargs: # Was pass",pass,1334 "Learning Python, 5th Edition","elif argname in positionals: # Was pass",pass,1334 "Learning Python, 5th Edition","else: # Assume not pass",pass,1334 "Learning Python, 5th Edition","of these tools in decorated functions: >>> def func(*kargs, **pargs): pass",pass,1339 "Learning Python, 5th Edition","for check in argchecks: pass",pass,1341 "Learning Python, 5th Edition","for check in argchecks: pass",pass,1341 "Learning Python, 5th Edition","else: # Assume not pass",pass,1343 "Learning Python, 5th Edition","class Eggs: pass",pass,1371 "Learning Python, 5th Edition","class Eggs: pass",pass,1372 "Learning Python, 5th Edition","class Eggs: pass",pass,1373 "Learning Python, 5th Edition","class Eggs: pass",pass,1374 "Learning Python, 5th Edition","class Eggs: pass",pass,1376 "Learning Python, 5th Edition",">>> class C(D): pass",pass,1387 "Learning Python, 5th Edition",">>> class C(metaclass=D): pass",pass,1388 "Learning Python, 5th Edition","except: pass",pass,1505 "Learning Python, 5th Edition","for (a, b, c) in [(1, 2, 3), (4, 5, 6)]:",fortuplename,343 "Learning Python, 5th Edition","for (a, *b, c) in [(1, 2, 3, 4), (5, 6, 7, 8)]:",fortuplename,348 "Learning Python, 5th Edition","for (a, b, c) in [(1, 2, 3), (4, 5, 6)]:",fortuplename,348 "Learning Python, 5th Edition","for (a, b) in T:",fortuplename,397 "Learning Python, 5th Edition","for (key, value) in D.items():",fortuplename,397 "Learning Python, 5th Edition","for (a, b, c) in [(1, 2, 3), (4, 5, 6)]:",fortuplename,398 "Learning Python, 5th Edition","for (a, *b, c) in [(1, 2, 3, 4), (5, 6, 7, 8)]:",fortuplename,399 "Learning Python, 5th Edition","for (x, y) in zip(L1, L2):",fortuplename,408 "Learning Python, 5th Edition","for (k, v) in zip(keys, vals):",fortuplename,410 "Learning Python, 5th Edition","for (offset, item) in enumerate(S):",fortuplename,411 "Learning Python, 5th Edition","for (i, l) in enumerate(open('test.txt')):",fortuplename,411 "Learning Python, 5th Edition","for (i, line) in enumerate(os.popen('systeminfo')):",fortuplename,412 "Learning Python, 5th Edition","for (k, v) in D.items():",fortuplename,440 "Learning Python, 5th Edition","for (func, arg) in schedule:",fortuplename,563 "Learning Python, 5th Edition","for (row1, row2) in zip(M, N):",fortuplename,588 "Learning Python, 5th Edition","for (col1, col2) in zip(row1, row2):",fortuplename,588 "Learning Python, 5th Edition","for (root, subs, files) in os.walk('.'):",fortuplename,607 "Learning Python, 5th Edition","for (number, repeat, stmt) in stmts:",fortuplename,648 "Learning Python, 5th Edition","for (ispy3, python) in pythons:",fortuplename,648 "Learning Python, 5th Edition","for (number, repeat, setup, stmt) in stmts:",fortuplename,655 "Learning Python, 5th Edition","for (ispy3, python) in pythons:",fortuplename,655 "Learning Python, 5th Edition","for (key, value) in table.items():",fortuplename,953 "Learning Python, 5th Edition","for (linenum, (line1, line2)) in enumerate(zip(f1, f2)):",fortuplename,1118 "Learning Python, 5th Edition","for (i, c) in enumerate(t):",fortuplename,1214 "Learning Python, 5th Edition","for (ix, low, high) in argchecks:",fortuplename,1331 "Learning Python, 5th Edition","for (argname, (low, high)) in argchecks.items():",fortuplename,1334 "Learning Python, 5th Edition","for (argname, type) in argchecks.items():",fortuplename,1342 "Learning Python, 5th Edition","for (argname, criteria) in argchecks.items():",fortuplename,1351 "Learning Python, 5th Edition","for (thisDir, subsHere, filesHere) in os.walk(dirname):",fortuplename,1500 "Learning Python, 5th Edition","for (thisDir, subsHere, filesHere) in os.walk(srcdir):",fortuplename,1500 "Learning Python, 5th Edition","for (ix, num) in enumerate(nums):",fortuplename,1501 "Learning Python, 5th Edition","for x in [1, 2, 3, 4, 5]:",forwithlist,120 "Learning Python, 5th Edition","for x in [1, 2, 3]:",forwithlist,242 "Learning Python, 5th Edition","for all in [(1, 2, 3, 4), (5, 6, 7, 8)]:",forwithlist,348 "Learning Python, 5th Edition","for x in [""spam"", ""eggs"", ""ham""]:",forwithlist,396 "Learning Python, 5th Edition","for x in [1, 2, 3, 4]:",forwithlist,396 "Learning Python, 5th Edition","for item in [1, 2, 3, 4]:",forwithlist,396 "Learning Python, 5th Edition","for all in [(1, 2, 3, 4), (5, 6, 7, 8)]:",forwithlist,399 "Learning Python, 5th Edition",for val in [line.split()[6] for line in open('input.txt')]:,forwithlist,413 "Learning Python, 5th Edition","for x in [1, 2, 3, 4]:",forwithlist,416 "Learning Python, 5th Edition","for x in [0, 1, 2]:",forwithlist,584 "Learning Python, 5th Edition","for y in [100, 200, 300]:",forwithlist,585 "Learning Python, 5th Edition",for x in [n ** 2 for n in range(5)]:,forwithlist,595 "Learning Python, 5th Edition","for x in (1, 2, 3, 4):",forwithtuple,416 "Learning Python, 5th Edition",for num in (x ** 2 for x in range(4)):,forwithtuple,598 "Learning Python, 5th Edition",for i in (x ** 2 for x in range(N)):,forwithtuple,605 "Learning Python, 5th Edition","for test in (forLoop, listComp, mapCall, genExpr, genFunc):",forwithtuple,634 "Learning Python, 5th Edition","for test in (forLoop, listComp, mapCall, genExpr, genFunc):",forwithtuple,640 "Learning Python, 5th Edition","for obj in (bob, sue, tom):",forwithtuple,832 "Learning Python, 5th Edition","for obj in (bob, sue, tom):",forwithtuple,849 "Learning Python, 5th Edition","for klass in (Inheritor, Replacer, Extender):",forwithtuple,868 "Learning Python, 5th Edition","for i in (x ** 2 for x in range(1, 6)):",forwithtuple,898 "Learning Python, 5th Edition","for klass in (Commuter1, Commuter2, Commuter3, Commuter4, Commuter5):",forwithtuple,920 "Learning Python, 5th Edition",for a in (x for x in dir(I) if not x.startswith('__')):,forwithtuple,1015 "Learning Python, 5th Edition","for func in (raiser0, raiser1, raiser2):",forwithtuple,1126 "Learning Python, 5th Edition","for func in (raiser0, raiser1, raiser2):",forwithtuple,1127 "Learning Python, 5th Edition",for attr in (x for x in dir(I) if not x.startswith('__')):,forwithtuple,1235 "Learning Python, 5th Edition","for func in (listcomp, mapcall):",forwithtuple,1300 "Learning Python, 5th Edition","for func in (listcomp, mapcall):",forwithtuple,1346 "Learning Python, 5th Edition","for func in (adder1, adder2):",forwithtuple,1476 "Learning Python, 5th Edition","for test in (mathMod, powCall, powExpr):",forwithtuple,1481 "Learning Python, 5th Edition","for test in (fact0, fact1, fact2, fact3, fact4):",forwithtuple,1484 "Learning Python, 5th Edition","diag = [M[i][i] for i in [0, 1, 2]]",nestedList,112 "Learning Python, 5th Edition","squares = [x ** 2 for x in [1, 2, 3, 4, 5]]",nestedList,120 "Learning Python, 5th Edition","L = ['Bob', 40.0, ['dev', 'mgr']]",nestedList,240 "Learning Python, 5th Edition","matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]",nestedList,243 "Learning Python, 5th Edition","L = ['Bob', 40.5, ['dev', 'mgr']]",nestedList,263 "Learning Python, 5th Edition","L = ['abc', [(1, 2), ([3], 4)], 5]",nestedList,297 "Learning Python, 5th Edition","L = ['a', X[:], 'b']",nestedList,300 "Learning Python, 5th Edition","M = ['X', L[:], 'Y']",nestedList,309 "Learning Python, 5th Edition","Y = [L] * 4 # [L] + [L] + ... = [L, L,...]",nestedList,309 "Learning Python, 5th Edition","L = [1, 0, 2, 0, 'spam', '', 'ham', []]",nestedList,385 "Learning Python, 5th Edition","L = [1, [2, [3, 4], 5], 6, [7, 8]]",nestedList,558 "Learning Python, 5th Edition","L = [[1, 2, 3], [4, 5, 6]]",nestedList,587 "Learning Python, 5th Edition","0, 0, ""L = [1, 2, 3, 4, 5]"", ""i=0\nwhile i < len(L):\n\tL[i] += 1\n\ti += 1"")]",nestedList,655 "Learning Python, 5th Edition","for i in range(len(L)): for j in range(len(L[i])):",fornested,587 "Learning Python, 5th Edition","for x in S: for y in S:",fornested,899 "Learning Python, 5th Edition","for x in S[::2]: for y in S[::2]:",fornested,901 "Learning Python, 5th Edition","for x in S: for y in S:",fornested,901 "Learning Python, 5th Edition","for attr in dir(instance): for obj in inherits:",fornested,1005 "Learning Python, 5th Edition","for attr in dir(instance): for obj in inherits:",fornested,1018 "Learning Python, 5th Edition","for node1 in xmltree.getElementsByTagName('title'): for node2 in node1.childNodes:",fornested,1212 "Learning Python, 5th Edition","for node in xmltree.getElementsByTagName('title'): for node2 in node.childNodes:",fornested,1213 "Learning Python, 5th Edition","D = {'food': 'Spam', 'quantity': 4, 'color': 'pink'}",simpleDict,114 "Learning Python, 5th Edition","rec = {'name': {'first': 'Bob', 'last': 'Smith'}",simpleDict,115 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,116 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,118 "Learning Python, 5th Edition","values = {'name': 'Bob', 'age': 40}",simpleDict,221 "Learning Python, 5th Edition","My {map[kind]} runs {sys.platform}'.format(sys=sys, map={'kind': 'laptop'}",simpleDict,224 "Learning Python, 5th Edition",0:10} = {1:10},simpleDict,225 "Learning Python, 5th Edition",0:>10} = {1:<10},simpleDict,225 "Learning Python, 5th Edition",10} = {:10},simpleDict,226 "Learning Python, 5th Edition",10} = {:<10},simpleDict,226 "Learning Python, 5th Edition",num:d} = {title:s},simpleDict,235 "Learning Python, 5th Edition","D = {'name': 'Bob', 'age': 40}",simpleDict,252 "Learning Python, 5th Edition","D = {'spam': 2, 'ham': 1, 'eggs': 3}",simpleDict,253 "Learning Python, 5th Edition","D = {'spam': 2, 'ham': 1, 'eggs': 3}",simpleDict,255 "Learning Python, 5th Edition","D2 = {'toast':4, 'muffin':5}",simpleDict,255 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,268 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,268 "Learning Python, 5th Edition",D = {'a': 1},simpleDict,269 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,269 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2}",simpleDict,288 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2}",simpleDict,290 "Learning Python, 5th Edition","D = {'x':X, 'y':2}",simpleDict,298 "Learning Python, 5th Edition","D = {'a':1, 'b':2}",simpleDict,299 "Learning Python, 5th Edition","D1 = {'a':1, 'b':2}",simpleDict,303 "Learning Python, 5th Edition","D2 = {'a':1, 'b':3}",simpleDict,303 "Learning Python, 5th Edition","D1 = {'a':1, 'b':2}",simpleDict,303 "Learning Python, 5th Edition","D2 = {'a':1, 'b':3}",simpleDict,303 "Learning Python, 5th Edition","D = {'x':1, 'y':2, 'z':3}",simpleDict,313 "Learning Python, 5th Edition","D = {'a': 1, 'b': 2, 'c': 3}",simpleDict,397 "Learning Python, 5th Edition","D1 = {'spam':1, 'eggs':3, 'toast':5}",simpleDict,409 "Learning Python, 5th Edition","D = {'a':1, 'b':2, 'c':3}",simpleDict,422 "Learning Python, 5th Edition","args = {'a': 1, 'b': 2, 'c': 3}",simpleDict,535 "Learning Python, 5th Edition",l=1; m=[1]; n={'a':0},simpleDict,551 "Learning Python, 5th Edition","D = {'a':1, 'b':2, 'c':3}",simpleDict,606 "Learning Python, 5th Edition","D = {'x':1, 'y':2, 'z':3}",simpleDict,1469 "Learning Python, 5th Edition","D = {'a':1, 'b':2, 'c':3}",simpleDict,1471 "Learning Python, 5th Edition","me = {'name':('John', 'Q', 'Doe'), 'age':'?', 'job':'engineer'}",simpleDict,1472 "Learning Python, 5th Edition","D = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7}",simpleDict,1474 "Learning Python, 5th Edition","d = {1: 1, 2: 2}",simpleDict,1478 "Learning Python, 5th Edition",x = {1: 1},simpleDict,1478 "Learning Python, 5th Edition",y = {2: 2},simpleDict,1478 "Learning Python, 5th Edition","rec1 = {'name': {'first': 'Bob', 'last': 'Smith'}",simpleDict,1504 "Learning Python, 5th Edition","rec2 = {'name': {'first': 'Sue', 'last': 'Jones'}",simpleDict,1504 "Learning Python, 5th Edition","been presented here. For instance, the exec(open('module.py').read())",openfunc,72 "Learning Python, 5th Edition",exec(open('script1.py').read()),openfunc,72 "Learning Python, 5th Edition",exec(open('script1.py').read()),openfunc,72 "Learning Python, 5th Edition",exec(open('script1.py').read()),openfunc,73 "Learning Python, 5th Edition",these are equivalent to the exec(open('module.py').read()),openfunc,73 "Learning Python, 5th Edition","open('eggs.txt'), open(r'C:\ham.bin', 'wb')",openfunc,96 "Learning Python, 5th Edition","f = open('data.txt', 'w') # Make a new file in output mode ('w' is write)",openfunc,122 "Learning Python, 5th Edition",f = open('data.txt') # 'r' (read),openfunc,123 "Learning Python, 5th Edition",for line in open('data.txt'): print(line),openfunc,123 "Learning Python, 5th Edition","file = open('data.bin', 'wb')",openfunc,124 "Learning Python, 5th Edition","data = open('data.bin', 'rb').read()",openfunc,124 "Learning Python, 5th Edition","file = open('unidata.txt', 'w', encoding='utf-8')",openfunc,124 "Learning Python, 5th Edition","text = open('unidata.txt', encoding='utf-8').read()",openfunc,125 "Learning Python, 5th Edition","raw = open('unidata.txt', 'rb').read()",openfunc,125 "Learning Python, 5th Edition","codecs.open('unidata.txt', encoding='utf8').read()",openfunc,126 "Learning Python, 5th Edition","myfile = open('C:\new\text.dat', 'w')",openfunc,196 "Learning Python, 5th Edition","myfile = open(r'C:\new\text.dat', 'w')",openfunc,197 "Learning Python, 5th Edition","myfile = open('C:\\new\\text.dat', 'w')",openfunc,197 "Learning Python, 5th Edition","file = dbm.open(""filename"")",openfunc,271 "Learning Python, 5th Edition","output = open(r'C:\spam', 'w')",openfunc,283 "Learning Python, 5th Edition","input = open('data', 'r')",openfunc,283 "Learning Python, 5th Edition",input = open('data'),openfunc,283 "Learning Python, 5th Edition",for line in open('data'),openfunc,283 "Learning Python, 5th Edition","codecs.open('f.txt', encoding='utf8')",openfunc,283 "Learning Python, 5th Edition","afile = open(filename, mode)",openfunc,283 "Learning Python, 5th Edition","myfile = open('myfile.txt', 'w')",openfunc,285 "Learning Python, 5th Edition",myfile = open('myfile.txt'),openfunc,286 "Learning Python, 5th Edition",print(open('myfile.txt').read()),openfunc,286 "Learning Python, 5th Edition",for line in open('myfile.txt'),openfunc,286 "Learning Python, 5th Edition","data = open('data.bin', 'rb').read()",openfunc,287 "Learning Python, 5th Edition","F = open('datafile.txt', 'w')",openfunc,288 "Learning Python, 5th Edition",chars = open('datafile.txt').read(),openfunc,288 "Learning Python, 5th Edition",F = open('datafile.txt'),openfunc,289 "Learning Python, 5th Edition","F = open('datafile.pkl', 'wb')",openfunc,290 "Learning Python, 5th Edition","F = open('datafile.pkl', 'rb')",openfunc,290 "Learning Python, 5th Edition","json.dump(rec, fp=open('testjson.txt', 'w'), indent=4)",openfunc,292 "Learning Python, 5th Edition",print(open('testjson.txt').read()),openfunc,292 "Learning Python, 5th Edition",P = json.load(open('testjson.txt')),openfunc,292 "Learning Python, 5th Edition",rdr = csv.reader(open('csvdata.txt')),openfunc,292 "Learning Python, 5th Edition","F = open('data.bin', 'wb')",openfunc,293 "Learning Python, 5th Edition","F = open('data.bin', 'rb')",openfunc,293 "Learning Python, 5th Edition",myfile = open(r'C:\code\data.txt'),openfunc,294 "Learning Python, 5th Edition","print(x, y, z, sep='...', file=open('data.txt', 'w'))",openfunc,361 "Learning Python, 5th Edition",print(open('data.txt').read()),openfunc,361 "Learning Python, 5th Edition","sys.stdout = open('log.txt', 'a')",openfunc,364 "Learning Python, 5th Edition","sys.stdout = open('log.txt', 'a')",openfunc,365 "Learning Python, 5th Edition",print(open('log.txt').read()),openfunc,365 "Learning Python, 5th Edition","log = open('log.txt', 'a')",openfunc,365 "Learning Python, 5th Edition","log = open('log.txt', 'a')",openfunc,365 "Learning Python, 5th Edition","log = open('log.txt', 'w')",openfunc,365 "Learning Python, 5th Edition",print(open('log.txt').read()),openfunc,366 "Learning Python, 5th Edition","print(X, Y, file=open('temp1', 'w'))",openfunc,366 "Learning Python, 5th Edition","print(open('temp1', 'rb').read())",openfunc,366 "Learning Python, 5th Edition","print(open('temp2', 'rb').read())",openfunc,366 "Learning Python, 5th Edition","file = open('test.txt', 'r')",openfunc,400 "Learning Python, 5th Edition",file = open('test.txt'),openfunc,401 "Learning Python, 5th Edition",for line in open('test.txt').readlines(),openfunc,401 "Learning Python, 5th Edition",for line in open('test.txt'),openfunc,401 "Learning Python, 5th Edition",for line in reversed(open('test.txt').readlines()),openfunc,401 "Learning Python, 5th Edition",F = os.popen('dir'),openfunc,412 "Learning Python, 5th Edition",F = os.popen('dir'),openfunc,412 "Learning Python, 5th Edition",os.popen('dir').readlines(),openfunc,412 "Learning Python, 5th Edition",os.popen('dir').read(),openfunc,412 "Learning Python, 5th Edition",for line in os.popen('dir'),openfunc,412 "Learning Python, 5th Edition",for line in os.popen('systeminfo'): print(line.rstrip()),openfunc,412 "Learning Python, 5th Edition",for line in os.popen('systeminfo'),openfunc,412 "Learning Python, 5th Edition",for line in open('input.txt'),openfunc,413 "Learning Python, 5th Edition",return [line.rstrip().split()[col-1] for line in open(file),openfunc,413 "Learning Python, 5th Edition",for line in urlopen('http://home.rmi.net/~lutz'),openfunc,413 "Learning Python, 5th Edition",print(open('script2.py').read()),openfunc,416 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,417 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,417 "Learning Python, 5th Edition",for line in open('script2.py'),openfunc,418 "Learning Python, 5th Edition",for line in open('script2.py').readlines(),openfunc,418 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,419 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,419 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,421 "Learning Python, 5th Edition",P = os.popen('dir'),openfunc,423 "Learning Python, 5th Edition",P = os.popen('dir'),openfunc,423 "Learning Python, 5th Edition",f = open('script2.py'),openfunc,426 "Learning Python, 5th Edition",line.upper() for line in open('script2.py'),openfunc,427 "Learning Python, 5th Edition",line.rstrip().upper() for line in open('script2.py'),openfunc,427 "Learning Python, 5th Edition",line.split() for line in open('script2.py'),openfunc,427 "Learning Python, 5th Edition","line.replace(' ', '!') for line in open('script2.py')",openfunc,427 "Learning Python, 5th Edition","sys' in line, line[:5]) for line in open('script2.py')",openfunc,427 "Learning Python, 5th Edition",for line in open('script2.py'),openfunc,428 "Learning Python, 5th Edition",line.rstrip() for line in open('script2.py') if line.rstrip()[-1].isdigit(),openfunc,428 "Learning Python, 5th Edition",len(open(fname).readlines()),openfunc,428 "Learning Python, 5th Edition",len([line for line in open(fname) if line.strip() != '']),openfunc,428 "Learning Python, 5th Edition",for line in open('script2.py'),openfunc,429 "Learning Python, 5th Edition","list(map(str.upper, open('script2.py')))",openfunc,430 "Learning Python, 5th Edition",sorted(open('script2.py')),openfunc,430 "Learning Python, 5th Edition","list(zip(open('script2.py'), open('script2.py')))",openfunc,430 "Learning Python, 5th Edition",list(enumerate(open('script2.py'))),openfunc,430 "Learning Python, 5th Edition","list(filter(bool, open('script2.py')))",openfunc,430 "Learning Python, 5th Edition","functools.reduce(operator.add, open('script2.py'))",openfunc,430 "Learning Python, 5th Edition",list(open('script2.py')),openfunc,431 "Learning Python, 5th Edition",tuple(open('script2.py')),openfunc,431 "Learning Python, 5th Edition",join(open('script2.py')),openfunc,431 "Learning Python, 5th Edition","a, b, c, d = open('script2.py')",openfunc,431 "Learning Python, 5th Edition","a, *b = open('script2.py')",openfunc,431 "Learning Python, 5th Edition",y = 2\n' in open('script2.py'),openfunc,431 "Learning Python, 5th Edition",x = 2\n' in open('script2.py'),openfunc,431 "Learning Python, 5th Edition",L[1:3] = open('script2.py'),openfunc,431 "Learning Python, 5th Edition",L.extend(open('script2.py')),openfunc,431 "Learning Python, 5th Edition",L.append(open('script2.py')),openfunc,432 "Learning Python, 5th Edition",set(open('script2.py')),openfunc,432 "Learning Python, 5th Edition",line for line in open('script2.py'),openfunc,432 "Learning Python, 5th Edition","ix: line for ix, line in enumerate(open('script2.py'))",openfunc,432 "Learning Python, 5th Edition",line for line in open('script2.py'),openfunc,432 "Learning Python, 5th Edition","ix: line for (ix, line) in enumerate(open('script2.py'))",openfunc,432 "Learning Python, 5th Edition",list(line.upper() for line in open('script2.py')),openfunc,432 "Learning Python, 5th Edition",max(open('script2.py')),openfunc,433 "Learning Python, 5th Edition",min(open('script2.py')),openfunc,433 "Learning Python, 5th Edition",f(*open('script2.py')),openfunc,433 "Learning Python, 5th Edition",def makeopen(id),openfunc,518 "Learning Python, 5th Edition",F = open('script2.py'),openfunc,518 "Learning Python, 5th Edition",makeopen('spam'),openfunc,518 "Learning Python, 5th Edition",F = open('script2.py'),openfunc,518 "Learning Python, 5th Edition",makeopen('eggs'),openfunc,518 "Learning Python, 5th Edition",F = open('script2.py'),openfunc,518 "Learning Python, 5th Edition",func(*open('fname')),openfunc,536 "Learning Python, 5th Edition",mysum(open(name))),openfunc,557 "Learning Python, 5th Edition",line.rstrip() for line in open('myfile').readlines(),openfunc,590 "Learning Python, 5th Edition",line.rstrip() for line in open('myfile'),openfunc,590 "Learning Python, 5th Edition","list(map((lambda line: line.rstrip()), open('myfile')))",openfunc,590 "Learning Python, 5th Edition",for line in open('temp.txt'),openfunc,606 "Learning Python, 5th Edition","x + y for (x, y) in zip(open('script2.py'), open('script2.py'))",openfunc,617 "Learning Python, 5th Edition",print('\t' + os.popen(cmd).read().rstrip()),openfunc,648 "Learning Python, 5th Edition","0, 0, ""f=open('C:/Python33/Lib/pdb.py')\nfor line in f: x=line\nf.close()"")",openfunc,652 "Learning Python, 5th Edition","c:\code> py −3 -m timeit -n 1000 -r 5 ""f=open('C:/Python33/Lib/pdb.py')",openfunc,653 "Learning Python, 5th Edition","stmt=""f=open('C:/Python33/Lib/pdb.py')\nfor line in f: x=line\nf.close()""))",openfunc,653 "Learning Python, 5th Edition",res1 = os.popen('reloadall.py tkinter').read(),openfunc,770 "Learning Python, 5th Edition",res2 = os.popen('reloadall2.py tkinter').read(),openfunc,770 "Learning Python, 5th Edition",res3 = os.popen('reloadall3.py tkinter').read(),openfunc,770 "Learning Python, 5th Edition",db = shelve.open('persondb'),openfunc,849 "Learning Python, 5th Edition","built-in open function, the filename in shelve.open()",openfunc,849 "Learning Python, 5th Edition",print(open('persondb.dir').read()),openfunc,850 "Learning Python, 5th Edition","print(open('persondb.dat','rb').read())",openfunc,850 "Learning Python, 5th Edition",db = shelve.open('persondb'),openfunc,850 "Learning Python, 5th Edition",db = shelve.open('persondb'),openfunc,852 "Learning Python, 5th Edition",db = shelve.open('persondb'),openfunc,852 "Learning Python, 5th Edition","obj = Uppercase(open('trispam.txt'), sys.stdout)",openfunc,939 "Learning Python, 5th Edition","prog = converters.Uppercase(open('trispam.txt'), open('trispamup.txt', 'w'))",openfunc,940 "Learning Python, 5th Edition","Uppercase(open('trispam.txt'), HTMLize()).process()",openfunc,940 "Learning Python, 5th Edition","file = open(filename, 'wb')",openfunc,941 "Learning Python, 5th Edition","file = open(filename, 'rb')",openfunc,941 "Learning Python, 5th Edition",dbase = shelve.open(filename),openfunc,941 "Learning Python, 5th Edition",dbase = shelve.open(filename),openfunc,941 "Learning Python, 5th Edition","obj = pickle.load(open('shopfile.pkl', 'rb'))",openfunc,942 "Learning Python, 5th Edition",len(open('savetree.txt').readlines()),openfunc,973 "Learning Python, 5th Edition","file = open('data', 'w') # Open an output file (this can fail too)",openfunc,1101 "Learning Python, 5th Edition",myfile = open(r'C:\misc\data'),openfunc,1115 "Learning Python, 5th Edition","for pair in zip(open('script1.py'), open('script2.py'))",openfunc,1118 "Learning Python, 5th Edition",print(open('upper.py').read()),openfunc,1119 "Learning Python, 5th Edition",fin = open('script2.py'),openfunc,1119 "Learning Python, 5th Edition","fout = open('upper.py', 'w')",openfunc,1119 "Learning Python, 5th Edition",fin = open('script2.py'),openfunc,1119 "Learning Python, 5th Edition","fout = open('upper.py', 'w')",openfunc,1119 "Learning Python, 5th Edition","log = open(self.logfile, 'a')",openfunc,1138 "Learning Python, 5th Edition","myfile = open(r'C:\code\textdata', 'w')",openfunc,1148 "Learning Python, 5th Edition","myfile = open(filename, 'w')",openfunc,1148 "Learning Python, 5th Edition","file = open('temp', 'w')",openfunc,1196 "Learning Python, 5th Edition","file = open('temp') # Default mode is ""r"" (== ""rt"")",openfunc,1196 "Learning Python, 5th Edition","X = open('latindata', 'rb').read()",openfunc,1200 "Learning Python, 5th Edition","X = open('utf8data', 'rb').read()",openfunc,1201 "Learning Python, 5th Edition","file = open(r'C:\Python33\python.exe', 'r')",openfunc,1201 "Learning Python, 5th Edition","file = open(r'C:\Python33\python.exe', 'rb')",openfunc,1201 "Learning Python, 5th Edition","codecs.open('latindata', 'w', encoding='latin-1').write(S)",openfunc,1204 "Learning Python, 5th Edition","codecs.open('utfdata', 'w', encoding='utf-8').write(S)",openfunc,1204 "Learning Python, 5th Edition","codecs.open('latindata', 'r', encoding='latin-1').read()",openfunc,1205 "Learning Python, 5th Edition","codecs.open('utfdata', 'r', encoding='utf-8').read()",openfunc,1205 "Learning Python, 5th Edition","print codecs.open('utfdata', 'r', encoding='utf-8').read()",openfunc,1205 "Learning Python, 5th Edition","f = open('xxx\u00A5', 'w')",openfunc,1205 "Learning Python, 5th Edition",print(open('xxx\u00A5').read()),openfunc,1205 "Learning Python, 5th Edition",print(open(b'xxx\xA5').read()),openfunc,1205 "Learning Python, 5th Edition","F = open('data.bin', 'wb')",openfunc,1208 "Learning Python, 5th Edition","F = open('data.bin', 'rb')",openfunc,1208 "Learning Python, 5th Edition",text = open('mybooks.xml').read(),openfunc,1212 "Learning Python, 5th Edition","f = open('py33-windows-launcher.html', encoding='utf8')",openfunc,1214 "Learning Python, 5th Edition","f = open('py33-windows-launcher.html', 'rb')",openfunc,1214 "Learning Python, 5th Edition",codecs.open() in 2.X),openfunc,1217 "Learning Python, 5th Edition",coding name to open in 3.X (codecs.open() in 2.X),openfunc,1217 "Learning Python, 5th Edition",codecs.open(),openfunc,1217 "Learning Python, 5th Edition","file = open(saveto, 'w')",openfunc,1415 "Learning Python, 5th Edition","file = open(htmlto, 'w')",openfunc,1415 "Learning Python, 5th Edition","print('\n' * 2, open(saveto).read())",openfunc,1416 "Learning Python, 5th Edition","webbrowser.open(htmlto, new=False)",openfunc,1416 "Learning Python, 5th Edition",exec open(filename),openfunc,1461 "Learning Python, 5th Edition","file = open('myfile.txt', 'w')",openfunc,1472 "Learning Python, 5th Edition",file.write('Hello file world!\n') # Or: open().write(),openfunc,1472 "Learning Python, 5th Edition",file = open('myfile.txt'),openfunc,1472 "Learning Python, 5th Edition",print(file.read()) # Or print(open().read()),openfunc,1473 "Learning Python, 5th Edition",file = open(name),openfunc,1485 "Learning Python, 5th Edition",return len(open(name).read()),openfunc,1485 "Learning Python, 5th Edition",for line in open(name),openfunc,1485 "Learning Python, 5th Edition",for line in open(name): tot += len(line),openfunc,1486 "Learning Python, 5th Edition",def countlines(name): return sum(+1 for line in open(name)),openfunc,1486 "Learning Python, 5th Edition",def countchars(name): return sum(len(line) for line in open(name)),openfunc,1486 "Learning Python, 5th Edition",file = open(name),openfunc,1486 "Learning Python, 5th Edition",file = open(name),openfunc,1486 "Learning Python, 5th Edition",return len(open(name).read()),openfunc,1487 "Learning Python, 5th Edition",for line in open(filename),openfunc,1500 "Learning Python, 5th Edition",for line in open(filename),openfunc,1501 "Learning Python, 5th Edition",output = os.popen(commandline).read(),openfunc,1501 "Learning Python, 5th Edition",priorresult = open(result).read(),openfunc,1501 "Learning Python, 5th Edition",db = shelve.open('dbfile'),openfunc,1504 "Learning Python, 5th Edition",db = shelve.open('dbfile'),openfunc,1504 "Learning Python, 5th Edition","localfile = open(filename, 'wb')",openfunc,1506 "Learning Python, 5th Edition",webbrowser.open(filename),openfunc,1506 "Learning Python, 5th Edition",f.write('Hello\n'),write,122 "Learning Python, 5th Edition",f.write('world\n'),write,122 "Learning Python, 5th Edition",file.write(packed),write,124 "Learning Python, 5th Edition",file.write(S),write,125 "Learning Python, 5th Edition",output.write(aString),write,283 "Learning Python, 5th Edition",myfile.write('hello text file\n'),write,285 "Learning Python, 5th Edition",myfile.write('goodbye text file\n'),write,286 "Learning Python, 5th Edition",F.write(S + '\n'),write,288 "Learning Python, 5th Edition","F.write('%s,%s,%s\n' % (X, Y, Z))",write,288 "Learning Python, 5th Edition",F.write(str(L) + '$' + str(D) + '\n'),write,288 "Learning Python, 5th Edition",F.write(data),write,293 "Learning Python, 5th Edition","log.write(""spam, ham"")",write,320 "Learning Python, 5th Edition",file.write(str)),write,358 "Learning Python, 5th Edition",object with a file-like write(string),write,359 "Learning Python, 5th Edition",sys.stdout.write('hello world\n'),write,363 "Learning Python, 5th Edition",sys.stdout.write(str(X) + ' ' + str(Y) + '\n'),write,364 "Learning Python, 5th Edition",sys.stderr.write(('Bad!' * 8) + '\n'),write,366 "Learning Python, 5th Edition",sys.stdout.write(str(X) + ' ' + str(Y) + '\n'),write,366 "Learning Python, 5th Edition","open('temp2', 'w').write(str(X) + ' ' + str(Y) + '\n')",write,366 "Learning Python, 5th Edition","def write(self, string)",write,369 "Learning Python, 5th Edition",file.write(output + end),write,548 "Learning Python, 5th Edition",file.write(output + end),write,549 "Learning Python, 5th Edition",file.write(output + end),write,549 "Learning Python, 5th Edition",say sys.stdout.write(str(X)+'\n'),write,571 "Learning Python, 5th Edition",showall = lambda x: [sys.stdout.write(line),write,572 "Learning Python, 5th Edition",command=(lambda:sys.stdout.write('Spam\n'))) # 3.X: print(),write,573 "Learning Python, 5th Edition",writer.write(data),write,794 "Learning Python, 5th Edition",writer.write(data),write,938 "Learning Python, 5th Edition",self.writer.write(data),write,939 "Learning Python, 5th Edition","def write(self, line)",write,940 "Learning Python, 5th Edition","open('savetree.txt', 'w').write(str(B))",write,973 "Learning Python, 5th Edition",file.write('The larch!\n'),write,1088 "Learning Python, 5th Edition",fout.write(line),write,1118 "Learning Python, 5th Edition",fout.write(line.upper()),write,1119 "Learning Python, 5th Edition",fout.write(line.upper()),write,1119 "Learning Python, 5th Edition",size = file.write('abc\n'),write,1196 "Learning Python, 5th Edition","open('temp', 'w').write('abd\n')",write,1197 "Learning Python, 5th Edition","open('temp', 'wb').write('abc\n')",write,1197 "Learning Python, 5th Edition","open('temp', 'w').write('abc\n')",write,1197 "Learning Python, 5th Edition","open('temp', 'wb').write(b'abc\n')",write,1197 "Learning Python, 5th Edition","open('temp', 'wb').write(b'a\x00c')",write,1198 "Learning Python, 5th Edition","open('temp', 'wb').write(BA)",write,1198 "Learning Python, 5th Edition","open('temp', 'w').write('abc\n')",write,1198 "Learning Python, 5th Edition","open('temp', 'w').write(b'abc\n')",write,1198 "Learning Python, 5th Edition","open('temp', 'wb').write(b'abc\n')",write,1198 "Learning Python, 5th Edition","open('temp', 'wb').write('abc\n')",write,1198 "Learning Python, 5th Edition","open('temp', 'w').write(b'\xFF\xFE\xFD')",write,1199 "Learning Python, 5th Edition","open('temp', 'w').write('\xFF\xFE\xFD')",write,1199 "Learning Python, 5th Edition","open('temp', 'wb').write(b'\xFF\xFE\xFD')",write,1199 "Learning Python, 5th Edition","open('latindata', 'w', encoding='latin-1').write(S)",write,1200 "Learning Python, 5th Edition","open('utf8data', 'w', encoding='utf-8').write(S)",write,1200 "Learning Python, 5th Edition","open('temp.txt', 'w', encoding='utf-8').write('spam\nSPAM\n')",write,1203 "Learning Python, 5th Edition","open('temp.txt', 'w', encoding='utf-8-sig').write('spam\nSPAM\n')",write,1203 "Learning Python, 5th Edition","open('temp.txt', 'w').write('spam\nSPAM\n')",write,1203 "Learning Python, 5th Edition","open('temp.txt', 'w', encoding='utf-16').write('spam\nSPAM\n')",write,1203 "Learning Python, 5th Edition","open('temp.txt', 'w', encoding='utf-16-be').write('\ufeffspam\nSPAM\n')",write,1204 "Learning Python, 5th Edition","open('temp.txt', 'w', encoding='utf-16-le').write('SPAM')",write,1204 "Learning Python, 5th Edition",f.write('\xA5999\n'),write,1205 "Learning Python, 5th Edition",F.write(data),write,1208 "Learning Python, 5th Edition",output.writelines(aList),writelines,283 "Learning Python, 5th Edition",text = f.read(),read,123 "Learning Python, 5th Edition","open('unidata.txt', 'rb').read()",read,126 "Learning Python, 5th Edition",open('unidata.txt').read(),read,126 "Learning Python, 5th Edition",aString = input.read(),read,283 "Learning Python, 5th Edition",aString = input.read(N),read,283 "Learning Python, 5th Edition",open('myfile.txt').read(),read,286 "Learning Python, 5th Edition","open('datafile.pkl', 'rb').read()",read,290 "Learning Python, 5th Edition",data = F.read(),read,293 "Learning Python, 5th Edition",print(file.read()),read,400 "Learning Python, 5th Edition",F.read(50),read,412 "Learning Python, 5th Edition",open('script2.py').read(),read,417 "Learning Python, 5th Edition",F.read(),read,518 "Learning Python, 5th Edition",F.read(),read,518 "Learning Python, 5th Edition",F.read(),read,518 "Learning Python, 5th Edition",data = reader.read(),read,793 "Learning Python, 5th Edition",def read(self),read,794 "Learning Python, 5th Edition",def read(self),read,794 "Learning Python, 5th Edition",def read(self),read,794 "Learning Python, 5th Edition",text = file.read(),read,1196 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1197 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1198 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1198 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1198 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1198 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1199 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1199 "Learning Python, 5th Edition","open('latindata', 'rb').read()",read,1200 "Learning Python, 5th Edition","open('utf8data', 'rb').read()",read,1200 "Learning Python, 5th Edition","open('latindata', 'r', encoding='latin-1').read()",read,1200 "Learning Python, 5th Edition","open('utf8data', 'r', encoding='utf-8').read()",read,1200 "Learning Python, 5th Edition",text = file.read(),read,1201 "Learning Python, 5th Edition",data = file.read(),read,1201 "Learning Python, 5th Edition","open('spam.txt', 'rb').read() # ASCII (UTF-8)",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r', encoding='utf-8').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'rb').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r', encoding='utf-8').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r', encoding='utf-8-sig').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'rb').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r', encoding='utf-16').read()",read,1202 "Learning Python, 5th Edition","open('spam.txt', 'r', encoding='utf-16-be').read()",read,1202 "Learning Python, 5th Edition","open('temp.txt', 'rb').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'rb').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-8').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-8-sig').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'rb').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-8').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-8-sig').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'rb').read()",read,1203 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-16').read()",read,1203 "Learning Python, 5th Edition","open('spam.txt', 'rb').read()",read,1204 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-16').read()",read,1204 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-16-be').read()",read,1204 "Learning Python, 5th Edition","open('temp.txt', 'rb').read()",read,1204 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-16-le').read()",read,1204 "Learning Python, 5th Edition","open('temp.txt', 'r', encoding='utf-16').read()",read,1204 "Learning Python, 5th Edition","open('latindata', 'rb').read()",read,1204 "Learning Python, 5th Edition","open('utfdata', 'rb').read()",read,1204 "Learning Python, 5th Edition",data = F.read(),read,1208 "Learning Python, 5th Edition","open('temp', 'r').read()",read,1210 "Learning Python, 5th Edition","open('temp', 'rb').read()",read,1210 "Learning Python, 5th Edition",open('temp').read(),read,1210 "Learning Python, 5th Edition",t = f.read(),read,1214 "Learning Python, 5th Edition",b = f.read(),read,1214 "Learning Python, 5th Edition",name).read()),read,1461 "Learning Python, 5th Edition",name).read()),read,1461 "Learning Python, 5th Edition",return len(file.read()),read,1486 "Learning Python, 5th Edition",aString = input.readline(),readline,283 "Learning Python, 5th Edition",myfile.readline(),readline,286 "Learning Python, 5th Edition",myfile.readline(),readline,286 "Learning Python, 5th Edition",myfile.readline(),readline,286 "Learning Python, 5th Edition",open(r'C:\Python33\Lib\pdb.py').readline(),readline,286 "Learning Python, 5th Edition",open('C:/Python33/Lib/pdb.py').readline(),readline,286 "Learning Python, 5th Edition",open('C:\\Python33\\Lib\\pdb.py').readline(),readline,287 "Learning Python, 5th Edition",line = F.readline(),readline,289 "Learning Python, 5th Edition",line = F.readline(),readline,289 "Learning Python, 5th Edition",line = F.readline(),readline,289 "Learning Python, 5th Edition",F.readline(),readline,412 "Learning Python, 5th Edition",f.readline(),readline,417 "Learning Python, 5th Edition",f.readline(),readline,417 "Learning Python, 5th Edition",f.readline(),readline,417 "Learning Python, 5th Edition",f.readline(),readline,417 "Learning Python, 5th Edition",f.readline(),readline,417 "Learning Python, 5th Edition",import this,importfunc,5 "Learning Python, 5th Edition",import this,importfunc,23 "Learning Python, 5th Edition",import this,importfunc,24 "Learning Python, 5th Edition",import basics,importfunc,31 "Learning Python, 5th Edition",import and,importfunc,34 "Learning Python, 5th Edition",import your,importfunc,51 "Learning Python, 5th Edition",import os,importfunc,51 "Learning Python, 5th Edition",import and,importfunc,52 "Learning Python, 5th Edition",import sys,importfunc,55 "Learning Python, 5th Edition",import to,importfunc,55 "Learning Python, 5th Edition",import into,importfunc,55 "Learning Python, 5th Edition","import them",importfunc,55 "Learning Python, 5th Edition",import spam,importfunc,59 "Learning Python, 5th Edition",import the,importfunc,60 "Learning Python, 5th Edition",import sys,importfunc,63 "Learning Python, 5th Edition",import sys,importfunc,64 "Learning Python, 5th Edition",import operations,importfunc,66 "Learning Python, 5th Edition",import tools,importfunc,67 "Learning Python, 5th Edition",import operations,importfunc,67 "Learning Python, 5th Edition",import script1,importfunc,67 "Learning Python, 5th Edition",import script1,importfunc,67 "Learning Python, 5th Edition",import script1,importfunc,67 "Learning Python, 5th Edition",import and,importfunc,68 "Learning Python, 5th Edition",import reported,importfunc,68 "Learning Python, 5th Edition",import does,importfunc,68 "Learning Python, 5th Edition",import is,importfunc,68 "Learning Python, 5th Edition",import it,importfunc,68 "Learning Python, 5th Edition",import imp,importfunc,68 "Learning Python, 5th Edition",import and,importfunc,68 "Learning Python, 5th Edition",import is,importfunc,68 "Learning Python, 5th Edition",import statement,importfunc,68 "Learning Python, 5th Edition",import and,importfunc,68 "Learning Python, 5th Edition",import and,importfunc,69 "Learning Python, 5th Edition",import myfile,importfunc,69 "Learning Python, 5th Edition",import or,importfunc,69 "Learning Python, 5th Edition",import and,importfunc,69 "Learning Python, 5th Edition",import or,importfunc,70 "Learning Python, 5th Edition",import get,importfunc,70 "Learning Python, 5th Edition",import threenames,importfunc,70 "Learning Python, 5th Edition",import instead,importfunc,71 "Learning Python, 5th Edition",import and,importfunc,71 "Learning Python, 5th Edition",import and,importfunc,71 "Learning Python, 5th Edition",import a,importfunc,72 "Learning Python, 5th Edition",import from,importfunc,72 "Learning Python, 5th Edition",import the,importfunc,73 "Learning Python, 5th Edition",import statement,importfunc,73 "Learning Python, 5th Edition",import it,importfunc,78 "Learning Python, 5th Edition",import and,importfunc,78 "Learning Python, 5th Edition",import commands,importfunc,79 "Learning Python, 5th Edition",import search,importfunc,79 "Learning Python, 5th Edition",import modules,importfunc,79 "Learning Python, 5th Edition",import and,importfunc,84 "Learning Python, 5th Edition",import a,importfunc,86 "Learning Python, 5th Edition",import other,importfunc,87 "Learning Python, 5th Edition",import the,importfunc,87 "Learning Python, 5th Edition",import to,importfunc,98 "Learning Python, 5th Edition",import math,importfunc,98 "Learning Python, 5th Edition",import random,importfunc,98 "Learning Python, 5th Edition",import a,importfunc,108 "Learning Python, 5th Edition",import struct,importfunc,124 "Learning Python, 5th Edition",import codecs,importfunc,126 "Learning Python, 5th Edition",import decimal,importfunc,127 "Learning Python, 5th Edition",import from,importfunc,148 "Learning Python, 5th Edition",import math,importfunc,148 "Learning Python, 5th Edition",import math,importfunc,149 "Learning Python, 5th Edition",import math,importfunc,149 "Learning Python, 5th Edition",import math,importfunc,155 "Learning Python, 5th Edition",import math,importfunc,156 "Learning Python, 5th Edition",import random,importfunc,156 "Learning Python, 5th Edition",import decimal,importfunc,159 "Learning Python, 5th Edition",import decimal,importfunc,159 "Learning Python, 5th Edition","import its",importfunc,160 "Learning Python, 5th Edition",import decimal,importfunc,161 "Learning Python, 5th Edition","import math",importfunc,173 "Learning Python, 5th Edition",import copy,importfunc,183 "Learning Python, 5th Edition",import sys,importfunc,184 "Learning Python, 5th Edition",import os,importfunc,199 "Learning Python, 5th Edition",import sys,importfunc,204 "Learning Python, 5th Edition",import the,importfunc,216 "Learning Python, 5th Edition",import string,importfunc,216 "Learning Python, 5th Edition",import the,importfunc,216 "Learning Python, 5th Edition",import sys,importfunc,223 "Learning Python, 5th Edition",import sys,importfunc,228 "Learning Python, 5th Edition",import string,importfunc,235 "Learning Python, 5th Edition",import cgi,importfunc,271 "Learning Python, 5th Edition",import the,importfunc,281 "Learning Python, 5th Edition",import pickle,importfunc,290 "Learning Python, 5th Edition",import pickle,importfunc,290 "Learning Python, 5th Edition",import json,importfunc,291 "Learning Python, 5th Edition",import csv,importfunc,292 "Learning Python, 5th Edition",import struct,importfunc,293 "Learning Python, 5th Edition",import struct,importfunc,293 "Learning Python, 5th Edition",import copy,importfunc,300 "Learning Python, 5th Edition",import types,importfunc,306 "Learning Python, 5th Edition",import to,importfunc,308 "Learning Python, 5th Edition","import from",importfunc,321 "Learning Python, 5th Edition",import sys,importfunc,321 "Learning Python, 5th Edition",import sys,importfunc,331 "Learning Python, 5th Edition","import modules",importfunc,335 "Learning Python, 5th Edition","import in",importfunc,353 "Learning Python, 5th Edition",import statements,importfunc,354 "Learning Python, 5th Edition",import and,importfunc,358 "Learning Python, 5th Edition",import sys,importfunc,363 "Learning Python, 5th Edition",import sys,importfunc,364 "Learning Python, 5th Edition",import sys,importfunc,364 "Learning Python, 5th Edition",import sys,importfunc,365 "Learning Python, 5th Edition",import sys,importfunc,366 "Learning Python, 5th Edition",import sys,importfunc,366 "Learning Python, 5th Edition",import another,importfunc,367 "Learning Python, 5th Edition",import sys,importfunc,369 "Learning Python, 5th Edition",import os,importfunc,412 "Learning Python, 5th Edition",import used,importfunc,413 "Learning Python, 5th Edition",import sys,importfunc,416 "Learning Python, 5th Edition",import os,importfunc,423 "Learning Python, 5th Edition",import sys,importfunc,433 "Learning Python, 5th Edition",import it,importfunc,444 "Learning Python, 5th Edition",import sys,importfunc,444 "Learning Python, 5th Edition",import the,importfunc,447 "Learning Python, 5th Edition",import docstrings,importfunc,447 "Learning Python, 5th Edition",import it,importfunc,448 "Learning Python, 5th Edition",import sys,importfunc,448 "Learning Python, 5th Edition",import sys,importfunc,449 "Learning Python, 5th Edition",import sys,importfunc,449 "Learning Python, 5th Edition","import sys",importfunc,449 "Learning Python, 5th Edition",import docstrings,importfunc,451 "Learning Python, 5th Edition",import search,importfunc,453 "Learning Python, 5th Edition",import search,importfunc,458 "Learning Python, 5th Edition",import search,importfunc,458 "Learning Python, 5th Edition",import a,importfunc,458 "Learning Python, 5th Edition",import on,importfunc,461 "Learning Python, 5th Edition",import search,importfunc,461 "Learning Python, 5th Edition","import a",importfunc,487 "Learning Python, 5th Edition",import builtins,importfunc,491 "Learning Python, 5th Edition",import it,importfunc,491 "Learning Python, 5th Edition",import builtins,importfunc,491 "Learning Python, 5th Edition",import builtins,importfunc,492 "Learning Python, 5th Edition",import but,importfunc,493 "Learning Python, 5th Edition",import on,importfunc,493 "Learning Python, 5th Edition",import buil,importfunc,493 "Learning Python, 5th Edition",import in,importfunc,493 "Learning Python, 5th Edition",import first,importfunc,497 "Learning Python, 5th Edition",import the,importfunc,497 "Learning Python, 5th Edition",import one,importfunc,497 "Learning Python, 5th Edition",import chain,importfunc,497 "Learning Python, 5th Edition",import first,importfunc,498 "Learning Python, 5th Edition",import thismod,importfunc,499 "Learning Python, 5th Edition",import sys,importfunc,499 "Learning Python, 5th Edition",import thismod,importfunc,499 "Learning Python, 5th Edition",import builtins,importfunc,517 "Learning Python, 5th Edition",import builtins,importfunc,518 "Learning Python, 5th Edition",import of,importfunc,547 "Learning Python, 5th Edition",import sys,importfunc,547 "Learning Python, 5th Edition",import this,importfunc,548 "Learning Python, 5th Edition",import sys,importfunc,548 "Learning Python, 5th Edition",import sys,importfunc,548 "Learning Python, 5th Edition",import sys,importfunc,549 "Learning Python, 5th Edition",import print_function,importfunc,551 "Learning Python, 5th Edition",import chains,importfunc,561 "Learning Python, 5th Edition",import sys,importfunc,572 "Learning Python, 5th Edition",import sys,importfunc,573 "Learning Python, 5th Edition",import math,importfunc,600 "Learning Python, 5th Edition",import os,importfunc,607 "Learning Python, 5th Edition",import math,importfunc,615 "Learning Python, 5th Edition",import random,importfunc,616 "Learning Python, 5th Edition",import time,importfunc,630 "Learning Python, 5th Edition",import the,importfunc,632 "Learning Python, 5th Edition",import timer,importfunc,632 "Learning Python, 5th Edition",import timeit,importfunc,643 "Learning Python, 5th Edition",import timeit,importfunc,643 "Learning Python, 5th Edition",import timeit,importfunc,643 "Learning Python, 5th Edition",import timeit,importfunc,645 "Learning Python, 5th Edition",import timeit,importfunc,647 "Learning Python, 5th Edition",import and,importfunc,647 "Learning Python, 5th Edition",import timeit,importfunc,653 "Learning Python, 5th Edition",import the,importfunc,658 "Learning Python, 5th Edition",import __main__,importfunc,658 "Learning Python, 5th Edition",import math,importfunc,665 "Learning Python, 5th Edition",import other,importfunc,669 "Learning Python, 5th Edition","import Lets",importfunc,669 "Learning Python, 5th Edition",import that,importfunc,670 "Learning Python, 5th Edition",import modules,importfunc,671 "Learning Python, 5th Edition",import b,importfunc,671 "Learning Python, 5th Edition",import b,importfunc,672 "Learning Python, 5th Edition",import statements,importfunc,672 "Learning Python, 5th Edition",import statement,importfunc,672 "Learning Python, 5th Edition",import is,importfunc,672 "Learning Python, 5th Edition",import literally,importfunc,672 "Learning Python, 5th Edition",import tools,importfunc,673 "Learning Python, 5th Edition",import b,importfunc,673 "Learning Python, 5th Edition",import the,importfunc,673 "Learning Python, 5th Edition",import are,importfunc,673 "Learning Python, 5th Edition",import operation,importfunc,674 "Learning Python, 5th Edition",import operation,importfunc,674 "Learning Python, 5th Edition",import statement,importfunc,674 "Learning Python, 5th Edition","import operation",importfunc,674 "Learning Python, 5th Edition",import statements,importfunc,674 "Learning Python, 5th Edition",import statement,importfunc,675 "Learning Python, 5th Edition",import operation,importfunc,675 "Learning Python, 5th Edition",import operation,importfunc,675 "Learning Python, 5th Edition",import time,importfunc,676 "Learning Python, 5th Edition",import step,importfunc,676 "Learning Python, 5th Edition",import operations,importfunc,676 "Learning Python, 5th Edition",import steps,importfunc,676 "Learning Python, 5th Edition",import a,importfunc,676 "Learning Python, 5th Edition","import sys",importfunc,676 "Learning Python, 5th Edition",import script0,importfunc,677 "Learning Python, 5th Edition",import script0,importfunc,677 "Learning Python, 5th Edition",import script0,importfunc,678 "Learning Python, 5th Edition",import procedure,importfunc,678 "Learning Python, 5th Edition",import search,importfunc,678 "Learning Python, 5th Edition",import a,importfunc,679 "Learning Python, 5th Edition",import across,importfunc,680 "Learning Python, 5th Edition",import the,importfunc,680 "Learning Python, 5th Edition",import syntax,importfunc,681 "Learning Python, 5th Edition",import of,importfunc,682 "Learning Python, 5th Edition",import sys,importfunc,682 "Learning Python, 5th Edition",import statements,importfunc,682 "Learning Python, 5th Edition",import statement,importfunc,683 "Learning Python, 5th Edition",import b,importfunc,683 "Learning Python, 5th Edition",import b,importfunc,683 "Learning Python, 5th Edition",import operation,importfunc,683 "Learning Python, 5th Edition",import statements,importfunc,684 "Learning Python, 5th Edition",import by,importfunc,684 "Learning Python, 5th Edition",import from,importfunc,685 "Learning Python, 5th Edition",import operation,importfunc,685 "Learning Python, 5th Edition",import statements,importfunc,685 "Learning Python, 5th Edition",import search,importfunc,685 "Learning Python, 5th Edition",import from,importfunc,686 "Learning Python, 5th Edition",import search,importfunc,686 "Learning Python, 5th Edition",import a,importfunc,687 "Learning Python, 5th Edition",import any,importfunc,688 "Learning Python, 5th Edition","import it",importfunc,688 "Learning Python, 5th Edition",import or,importfunc,688 "Learning Python, 5th Edition",import fetches,importfunc,688 "Learning Python, 5th Edition",import Statement,importfunc,689 "Learning Python, 5th Edition",import module1,importfunc,689 "Learning Python, 5th Edition",import statement,importfunc,689 "Learning Python, 5th Edition",import and,importfunc,689 "Learning Python, 5th Edition","import works",importfunc,690 "Learning Python, 5th Edition",import or,importfunc,690 "Learning Python, 5th Edition",import operations,importfunc,690 "Learning Python, 5th Edition",import simple,importfunc,690 "Learning Python, 5th Edition",import simple,importfunc,691 "Learning Python, 5th Edition",import and,importfunc,691 "Learning Python, 5th Edition",import and,importfunc,691 "Learning Python, 5th Edition",import or,importfunc,691 "Learning Python, 5th Edition",import and,importfunc,691 "Learning Python, 5th Edition",import assigns,importfunc,691 "Learning Python, 5th Edition",import small,importfunc,691 "Learning Python, 5th Edition",import small,importfunc,692 "Learning Python, 5th Edition",import and,importfunc,692 "Learning Python, 5th Edition",import statement,importfunc,692 "Learning Python, 5th Edition",import module,importfunc,692 "Learning Python, 5th Edition",import instead,importfunc,693 "Learning Python, 5th Edition",import variables,importfunc,693 "Learning Python, 5th Edition",import statement,importfunc,693 "Learning Python, 5th Edition",import to,importfunc,693 "Learning Python, 5th Edition",import per,importfunc,693 "Learning Python, 5th Edition",import is,importfunc,694 "Learning Python, 5th Edition",import instead,importfunc,694 "Learning Python, 5th Edition",import will,importfunc,694 "Learning Python, 5th Edition",import allows,importfunc,694 "Learning Python, 5th Edition",import and,importfunc,694 "Learning Python, 5th Edition",import sys,importfunc,695 "Learning Python, 5th Edition",import is,importfunc,696 "Learning Python, 5th Edition",import module2,importfunc,696 "Learning Python, 5th Edition",import statements,importfunc,696 "Learning Python, 5th Edition",import moda,importfunc,698 "Learning Python, 5th Edition",import operations,importfunc,698 "Learning Python, 5th Edition",import mod3,importfunc,699 "Learning Python, 5th Edition",import mod2,importfunc,699 "Learning Python, 5th Edition",import is,importfunc,700 "Learning Python, 5th Edition",import statements,importfunc,700 "Learning Python, 5th Edition",import and,importfunc,700 "Learning Python, 5th Edition",import or,importfunc,701 "Learning Python, 5th Edition",import and,importfunc,701 "Learning Python, 5th Edition",import was,importfunc,701 "Learning Python, 5th Edition",import statements,importfunc,701 "Learning Python, 5th Edition",import statements,importfunc,701 "Learning Python, 5th Edition",import module,importfunc,701 "Learning Python, 5th Edition",import a,importfunc,701 "Learning Python, 5th Edition",import to,importfunc,702 "Learning Python, 5th Edition",import qualify,importfunc,702 "Learning Python, 5th Edition",import the,importfunc,702 "Learning Python, 5th Edition",import changer,importfunc,702 "Learning Python, 5th Edition",import changer,importfunc,702 "Learning Python, 5th Edition",import instead,importfunc,703 "Learning Python, 5th Edition",import and,importfunc,703 "Learning Python, 5th Edition",import model,importfunc,704 "Learning Python, 5th Edition",import statements,importfunc,704 "Learning Python, 5th Edition",import instead,importfunc,704 "Learning Python, 5th Edition",import instead,importfunc,704 "Learning Python, 5th Edition",import story,importfunc,707 "Learning Python, 5th Edition",import can,importfunc,707 "Learning Python, 5th Edition",import turns,importfunc,707 "Learning Python, 5th Edition","import ambiguities",importfunc,707 "Learning Python, 5th Edition",import statements,importfunc,708 "Learning Python, 5th Edition",import path,importfunc,708 "Learning Python, 5th Edition",import statements,importfunc,708 "Learning Python, 5th Edition",import statements,importfunc,708 "Learning Python, 5th Edition",import and,importfunc,709 "Learning Python, 5th Edition",import statement,importfunc,709 "Learning Python, 5th Edition",import statement,importfunc,709 "Learning Python, 5th Edition",import statements,importfunc,709 "Learning Python, 5th Edition",import statements,importfunc,712 "Learning Python, 5th Edition",import statement,importfunc,712 "Learning Python, 5th Edition",import as,importfunc,713 "Learning Python, 5th Edition",import of,importfunc,714 "Learning Python, 5th Edition",import utilities,importfunc,714 "Learning Python, 5th Edition",import that,importfunc,714 "Learning Python, 5th Edition",import utilities,importfunc,714 "Learning Python, 5th Edition",import utilities,importfunc,714 "Learning Python, 5th Edition",import across,importfunc,715 "Learning Python, 5th Edition",import utilities,importfunc,715 "Learning Python, 5th Edition",import it,importfunc,715 "Learning Python, 5th Edition",import either,importfunc,716 "Learning Python, 5th Edition",import both,importfunc,716 "Learning Python, 5th Edition",import statement,importfunc,716 "Learning Python, 5th Edition",import instead,importfunc,716 "Learning Python, 5th Edition",import statements,importfunc,716 "Learning Python, 5th Edition",import utilities,importfunc,716 "Learning Python, 5th Edition",import from,importfunc,717 "Learning Python, 5th Edition",import syntax,importfunc,717 "Learning Python, 5th Edition",import from,importfunc,717 "Learning Python, 5th Edition",import syntax,importfunc,717 "Learning Python, 5th Edition",import operations,importfunc,718 "Learning Python, 5th Edition",import search,importfunc,718 "Learning Python, 5th Edition",import search,importfunc,718 "Learning Python, 5th Edition",import search,importfunc,718 "Learning Python, 5th Edition",import a,importfunc,719 "Learning Python, 5th Edition",import name,importfunc,719 "Learning Python, 5th Edition",import the,importfunc,719 "Learning Python, 5th Edition",import will,importfunc,719 "Learning Python, 5th Edition",import without,importfunc,719 "Learning Python, 5th Edition",import search,importfunc,719 "Learning Python, 5th Edition",import string,importfunc,719 "Learning Python, 5th Edition",import change,importfunc,719 "Learning Python, 5th Edition",import modname,importfunc,719 "Learning Python, 5th Edition",import forms,importfunc,720 "Learning Python, 5th Edition",import string,importfunc,720 "Learning Python, 5th Edition",import a,importfunc,720 "Learning Python, 5th Edition",import the,importfunc,720 "Learning Python, 5th Edition",import was,importfunc,720 "Learning Python, 5th Edition",import spam,importfunc,720 "Learning Python, 5th Edition",import statement,importfunc,721 "Learning Python, 5th Edition",import search,importfunc,721 "Learning Python, 5th Edition",import string,importfunc,721 "Learning Python, 5th Edition",import without,importfunc,721 "Learning Python, 5th Edition",import a,importfunc,721 "Learning Python, 5th Edition",import name1,importfunc,721 "Learning Python, 5th Edition",import is,importfunc,721 "Learning Python, 5th Edition",import starting,importfunc,721 "Learning Python, 5th Edition",import spam,importfunc,721 "Learning Python, 5th Edition",import E,importfunc,721 "Learning Python, 5th Edition",import X,importfunc,721 "Learning Python, 5th Edition",import X,importfunc,721 "Learning Python, 5th Edition",import dot,importfunc,722 "Learning Python, 5th Edition",import statements,importfunc,722 "Learning Python, 5th Edition",import syntax,importfunc,722 "Learning Python, 5th Edition",import statements,importfunc,722 "Learning Python, 5th Edition",import of,importfunc,723 "Learning Python, 5th Edition","import search",importfunc,723 "Learning Python, 5th Edition",import and,importfunc,723 "Learning Python, 5th Edition",import search,importfunc,723 "Learning Python, 5th Edition",import string,importfunc,724 "Learning Python, 5th Edition",import string,importfunc,724 "Learning Python, 5th Edition","import syntax",importfunc,724 "Learning Python, 5th Edition","import In",importfunc,724 "Learning Python, 5th Edition",import string,importfunc,724 "Learning Python, 5th Edition",import eggs,importfunc,725 "Learning Python, 5th Edition",import string,importfunc,725 "Learning Python, 5th Edition",import the,importfunc,725 "Learning Python, 5th Edition",import searches,importfunc,725 "Learning Python, 5th Edition",import in,importfunc,725 "Learning Python, 5th Edition",import string,importfunc,725 "Learning Python, 5th Edition",import in,importfunc,726 "Learning Python, 5th Edition",import string,importfunc,726 "Learning Python, 5th Edition",import string,importfunc,726 "Learning Python, 5th Edition",import in,importfunc,726 "Learning Python, 5th Edition",import syntax,importfunc,727 "Learning Python, 5th Edition",import syntax,importfunc,727 "Learning Python, 5th Edition",import syntax,importfunc,727 "Learning Python, 5th Edition",import in,importfunc,727 "Learning Python, 5th Edition",import name,importfunc,727 "Learning Python, 5th Edition",import name,importfunc,727 "Learning Python, 5th Edition",import the,importfunc,728 "Learning Python, 5th Edition",import syntax,importfunc,728 "Learning Python, 5th Edition",import string,importfunc,728 "Learning Python, 5th Edition",import resolution,importfunc,728 "Learning Python, 5th Edition",import protocol,importfunc,728 "Learning Python, 5th Edition",import dot,importfunc,729 "Learning Python, 5th Edition",import syntax,importfunc,729 "Learning Python, 5th Edition",import statements,importfunc,729 "Learning Python, 5th Edition",import mod,importfunc,729 "Learning Python, 5th Edition",import spam,importfunc,730 "Learning Python, 5th Edition",import eggs,importfunc,730 "Learning Python, 5th Edition",import syntax,importfunc,730 "Learning Python, 5th Edition",import spam,importfunc,730 "Learning Python, 5th Edition","import Fix",importfunc,731 "Learning Python, 5th Edition","import Fix",importfunc,731 "Learning Python, 5th Edition",import syntax,importfunc,731 "Learning Python, 5th Edition",import spam,importfunc,731 "Learning Python, 5th Edition",import m1,importfunc,732 "Learning Python, 5th Edition",import statement,importfunc,732 "Learning Python, 5th Edition",import the,importfunc,732 "Learning Python, 5th Edition",import m1,importfunc,732 "Learning Python, 5th Edition",import statement,importfunc,732 "Learning Python, 5th Edition",import statement,importfunc,733 "Learning Python, 5th Edition",import m1,importfunc,733 "Learning Python, 5th Edition",import mod,importfunc,734 "Learning Python, 5th Edition",import algorithm,importfunc,735 "Learning Python, 5th Edition",import operation,importfunc,735 "Learning Python, 5th Edition",import sub,importfunc,737 "Learning Python, 5th Edition",import through,importfunc,738 "Learning Python, 5th Edition",import statement,importfunc,738 "Learning Python, 5th Edition",import of,importfunc,738 "Learning Python, 5th Edition",import sub,importfunc,739 "Learning Python, 5th Edition",import search,importfunc,739 "Learning Python, 5th Edition",import ns2,importfunc,740 "Learning Python, 5th Edition",import ns2,importfunc,740 "Learning Python, 5th Edition",import ns2,importfunc,740 "Learning Python, 5th Edition",import sys,importfunc,741 "Learning Python, 5th Edition",import ns2,importfunc,741 "Learning Python, 5th Edition",import algorithm,importfunc,741 "Learning Python, 5th Edition",import algorithm,importfunc,741 "Learning Python, 5th Edition",import sub,importfunc,741 "Learning Python, 5th Edition",import path,importfunc,741 "Learning Python, 5th Edition",import sub,importfunc,741 "Learning Python, 5th Edition",import search,importfunc,742 "Learning Python, 5th Edition",import search,importfunc,742 "Learning Python, 5th Edition","import helps",importfunc,742 "Learning Python, 5th Edition",import model,importfunc,742 "Learning Python, 5th Edition",import instead,importfunc,742 "Learning Python, 5th Edition",import through,importfunc,742 "Learning Python, 5th Edition",import through,importfunc,742 "Learning Python, 5th Edition",import statement,importfunc,743 "Learning Python, 5th Edition",import or,importfunc,743 "Learning Python, 5th Edition",import instead,importfunc,743 "Learning Python, 5th Edition",import searches,importfunc,743 "Learning Python, 5th Edition",import and,importfunc,746 "Learning Python, 5th Edition",import unders,importfunc,747 "Learning Python, 5th Edition",import alls,importfunc,748 "Learning Python, 5th Edition",import statements,importfunc,748 "Learning Python, 5th Edition",import statement,importfunc,748 "Learning Python, 5th Edition",import and,importfunc,748 "Learning Python, 5th Edition",import even,importfunc,749 "Learning Python, 5th Edition",import a,importfunc,749 "Learning Python, 5th Edition",import and,importfunc,749 "Learning Python, 5th Edition",import runme,importfunc,749 "Learning Python, 5th Edition",import the,importfunc,751 "Learning Python, 5th Edition",import minmax2,importfunc,751 "Learning Python, 5th Edition",import sys,importfunc,752 "Learning Python, 5th Edition","import its",importfunc,753 "Learning Python, 5th Edition",import enables,importfunc,754 "Learning Python, 5th Edition",import formats,importfunc,756 "Learning Python, 5th Edition",import sys,importfunc,757 "Learning Python, 5th Edition",import string,importfunc,757 "Learning Python, 5th Edition",import string,importfunc,757 "Learning Python, 5th Edition",import and,importfunc,758 "Learning Python, 5th Edition",import modulename,importfunc,758 "Learning Python, 5th Edition",import reallylongmodulename,importfunc,758 "Learning Python, 5th Edition",import feature,importfunc,758 "Learning Python, 5th Edition",import to,importfunc,759 "Learning Python, 5th Edition",import mydir,importfunc,760 "Learning Python, 5th Edition",import mydir,importfunc,761 "Learning Python, 5th Edition",import tkinter,importfunc,761 "Learning Python, 5th Edition",import or,importfunc,761 "Learning Python, 5th Edition",import statements,importfunc,761 "Learning Python, 5th Edition",import x,importfunc,762 "Learning Python, 5th Edition",import a,importfunc,762 "Learning Python, 5th Edition",import statement,importfunc,762 "Learning Python, 5th Edition",import statement,importfunc,762 "Learning Python, 5th Edition",import by,importfunc,763 "Learning Python, 5th Edition",import operations,importfunc,763 "Learning Python, 5th Edition",import B,importfunc,763 "Learning Python, 5th Edition",import B,importfunc,763 "Learning Python, 5th Edition",import C,importfunc,763 "Learning Python, 5th Edition",import of,importfunc,763 "Learning Python, 5th Edition",import types,importfunc,764 "Learning Python, 5th Edition",import a,importfunc,765 "Learning Python, 5th Edition",import its,importfunc,765 "Learning Python, 5th Edition",import itself,importfunc,765 "Learning Python, 5th Edition",import b,importfunc,766 "Learning Python, 5th Edition",import c,importfunc,766 "Learning Python, 5th Edition",import a,importfunc,766 "Learning Python, 5th Edition",import types,importfunc,767 "Learning Python, 5th Edition",import types,importfunc,768 "Learning Python, 5th Edition",import tkinter,importfunc,769 "Learning Python, 5th Edition",import os,importfunc,770 "Learning Python, 5th Edition",import operation,importfunc,770 "Learning Python, 5th Edition",import to,importfunc,770 "Learning Python, 5th Edition",import one,importfunc,771 "Learning Python, 5th Edition",import directory,importfunc,771 "Learning Python, 5th Edition",import statements,importfunc,771 "Learning Python, 5th Edition",import its,importfunc,772 "Learning Python, 5th Edition",import to,importfunc,773 "Learning Python, 5th Edition",import nested1,importfunc,773 "Learning Python, 5th Edition",import instead,importfunc,773 "Learning Python, 5th Edition",import its,importfunc,774 "Learning Python, 5th Edition",import and,importfunc,774 "Learning Python, 5th Edition",import module,importfunc,774 "Learning Python, 5th Edition",import statement,importfunc,774 "Learning Python, 5th Edition",import reload,importfunc,775 "Learning Python, 5th Edition",import each,importfunc,775 "Learning Python, 5th Edition",import to,importfunc,775 "Learning Python, 5th Edition",import is,importfunc,775 "Learning Python, 5th Edition",import in,importfunc,775 "Learning Python, 5th Edition",import recur2,importfunc,776 "Learning Python, 5th Edition",import recur1,importfunc,776 "Learning Python, 5th Edition",import recur2,importfunc,776 "Learning Python, 5th Edition",import name,importfunc,776 "Learning Python, 5th Edition",import cycles,importfunc,776 "Learning Python, 5th Edition",import and,importfunc,776 "Learning Python, 5th Edition",import from,importfunc,777 "Learning Python, 5th Edition","import from",importfunc,777 "Learning Python, 5th Edition",import or,importfunc,777 "Learning Python, 5th Edition",import the,importfunc,777 "Learning Python, 5th Edition",import statement,importfunc,777 "Learning Python, 5th Edition",import from,importfunc,777 "Learning Python, 5th Edition",import and,importfunc,778 "Learning Python, 5th Edition",import search,importfunc,779 "Learning Python, 5th Edition",import it,importfunc,779 "Learning Python, 5th Edition",import of,importfunc,779 "Learning Python, 5th Edition",import recur2,importfunc,779 "Learning Python, 5th Edition",import it,importfunc,804 "Learning Python, 5th Edition",import modulename,importfunc,804 "Learning Python, 5th Edition",import person,importfunc,804 "Learning Python, 5th Edition",import person,importfunc,805 "Learning Python, 5th Edition",import modules,importfunc,819 "Learning Python, 5th Edition",import the,importfunc,820 "Learning Python, 5th Edition",import the,importfunc,821 "Learning Python, 5th Edition",import person,importfunc,821 "Learning Python, 5th Edition",import of,importfunc,822 "Learning Python, 5th Edition",import this,importfunc,825 "Learning Python, 5th Edition",import it,importfunc,845 "Learning Python, 5th Edition","import our",importfunc,848 "Learning Python, 5th Edition",import person,importfunc,849 "Learning Python, 5th Edition","import bob",importfunc,849 "Learning Python, 5th Edition",import the,importfunc,849 "Learning Python, 5th Edition",import shelve,importfunc,849 "Learning Python, 5th Edition",import glob,importfunc,850 "Learning Python, 5th Edition",import shelve,importfunc,850 "Learning Python, 5th Edition",import our,importfunc,851 "Learning Python, 5th Edition",import the,importfunc,851 "Learning Python, 5th Edition",import our,importfunc,851 "Learning Python, 5th Edition",import shelve,importfunc,852 "Learning Python, 5th Edition",import shelve,importfunc,852 "Learning Python, 5th Edition",import before,importfunc,874 "Learning Python, 5th Edition",import manynames,importfunc,874 "Learning Python, 5th Edition",import these,importfunc,881 "Learning Python, 5th Edition",import classtree,importfunc,881 "Learning Python, 5th Edition",import docstr,importfunc,882 "Learning Python, 5th Edition","import the",importfunc,900 "Learning Python, 5th Edition",import sys,importfunc,939 "Learning Python, 5th Edition",import converters,importfunc,940 "Learning Python, 5th Edition",import pickle,importfunc,941 "Learning Python, 5th Edition",import pickle,importfunc,941 "Learning Python, 5th Edition",import shelve,importfunc,941 "Learning Python, 5th Edition",import shelve,importfunc,941 "Learning Python, 5th Edition",import pickle,importfunc,941 "Learning Python, 5th Edition",import pickle,importfunc,942 "Learning Python, 5th Edition",import testmixin,importfunc,959 "Learning Python, 5th Edition",import listinstance,importfunc,963 "Learning Python, 5th Edition",import testmixin,importfunc,964 "Learning Python, 5th Edition",import testmixin,importfunc,967 "Learning Python, 5th Edition",import lister,importfunc,974 "Learning Python, 5th Edition",import pprint,importfunc,1004 "Learning Python, 5th Edition",import spam,importfunc,1027 "Learning Python, 5th Edition",import parrot,importfunc,1076 "Learning Python, 5th Edition","import from",importfunc,1088 "Learning Python, 5th Edition",import asserter,importfunc,1113 "Learning Python, 5th Edition",import of,importfunc,1114 "Learning Python, 5th Edition",import decimal,importfunc,1116 "Learning Python, 5th Edition",import sys,importfunc,1118 "Learning Python, 5th Edition",import sys,importfunc,1126 "Learning Python, 5th Edition",import mathlib,importfunc,1130 "Learning Python, 5th Edition",import the,importfunc,1130 "Learning Python, 5th Edition",import exceptions,importfunc,1132 "Learning Python, 5th Edition",import sys,importfunc,1154 "Learning Python, 5th Edition",import the,importfunc,1158 "Learning Python, 5th Edition",import of,importfunc,1158 "Learning Python, 5th Edition",import the,importfunc,1159 "Learning Python, 5th Edition",import hooks,importfunc,1159 "Learning Python, 5th Edition",import sys,importfunc,1178 "Learning Python, 5th Edition",import sys,importfunc,1188 "Learning Python, 5th Edition",import sys,importfunc,1202 "Learning Python, 5th Edition",import codecs,importfunc,1204 "Learning Python, 5th Edition",import sys,importfunc,1205 "Learning Python, 5th Edition",import glob,importfunc,1205 "Learning Python, 5th Edition",import struct,importfunc,1208 "Learning Python, 5th Edition",import struct,importfunc,1208 "Learning Python, 5th Edition",import pickle,importfunc,1209 "Learning Python, 5th Edition",import pickle,importfunc,1210 "Learning Python, 5th Edition",import pickle,importfunc,1211 "Learning Python, 5th Edition",import it,importfunc,1258 "Learning Python, 5th Edition",import with,importfunc,1272 "Learning Python, 5th Edition",import this,importfunc,1283 "Learning Python, 5th Edition",import timer,importfunc,1297 "Learning Python, 5th Edition",import timeit,importfunc,1297 "Learning Python, 5th Edition",import time,importfunc,1299 "Learning Python, 5th Edition",import sys,importfunc,1299 "Learning Python, 5th Edition",import time,importfunc,1345 "Learning Python, 5th Edition",import sys,importfunc,1348 "Learning Python, 5th Edition",import sys,importfunc,1351 "Learning Python, 5th Edition",import this,importfunc,1388 "Learning Python, 5th Edition",import time,importfunc,1400 "Learning Python, 5th Edition","import them",importfunc,1401 "Learning Python, 5th Edition",import this,importfunc,1409 "Learning Python, 5th Edition",import cgi,importfunc,1414 "Learning Python, 5th Edition",import html,importfunc,1414 "Learning Python, 5th Edition",import them,importfunc,1428 "Learning Python, 5th Edition",import search,importfunc,1428 "Learning Python, 5th Edition","import another",importfunc,1428 "Learning Python, 5th Edition",import each,importfunc,1428 "Learning Python, 5th Edition",import these,importfunc,1429 "Learning Python, 5th Edition",import spam,importfunc,1430 "Learning Python, 5th Edition",import search,importfunc,1431 "Learning Python, 5th Edition",import search,importfunc,1431 "Learning Python, 5th Edition",import sys,importfunc,1432 "Learning Python, 5th Edition",import operations,importfunc,1433 "Learning Python, 5th Edition",import pdb,importfunc,1433 "Learning Python, 5th Edition",import sys,importfunc,1433 "Learning Python, 5th Edition",import pdb,importfunc,1435 "Learning Python, 5th Edition",import sys,importfunc,1441 "Learning Python, 5th Edition",import sys,importfunc,1442 "Learning Python, 5th Edition",import sys,importfunc,1445 "Learning Python, 5th Edition",import syntax,importfunc,1460 "Learning Python, 5th Edition",import syntax,importfunc,1463 "Learning Python, 5th Edition",import module1,importfunc,1465 "Learning Python, 5th Edition",import the,importfunc,1465 "Learning Python, 5th Edition",import math,importfunc,1480 "Learning Python, 5th Edition",import it,importfunc,1482 "Learning Python, 5th Edition",import mymod,importfunc,1485 "Learning Python, 5th Edition",import mymod2,importfunc,1486 "Learning Python, 5th Edition",import sys,importfunc,1487 "Learning Python, 5th Edition",import myclient,importfunc,1487 "Learning Python, 5th Edition",import instead,importfunc,1487 "Learning Python, 5th Edition",import myclient,importfunc,1487 "Learning Python, 5th Edition",import all,importfunc,1487 "Learning Python, 5th Edition",import then,importfunc,1488 "Learning Python, 5th Edition",import in,importfunc,1488 "Learning Python, 5th Edition",import from,importfunc,1488 "Learning Python, 5th Edition",import or,importfunc,1489 "Learning Python, 5th Edition",import could,importfunc,1494 "Learning Python, 5th Edition",import oops2,importfunc,1499 "Learning Python, 5th Edition",import search,importfunc,1500 "Learning Python, 5th Edition",import sys,importfunc,1501 "Learning Python, 5th Edition",import os,importfunc,1501 "Learning Python, 5th Edition",import random,importfunc,1501 "Learning Python, 5th Edition",import random,importfunc,1502 "Learning Python, 5th Edition",import cgi,importfunc,1504 "Learning Python, 5th Edition",import shelve,importfunc,1504 "Learning Python, 5th Edition",import shelve,importfunc,1504 "Learning Python, 5th Edition",import statement,importfunc,1518 "Learning Python, 5th Edition",import this,importfunc,1520 "Learning Python, 5th Edition",from imp import reload,importfromsimple,67 "Learning Python, 5th Edition",from imp import reload,importfromsimple,68 "Learning Python, 5th Edition",from myfile import title,importfromsimple,69 "Learning Python, 5th Edition","from accidentally replacing each other. import versus",importfromsimple,71 "Learning Python, 5th Edition","from the interactive prompt without having to import and",importfromsimple,72 "Learning Python, 5th Edition",from fractions import Fraction,importfromsimple,127 "Learning Python, 5th Edition",from __future__ import division,importfromsimple,148 "Learning Python, 5th Edition",from decimal import Decimal,importfromsimple,158 "Learning Python, 5th Edition",from fractions import Fraction,importfromsimple,160 "Learning Python, 5th Edition",from fractions import Fraction,importfromsimple,161 "Learning Python, 5th Edition",from decimal import Decimal,importfromsimple,161 "Learning Python, 5th Edition","from Python’s import this",importfromsimple,217 "Learning Python, 5th Edition",from collections import namedtuple,importfromsimple,281 "Learning Python, 5th Edition",from sys import stdin,importfromsimple,321 "Learning Python, 5th Edition",from __future__ import with_statement,importfromsimple,322 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,367 "Learning Python, 5th Edition",from urllib.request import urlopen,importfromsimple,413 "Learning Python, 5th Edition",from makeopen import makeopen,importfromsimple,518 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,547 "Learning Python, 5th Edition",from print3 import print3,importfromsimple,548 "Learning Python, 5th Edition",from functools import reduce,importfromsimple,577 "Learning Python, 5th Edition",from Python’s import this,importfromsimple,589 "Learning Python, 5th Edition",from scramble import scramble,importfromsimple,612 "Learning Python, 5th Edition",from scramble import scramble,importfromsimple,613 "Learning Python, 5th Edition",from Python’s import this,importfromsimple,614 "Learning Python, 5th Edition",from timer0 import timer,importfromsimple,630 "Learning Python, 5th Edition",from timeit import repeat,importfromsimple,646 "Learning Python, 5th Edition",from ZIP archives: archived files are automatically extracted at import time,importfromsimple,684 "Learning Python, 5th Edition",from the module import search,importfromsimple,684 "Learning Python, 5th Edition",from module1 import printer,importfromsimple,689 "Learning Python, 5th Edition",from M import func,importfromsimple,694 "Learning Python, 5th Edition",from N import func,importfromsimple,694 "Learning Python, 5th Edition",from imp import reload,importfromsimple,701 "Learning Python, 5th Edition",from imp import reload,importfromsimple,702 "Learning Python, 5th Edition",from dir1.dir2.mod import x,importfromsimple,708 "Learning Python, 5th Edition","from statements. These import statements",importfromsimple,709 "Learning Python, 5th Edition",from submodule import X,importfromsimple,711 "Learning Python, 5th Edition",from imp import reload,importfromsimple,712 "Learning Python, 5th Edition","from Versus import with Packages import statements",importfromsimple,713 "Learning Python, 5th Edition",from dir1.dir2 import mod,importfromsimple,713 "Learning Python, 5th Edition",from dir1.dir2.mod import z,importfromsimple,713 "Learning Python, 5th Edition",from email.message import Message,importfromsimple,717 "Learning Python, 5th Edition",from tkinter.filedialog import askopenfilename,importfromsimple,717 "Learning Python, 5th Edition",from http.server import CGIHTTPRequestHandler,importfromsimple,717 "Learning Python, 5th Edition",from dotted syntax to import modules,importfromsimple,718 "Learning Python, 5th Edition",from __future__ import absolute_import # Use 3.X relative import model,importfromsimple,719 "Learning Python, 5th Edition",from string import name,importfromsimple,721 "Learning Python, 5th Edition",from mypkg import string,importfromsimple,722 "Learning Python, 5th Edition",from system.section.mypkg import string,importfromsimple,722 "Learning Python, 5th Edition",from m import x,importfromsimple,723 "Learning Python, 5th Edition",from system.section.mypkg import mod,importfromsimple,729 "Learning Python, 5th Edition",from mod import attr,importfromsimple,734 "Learning Python, 5th Edition",from dir1.mod import attr,importfromsimple,734 "Learning Python, 5th Edition",from sub import mod1,importfromsimple,737 "Learning Python, 5th Edition",from mypkg import spam,importfromsimple,742 "Learning Python, 5th Edition",from mypkg import spam,importfromsimple,743 "Learning Python, 5th Edition",from __future__ import featurename,importfromsimple,748 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,754 "Learning Python, 5th Edition",from formats import money,importfromsimple,754 "Learning Python, 5th Edition","from Both the import and",importfromsimple,758 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,760 "Learning Python, 5th Edition",from imp import reload,importfromsimple,763 "Learning Python, 5th Edition",from imp import reload,importfromsimple,764 "Learning Python, 5th Edition",from reloadall import reload_all,importfromsimple,766 "Learning Python, 5th Edition",from imp import reload,importfromsimple,767 "Learning Python, 5th Edition",from reloadall import reload_all,importfromsimple,767 "Learning Python, 5th Edition",from imp import reload,importfromsimple,767 "Learning Python, 5th Edition",from imp import reload,importfromsimple,768 "Learning Python, 5th Edition",from module import X,importfromsimple,774 "Learning Python, 5th Edition",from imp import reload,importfromsimple,774 "Learning Python, 5th Edition",from imp import reload,importfromsimple,774 "Learning Python, 5th Edition",from module import function,importfromsimple,774 "Learning Python, 5th Edition",from imp import reload,importfromsimple,774 "Learning Python, 5th Edition","from imp import reload import module",importfromsimple,774 "Learning Python, 5th Edition","from imp import reload import module",importfromsimple,775 "Learning Python, 5th Edition",from module import function,importfromsimple,775 "Learning Python, 5th Edition",from recur1 import X,importfromsimple,776 "Learning Python, 5th Edition",from recur1 import Y,importfromsimple,776 "Learning Python, 5th Edition",from recur1 import Y,importfromsimple,776 "Learning Python, 5th Edition",from modulename import FirstClass,importfromsimple,804 "Learning Python, 5th Edition",from person import person,importfromsimple,804 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,822 "Learning Python, 5th Edition",from person import Person,importfromsimple,841 "Learning Python, 5th Edition",from person import Person,importfromsimple,843 "Learning Python, 5th Edition",from classtools import AttrDisplay,importfromsimple,845 "Learning Python, 5th Edition",from person import Person,importfromsimple,849 "Learning Python, 5th Edition",from number import Number,importfromsimple,888 "Learning Python, 5th Edition",from squares import Squares,importfromsimple,896 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,900 "Learning Python, 5th Edition",from squares_yield import Squares,importfromsimple,902 "Learning Python, 5th Edition",from squares_manual import Squares,importfromsimple,903 "Learning Python, 5th Edition",from squares_yield import Squares,importfromsimple,904 "Learning Python, 5th Edition",from squares_nonyield import Squares,importfromsimple,905 "Learning Python, 5th Edition",from skipper_yield import SkipObject,importfromsimple,906 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,907 "Learning Python, 5th Edition",from contains import Iters,importfromsimple,909 "Learning Python, 5th Edition",from commuter import Commuter1,importfromsimple,918 "Learning Python, 5th Edition",from commuter import Commuter5,importfromsimple,919 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,920 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,935 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,937 "Learning Python, 5th Edition",from streams import Processor,importfromsimple,939 "Learning Python, 5th Edition",from converters import Uppercase,importfromsimple,940 "Learning Python, 5th Edition",from pizzashop import PizzaShop,importfromsimple,941 "Learning Python, 5th Edition",from trace import Wrapper,importfromsimple,943 "Learning Python, 5th Edition","from config file... import streamtypes",importfromsimple,956 "Learning Python, 5th Edition",from listinstance import ListInstance,importfromsimple,960 "Learning Python, 5th Edition",from listinstance import ListInstance,importfromsimple,961 "Learning Python, 5th Edition",from listtree import ListTree,importfromsimple,973 "Learning Python, 5th Edition",from tkinter import Button,importfromsimple,973 "Learning Python, 5th Edition",from listinstance import ListInstance,importfromsimple,974 "Learning Python, 5th Edition",from listinherited import ListInherited,importfromsimple,974 "Learning Python, 5th Edition",from listtree import ListTree,importfromsimple,974 "Learning Python, 5th Edition",from lister import Lister,importfromsimple,974 "Learning Python, 5th Edition",from setwrapper import Set,importfromsimple,981 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,982 "Learning Python, 5th Edition",from testmixin0 import Sub,importfromsimple,1007 "Learning Python, 5th Edition","from __future__ import print_function import timeit",importfromsimple,1019 "Learning Python, 5th Edition",from spam import Spam,importfromsimple,1026 "Learning Python, 5th Edition",from spam import Spam,importfromsimple,1027 "Learning Python, 5th Edition",from spam import Spam,importfromsimple,1028 "Learning Python, 5th Edition",from bothmethods import Methods,importfromsimple,1029 "Learning Python, 5th Edition",from spam_static import Spam,importfromsimple,1030 "Learning Python, 5th Edition",from spam_class import Spam,importfromsimple,1032 "Learning Python, 5th Edition",from spam_static_deco import Spam,importfromsimple,1036 "Learning Python, 5th Edition",from bothmethods_decorators import Methods,importfromsimple,1036 "Learning Python, 5th Edition",from its import this,importfromsimple,1063 "Learning Python, 5th Edition",from __future__ import with_statement,importfromsimple,1114 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1138 "Learning Python, 5th Edition",from struct import pack,importfromsimple,1207 "Learning Python, 5th Edition",from struct import pack,importfromsimple,1208 "Learning Python, 5th Edition",from xml.etree.ElementTree import parse,importfromsimple,1213 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1258 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1261 "Learning Python, 5th Edition",from validate_tester import loadclass,importfromsimple,1261 "Learning Python, 5th Edition",from validate_descriptors1 import CardHolder,importfromsimple,1263 "Learning Python, 5th Edition",from validate_descriptors2 import CardHolder,importfromsimple,1263 "Learning Python, 5th Edition",from decorator1 import spam,importfromsimple,1284 "Learning Python, 5th Edition",from timerdeco2 import timer,importfromsimple,1299 "Learning Python, 5th Edition",from timerdeco2 import timer,importfromsimple,1300 "Learning Python, 5th Edition",from interfacetracer import Tracer,importfromsimple,1306 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1312 "Learning Python, 5th Edition",from access2 import Private,importfromsimple,1323 "Learning Python, 5th Edition",from access2 import Private,importfromsimple,1323 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1332 "Learning Python, 5th Edition",from rangetest1 import rangetest,importfromsimple,1332 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1334 "Learning Python, 5th Edition",from rangetest import rangetest,importfromsimple,1334 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1345 "Learning Python, 5th Edition","from timerdeco import timer import sys",importfromsimple,1345 "Learning Python, 5th Edition",from access_builtins import BuiltinsMixin,importfromsimple,1347 "Learning Python, 5th Edition",from argtest_testmeth import C,importfromsimple,1353 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1372 "Learning Python, 5th Edition",from decotools import tracer,importfromsimple,1401 "Learning Python, 5th Edition",from types import FunctionType,importfromsimple,1402 "Learning Python, 5th Edition",from decotools import tracer,importfromsimple,1402 "Learning Python, 5th Edition",from types import FunctionType,importfromsimple,1403 "Learning Python, 5th Edition",from types import FunctionType,importfromsimple,1404 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1414 "Learning Python, 5th Edition",from math import sqrt,importfromsimple,1481 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1484 "Learning Python, 5th Edition",from functools import reduce,importfromsimple,1484 "Learning Python, 5th Edition","from timeit import repeat import math",importfromsimple,1484 "Learning Python, 5th Edition",from myclient import countChars,importfromsimple,1487 "Learning Python, 5th Edition",from myclient import mymod,importfromsimple,1487 "Learning Python, 5th Edition",from collector import somename,importfromsimple,1488 "Learning Python, 5th Edition",from mypkg.mymod import countChars,importfromsimple,1488 "Learning Python, 5th Edition","from recur1, but because it uses import instead",importfromsimple,1488 "Learning Python, 5th Edition",from mylist import MyList,importfromsimple,1492 "Learning Python, 5th Edition",from setwrapper import Set,importfromsimple,1493 "Learning Python, 5th Edition",from setwrapper import Set,importfromsimple,1494 "Learning Python, 5th Edition",from __future__ import print_function,importfromsimple,1498 "Learning Python, 5th Edition",from MySQLdb import Connect,importfromsimple,1505 "Learning Python, 5th Edition",from getpass import getpass,importfromsimple,1505 "Learning Python, 5th Edition",self.name = name # self is the new object,simpleattr,129 "Learning Python, 5th Edition",self.pay = pay,simpleattr,129 "Learning Python, 5th Edition",self.pay *= (1.0 + percent) # Update pay in place,simpleattr,129 "Learning Python, 5th Edition",self.state = start # save state explicitly in new object,simpleattr,514 "Learning Python, 5th Edition",self.state += 1 # Changes are always allowed,simpleattr,514 "Learning Python, 5th Edition",self.state = start,simpleattr,514 "Learning Python, 5th Edition",self.state += 1,simpleattr,514 "Learning Python, 5th Edition",self.id = id,simpleattr,518 "Learning Python, 5th Edition",self.original = builtins.open,simpleattr,518 "Learning Python, 5th Edition","self.name='bob'). Moreover, if classes are not used, global variables are often the most",simpleattr,554 "Learning Python, 5th Edition",self.name = who # Self is either I1 or I2,simpleattr,790 "Learning Python, 5th Edition",self.name = who # Self is either I1 or I2,simpleattr,791 "Learning Python, 5th Edition",self.data = value # self is the instance,simpleattr,799 "Learning Python, 5th Edition",self.data = value,simpleattr,806 "Learning Python, 5th Edition",self.data *= other,simpleattr,807 "Learning Python, 5th Edition",self.name = name,simpleattr,813 "Learning Python, 5th Edition",self.jobs = jobs,simpleattr,813 "Learning Python, 5th Edition",self.age = age,simpleattr,813 "Learning Python, 5th Edition",self.name = name # Fill out fields when created,simpleattr,818 "Learning Python, 5th Edition",self.job = job # self is the new instance object,simpleattr,818 "Learning Python, 5th Edition",self.pay = pay,simpleattr,818 "Learning Python, 5th Edition","self.job=job, we save the passed-in job on the instance for later use. As usual in Python,",simpleattr,819 "Learning Python, 5th Edition",self.name = name,simpleattr,819 "Learning Python, 5th Edition",self.job = job,simpleattr,819 "Learning Python, 5th Edition",self.pay = pay,simpleattr,819 "Learning Python, 5th Edition",self.name = name,simpleattr,820 "Learning Python, 5th Edition",self.job = job,simpleattr,820 "Learning Python, 5th Edition",self.pay = pay,simpleattr,820 "Learning Python, 5th Edition",self.name = name,simpleattr,821 "Learning Python, 5th Edition",self.job = job,simpleattr,821 "Learning Python, 5th Edition",self.pay = pay,simpleattr,821 "Learning Python, 5th Edition",self.name = name,simpleattr,823 "Learning Python, 5th Edition",self.job = job,simpleattr,823 "Learning Python, 5th Edition",self.pay = pay,simpleattr,823 "Learning Python, 5th Edition",self.name = name,simpleattr,824 "Learning Python, 5th Edition",self.job = job,simpleattr,824 "Learning Python, 5th Edition",self.pay = pay,simpleattr,824 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)) # Must change here only,simpleattr,824 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,826 "Learning Python, 5th Edition",self.name = name,simpleattr,827 "Learning Python, 5th Edition",self.job = job,simpleattr,827 "Learning Python, 5th Edition",self.pay = pay,simpleattr,827 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,827 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent + bonus)) # Bad: cut and paste,simpleattr,829 "Learning Python, 5th Edition",self.name = name,simpleattr,830 "Learning Python, 5th Edition",self.job = job,simpleattr,830 "Learning Python, 5th Edition",self.pay = pay,simpleattr,830 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,830 "Learning Python, 5th Edition",self.name = name,simpleattr,834 "Learning Python, 5th Edition",self.job = job,simpleattr,835 "Learning Python, 5th Edition",self.pay = pay,simpleattr,835 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,835 "Learning Python, 5th Edition","self.person = Person(name, 'mgr', pay) # Embed a Person object",simpleattr,837 "Learning Python, 5th Edition",self.members = list(args),simpleattr,838 "Learning Python, 5th Edition",self.attr1 = TopTest.count,simpleattr,842 "Learning Python, 5th Edition",self.attr2 = TopTest.count+1,simpleattr,842 "Learning Python, 5th Edition",self.name = name,simpleattr,845 "Learning Python, 5th Edition",self.job = job,simpleattr,845 "Learning Python, 5th Edition",self.pay = pay,simpleattr,845 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,846 "Learning Python, 5th Edition",self.attr = value # Per-instance data,simpleattr,860 "Learning Python, 5th Edition",self.data = value # Assign instance attr,simpleattr,861 "Learning Python, 5th Edition",self.message = text # Change instance,simpleattr,863 "Learning Python, 5th Edition",self.X = 55 # Instance attribute (instance.X),simpleattr,873 "Learning Python, 5th Edition",self.X = 5 # Hides class,simpleattr,877 "Learning Python, 5th Edition",self.data1 = 'spam',simpleattr,878 "Learning Python, 5th Edition",self.data2 = 'eggs',simpleattr,878 "Learning Python, 5th Edition",self.data = start,simpleattr,888 "Learning Python, 5th Edition",self.data[index] = value # Assign index or slice,simpleattr,893 "Learning Python, 5th Edition",self.value = start - 1,simpleattr,896 "Learning Python, 5th Edition",self.stop = stop,simpleattr,896 "Learning Python, 5th Edition",self.value += 1,simpleattr,896 "Learning Python, 5th Edition",self.wrapped = wrapped,simpleattr,900 "Learning Python, 5th Edition",self.wrapped = wrapped # Iterator state information,simpleattr,900 "Learning Python, 5th Edition",self.offset = 0,simpleattr,900 "Learning Python, 5th Edition",self.offset += 2,simpleattr,900 "Learning Python, 5th Edition",self.start = start,simpleattr,902 "Learning Python, 5th Edition",self.stop = stop,simpleattr,902 "Learning Python, 5th Edition",self.start = start # Multiscans: extra object,simpleattr,905 "Learning Python, 5th Edition",self.stop = stop,simpleattr,905 "Learning Python, 5th Edition",self.value = start - 1,simpleattr,905 "Learning Python, 5th Edition",self.stop = stop,simpleattr,905 "Learning Python, 5th Edition",self.value += 1,simpleattr,905 "Learning Python, 5th Edition",self.wrapped = wrapped # Local scope state saved auto,simpleattr,906 "Learning Python, 5th Edition",self.data = value,simpleattr,907 "Learning Python, 5th Edition",self.ix = 0,simpleattr,907 "Learning Python, 5th Edition",self.ix += 1,simpleattr,907 "Learning Python, 5th Edition",self.data = value,simpleattr,908 "Learning Python, 5th Edition",self.age = value + 10 # Loops,simpleattr,911 "Learning Python, 5th Edition",self.other = 99 # Recurs but doesn't loop: fails,simpleattr,911 "Learning Python, 5th Edition",self.data = value # Initialize data,simpleattr,913 "Learning Python, 5th Edition",self.data += other # Add other in place (bad form?),simpleattr,914 "Learning Python, 5th Edition",self.val = val,simpleattr,916 "Learning Python, 5th Edition",self.val = val,simpleattr,916 "Learning Python, 5th Edition",self.data = value,simpleattr,917 "Learning Python, 5th Edition",self.val = val,simpleattr,917 "Learning Python, 5th Edition",self.val = val,simpleattr,918 "Learning Python, 5th Edition",self.val = val,simpleattr,918 "Learning Python, 5th Edition",self.val = val,simpleattr,919 "Learning Python, 5th Edition",self.val = val,simpleattr,919 "Learning Python, 5th Edition",self.val = val,simpleattr,921 "Learning Python, 5th Edition",self.val += other # Usually returns self,simpleattr,921 "Learning Python, 5th Edition",self.val = val,simpleattr,921 "Learning Python, 5th Edition",self.value = value,simpleattr,922 "Learning Python, 5th Edition",self.value = value,simpleattr,923 "Learning Python, 5th Edition",self.color = color,simpleattr,923 "Learning Python, 5th Edition",self.color = color,simpleattr,925 "Learning Python, 5th Edition",self.name = name,simpleattr,929 "Learning Python, 5th Edition",self.name = name,simpleattr,935 "Learning Python, 5th Edition",self.salary = salary,simpleattr,935 "Learning Python, 5th Edition",self.salary = self.salary + (self.salary * percent),simpleattr,935 "Learning Python, 5th Edition",self.name = name,simpleattr,937 "Learning Python, 5th Edition",self.server = Server('Pat') # Embed other objects,simpleattr,937 "Learning Python, 5th Edition",self.chef = PizzaRobot('Bob') # A robot named bob,simpleattr,937 "Learning Python, 5th Edition",self.oven = Oven(),simpleattr,937 "Learning Python, 5th Edition",self.reader = reader,simpleattr,939 "Learning Python, 5th Edition",self.writer = writer,simpleattr,939 "Learning Python, 5th Edition",self.wrapped = object # Save object,simpleattr,942 "Learning Python, 5th Edition","self.attr = value), it changes or creates an attribute in the instance (recall that inher-",simpleattr,945 "Learning Python, 5th Edition",self.method = 99 # Doesn't break Tool.__method,simpleattr,947 "Learning Python, 5th Edition",self.data = data,simpleattr,950 "Learning Python, 5th Edition",self.base = base,simpleattr,951 "Learning Python, 5th Edition",self.val = val,simpleattr,952 "Learning Python, 5th Edition",self.val = val,simpleattr,952 "Learning Python, 5th Edition","self.val = -val # But called for object, not work",simpleattr,953 "Learning Python, 5th Edition",self.name = name,simpleattr,955 "Learning Python, 5th Edition",self.job = job,simpleattr,955 "Learning Python, 5th Edition","self.data1 = ""food""",simpleattr,958 "Learning Python, 5th Edition",self.__attrnames()) # name=value list,simpleattr,959 "Learning Python, 5th Edition",self.data1 = 'food',simpleattr,960 "Learning Python, 5th Edition",self.data1 = 'spam' # Create instance attrs,simpleattr,961 "Learning Python, 5th Edition",self.data2 = 'eggs' # More instance attrs,simpleattr,961 "Learning Python, 5th Edition",self.data3 = 42,simpleattr,961 "Learning Python, 5th Edition",self.data1 = 'spam' # Create instance attrs,simpleattr,962 "Learning Python, 5th Edition",self.data2 = 'eggs' # More instance attrs,simpleattr,962 "Learning Python, 5th Edition",self.data3 = 42,simpleattr,962 "Learning Python, 5th Edition",self.__attrnames()) # name=value list,simpleattr,964 "Learning Python, 5th Edition",self.__visited[aClass] = True,simpleattr,967 "Learning Python, 5th Edition",self.__visited = {},simpleattr,967 "Learning Python, 5th Edition",self.__visited[aClass] = True,simpleattr,968 "Learning Python, 5th Edition",self.data = [] # Manages a list,simpleattr,980 "Learning Python, 5th Edition",self.name = 'Bob';,simpleattr,1009 "Learning Python, 5th Edition",self.c = data,simpleattr,1015 "Learning Python, 5th Edition",self._age = value,simpleattr,1021 "Learning Python, 5th Edition",self.calls = 0,simpleattr,1037 "Learning Python, 5th Edition",self.func = func,simpleattr,1037 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1037 "Learning Python, 5th Edition",self.wrapped = cls(*args),simpleattr,1039 "Learning Python, 5th Edition",self.name = name,simpleattr,1060 "Learning Python, 5th Edition",self.salary = salary,simpleattr,1060 "Learning Python, 5th Edition",self.perobj = [] # Instance attribute,simpleattr,1066 "Learning Python, 5th Edition",self.line = line,simpleattr,1137 "Learning Python, 5th Edition",self.file = file,simpleattr,1137 "Learning Python, 5th Edition",self.line = line,simpleattr,1138 "Learning Python, 5th Edition",self.file = file,simpleattr,1138 "Learning Python, 5th Edition",self.inTitle = False,simpleattr,1212 "Learning Python, 5th Edition",self.name = transform(value),simpleattr,1220 "Learning Python, 5th Edition",self._name = name,simpleattr,1222 "Learning Python, 5th Edition",self._name = value,simpleattr,1222 "Learning Python, 5th Edition",self.value = start,simpleattr,1224 "Learning Python, 5th Edition",self.value = value,simpleattr,1224 "Learning Python, 5th Edition",self._name = name,simpleattr,1225 "Learning Python, 5th Edition",self._name = value,simpleattr,1225 "Learning Python, 5th Edition",self._name = name,simpleattr,1230 "Learning Python, 5th Edition",self._name = name,simpleattr,1231 "Learning Python, 5th Edition",self._name = name,simpleattr,1231 "Learning Python, 5th Edition",self.value = start,simpleattr,1232 "Learning Python, 5th Edition",self.value = value # No delete or docs,simpleattr,1232 "Learning Python, 5th Edition",self.value = value,simpleattr,1233 "Learning Python, 5th Edition",self.value = value,simpleattr,1233 "Learning Python, 5th Edition",self.Z = 4 # Instance attr,simpleattr,1233 "Learning Python, 5th Edition",self._X = 2 # Instance attr,simpleattr,1234 "Learning Python, 5th Edition",self.Z = 4 # Instance attr,simpleattr,1234 "Learning Python, 5th Edition",self.data = data,simpleattr,1235 "Learning Python, 5th Edition",self.data = data,simpleattr,1235 "Learning Python, 5th Edition",self.fget = fget,simpleattr,1236 "Learning Python, 5th Edition",self.fset = fset,simpleattr,1236 "Learning Python, 5th Edition",self.fdel = fdel # Save unbound methods,simpleattr,1236 "Learning Python, 5th Edition",self.__doc__ = doc # or other callables,simpleattr,1236 "Learning Python, 5th Edition",self.wrapped = object # Save object,simpleattr,1239 "Learning Python, 5th Edition",self.other = value # Recurs (and might LOOP!),simpleattr,1240 "Learning Python, 5th Edition",self._name = name # Triggers __setattr__!,simpleattr,1241 "Learning Python, 5th Edition",self.value = start # Triggers __setattr__!,simpleattr,1243 "Learning Python, 5th Edition",self.value = start # Triggers __setattr__!,simpleattr,1244 "Learning Python, 5th Edition",self.value=start inside the constructor triggers __setattr__,simpleattr,1244 "Learning Python, 5th Edition",self.attr2 = 2,simpleattr,1245 "Learning Python, 5th Edition",self.attr2 = 2,simpleattr,1245 "Learning Python, 5th Edition",self._square = square # _square is the base value,simpleattr,1246 "Learning Python, 5th Edition",self._cube = cube # square is the property name,simpleattr,1246 "Learning Python, 5th Edition",self._square = value,simpleattr,1246 "Learning Python, 5th Edition","self._square = square # ""self.square = square"" works too,",simpleattr,1247 "Learning Python, 5th Edition",self._cube = cube # because it triggers desc __set__!,simpleattr,1247 "Learning Python, 5th Edition",self._square = square,simpleattr,1247 "Learning Python, 5th Edition",self._cube = cube,simpleattr,1247 "Learning Python, 5th Edition",self._square = square,simpleattr,1248 "Learning Python, 5th Edition",self._cube = cube,simpleattr,1248 "Learning Python, 5th Edition",self.spam = 77,simpleattr,1250 "Learning Python, 5th Edition","self.spam = 77 # incl __getattribute__, some __X__ defaults",simpleattr,1250 "Learning Python, 5th Edition",self.name = name,simpleattr,1253 "Learning Python, 5th Edition",self.job = job,simpleattr,1253 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1253 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1253 "Learning Python, 5th Edition","self.person = Person(name, 'mgr', pay) # Embed a Person object",simpleattr,1253 "Learning Python, 5th Edition","self.person = Person(name, 'mgr', pay) # Embed a Person object",simpleattr,1254 "Learning Python, 5th Edition","self.person = Person(name, 'mgr', pay) # Embed a Person object",simpleattr,1255 "Learning Python, 5th Edition","self.person = Person(name, 'mgr', pay)",simpleattr,1255 "Learning Python, 5th Edition",self.acct = acct # Instance data,simpleattr,1257 "Learning Python, 5th Edition",self.name = name # These trigger prop setters too!,simpleattr,1257 "Learning Python, 5th Edition",self.age = age # __X mangled to have class name,simpleattr,1257 "Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1257 "Learning Python, 5th Edition",self.__name = value,simpleattr,1257 "Learning Python, 5th Edition",self.__age = value,simpleattr,1257 "Learning Python, 5th Edition",self.__acct = value,simpleattr,1258 "Learning Python, 5th Edition",self.acct = acct # Instance data,simpleattr,1260 "Learning Python, 5th Edition",self.name = name # These trigger __set__ calls too!,simpleattr,1260 "Learning Python, 5th Edition",self.age = age # __X not needed: in descriptor,simpleattr,1260 "Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1260 "Learning Python, 5th Edition",self.name = value,simpleattr,1260 "Learning Python, 5th Edition",self.age = value,simpleattr,1260 "Learning Python, 5th Edition",self.acct = value,simpleattr,1260 "Learning Python, 5th Edition",self.acct = acct # Client instance data,simpleattr,1262 "Learning Python, 5th Edition",self.name = name # These trigger __set__ calls too!,simpleattr,1262 "Learning Python, 5th Edition",self.age = age # __X needed: in client instance,simpleattr,1262 "Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1262 "Learning Python, 5th Edition",self.acct = acct # Instance data,simpleattr,1264 "Learning Python, 5th Edition",self.name = name # These trigger __setattr__ too,simpleattr,1264 "Learning Python, 5th Edition",self.age = age # _acct not mangled: name tested,simpleattr,1264 "Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1264 "Learning Python, 5th Edition",self.acct = acct # Instance data,simpleattr,1265 "Learning Python, 5th Edition",self.name = name # These trigger __setattr__ too,simpleattr,1265 "Learning Python, 5th Edition",self.age = age # acct not mangled: name tested,simpleattr,1265 "Learning Python, 5th Edition",self.addr = addr # addr is not managed,simpleattr,1265 "Learning Python, 5th Edition",self.func = func,simpleattr,1275 "Learning Python, 5th Edition",self.func = func,simpleattr,1275 "Learning Python, 5th Edition",self.wrapped = cls(*args),simpleattr,1278 "Learning Python, 5th Edition",self.attr = 'spam',simpleattr,1278 "Learning Python, 5th Edition",self.C = C,simpleattr,1279 "Learning Python, 5th Edition",self.wrapped = self.C(*args),simpleattr,1279 "Learning Python, 5th Edition",self.wrapped = C(*args) # Embed instance in instance,simpleattr,1279 "Learning Python, 5th Edition",self.calls = 0,simpleattr,1283 "Learning Python, 5th Edition",self.func = func,simpleattr,1283 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1283 "Learning Python, 5th Edition",self.calls = 0 # Save func for later call,simpleattr,1285 "Learning Python, 5th Edition",self.func = func,simpleattr,1285 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1285 "Learning Python, 5th Edition",self.calls = 0 # Save func for later call,simpleattr,1289 "Learning Python, 5th Edition",self.func = func,simpleattr,1289 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1289 "Learning Python, 5th Edition",self.name = name,simpleattr,1290 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1290 "Learning Python, 5th Edition",self.pay *= (1.0 + percent),simpleattr,1290 "Learning Python, 5th Edition",self.name = name,simpleattr,1291 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1291 "Learning Python, 5th Edition",self.pay *= (1.0 + percent) # onCall remembers giveRaise,simpleattr,1292 "Learning Python, 5th Edition",self.calls = 0 # Save func for later call,simpleattr,1293 "Learning Python, 5th Edition",self.func = func,simpleattr,1293 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1293 "Learning Python, 5th Edition",self.desc = desc # Route calls back to deco/desc,simpleattr,1293 "Learning Python, 5th Edition",self.subj = subj,simpleattr,1293 "Learning Python, 5th Edition",self.calls = 0 # Save func for later call,simpleattr,1294 "Learning Python, 5th Edition",self.func = func,simpleattr,1294 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1294 "Learning Python, 5th Edition",self.calls = 0,simpleattr,1295 "Learning Python, 5th Edition",self.meth = meth,simpleattr,1295 "Learning Python, 5th Edition",self.calls += 1,simpleattr,1295 "Learning Python, 5th Edition",self.func = func,simpleattr,1295 "Learning Python, 5th Edition",self.alltime = 0,simpleattr,1295 "Learning Python, 5th Edition",self.alltime += elapsed,simpleattr,1296 "Learning Python, 5th Edition",self.func = func,simpleattr,1299 "Learning Python, 5th Edition",self.alltime = 0,simpleattr,1299 "Learning Python, 5th Edition",self.alltime += elapsed,simpleattr,1299 "Learning Python, 5th Edition",self.name = name,simpleattr,1302 "Learning Python, 5th Edition",self.hours = hours,simpleattr,1302 "Learning Python, 5th Edition",self.rate = rate,simpleattr,1302 "Learning Python, 5th Edition",self.attr = val,simpleattr,1302 "Learning Python, 5th Edition",self.aClass = aClass,simpleattr,1303 "Learning Python, 5th Edition",self.instance = None,simpleattr,1303 "Learning Python, 5th Edition",self.wrapped = object # Save object,simpleattr,1304 "Learning Python, 5th Edition",self.fetches = 0,simpleattr,1304 "Learning Python, 5th Edition","self.wrapped = aClass(*args, **kargs) # Use enclosing scope name",simpleattr,1305 "Learning Python, 5th Edition",self.fetches += 1,simpleattr,1305 "Learning Python, 5th Edition",self.name = name,simpleattr,1305 "Learning Python, 5th Edition",self.hours = hours,simpleattr,1305 "Learning Python, 5th Edition",self.rate = rate,simpleattr,1305 "Learning Python, 5th Edition",self.aClass = aClass # Use instance attribute,simpleattr,1308 "Learning Python, 5th Edition",self.wrapped = self.aClass(*args) # ONE (LAST) INSTANCE PER CLASS!,simpleattr,1308 "Learning Python, 5th Edition",self.name = name,simpleattr,1308 "Learning Python, 5th Edition",self.data = x ** 4,simpleattr,1312 "Learning Python, 5th Edition","self.wrapped = aClass(*args, **kargs)",simpleattr,1315 "Learning Python, 5th Edition",self.label = label # Accesses inside the subject class,simpleattr,1316 "Learning Python, 5th Edition",self.data = start # Not intercepted: run normally,simpleattr,1316 "Learning Python, 5th Edition",self.data[i] = self.data[i] * 2,simpleattr,1316 "Learning Python, 5th Edition","self.__wrapped = aClass(*args, **kargs)",simpleattr,1319 "Learning Python, 5th Edition",self.name = name,simpleattr,1320 "Learning Python, 5th Edition",self.age = age # Inside accesses run normally,simpleattr,1320 "Learning Python, 5th Edition",self.name = name,simpleattr,1320 "Learning Python, 5th Edition",self.age = age,simpleattr,1320 "Learning Python, 5th Edition",self.age = 42,simpleattr,1323 "Learning Python, 5th Edition",self.age += yrs,simpleattr,1323 "Learning Python, 5th Edition",self.age = 42,simpleattr,1323 "Learning Python, 5th Edition",self.age += yrs,simpleattr,1323 "Learning Python, 5th Edition","self.__wrapped = aClass(*args, **kargs)",simpleattr,1324 "Learning Python, 5th Edition",self.attrname = attrname,simpleattr,1326 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1330 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1330 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1330 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1331 "Learning Python, 5th Edition",self.job = job,simpleattr,1332 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1332 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1332 "Learning Python, 5th Edition",self.job = job,simpleattr,1335 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1335 "Learning Python, 5th Edition",self.pay = int(self.pay * (1 + percent)),simpleattr,1335 "Learning Python, 5th Edition",self.name = name,simpleattr,1346 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1346 "Learning Python, 5th Edition",self.pay *= (1.0 + percent) # tracer remembers giveRaise,simpleattr,1346 "Learning Python, 5th Edition","self.__wrapped = aClass(*args, **kargs)",simpleattr,1347 "Learning Python, 5th Edition",self.name = name,simpleattr,1349 "Learning Python, 5th Edition",self.age = age # Inside accesses run normally,simpleattr,1349 "Learning Python, 5th Edition",self.age += N # Built-ins caught by mix-in in 3.X,simpleattr,1349 "Learning Python, 5th Edition",self.value = value,simpleattr,1392 "Learning Python, 5th Edition",self.value = value,simpleattr,1393 "Learning Python, 5th Edition",self.value = value,simpleattr,1395 "Learning Python, 5th Edition","self.wrapped = aClass(*args, **kargs) # Use enclosing scope name",simpleattr,1396 "Learning Python, 5th Edition",self.name = name,simpleattr,1396 "Learning Python, 5th Edition",self.hours = hours,simpleattr,1396 "Learning Python, 5th Edition",self.rate = rate # In-method fetch not traced,simpleattr,1396 "Learning Python, 5th Edition","self.wrapped = aClass(*args, **kargs)",simpleattr,1397 "Learning Python, 5th Edition",self.name = name,simpleattr,1397 "Learning Python, 5th Edition",self.hours = hours,simpleattr,1397 "Learning Python, 5th Edition",self.rate = rate # In-method fetch not traced,simpleattr,1397 "Learning Python, 5th Edition",self.name = name,simpleattr,1401 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1401 "Learning Python, 5th Edition",self.pay *= (1.0 + percent) # onCall remembers giveRaise,simpleattr,1401 "Learning Python, 5th Edition",self.name = name,simpleattr,1402 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1402 "Learning Python, 5th Edition",self.pay *= (1.0 + percent),simpleattr,1402 "Learning Python, 5th Edition",self.name = name,simpleattr,1403 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1403 "Learning Python, 5th Edition",self.pay *= (1.0 + percent),simpleattr,1403 "Learning Python, 5th Edition",self.name = name # Person = DecoDecorate(Person),simpleattr,1405 "Learning Python, 5th Edition",self.pay = pay,simpleattr,1405 "Learning Python, 5th Edition",self.pay *= (1.0 + percent),simpleattr,1405 "Learning Python, 5th Edition",self.data = start,simpleattr,1489 "Learning Python, 5th Edition",self.data = start,simpleattr,1490 "Learning Python, 5th Edition",self.wrapped = start[:] # Copy start: no side effects,simpleattr,1491 "Learning Python, 5th Edition",self.wrapped = list(start) # Make sure it's a list here,simpleattr,1491 "Learning Python, 5th Edition",self.adds = 0 # Varies in each instance,simpleattr,1492 "Learning Python, 5th Edition",self.adds += 1 # Per-instance counts,simpleattr,1492 "Learning Python, 5th Edition",self.__attrnames()) # name=value list,simpleattr,1495 "Learning Python, 5th Edition",self.cust = Customer(),simpleattr,1495 "Learning Python, 5th Edition",self.empl = Employee(),simpleattr,1495 "Learning Python, 5th Edition",self.food = None,simpleattr,1495 "Learning Python, 5th Edition",self.food = employee.takeOrder(foodName),simpleattr,1496 "Learning Python, 5th Edition",self.name = name,simpleattr,1496 "Learning Python, 5th Edition",self.clerk = Clerk() # Embed some instances,simpleattr,1497 "Learning Python, 5th Edition",self.customer = Customer() # Scene is a composite,simpleattr,1497 "Learning Python, 5th Edition",self.subject = Parrot(),simpleattr,1497 "Learning Python, 5th Edition",self.growing = False,simpleattr,1502 "Learning Python, 5th Edition",self.fontsize = 10,simpleattr,1502 "Learning Python, 5th Edition","self.lab = Label(parent, text='Gui1', fg='white', bg='navy')",simpleattr,1502 "Learning Python, 5th Edition","self.lab.pack(expand=YES, fill=BOTH)",simpleattr,1502 "Learning Python, 5th Edition",self.fontsize += 5,simpleattr,1502 "Learning Python, 5th Edition","self.lab.config(bg=color,",simpleattr,1502 "Learning Python, 5th Edition",self.growing = True,simpleattr,1503 "Learning Python, 5th Edition","self.lab.config(font=('courier', self.fontsize, 'bold'))",simpleattr,1503 "Learning Python, 5th Edition",self.growing = False,simpleattr,1503 "Learning Python, 5th Edition",D['quantity'] += 1 # Add 1 to 'quantity' value,assignIncrement,114 "Learning Python, 5th Edition",spams += 42,assignIncrement,340 "Learning Python, 5th Edition","that combines an expression and an assignment in a concise way. Saying spam += 42, for example, has the same effect as spam = spam + 42, but the augmented form",assignIncrement,341 "Learning Python, 5th Edition",X += Y # Newer augmented form,assignIncrement,350 "Learning Python, 5th Edition",X += Y,assignIncrement,350 "Learning Python, 5th Edition",x += 1 # Augmented,assignIncrement,350 "Learning Python, 5th Edition","The left side has to be evaluated only once. In X += Y, X may be a complicated object",assignIncrement,350 "Learning Python, 5th Edition","1. C/C++ programmers take note: although Python now supports statements like X += Y, it still does not",assignIncrement,350 "Learning Python, 5th Edition","Note however, that because of this equivalence += for a list is not exactly the same as a",assignIncrement,351 "Learning Python, 5th Edition","and = in all cases—for lists += allows arbitrary sequences (just like extend), but con-",assignIncrement,351 "Learning Python, 5th Edition","L += 'spam' # += and extend allow any sequence, but + does not!",assignIncrement,351 "Learning Python, 5th Edition","This behavior is usually what we want, but notice that it implies that the += is an in-",assignIncrement,352 "Learning Python, 5th Edition","L += [3, 4] # But += really means extend",assignIncrement,352 "Learning Python, 5th Edition","a += 1 # Or, a = a + 1",assignIncrement,388 "Learning Python, 5th Edition",i += 1,assignIncrement,404 "Learning Python, 5th Edition","x += 1 # Changes x, not L",assignIncrement,406 "Learning Python, 5th Edition",L[i] += 1 # Or L[i] = L[i] + 1,assignIncrement,406 "Learning Python, 5th Edition",L[i] += 1,assignIncrement,407 "Learning Python, 5th Edition",i += 1,assignIncrement,407 "Learning Python, 5th Edition",offset += 1,assignIncrement,410 "Learning Python, 5th Edition",L[i] += 10,assignIncrement,424 "Learning Python, 5th Edition",var += 1 # Change global var,assignIncrement,499 "Learning Python, 5th Edition",thismod.var += 1 # Change global var,assignIncrement,499 "Learning Python, 5th Edition",glob.var += 1 # Change global var,assignIncrement,499 "Learning Python, 5th Edition",state += 1 # Cannot change by default (never in 2.X),assignIncrement,510 "Learning Python, 5th Edition",state += 1 # Allowed to change it if nonlocal,assignIncrement,510 "Learning Python, 5th Edition",spam += 1,assignIncrement,511 "Learning Python, 5th Edition",state += 1 # Allowed to change it if nonlocal,assignIncrement,512 "Learning Python, 5th Edition",state += 1,assignIncrement,513 "Learning Python, 5th Edition","nested.state += 1 # Change attr, not nested itself",assignIncrement,516 "Learning Python, 5th Edition","state[0] += 1 # Extra syntax, deep magic?",assignIncrement,517 "Learning Python, 5th Edition",sum += L[0],assignIncrement,557 "Learning Python, 5th Edition",for x in L: sum += x,assignIncrement,558 "Learning Python, 5th Edition",tot += sumtree(x) # Recur for sublists,assignIncrement,558 "Learning Python, 5th Edition",func.count += 1,assignIncrement,564 "Learning Python, 5th Edition",L[i][j] += 10,assignIncrement,587 "Learning Python, 5th Edition",res += x.upper(),assignIncrement,602 "Learning Python, 5th Edition","stmt=""L = [1, 2, 3, 4, 5]\nfor i in range(len(L)): L[i] += 1""))",assignIncrement,645 "Learning Python, 5th Edition","stmt=""L = [1, 2, 3, 4, 5]\ni=0\nwhile i < len(L):\n\tL[i] += 1\n\ti += 1""))",assignIncrement,645 "Learning Python, 5th Edition","L[i] += 1"" "" i += 1""",assignIncrement,646 "Learning Python, 5th Edition","0, 0, ""L = [1, 2, 3, 4, 5]"", ""for i in range(len(L)): L[i] += 1""),",assignIncrement,655 "Learning Python, 5th Edition","tests += 12, 123, 1234, 12345, 123456, 1234567",assignIncrement,752 "Learning Python, 5th Edition","tests += 2 ** 32, 2 ** 100",assignIncrement,752 "Learning Python, 5th Edition","tests += 12.34, 12.344, 12.345, 12.346",assignIncrement,752 "Learning Python, 5th Edition","tests += 2 ** 32, (2 ** 32 + .2345)",assignIncrement,752 "Learning Python, 5th Edition","tests += 1.2345, 1.2, 0.2345",assignIncrement,752 "Learning Python, 5th Edition",count += 1,assignIncrement,760 "Learning Python, 5th Edition",TopTest.count += 2,assignIncrement,842 "Learning Python, 5th Edition","X + Y, X += Y if no __iadd__",assignIncrement,889 "Learning Python, 5th Edition",X += Y (or else __add__),assignIncrement,889 "Learning Python, 5th Edition",offset += 2,assignIncrement,906 "Learning Python, 5th Edition","To also implement += in-place augmented addition, code either an __iadd__ or an",assignIncrement,920 "Learning Python, 5th Edition",classes already support += for this reason—Python runs __add__ and assigns the result,assignIncrement,921 "Learning Python, 5th Edition","def __iadd__(self, other): # __iadd__ explicit: x += y",assignIncrement,921 "Learning Python, 5th Edition",x += 1,assignIncrement,921 "Learning Python, 5th Edition",x += 1,assignIncrement,921 "Learning Python, 5th Edition",x += 1,assignIncrement,921 "Learning Python, 5th Edition",x += 1 # And += does concatenation here,assignIncrement,921 "Learning Python, 5th Edition","result += spaces + '{0}={1}\n'.format(attr, getattr(obj, attr))",assignIncrement,967 "Learning Python, 5th Edition","above += self.__listclass(super, indent+4)",assignIncrement,967 "Learning Python, 5th Edition","above += self.__listclass(super, indent+4)",assignIncrement,968 "Learning Python, 5th Edition","result += spaces + '{0}={1}\n'.format(attr, getattr(obj, attr))",assignIncrement,971 "Learning Python, 5th Edition","result += spaces + '{0}={1}\n'.format(attr, getattr(obj, attr))",assignIncrement,972 "Learning Python, 5th Edition","result += spaces + '{0}={1}\n'.format(attr, getattr(obj, attr))",assignIncrement,973 "Learning Python, 5th Edition","result += spaces + '%s=%s\n' % (attr, getattr(obj, attr))",assignIncrement,973 "Learning Python, 5th Edition",here += dflr(sup),assignIncrement,1005 "Learning Python, 5th Edition",Spam.numInstances += 1,assignIncrement,1030 "Learning Python, 5th Edition",Spam.numInstances += 1,assignIncrement,1032 "Learning Python, 5th Edition",Spam.numInstances += 1,assignIncrement,1032 "Learning Python, 5th Edition",cls.numInstances += 1 # cls is lowest class above instance,assignIncrement,1033 "Learning Python, 5th Edition",oncall.calls += 1,assignIncrement,1038 "Learning Python, 5th Edition",__setitem__ methods in bytearray implement += in-place concatenation and index as-,assignIncrement,1194 "Learning Python, 5th Edition",calls += 1,assignIncrement,1284 "Learning Python, 5th Edition",calls += 1,assignIncrement,1286 "Learning Python, 5th Edition",calls += 1,assignIncrement,1287 "Learning Python, 5th Edition",wrapper.calls += 1,assignIncrement,1288 "Learning Python, 5th Edition",use [onCall.calls += 1],assignIncrement,1291 "Learning Python, 5th Edition",calls += 1,assignIncrement,1291 "Learning Python, 5th Edition",onCall.alltime += elapsed,assignIncrement,1345 "Learning Python, 5th Edition",calls += 1,assignIncrement,1400 "Learning Python, 5th Edition",onCall.alltime += elapsed,assignIncrement,1400 "Learning Python, 5th Edition",for c in S: x += ord(c) # Or: x = x + ord(c),assignIncrement,1473 "Learning Python, 5th Edition",sum += next # Add items 2..N,assignIncrement,1476 "Learning Python, 5th Edition",tot += arg,assignIncrement,1477 "Learning Python, 5th Edition",tot += args[key],assignIncrement,1477 "Learning Python, 5th Edition",tot += arg,assignIncrement,1477 "Learning Python, 5th Edition",tot += 1,assignIncrement,1485 "Learning Python, 5th Edition",MyListSub.calls += 1 # Class-wide counter,assignIncrement,1492 "Learning Python, 5th Edition",fontsize += 5,assignIncrement,1502 "Learning Python, 5th Edition",bob['age'] += 1,assignIncrement,1504 "Learning Python, 5th Edition","concatenating strings, 100, 200, 1100 += in-place addition, 920, 1194",assignIncrement,1507 "Learning Python, 5th Edition",def f2(x=x):,funcdefault,504 "Learning Python, 5th Edition","def f(a, b=2, c=3):",funcdefault,533 "Learning Python, 5th Edition","def func(spam, eggs, toast=0, ham=0):",funcdefault,534 "Learning Python, 5th Edition","def tester(func, items, trace=True):",funcdefault,546 "Learning Python, 5th Edition","def tester(func, items, trace=True):",funcdefault,547 "Learning Python, 5th Edition","def func(a, b=4, c=5):",funcdefault,551 "Learning Python, 5th Edition","def func(a, b, c=5):",funcdefault,551 "Learning Python, 5th Edition","def func(a, b, c=3, d=4):",funcdefault,551 "Learning Python, 5th Edition","def func(a: 'spam' = 4, b: (1, 10) = 5, c: float = 6) -> int:",funcdefault,566 "Learning Python, 5th Edition","def func(a:'spam'=4, b:(1,10)=5, c:float=6)->int:",funcdefault,567 "Learning Python, 5th Edition","def tester(func, items, trace=True):",funcdefault,612 "Learning Python, 5th Edition","def runner(stmts, pythons=None, tracecmd=False):",funcdefault,648 "Learning Python, 5th Edition","def runner(stmts, pythons=None, tracecmd=False):",funcdefault,654 "Learning Python, 5th Edition",def saver(x=[]):,funcdefault,658 "Learning Python, 5th Edition","def money(N, numwidth=0, currency='$'):",funcdefault,752 "Learning Python, 5th Edition","def listing(module, verbose=True):",funcdefault,760 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,829 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,829 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,829 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,831 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,835 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,837 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,846 "Learning Python, 5th Edition","def __call__(self, a, b, c=5, d=6):",funcdefault,922 "Learning Python, 5th Edition","def tester(listerclass, sept=False):",funcdefault,962 "Learning Python, 5th Edition","def testByNames(modname, classname, sept=False):",funcdefault,962 "Learning Python, 5th Edition","def trace(X, label='', end='\n'):",funcdefault,1004 "Learning Python, 5th Edition","def mapattrs(instance, withobject=False, bysource=False):",funcdefault,1005 "Learning Python, 5th Edition","def mapattrs(instance, withobject=False, bysource=False):",funcdefault,1018 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,1253 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,1254 "Learning Python, 5th Edition","def giveRaise(self, percent, bonus=.10):",funcdefault,1255 "Learning Python, 5th Edition",def timer(label=''):,funcdefault,1298 "Learning Python, 5th Edition","def timer(label='', trace=True): # On decorator args:",funcdefault,1299 "Learning Python, 5th Edition","def func(a, b, c, e=True, f=None): # Args:",funcdefault,1336 "Learning Python, 5th Edition","def timer(label='', trace=True): # On decorator args:",funcdefault,1345 "Learning Python, 5th Edition","def timer(label='', trace=True): # On decorator args:",funcdefault,1400 "Learning Python, 5th Edition","def adder(good=1, bad=2, ugly=3):",funcdefault,1477 "Learning Python, 5th Edition","def f5(a, b=2, c=3):",funcdefault,1479 "Learning Python, 5th Edition",range(10)),rangefunc,96 "Learning Python, 5th Edition",range(4)) # 0..3 (list() required in 3.X),rangefunc,112 "Learning Python, 5th Edition","range(−6, 7, 2)) # −6 to +6 by 2 (need list() in 3.X)",rangefunc,112 "Learning Python, 5th Edition",range(4),rangefunc,112 "Learning Python, 5th Edition","range(−6, 7, 2)",rangefunc,112 "Learning Python, 5th Edition",range(3),rangefunc,113 "Learning Python, 5th Edition","range(-5, 5))",rangefunc,165 "Learning Python, 5th Edition","range(-5, 5))",rangefunc,167 "Learning Python, 5th Edition","range(1, 5)",rangefunc,265 "Learning Python, 5th Edition",range(5)]),rangefunc,272 "Learning Python, 5th Edition",range(3)) # list(),rangefunc,344 "Learning Python, 5th Edition","range(5)), list(range(2, 5)), list(range(0, 10, 2))",rangefunc,403 "Learning Python, 5th Edition","range(−5, 5))",rangefunc,403 "Learning Python, 5th Edition","range(5, −5, −1))",rangefunc,403 "Learning Python, 5th Edition",range(len(X))),rangefunc,404 "Learning Python, 5th Edition","range(0, len(S), 2))",rangefunc,405 "Learning Python, 5th Edition","range(0, 5)",rangefunc,423 "Learning Python, 5th Edition",range(5)),rangefunc,423 "Learning Python, 5th Edition",range(...)),rangefunc,435 "Learning Python, 5th Edition","range(0, 10)",rangefunc,435 "Learning Python, 5th Edition",range(10)),rangefunc,435 "Learning Python, 5th Edition","range(−5, 5))",rangefunc,576 "Learning Python, 5th Edition","range(−5, 5) if x > 0] # Use ()",rangefunc,576 "Learning Python, 5th Edition",range(10),rangefunc,583 "Learning Python, 5th Edition",range(len(M)),rangefunc,586 "Learning Python, 5th Edition",range(len(M)),rangefunc,586 "Learning Python, 5th Edition",range(3) for col in range(3),rangefunc,588 "Learning Python, 5th Edition",range(3)] for row in range(3),rangefunc,588 "Learning Python, 5th Edition",range(4)),rangefunc,597 "Learning Python, 5th Edition",range(4)),rangefunc,599 "Learning Python, 5th Edition",range(4)),rangefunc,599 "Learning Python, 5th Edition",range(4)),rangefunc,601 "Learning Python, 5th Edition",range(N),rangefunc,606 "Learning Python, 5th Edition",range(N)),rangefunc,606 "Learning Python, 5th Edition",range(3)),rangefunc,608 "Learning Python, 5th Edition",range(3))),rangefunc,608 "Learning Python, 5th Edition",range(10),rangefunc,623 "Learning Python, 5th Edition",range(10),rangefunc,623 "Learning Python, 5th Edition",range(5)),rangefunc,623 "Learning Python, 5th Edition",range(5)),rangefunc,624 "Learning Python, 5th Edition",range(10),rangefunc,624 "Learning Python, 5th Edition",range(10)),rangefunc,624 "Learning Python, 5th Edition",range(10),rangefunc,624 "Learning Python, 5th Edition",range(10)),rangefunc,624 "Learning Python, 5th Edition",range(50)),rangefunc,633 "Learning Python, 5th Edition",range(),rangefunc,641 "Learning Python, 5th Edition",range(1000),rangefunc,644 "Learning Python, 5th Edition",range(1000),rangefunc,644 "Learning Python, 5th Edition",range(1000),rangefunc,644 "Learning Python, 5th Edition",range(1000),rangefunc,644 "Learning Python, 5th Edition",range(1000),rangefunc,644 "Learning Python, 5th Edition",range(1000),rangefunc,645 "Learning Python, 5th Edition",range(10000),rangefunc,645 "Learning Python, 5th Edition",range(10000),rangefunc,645 "Learning Python, 5th Edition",range(10000),rangefunc,645 "Learning Python, 5th Edition",range(1000)]').timeit(1000),rangefunc,647 "Learning Python, 5th Edition","range(1000)]"")",rangefunc,649 "Learning Python, 5th Edition",range(1000),rangefunc,649 "Learning Python, 5th Edition",range(1000)),rangefunc,649 "Learning Python, 5th Edition",range(1000),rangefunc,649 "Learning Python, 5th Edition",range(1000)),rangefunc,649 "Learning Python, 5th Edition",range(1000),rangefunc,649 "Learning Python, 5th Edition",range(1000)),rangefunc,650 "Learning Python, 5th Edition",range(1000),rangefunc,650 "Learning Python, 5th Edition",range(1000)),rangefunc,650 "Learning Python, 5th Edition","range(1000)}"")",rangefunc,652 "Learning Python, 5th Edition","range(1000)}"")",rangefunc,652 "Learning Python, 5th Edition",range(1000),rangefunc,652 "Learning Python, 5th Edition",range(1000),rangefunc,652 "Learning Python, 5th Edition",range(1000),rangefunc,654 "Learning Python, 5th Edition",range(1000)),rangefunc,654 "Learning Python, 5th Edition","range(1000)]"")",rangefunc,655 "Learning Python, 5th Edition","range(1, 6)",rangefunc,899 "Learning Python, 5th Edition",range(128),rangefunc,1180 "Learning Python, 5th Edition",range(128),rangefunc,1185 "Learning Python, 5th Edition",range(128),rangefunc,1187 "Learning Python, 5th Edition",range(N),rangefunc,1297 "Learning Python, 5th Edition","range(y, 1, −1)",rangefunc,1480 "Learning Python, 5th Edition","range(5, 0, −1))",rangefunc,1483 "Learning Python, 5th Edition","range(5, 0, −1) # Pre 3.3: for x in range()",rangefunc,1483 "Learning Python, 5th Edition","range(5, 0, −1))",rangefunc,1483 "Learning Python, 5th Edition","range(5, 0, −1))",rangefunc,1483 "Learning Python, 5th Edition","range(N, 1, −1))",rangefunc,1484 "Learning Python, 5th Edition",range(10)),rangefunc,1494 "Learning Python, 5th Edition",def lastName(self):,simplefunc,129 "Learning Python, 5th Edition",def __iter__(self):,simplefunc,297 "Learning Python, 5th Edition",def function():,simplefunc,320 "Learning Python, 5th Edition",def outer():,simplefunc,320 "Learning Python, 5th Edition",def function():,simplefunc,321 "Learning Python, 5th Edition",def func2():,simplefunc,390 "Learning Python, 5th Edition",def square(x):,simplefunc,447 "Learning Python, 5th Edition",def printer(messge):,simplefunc,473 "Learning Python, 5th Edition",def changer():,simplefunc,474 "Learning Python, 5th Edition",def outer():,simplefunc,474 "Learning Python, 5th Edition",def changer():,simplefunc,474 "Learning Python, 5th Edition",def func():,simplefunc,486 "Learning Python, 5th Edition",def hider():,simplefunc,492 "Learning Python, 5th Edition",def func():,simplefunc,493 "Learning Python, 5th Edition",def func():,simplefunc,495 "Learning Python, 5th Edition",def all_global():,simplefunc,495 "Learning Python, 5th Edition",def func1():,simplefunc,496 "Learning Python, 5th Edition",def func2():,simplefunc,496 "Learning Python, 5th Edition",def local():,simplefunc,499 "Learning Python, 5th Edition",def glob1():,simplefunc,499 "Learning Python, 5th Edition",def glob2():,simplefunc,499 "Learning Python, 5th Edition",def glob3():,simplefunc,499 "Learning Python, 5th Edition",def test():,simplefunc,499 "Learning Python, 5th Edition",def f1():,simplefunc,500 "Learning Python, 5th Edition",def f2():,simplefunc,500 "Learning Python, 5th Edition",def f1():,simplefunc,501 "Learning Python, 5th Edition",def f2():,simplefunc,501 "Learning Python, 5th Edition",def maker(N):,simplefunc,501 "Learning Python, 5th Edition",def maker(N):,simplefunc,502 "Learning Python, 5th Edition",def f1():,simplefunc,504 "Learning Python, 5th Edition",def f1():,simplefunc,505 "Learning Python, 5th Edition",def f2(x):,simplefunc,505 "Learning Python, 5th Edition",def func():,simplefunc,505 "Learning Python, 5th Edition",def func():,simplefunc,505 "Learning Python, 5th Edition",def makeActions():,simplefunc,506 "Learning Python, 5th Edition",def makeActions():,simplefunc,507 "Learning Python, 5th Edition",def f1():,simplefunc,507 "Learning Python, 5th Edition",def f2():,simplefunc,507 "Learning Python, 5th Edition",def f3():,simplefunc,507 "Learning Python, 5th Edition",def func():,simplefunc,508 "Learning Python, 5th Edition",def tester(start):,simplefunc,509 "Learning Python, 5th Edition",def nested(label):,simplefunc,510 "Learning Python, 5th Edition",def tester(start):,simplefunc,510 "Learning Python, 5th Edition",def nested(label):,simplefunc,510 "Learning Python, 5th Edition",def tester(start):,simplefunc,510 "Learning Python, 5th Edition",def nested(label):,simplefunc,510 "Learning Python, 5th Edition",def tester(start):,simplefunc,511 "Learning Python, 5th Edition",def nested(label):,simplefunc,511 "Learning Python, 5th Edition",def tester(start):,simplefunc,511 "Learning Python, 5th Edition",def nested(label):,simplefunc,511 "Learning Python, 5th Edition",def tester():,simplefunc,511 "Learning Python, 5th Edition",def nested():,simplefunc,511 "Learning Python, 5th Edition",def tester(start):,simplefunc,512 "Learning Python, 5th Edition",def nested(label):,simplefunc,512 "Learning Python, 5th Edition",def tester(start):,simplefunc,513 "Learning Python, 5th Edition",def nested(label):,simplefunc,513 "Learning Python, 5th Edition",def tester(start):,simplefunc,516 "Learning Python, 5th Edition",def nested(label):,simplefunc,516 "Learning Python, 5th Edition",def tester(start):,simplefunc,517 "Learning Python, 5th Edition",def nested(label):,simplefunc,517 "Learning Python, 5th Edition",def func():,simplefunc,519 "Learning Python, 5th Edition",def func():,simplefunc,519 "Learning Python, 5th Edition",def func():,simplefunc,519 "Learning Python, 5th Edition",def func():,simplefunc,520 "Learning Python, 5th Edition",def func():,simplefunc,520 "Learning Python, 5th Edition",def nested():,simplefunc,520 "Learning Python, 5th Edition",def func():,simplefunc,520 "Learning Python, 5th Edition",def nested():,simplefunc,520 "Learning Python, 5th Edition",def mysum(L):,simplefunc,555 "Learning Python, 5th Edition",def mysum(L):,simplefunc,556 "Learning Python, 5th Edition",def mysum(L):,simplefunc,556 "Learning Python, 5th Edition",def mysum(L):,simplefunc,556 "Learning Python, 5th Edition",def mysum(L):,simplefunc,556 "Learning Python, 5th Edition",def sumtree(L):,simplefunc,558 "Learning Python, 5th Edition",def echo(message):,simplefunc,563 "Learning Python, 5th Edition",def func(a):,simplefunc,563 "Learning Python, 5th Edition",def knights():,simplefunc,569 "Learning Python, 5th Edition",def action(x):,simplefunc,572 "Learning Python, 5th Edition",def makewidgets(self):,simplefunc,573 "Learning Python, 5th Edition",def gensquares(N):,simplefunc,593 "Learning Python, 5th Edition",def buildsquares(n):,simplefunc,595 "Learning Python, 5th Edition",def ups(line):,simplefunc,596 "Learning Python, 5th Edition",def gen():,simplefunc,596 "Learning Python, 5th Edition",def timesfour(S):,simplefunc,604 "Learning Python, 5th Edition",def scramble(seq):,simplefunc,610 "Learning Python, 5th Edition",def scramble(seq):,simplefunc,610 "Learning Python, 5th Edition",def scramble(seq):,simplefunc,610 "Learning Python, 5th Edition",def scramble(seq):,simplefunc,611 "Learning Python, 5th Edition",def scramble(seq):,simplefunc,612 "Learning Python, 5th Edition",def permute1(seq):,simplefunc,612 "Learning Python, 5th Edition",def permute2(seq):,simplefunc,613 "Learning Python, 5th Edition",def func():,simplefunc,623 "Learning Python, 5th Edition",def forLoop():,simplefunc,634 "Learning Python, 5th Edition",def listComp():,simplefunc,634 "Learning Python, 5th Edition",def mapCall():,simplefunc,634 "Learning Python, 5th Edition",def genExpr():,simplefunc,634 "Learning Python, 5th Edition",def genFunc():,simplefunc,634 "Learning Python, 5th Edition",def gen():,simplefunc,634 "Learning Python, 5th Edition",def forLoop():,simplefunc,637 "Learning Python, 5th Edition",def listComp():,simplefunc,637 "Learning Python, 5th Edition",def mapCall():,simplefunc,637 "Learning Python, 5th Edition",def genExpr():,simplefunc,637 "Learning Python, 5th Edition",def genFunc():,simplefunc,637 "Learning Python, 5th Edition",def gen():,simplefunc,637 "Learning Python, 5th Edition",def listComp():,simplefunc,638 "Learning Python, 5th Edition",def mapCall():,simplefunc,638 "Learning Python, 5th Edition",def testcase():,simplefunc,647 "Learning Python, 5th Edition",def selector():,simplefunc,657 "Learning Python, 5th Edition",def selector():,simplefunc,657 "Learning Python, 5th Edition",def selector():,simplefunc,658 "Learning Python, 5th Edition",def saver():,simplefunc,660 "Learning Python, 5th Edition",def proc(x):,simplefunc,660 "Learning Python, 5th Edition",def func():,simplefunc,694 "Learning Python, 5th Edition",def func():,simplefunc,694 "Learning Python, 5th Edition",def f():,simplefunc,698 "Learning Python, 5th Edition",def printer():,simplefunc,702 "Learning Python, 5th Edition",def printer():,simplefunc,702 "Learning Python, 5th Edition",def somefunc():,simplefunc,732 "Learning Python, 5th Edition",def somefunc():,simplefunc,732 "Learning Python, 5th Edition",def tester():,simplefunc,749 "Learning Python, 5th Edition",def commas(N):,simplefunc,752 "Learning Python, 5th Edition",def selftest():,simplefunc,752 "Learning Python, 5th Edition",def status(module):,simplefunc,764 "Learning Python, 5th Edition",def tryreload(module):,simplefunc,764 "Learning Python, 5th Edition",def func1():,simplefunc,772 "Learning Python, 5th Edition",def func2():,simplefunc,772 "Learning Python, 5th Edition",def display(self):,simplefunc,799 "Learning Python, 5th Edition",def uppername(obj):,simplefunc,811 "Learning Python, 5th Edition",def info(self):,simplefunc,813 "Learning Python, 5th Edition",def lastName(self):,simplefunc,827 "Learning Python, 5th Edition",def lastName(self):,simplefunc,830 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,830 "Learning Python, 5th Edition",def lastName(self):,simplefunc,835 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,835 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,837 "Learning Python, 5th Edition",def showAll(self):,simplefunc,838 "Learning Python, 5th Edition",def gatherAttrs(self):,simplefunc,842 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,842 "Learning Python, 5th Edition",def display(self):,simplefunc,861 "Learning Python, 5th Edition",def method(self):,simplefunc,867 "Learning Python, 5th Edition",def method(self):,simplefunc,868 "Learning Python, 5th Edition",def delegate(self):,simplefunc,868 "Learning Python, 5th Edition",def method(self):,simplefunc,868 "Learning Python, 5th Edition",def method(self):,simplefunc,868 "Learning Python, 5th Edition",def action(self):,simplefunc,868 "Learning Python, 5th Edition",def delegate(self):,simplefunc,869 "Learning Python, 5th Edition",def action(self):,simplefunc,869 "Learning Python, 5th Edition",def delegate(self):,simplefunc,870 "Learning Python, 5th Edition",def action(self):,simplefunc,870 "Learning Python, 5th Edition",def delegate(self):,simplefunc,871 "Learning Python, 5th Edition",def f():,simplefunc,873 "Learning Python, 5th Edition",def g():,simplefunc,873 "Learning Python, 5th Edition",def m(self):,simplefunc,873 "Learning Python, 5th Edition",def g1():,simplefunc,875 "Learning Python, 5th Edition",def g2():,simplefunc,875 "Learning Python, 5th Edition",def h1():,simplefunc,875 "Learning Python, 5th Edition",def nested():,simplefunc,875 "Learning Python, 5th Edition",def h2():,simplefunc,875 "Learning Python, 5th Edition",def nested():,simplefunc,875 "Learning Python, 5th Edition",def nester():,simplefunc,876 "Learning Python, 5th Edition",def method1(self):,simplefunc,876 "Learning Python, 5th Edition",def method2(self):,simplefunc,876 "Learning Python, 5th Edition",def nester():,simplefunc,876 "Learning Python, 5th Edition",def method1(self):,simplefunc,877 "Learning Python, 5th Edition",def method2(self):,simplefunc,877 "Learning Python, 5th Edition",def nester():,simplefunc,877 "Learning Python, 5th Edition",def method1(self):,simplefunc,877 "Learning Python, 5th Edition",def method2(self):,simplefunc,877 "Learning Python, 5th Edition",def hello(self):,simplefunc,878 "Learning Python, 5th Edition",def hola(self):,simplefunc,878 "Learning Python, 5th Edition",def instancetree(inst):,simplefunc,880 "Learning Python, 5th Edition",def func(args):,simplefunc,882 "Learning Python, 5th Edition",def method(self):,simplefunc,882 "Learning Python, 5th Edition",def __index__(self):,simplefunc,894 "Learning Python, 5th Edition",def __iter__(self):,simplefunc,900 "Learning Python, 5th Edition",def __next__(self):,simplefunc,900 "Learning Python, 5th Edition",def __next__(self):,simplefunc,900 "Learning Python, 5th Edition",def __iter__(self):,simplefunc,902 "Learning Python, 5th Edition",def gen(self):,simplefunc,903 "Learning Python, 5th Edition",def __iter__(self):,simplefunc,905 "Learning Python, 5th Edition",def __next__(self):,simplefunc,905 "Learning Python, 5th Edition",def __iter__(self):,simplefunc,906 "Learning Python, 5th Edition",def __next__(self):,simplefunc,907 "Learning Python, 5th Edition",def __str__(self):,simplefunc,915 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,915 "Learning Python, 5th Edition",def __str__(self):,simplefunc,919 "Learning Python, 5th Edition",def oncall():,simplefunc,924 "Learning Python, 5th Edition",def __bool__(self):,simplefunc,928 "Learning Python, 5th Edition",def __bool__(self):,simplefunc,929 "Learning Python, 5th Edition",def __nonzero__(self):,simplefunc,929 "Learning Python, 5th Edition",def live(self):,simplefunc,929 "Learning Python, 5th Edition",def __del__(self):,simplefunc,929 "Learning Python, 5th Edition",def work(self):,simplefunc,935 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,935 "Learning Python, 5th Edition",def work(self):,simplefunc,936 "Learning Python, 5th Edition",def work(self):,simplefunc,936 "Learning Python, 5th Edition",def work(self):,simplefunc,936 "Learning Python, 5th Edition",def bake(self):,simplefunc,937 "Learning Python, 5th Edition",def process(self):,simplefunc,939 "Learning Python, 5th Edition",def m2(self):,simplefunc,949 "Learning Python, 5th Edition",def double(self):,simplefunc,951 "Learning Python, 5th Edition",def triple(self):,simplefunc,951 "Learning Python, 5th Edition",def square(arg):,simplefunc,952 "Learning Python, 5th Edition",def handler():,simplefunc,953 "Learning Python, 5th Edition",def handler(self):,simplefunc,954 "Learning Python, 5th Edition",def makewidgets(self):,simplefunc,954 "Learning Python, 5th Edition",def __str__(self):,simplefunc,959 "Learning Python, 5th Edition",def __str__(self):,simplefunc,964 "Learning Python, 5th Edition",def __str__(self):,simplefunc,967 "Learning Python, 5th Edition",def invertdict(D):,simplefunc,1005 "Learning Python, 5th Edition",def keysof(V):,simplefunc,1005 "Learning Python, 5th Edition",def dflr(cls):,simplefunc,1005 "Learning Python, 5th Edition",def inheritance(instance):,simplefunc,1005 "Learning Python, 5th Edition",def getage(self):,simplefunc,1021 "Learning Python, 5th Edition",def getage(self):,simplefunc,1021 "Learning Python, 5th Edition",def printNumInstances():,simplefunc,1026 "Learning Python, 5th Edition",def printNumInstances():,simplefunc,1027 "Learning Python, 5th Edition",def printNumInstances(self):,simplefunc,1028 "Learning Python, 5th Edition",def printNumInstances():,simplefunc,1030 "Learning Python, 5th Edition",def printNumInstances(cls):,simplefunc,1032 "Learning Python, 5th Edition",def printNumInstances(cls):,simplefunc,1032 "Learning Python, 5th Edition",def meth():,simplefunc,1035 "Learning Python, 5th Edition",def count(aClass):,simplefunc,1039 "Learning Python, 5th Edition",def act(self):,simplefunc,1042 "Learning Python, 5th Edition",def act(self):,simplefunc,1043 "Learning Python, 5th Edition",def act(self):,simplefunc,1043 "Learning Python, 5th Edition",def act(self):,simplefunc,1045 "Learning Python, 5th Edition",def act(self):,simplefunc,1045 "Learning Python, 5th Edition",def act(self):,simplefunc,1045 "Learning Python, 5th Edition",def act(self):,simplefunc,1048 "Learning Python, 5th Edition",def act(self):,simplefunc,1048 "Learning Python, 5th Edition",def act(self):,simplefunc,1048 "Learning Python, 5th Edition",def act(self):,simplefunc,1048 "Learning Python, 5th Edition",def generate():,simplefunc,1068 "Learning Python, 5th Edition",def method(self):,simplefunc,1068 "Learning Python, 5th Edition",def generate():,simplefunc,1068 "Learning Python, 5th Edition",def method(self):,simplefunc,1068 "Learning Python, 5th Edition",def method(self):,simplefunc,1069 "Learning Python, 5th Edition",def catcher():,simplefunc,1085 "Learning Python, 5th Edition",def gosouth(x):,simplefunc,1099 "Learning Python, 5th Edition",def stuff(file):,simplefunc,1101 "Learning Python, 5th Edition",def f(x):,simplefunc,1113 "Learning Python, 5th Edition",def reciprocal(x):,simplefunc,1113 "Learning Python, 5th Edition",def __enter__(self):,simplefunc,1116 "Learning Python, 5th Edition",def raiser0():,simplefunc,1126 "Learning Python, 5th Edition",def raiser1():,simplefunc,1126 "Learning Python, 5th Edition",def raiser2():,simplefunc,1126 "Learning Python, 5th Edition",def func():,simplefunc,1130 "Learning Python, 5th Edition",def parser():,simplefunc,1137 "Learning Python, 5th Edition",def logerror(self):,simplefunc,1138 "Learning Python, 5th Edition",def parser():,simplefunc,1138 "Learning Python, 5th Edition",def logerror(self):,simplefunc,1138 "Learning Python, 5th Edition",def action2():,simplefunc,1143 "Learning Python, 5th Edition",def action1():,simplefunc,1143 "Learning Python, 5th Edition",def searcher():,simplefunc,1147 "Learning Python, 5th Edition",def searcher():,simplefunc,1147 "Learning Python, 5th Edition",def func():,simplefunc,1153 "Learning Python, 5th Edition",def bye():,simplefunc,1154 "Learning Python, 5th Edition",def getName(self):,simplefunc,1219 "Learning Python, 5th Edition",def getName(self):,simplefunc,1222 "Learning Python, 5th Edition",def delName(self):,simplefunc,1222 "Learning Python, 5th Edition",def getSquare(self):,simplefunc,1246 "Learning Python, 5th Edition",def getCube(self):,simplefunc,1246 "Learning Python, 5th Edition",def __len__(self):,simplefunc,1250 "Learning Python, 5th Edition",def lastName(self):,simplefunc,1253 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,1253 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,1254 "Learning Python, 5th Edition",def __repr__(self):,simplefunc,1256 "Learning Python, 5th Edition",def getName(self):,simplefunc,1257 "Learning Python, 5th Edition",def getAge(self):,simplefunc,1257 "Learning Python, 5th Edition",def getAcct(self):,simplefunc,1258 "Learning Python, 5th Edition",def loadclass():,simplefunc,1258 "Learning Python, 5th Edition",def printholder(who):,simplefunc,1258 "Learning Python, 5th Edition",def F(arg):,simplefunc,1273 "Learning Python, 5th Edition",def decorator(F):,simplefunc,1274 "Learning Python, 5th Edition",def decorator(F):,simplefunc,1274 "Learning Python, 5th Edition",def decorator(C):,simplefunc,1278 "Learning Python, 5th Edition",def decorator(C):,simplefunc,1278 "Learning Python, 5th Edition",def F(arg):,simplefunc,1282 "Learning Python, 5th Edition",def actualDecorator(F):,simplefunc,1282 "Learning Python, 5th Edition",def decorator(O):,simplefunc,1282 "Learning Python, 5th Edition",def decorator(func):,simplefunc,1298 "Learning Python, 5th Edition",def pay(self):,simplefunc,1302 "Learning Python, 5th Edition",def display(self):,simplefunc,1308 "Learning Python, 5th Edition",def getInstance(object):,simplefunc,1309 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1312 "Learning Python, 5th Edition",def decorate(func):,simplefunc,1313 "Learning Python, 5th Edition",def decorate(func):,simplefunc,1314 "Learning Python, 5th Edition",def size(self):,simplefunc,1316 "Learning Python, 5th Edition",def display(self):,simplefunc,1316 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1319 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1319 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1323 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1323 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1324 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1324 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1324 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1325 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1325 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1325 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1326 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1326 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1326 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1328 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1328 "Learning Python, 5th Edition",def onDecorator(func):,simplefunc,1331 "Learning Python, 5th Edition",def onDecorator(func):,simplefunc,1341 "Learning Python, 5th Edition",def rangetest(func):,simplefunc,1341 "Learning Python, 5th Edition",def onDecorator(func):,simplefunc,1342 "Learning Python, 5th Edition",def accessControl(failIf):,simplefunc,1347 "Learning Python, 5th Edition",def onDecorator(aClass):,simplefunc,1347 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1348 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1349 "Learning Python, 5th Edition",def fails(test):,simplefunc,1351 "Learning Python, 5th Edition",def extras(Class):,simplefunc,1362 "Learning Python, 5th Edition",def extras(Class):,simplefunc,1362 "Learning Python, 5th Edition",def toast(self):,simplefunc,1379 "Learning Python, 5th Edition",def spam(self):,simplefunc,1392 "Learning Python, 5th Edition",def eggsfunc(obj):,simplefunc,1392 "Learning Python, 5th Edition",def eggsfunc(obj):,simplefunc,1393 "Learning Python, 5th Edition",def spam(self):,simplefunc,1393 "Learning Python, 5th Edition",def Extender(aClass):,simplefunc,1395 "Learning Python, 5th Edition",def spam(self):,simplefunc,1395 "Learning Python, 5th Edition",def pay(self):,simplefunc,1396 "Learning Python, 5th Edition",def pay(self):,simplefunc,1397 "Learning Python, 5th Edition",def decorator(cls):,simplefunc,1398 "Learning Python, 5th Edition",def func(cls):,simplefunc,1399 "Learning Python, 5th Edition",def lastName(self):,simplefunc,1402 "Learning Python, 5th Edition",def decorateAll(decorator):,simplefunc,1403 "Learning Python, 5th Edition",def lastName(self):,simplefunc,1403 "Learning Python, 5th Edition",def decorateAll(decorator):,simplefunc,1405 "Learning Python, 5th Edition",def DecoDecorate(aClass):,simplefunc,1405 "Learning Python, 5th Edition",def lastName(self):,simplefunc,1405 "Learning Python, 5th Edition",def copyDict(old):,simplefunc,1478 "Learning Python, 5th Edition",def mathMod():,simplefunc,1481 "Learning Python, 5th Edition",def powCall():,simplefunc,1481 "Learning Python, 5th Edition",def powExpr():,simplefunc,1481 "Learning Python, 5th Edition",def dictcomp(I):,simplefunc,1482 "Learning Python, 5th Edition",def dictloop(I):,simplefunc,1482 "Learning Python, 5th Edition",def countdown(N):,simplefunc,1483 "Learning Python, 5th Edition",def fact1(N):,simplefunc,1484 "Learning Python, 5th Edition",def fact3(N):,simplefunc,1484 "Learning Python, 5th Edition",def fact4(N):,simplefunc,1484 "Learning Python, 5th Edition",def rev1(S):,simplefunc,1485 "Learning Python, 5th Edition",def rev2(S):,simplefunc,1485 "Learning Python, 5th Edition",def rev3(S):,simplefunc,1485 "Learning Python, 5th Edition",def countLines(name):,simplefunc,1485 "Learning Python, 5th Edition",def countChars(name):,simplefunc,1485 "Learning Python, 5th Edition",def countLines(name):,simplefunc,1485 "Learning Python, 5th Edition",def countChars(name):,simplefunc,1485 "Learning Python, 5th Edition",def countLines(file):,simplefunc,1486 "Learning Python, 5th Edition",def countChars(file):,simplefunc,1486 "Learning Python, 5th Edition",def test(name):,simplefunc,1486 "Learning Python, 5th Edition",def countLines(name):,simplefunc,1486 "Learning Python, 5th Edition",def countChars(name):,simplefunc,1487 "Learning Python, 5th Edition",def __len__(self):,simplefunc,1491 "Learning Python, 5th Edition",def stats(self):,simplefunc,1492 "Learning Python, 5th Edition",def __str__(self):,simplefunc,1495 "Learning Python, 5th Edition",def action(self):,simplefunc,1497 "Learning Python, 5th Edition",def oops():,simplefunc,1497 "Learning Python, 5th Edition",def doomed():,simplefunc,1497 "Learning Python, 5th Edition",def oops():,simplefunc,1498 "Learning Python, 5th Edition",def doomed():,simplefunc,1498 "Learning Python, 5th Edition",def safe(callee):,simplefunc,1499 "Learning Python, 5th Edition",def reply(text):,simplefunc,1501 "Learning Python, 5th Edition",def timer():,simplefunc,1502 "Learning Python, 5th Edition",def grow():,simplefunc,1502 "Learning Python, 5th Edition",def reply(self):,simplefunc,1502 "Learning Python, 5th Edition",def grow(self):,simplefunc,1502 "Learning Python, 5th Edition",def grower(self):,simplefunc,1503 "Learning Python, 5th Edition",def stop(self):,simplefunc,1503 "Learning Python, 5th Edition","return to some of these tradeoffs at the end of the book, after you’ve learned",return,8 "Learning Python, 5th Edition","return to your system shell prompt, type Ctrl-D on Unix-like machines,",return,50 "Learning Python, 5th Edition","return value, a Python module",return,68 "Learning Python, 5th Edition","return str strings, but binary files instead deal in",return,107 "Learning Python, 5th Edition",return all its values in Python 3.X; this isn’t needed in 2.X where map makes a list of,return,113 "Learning Python, 5th Edition",return self.name.split()[-1] # Split string on blanks,return,129 "Learning Python, 5th Edition","return a Boolean result, which we would normally test and take",return,145 "Learning Python, 5th Edition",return value is much less critical than differences in the return value,return,147 "Learning Python, 5th Edition",return integers for integers. Using // instead of / in 2.X when integer truncation,return,147 "Learning Python, 5th Edition","return just digits, not Python literal strings:",return,152 "Learning Python, 5th Edition",return the octal and hexadecimal string,return,174 "Learning Python, 5th Edition","return the same type of object. For example, the",return,193 "Learning Python, 5th Edition","return Horizontal tab",return,195 "Learning Python, 5th Edition",return strings of raw bytes from the external file (there’s much more on files in,return,196 "Learning Python, 5th Edition","return all but the first item of a list. Here, sys.argv[1:] returns the desired list,",return,204 "Learning Python, 5th Edition","return function’s result value.”",return,209 "Learning Python, 5th Edition",return fmt % args # See Part IV,return,234 "Learning Python, 5th Edition",return to Python’s string model to flesh out the details of Unicode,return,237 "Learning Python, 5th Edition",return new lists instead of new strings when applied,return,240 "Learning Python, 5th Edition","return objects) in square brackets, separated by commas. For instance,",return,241 "Learning Python, 5th Edition","return the list as a result (technically, they both return a value called",return,248 "Learning Python, 5th Edition",return last item (by default: −1),return,248 "Learning Python, 5th Edition",return information about its content. See other documentation sources or experiment,return,249 "Learning Python, 5th Edition","return any (key, value) pair; etc.",return,252 "Learning Python, 5th Edition","return all of the dictionary’s values and (key,value) pair",return,254 "Learning Python, 5th Edition","return iterable objects in 3.X, so wrap",return,255 "Learning Python, 5th Edition",return from a key,return,255 "Learning Python, 5th Edition",return from the end,return,255 "Learning Python, 5th Edition","return a list of titles: in dictionaries, there’s",return,258 "Learning Python, 5th Edition","return 88",return,260 "Learning Python, 5th Edition",return lists as before,return,264 "Learning Python, 5th Edition","return view objects, whereas",return,266 "Learning Python, 5th Edition","return actual result lists. This functionality is also available in Python 2.7,",return,266 "Learning Python, 5th Edition","return simple lists, so as to avoid breaking existing 2.X",return,266 "Learning Python, 5th Edition",return successive,return,267 "Learning Python, 5th Edition","return a list in 3.X, the traditional coding pattern for",return,269 "Learning Python, 5th Edition",return keys,return,270 "Learning Python, 5th Edition","return new tuples when applied to tuples, and that tuples",return,278 "Learning Python, 5th Edition",return the number of characters written in Python 3.X; in,return,286 "Learning Python, 5th Edition","return one line on each loop iteration. This form is usually easiest to code, good",return,286 "Learning Python, 5th Edition",return values from write methods,return,288 "Learning Python, 5th Edition",return value of functions,return,305 "Learning Python, 5th Edition",return statement with a result value.,return,305 "Learning Python, 5th Edition","return yield",return,320 "Learning Python, 5th Edition",return a+b+c+d[0],return,320 "Learning Python, 5th Edition",return to this topic in Chapter 13.,return,348 "Learning Python, 5th Edition","return try",return,353 "Learning Python, 5th Edition","return values that you might be interested in retaining, you can call these functions with",return,356 "Learning Python, 5th Edition","return value is None, the",return,357 "Learning Python, 5th Edition",return value for functions that don’t return anything meaningful):,return,357 "Learning Python, 5th Edition","return the list they have changed; instead, they return the None object. Thus, if you",return,357 "Learning Python, 5th Edition","return any value we care about (technically, it returns None, as we saw in the preceding",return,359 "Learning Python, 5th Edition",return True or False (custom versions of 1 and 0).,return,381 "Learning Python, 5th Edition",return a true or false operand object.,return,381 "Learning Python, 5th Edition","return a true or false object in Python, not the values True or False. Let’s look at a few examples",return,381 "Learning Python, 5th Edition",return True or False (1 or 0),return,381 "Learning Python, 5th Edition","return True or False as their truth results, which,",return,381 "Learning Python, 5th Edition",return an object—either the object,return,381 "Learning Python, 5th Edition",return right operand (true or false),return,381 "Learning Python, 5th Edition",return right operand (true or false),return,382 "Learning Python, 5th Edition","return either the left or the right object,",return,382 "Learning Python, 5th Edition",return either the,return,383 "Learning Python, 5th Edition","return all that are true), and the any and all built-ins can",return,385 "Learning Python, 5th Edition","return the value assigned, but Python assignments are just statements,",return,394 "Learning Python, 5th Edition",return sequences of the same type as that being shuffled—,return,405 "Learning Python, 5th Edition",return a different object,return,421 "Learning Python, 5th Edition",return results one at a,return,423 "Learning Python, 5th Edition","return a new string, to which we can apply another string method. The last",return,427 "Learning Python, 5th Edition","return an iterable in Python 3.X, like map. Here they are",return,430 "Learning Python, 5th Edition",return True if any,return,432 "Learning Python, 5th Edition",return the largest and,return,432 "Learning Python, 5th Edition",return a single result:,return,433 "Learning Python, 5th Edition",return iterables instead of processing them. To see how these have been absorbed into,return,434 "Learning Python, 5th Edition",return iterable objects in,return,434 "Learning Python, 5th Edition",return iterables and process them.,return,434 "Learning Python, 5th Edition",return lists of results.,return,435 "Learning Python, 5th Edition","return iterable objects, producing results on demand. This may",return,435 "Learning Python, 5th Edition","return iterable results in 3.X. Unlike range, though,",return,436 "Learning Python, 5th Edition",return multiple-scan lists so the,return,438 "Learning Python, 5th Edition","return iterable view objects that generate result items one at a time,",return,439 "Learning Python, 5th Edition",return [a for a in dir(x) if not a.startswith('__')] # See Part IV,return,445 "Learning Python, 5th Edition",return x ** 2 # square,return,447 "Learning Python, 5th Edition",return values (other than,return,464 "Learning Python, 5th Edition",return a new list that contains the ASCII,return,467 "Learning Python, 5th Edition",return and yield).,return,473 "Learning Python, 5th Edition","return Examples",return,473 "Learning Python, 5th Edition",return a + b + c[0],return,473 "Learning Python, 5th Edition",return results. But writing new functions requires the,return,475 "Learning Python, 5th Edition","return sends a result object back to the caller. When a function is called, the",return,475 "Learning Python, 5th Edition",return statement;,return,475 "Learning Python, 5th Edition",return without a value,return,475 "Learning Python, 5th Edition","return values, and variables are not declared. As with everything",return,476 "Learning Python, 5th Edition","return any kind of object, and so on. As one consequence, a single function can",return,476 "Learning Python, 5th Edition",return statement:,return,477 "Learning Python, 5th Edition",return value,return,477 "Learning Python, 5th Edition","return statement can show up anywhere in a function body; when reached,",return,477 "Learning Python, 5th Edition",return statement,return,477 "Learning Python, 5th Edition",return sends back a None.,return,477 "Learning Python, 5th Edition","return statement itself is optional too; if it’s not present, the function exits when",return,477 "Learning Python, 5th Edition","return statement also returns the None object automatically, but this return value is",return,477 "Learning Python, 5th Edition",return x * y # Body executed when called,return,478 "Learning Python, 5th Edition",return statement that sends back the result as the value of the call,return,479 "Learning Python, 5th Edition","return values in Python, we can use",return,479 "Learning Python, 5th Edition",return res,return,481 "Learning Python, 5th Edition",return statement to send a result object back to the caller.,return,481 "Learning Python, 5th Edition",return statement at the end of intersect sends back the result,return,483 "Learning Python, 5th Edition","return statements, the behavior of function call expressions,",return,483 "Learning Python, 5th Edition",return if it has no return statement in it?,return,483 "Learning Python, 5th Edition",return statement. Such functions are,return,484 "Learning Python, 5th Edition",return statement with no expression in it also returns,return,484 "Learning Python, 5th Edition",return Z,return,491 "Learning Python, 5th Edition","return False. All other scopes still find the originals in the built-in scope.",return,494 "Learning Python, 5th Edition","return values instead of globals, but I need to explain why.",return,495 "Learning Python, 5th Edition",return values instead. Six,return,497 "Learning Python, 5th Edition","return values. In this specific case, we would probably be better off coding an accessor",return,498 "Learning Python, 5th Edition",return f2 # Return f2 but don't call it,return,501 "Learning Python, 5th Edition","return values from other functions. Most importantly, f2 remembers",return,501 "Learning Python, 5th Edition",return action,return,501 "Learning Python, 5th Edition",return X ** N # action retains N from enclosing scope,return,501 "Learning Python, 5th Edition",return action,return,501 "Learning Python, 5th Edition",return lambda X: X ** N # lambda functions retain state too,return,502 "Learning Python, 5th Edition",return action,return,505 "Learning Python, 5th Edition",return action,return,505 "Learning Python, 5th Edition",return acts,return,506 "Learning Python, 5th Edition",return acts,return,507 "Learning Python, 5th Edition",return and review this,return,507 "Learning Python, 5th Edition",return nested,return,510 "Learning Python, 5th Edition",return nested,return,510 "Learning Python, 5th Edition",return nested,return,510 "Learning Python, 5th Edition",return nested,return,511 "Learning Python, 5th Edition",return nested,return,511 "Learning Python, 5th Edition",return nested,return,512 "Learning Python, 5th Edition","return results, their local variables won’t",return,512 "Learning Python, 5th Edition",return nested,return,512 "Learning Python, 5th Edition",return nested,return,513 "Learning Python, 5th Edition",return nested,return,516 "Learning Python, 5th Edition",return nested,return,517 "Learning Python, 5th Edition","return original(*kargs, **pargs)",return,518 "Learning Python, 5th Edition","return self.original(*kargs, **pargs)",return,518 "Learning Python, 5th Edition",return statement and used it in a few examples. Here’s,return,527 "Learning Python, 5th Edition","return can send back any sort of object, it",return,527 "Learning Python, 5th Edition","return multiple values by packaging them in a tuple or other collection type. In fact,",return,527 "Learning Python, 5th Edition","return x, y # Return multiple new values in a tuple",return,527 "Learning Python, 5th Edition","return func(*pargs, **kargs) # Pass along arbitrary arguments",return,537 "Learning Python, 5th Edition",return a + b + c + d,return,537 "Learning Python, 5th Edition",return res,return,543 "Learning Python, 5th Edition",return first,return,543 "Learning Python, 5th Edition",return tmp[0],return,543 "Learning Python, 5th Edition",return item 0 at the end.,return,543 "Learning Python, 5th Edition",return tmp[−1] instead of,return,544 "Learning Python, 5th Edition",return res,return,544 "Learning Python, 5th Edition","return x < y # See also: lambda, eval",return,544 "Learning Python, 5th Edition",return x > y,return,544 "Learning Python, 5th Edition",return res,return,545 "Learning Python, 5th Edition",return res,return,545 "Learning Python, 5th Edition","return for outputs. Generally, you",return,553 "Learning Python, 5th Edition",return statements are often the best ways to isolate external dependencies to,return,553 "Learning Python, 5th Edition","return statements for outputs, whenever possible.",return,554 "Learning Python, 5th Edition",return statements and anticipated mutable argument changes for output. In Python 3.X,return,555 "Learning Python, 5th Edition",return L[0] + mysum(L[1:]) # Call myself recursively,return,555 "Learning Python, 5th Edition",return 0,return,556 "Learning Python, 5th Edition",return L[0] + mysum(L[1:]),return,556 "Learning Python, 5th Edition",return 0 if not L else L[0] + mysum(L[1:]) # Use ternary expression,return,556 "Learning Python, 5th Edition","return L[0] if len(L) == 1 else L[0] + mysum(L[1:]) # Any type, assume one",return,556 "Learning Python, 5th Edition",return first if not rest else first + mysum(rest) # Use 3.X ext seq assign,return,556 "Learning Python, 5th Edition",return L[0] + mysum(L[1:]) # Indirectly recursive,return,557 "Learning Python, 5th Edition",return tot,return,558 "Learning Python, 5th Edition","return and continue later. In fact, it’s generally possible to implement recursive-style",return,559 "Learning Python, 5th Edition",return tot,return,559 "Learning Python, 5th Edition",return echo,return,563 "Learning Python, 5th Edition",return b * a,return,563 "Learning Python, 5th Edition",return a + b + c,return,565 "Learning Python, 5th Edition","return values. For arguments, they appear after a",return,566 "Learning Python, 5th Edition","return values, they are written",return,566 "Learning Python, 5th Edition",return value:,return,566 "Learning Python, 5th Edition",return a + b + c,return,566 "Learning Python, 5th Edition",return value annotation is stored under key “return” if coded,return,566 "Learning Python, 5th Edition",return a + b + c,return,566 "Learning Python, 5th Edition",return a + b + c,return,566 "Learning Python, 5th Edition",return a + b + c,return,567 "Learning Python, 5th Edition",return statement; you simply type,return,568 "Learning Python, 5th Edition",return x + y + z,return,568 "Learning Python, 5th Edition",return action # Return a function object,return,569 "Learning Python, 5th Edition",return x ** 2,return,570 "Learning Python, 5th Edition",return x ** 3 # Define named functions,return,570 "Learning Python, 5th Edition",return x ** 4,return,570 "Learning Python, 5th Edition",return 2 + 2,return,570 "Learning Python, 5th Edition",return 2 * 4,return,570 "Learning Python, 5th Edition",return 2 ** 6,return,570 "Learning Python, 5th Edition","return (lambda y: x + y) # Make and return function, remember x",return,572 "Learning Python, 5th Edition",return x + 10 # Function to be run,return,574 "Learning Python, 5th Edition",return values into a new list. Remember that map is an iterable in,return,574 "Learning Python, 5th Edition",return res,return,575 "Learning Python, 5th Edition",return tally,return,577 "Learning Python, 5th Edition",return to in the next chapter.,return,577 "Learning Python, 5th Edition","return value expression,",return,578 "Learning Python, 5th Edition",return values. They may use mutable arguments to communicate results,return,579 "Learning Python, 5th Edition","return statements, by changing passed-in",return,579 "Learning Python, 5th Edition",return statements are usually,return,579 "Learning Python, 5th Edition","return them in a new list. Syntactically, list comprehensions are enclosed",return,582 "Learning Python, 5th Edition","return results one at a time, suspending and resuming their",return,591 "Learning Python, 5th Edition",return an object that produces results on demand,return,591 "Learning Python, 5th Edition","return In this part of the book, we’ve learned about coding normal functions that receive input",return,592 "Learning Python, 5th Edition",return a,return,592 "Learning Python, 5th Edition",return a result generator that can appear in any iteration context. We stud-,return,592 "Learning Python, 5th Edition","return a value and exit, generator functions automatically",return,592 "Learning Python, 5th Edition",return an object,return,593 "Learning Python, 5th Edition",return a gener-,return,593 "Learning Python, 5th Edition","return statement that, along with falling off the",return,593 "Learning Python, 5th Edition",return statement with no value,return,594 "Learning Python, 5th Edition",return this automatically. The returned,return,594 "Learning Python, 5th Edition","return themselves for iter, because they support next directly.",return,594 "Learning Python, 5th Edition",return res,return,595 "Learning Python, 5th Edition","return any type of object, and as iterables may appear in any of Chap-",return,595 "Learning Python, 5th Edition",return a generator object—an automatically created,return,597 "Learning Python, 5th Edition",return supplemental class objects in-,return,605 "Learning Python, 5th Edition",return a final value to the outer,return,606 "Learning Python, 5th Edition","return results, it’s a normal generator function, and hence an",return,607 "Learning Python, 5th Edition","return values, and the first may leave your cursor at the end of the output line in some",return,608 "Learning Python, 5th Edition",return self or supplemental object,return,608 "Learning Python, 5th Edition",return their objects directly for,return,608 "Learning Python, 5th Edition",return a result;,return,610 "Learning Python, 5th Edition",return res,return,610 "Learning Python, 5th Edition",return [seq[i:] + seq[:i] for i in range(len(seq))],return,610 "Learning Python, 5th Edition",return [seq] # Empty sequence,return,613 "Learning Python, 5th Edition",return res,return,613 "Learning Python, 5th Edition",return objects with methods that handle next operations run by for loops at,return,613 "Learning Python, 5th Edition",return res,return,618 "Learning Python, 5th Edition",return [func(*args) for args in zip(*seqs)],return,618 "Learning Python, 5th Edition",return (func(*args) for args in zip(*seqs)),return,618 "Learning Python, 5th Edition",return generators designed to support the,return,618 "Learning Python, 5th Edition",return res,return,619 "Learning Python, 5th Edition",return res,return,619 "Learning Python, 5th Edition",return True if all and any items in an iterable are True (or,return,619 "Learning Python, 5th Edition","return result lists, it’s just as easy to turn them into generators with yield so that",return,620 "Learning Python, 5th Edition","return one piece of their result set at a time. The results are the same as before,",return,620 "Learning Python, 5th Edition",return [tuple(S[i] for S in seqs) for i in range(minlen)],return,620 "Learning Python, 5th Edition",return [tuple((S[i] if len(S) > i else pad) for S in seqs) for i in index],return,620 "Learning Python, 5th Edition",return (tuple(S[i] for S in seqs) for i in range(minlen)),return,621 "Learning Python, 5th Edition",return statement would. The,return,622 "Learning Python, 5th Edition",return an empty list).,return,622 "Learning Python, 5th Edition","return a generator object, which yields one",return,627 "Learning Python, 5th Edition",return an iterable generator object when,return,627 "Learning Python, 5th Edition","return statement, which terminates the",return,627 "Learning Python, 5th Edition",return time.clock() - start # Total elapsed time in seconds,return,630 "Learning Python, 5th Edition","return (elapsed, ret)",return,631 "Learning Python, 5th Edition","return (best, ret)",return,631 "Learning Python, 5th Edition","return bestof(reps1, total, reps2, func, *pargs, **kargs)",return,631 "Learning Python, 5th Edition",return value so callers can verify its operation.,return,632 "Learning Python, 5th Edition","return the best-of tuple, which embeds the last total call’s result tuple.",return,632 "Learning Python, 5th Edition",return res,return,634 "Learning Python, 5th Edition",return [abs(x) for x in repslist],return,634 "Learning Python, 5th Edition","return list(map(abs, repslist)) # Use list() here in 3.X only!",return,634 "Learning Python, 5th Edition","return map(abs, repslist)",return,634 "Learning Python, 5th Edition",return list(abs(x) for x in repslist) # list() required to force results,return,634 "Learning Python, 5th Edition",return list(gen()) # list() required to force results,return,634 "Learning Python, 5th Edition",return [abs(x) for x in repslist] # 0.69 seconds,return,636 "Learning Python, 5th Edition",return list(abs(x) for x in repslist) # 1.08 seconds: differs internally,return,636 "Learning Python, 5th Edition",return res,return,637 "Learning Python, 5th Edition",return [x + 10 for x in repslist],return,637 "Learning Python, 5th Edition","return list(map((lambda x: x + 10), repslist)) # list() in 3.X only",return,637 "Learning Python, 5th Edition",return list(x + 10 for x in repslist) # list() in 2.X + 3.X,return,637 "Learning Python, 5th Edition",return list(gen()) # list in 2.X + 3.X,return,637 "Learning Python, 5th Edition",return x,return,638 "Learning Python, 5th Edition",return [F(x) for x in repslist],return,638 "Learning Python, 5th Edition","return list(map(F, repslist))",return,638 "Learning Python, 5th Edition",return value slightly and remove a minor overhead charge.,return,638 "Learning Python, 5th Edition","return (elapsed, ret)",return,639 "Learning Python, 5th Edition","return (best, ret)",return,639 "Learning Python, 5th Edition","return min(total(func, *pargs, **kargs) for i in range(_reps1))",return,639 "Learning Python, 5th Edition",return a + b + c + d,return,640 "Learning Python, 5th Edition","return (elapsed, ret)",return,641 "Learning Python, 5th Edition","return (best, ret)",return,641 "Learning Python, 5th Edition","return min(total(func, *pargs, **kargs) for i in range(_reps1))",return,641 "Learning Python, 5th Edition","return x\nlist(f(x) for x in 'spam' * 2500)"")]",return,653 "Learning Python, 5th Edition","return x\n[f(x) for x in 'spam' * 2500]""]",return,653 "Learning Python, 5th Edition","return x\nlist(map(f, 'spam' * 2500))""]",return,653 "Learning Python, 5th Edition","return x\nlist(f(x) for x in 'spam' * 2500)""]",return,653 "Learning Python, 5th Edition","return x"",",return,655 "Learning Python, 5th Edition","return x"",",return,655 "Learning Python, 5th Edition","return x"",",return,655 "Learning Python, 5th Edition",return the new empty list on the right.,return,659 "Learning Python, 5th Edition","return a newly created list, rather than ex-",return,659 "Learning Python, 5th Edition",return (and yield) statements are optional. When a function,return,660 "Learning Python, 5th Edition","return a value explicitly, the function exits when control falls off the end of the",return,660 "Learning Python, 5th Edition",return a value; if you don’t provide a return,return,660 "Learning Python, 5th Edition",return is a None return,return,660 "Learning Python, 5th Edition",return are Python’s equivalent of what are called,return,660 "Learning Python, 5th Edition","return one. As we noted in Chapter 11, for instance, assigning",return,660 "Learning Python, 5th Edition",return the sum (or concatenation) of the two.,return,663 "Learning Python, 5th Edition",return value sum? (Hints: a slice,return,663 "Learning Python, 5th Edition",return a new dictionary containing all the items in its argu-,return,663 "Learning Python, 5th Edition",return a new dictionary containing all the items,return,663 "Learning Python, 5th Edition",return N!. Code,return,665 "Learning Python, 5th Edition",return to this topic in a moment.,return,674 "Learning Python, 5th Edition",return to the Python window and reload the module to fetch the new code. Notice,return,702 "Learning Python, 5th Edition","return values, not cross-module changes.",return,746 "Learning Python, 5th Edition",return res,return,750 "Learning Python, 5th Edition",return x < y,return,750 "Learning Python, 5th Edition",return x > y,return,750 "Learning Python, 5th Edition",return res,return,750 "Learning Python, 5th Edition",return x < y,return,751 "Learning Python, 5th Edition",return x > y,return,751 "Learning Python, 5th Edition",return result,return,752 "Learning Python, 5th Edition","return '%s%*s' % (currency, numwidth, number)",return,752 "Learning Python, 5th Edition","return to more general module topics. In Chapter 22, we learned that the module",return,756 "Learning Python, 5th Edition","return ""Hello""",return,772 "Learning Python, 5th Edition",return an empty,return,791 "Learning Python, 5th Edition","return values, yield items on request, and so on). But in a method function, the",return,799 "Learning Python, 5th Edition",return value becomes the result of the corresponding expression.,return,805 "Learning Python, 5th Edition",return ThirdClass(self.data + other),return,806 "Learning Python, 5th Edition",return '[ThirdClass: %s]' % self.data,return,806 "Learning Python, 5th Edition",return obj.name.upper() # Still needs a self argument (obj),return,811 "Learning Python, 5th Edition","return (self.name, self.jobs)",return,813 "Learning Python, 5th Edition",return self.name.split()[-1] # self is implied subject,return,824 "Learning Python, 5th Edition",return self.name.split()[-1],return,827 "Learning Python, 5th Edition","return '[Person: %s, %s]' % (self.name, self.pay) # String to print",return,827 "Learning Python, 5th Edition",return self.name.split()[-1],return,830 "Learning Python, 5th Edition","return '[Person: %s, %s]' % (self.name, self.pay)",return,830 "Learning Python, 5th Edition",return self.name.split()[-1],return,835 "Learning Python, 5th Edition","return '[Person: %s, %s]' % (self.name, self.pay)",return,835 "Learning Python, 5th Edition","return getattr(self.person, attr) # Delegate all other attrs",return,837 "Learning Python, 5th Edition",return str(self.person) # Must overload again (in 3.X),return,837 "Learning Python, 5th Edition","return ', '.join(attrs)",return,842 "Learning Python, 5th Edition",return 'Spam',return,845 "Learning Python, 5th Edition",return self.name.split()[-1],return,846 "Learning Python, 5th Edition",return data more directly than text embed-,return,854 "Learning Python, 5th Edition",return to class fundamentals and finish,return,855 "Learning Python, 5th Edition",return to our study of the details,return,855 "Learning Python, 5th Edition",return an,return,862 "Learning Python, 5th Edition",return value becomes the result of the,return,887 "Learning Python, 5th Edition",return Number(self.data - other) # Result is a new instance,return,888 "Learning Python, 5th Edition",return index ** 2,return,891 "Learning Python, 5th Edition",return self.data[index] # Perform index or slice,return,892 "Learning Python, 5th Edition",return 255,return,894 "Learning Python, 5th Edition",return self.data[i],return,894 "Learning Python, 5th Edition",return an iterator object.,return,895 "Learning Python, 5th Edition",return self,return,896 "Learning Python, 5th Edition",return self.value ** 2,return,896 "Learning Python, 5th Edition",return SkipIterator(self.wrapped) # New iterator each time,return,900 "Learning Python, 5th Edition",return item,return,900 "Learning Python, 5th Edition","return a new generator object with the requisite __next__. As an added bonus, generator",return,902 "Learning Python, 5th Edition","return SquaresIter(self.start, self.stop)",return,905 "Learning Python, 5th Edition",return self.value ** 2,return,905 "Learning Python, 5th Edition",return self.data[i],return,907 "Learning Python, 5th Edition",return self,return,907 "Learning Python, 5th Edition",return item,return,907 "Learning Python, 5th Edition",return x in self.data,return,907 "Learning Python, 5th Edition",return self.data[i],return,908 "Learning Python, 5th Edition",return x in self.data,return,908 "Learning Python, 5th Edition",return 'addrepr(%s)' % self.data # Convert to as-code string,return,914 "Learning Python, 5th Edition",return a user-friendly,return,914 "Learning Python, 5th Edition","return an as-code string that could be used to re-create the object, or a",return,914 "Learning Python, 5th Edition",return '[Value: %s]' % self.data # Convert to nice string,return,915 "Learning Python, 5th Edition",return '[Value: %s]' % self.data # User-friendly string,return,915 "Learning Python, 5th Edition",return 'addboth(%s)' % self.data # As-code string,return,915 "Learning Python, 5th Edition",return strings;,return,916 "Learning Python, 5th Edition",return str(self.val) # Convert to a string result,return,916 "Learning Python, 5th Edition",return str(self.val) # __repr__ used if echoed or nested,return,916 "Learning Python, 5th Edition",return self.data + other,return,917 "Learning Python, 5th Edition",return self.val + other,return,918 "Learning Python, 5th Edition",return other + self.val,return,918 "Learning Python, 5th Edition",return the same results as the original—though the last saves an extra call or dis-,return,918 "Learning Python, 5th Edition",return self.val + other,return,918 "Learning Python, 5th Edition",return self.__add__(other) # Call __add__ explicitly,return,918 "Learning Python, 5th Edition",return self.val + other,return,918 "Learning Python, 5th Edition",return self + other # Swap order and re-add,return,919 "Learning Python, 5th Edition",return self.val + other,return,919 "Learning Python, 5th Edition",return Commuter5(self.val + other) # Else + result is another Commuter,return,919 "Learning Python, 5th Edition",return Commuter5(other + self.val),return,919 "Learning Python, 5th Edition",return '<Commuter5: %s>' % self.val,return,919 "Learning Python, 5th Edition",return the special NotImplemented object for unsupported operands to influence method,return,920 "Learning Python, 5th Edition",return self,return,921 "Learning Python, 5th Edition",return Number(self.val + other) # Propagates class type,return,921 "Learning Python, 5th Edition",return self.value * other,return,922 "Learning Python, 5th Edition",return self.value * other,return,923 "Learning Python, 5th Edition",return oncall,return,924 "Learning Python, 5th Edition",return self.data > other,return,926 "Learning Python, 5th Edition",return self.data < other,return,926 "Learning Python, 5th Edition",return NotImplemented for unsup-,return,926 "Learning Python, 5th Edition","return cmp(self.data, other) # cmp not defined in 3.X",return,926 "Learning Python, 5th Edition",return (self.data > other) - (self.data < other),return,926 "Learning Python, 5th Edition",return True,return,927 "Learning Python, 5th Edition",return False,return,927 "Learning Python, 5th Edition",return 0,return,927 "Learning Python, 5th Edition",return True # 3.X tries __bool__ first,return,928 "Learning Python, 5th Edition",return 0 # 2.X tries __len__ first,return,928 "Learning Python, 5th Edition",return False:,return,928 "Learning Python, 5th Edition",return False,return,928 "Learning Python, 5th Edition",return False,return,929 "Learning Python, 5th Edition",return 0 from the,return,929 "Learning Python, 5th Edition","return False # Returns int (or True/False, same as 1/0)",return,929 "Learning Python, 5th Edition","return values, but the general usage pattern is",return,931 "Learning Python, 5th Edition","return ""<Employee: name=%s, salary=%s>"" % (self.name, self.salary)",return,935 "Learning Python, 5th Edition",return data.upper(),return,939 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate fetch",return,942 "Learning Python, 5th Edition","return to this issue in the next chapter as a new-style class change,",return,944 "Learning Python, 5th Edition",return arg1 + arg2,return,950 "Learning Python, 5th Edition",return self.data + arg1 + arg2,return,950 "Learning Python, 5th Edition",return self.base * 2,return,951 "Learning Python, 5th Edition",return self.base * 3,return,951 "Learning Python, 5th Edition",return arg ** 2 # Simple functions (def or lambda),return,952 "Learning Python, 5th Edition",return self.val + arg,return,952 "Learning Python, 5th Edition",return self.val * arg,return,952 "Learning Python, 5th Edition",return str(self.val),return,953 "Learning Python, 5th Edition","return aClass(*pargs, **kargs) # Call aClass (or apply in 2.X only)",return,954 "Learning Python, 5th Edition",return an instance.,return,955 "Learning Python, 5th Edition",return result,return,959 "Learning Python, 5th Edition","return '<Instance of %s, address %s:\n%s>' % (",return,959 "Learning Python, 5th Edition",return result,return,964 "Learning Python, 5th Edition","return '<Instance of %s, address %s:\n%s>' % (",return,964 "Learning Python, 5th Edition","return result % ', '.join(unders)",return,965 "Learning Python, 5th Edition",return result,return,967 "Learning Python, 5th Edition","return '\n{0}<Class {1}, address {2}:\n{3}{4}{5}>\n'.format(",return,967 "Learning Python, 5th Edition","return '<Instance of {0}, address {1}:\n{2}{3}>'.format(",return,967 "Learning Python, 5th Edition","return '\n{0}<Class {1}, address {2}:\n{3}{4}{5}>\n'.format(",return,968 "Learning Python, 5th Edition","return '<Instance of %s, address %s:\n%s%s>' % (...) # Expression",return,968 "Learning Python, 5th Edition","return '<Instance of {0}, address {1}:\n{2}{3}>'.format(...) # Method",return,968 "Learning Python, 5th Edition",return Set(res) # Return a new Set,return,980 "Learning Python, 5th Edition",return Set(res),return,980 "Learning Python, 5th Edition","return self.data[key] # self[i], self[i:j]",return,980 "Learning Python, 5th Edition","return list.__getitem__(self, offset - 1)",return,981 "Learning Python, 5th Edition",return Set(res) # Return a new Set,return,982 "Learning Python, 5th Edition",return res,return,982 "Learning Python, 5th Edition",return 'Set:' + list.__repr__(self),return,983 "Learning Python, 5th Edition","return getattr(self.data, name)",return,988 "Learning Python, 5th Edition","return getattr(self.data, name)",return,990 "Learning Python, 5th Edition","return getattr(self.data, name)",return,990 "Learning Python, 5th Edition",return self.data[i] # Run expr or getattr,return,990 "Learning Python, 5th Edition","return getattr(self.data, '__add__')(other)",return,990 "Learning Python, 5th Edition",return value is a list used to initialize the __mro__ attribute when the,return,1004 "Learning Python, 5th Edition","return {K: V2 for (K, V2) in D.items() if V2 != V}",return,1005 "Learning Python, 5th Edition",return sorted(K for K in D.keys() if D[K] == V),return,1005 "Learning Python, 5th Edition",return {V: keysof(V) for V in set(D.values())},return,1005 "Learning Python, 5th Edition",return here,return,1005 "Learning Python, 5th Edition",return attr2obj if not bysource else invertdict(attr2obj),return,1006 "Learning Python, 5th Edition","return the instance’s value. If I code anymore here, though, I’ll deprive readers of the remaining",return,1009 "Learning Python, 5th Edition",return 40,return,1021 "Learning Python, 5th Edition",return 40,return,1021 "Learning Python, 5th Edition",return 40,return,1023 "Learning Python, 5th Edition","return any sort of object, this allows the",return,1035 "Learning Python, 5th Edition","return either the original function itself, or a new proxy object that saves the original",return,1035 "Learning Python, 5th Edition","return functions, the classmethod and property built-in",return,1036 "Learning Python, 5th Edition","return a callable to which the original function name can be rebound. In fact, any such",return,1036 "Learning Python, 5th Edition",return self.func(*args),return,1037 "Learning Python, 5th Edition",return a + b + c,return,1037 "Learning Python, 5th Edition",return value of the spam function itself:,return,1037 "Learning Python, 5th Edition",return func(*args),return,1038 "Learning Python, 5th Edition",return oncall,return,1038 "Learning Python, 5th Edition",return a + b + c,return,1038 "Learning Python, 5th Edition",return a proxy object that,return,1038 "Learning Python, 5th Edition","return aClass # Return class itself, instead of a wrapper",return,1039 "Learning Python, 5th Edition","return getattr(self.wrapped, name)",return,1039 "Learning Python, 5th Edition",return Proxy,return,1039 "Learning Python, 5th Edition","return an arbitrary object to replace it—a protocol with almost limitless class-based custom-",return,1040 "Learning Python, 5th Edition",return to such things at the,return,1041 "Learning Python, 5th Edition",return Spam(),return,1068 "Learning Python, 5th Edition",return Spam(),return,1068 "Learning Python, 5th Edition",return Spam,return,1069 "Learning Python, 5th Edition",return obj[index],return,1083 "Learning Python, 5th Edition",return obj[index],return,1084 "Learning Python, 5th Edition",return 'So I became a waiter...',return,1087 "Learning Python, 5th Edition",return values or status codes after every,return,1088 "Learning Python, 5th Edition",return ERROR; # even if not handled here,return,1089 "Learning Python, 5th Edition",return ERROR;,return,1089 "Learning Python, 5th Edition",return doLastThing();,return,1089 "Learning Python, 5th Edition",return to it if an exception occurs.,return,1094 "Learning Python, 5th Edition",return x / y,return,1099 "Learning Python, 5th Edition",return x / y,return,1099 "Learning Python, 5th Edition",return state-,return,1099 "Learning Python, 5th Edition",return to the code that,return,1100 "Learning Python, 5th Edition",return x ** 2,return,1113 "Learning Python, 5th Edition",return 1 / x # Python checks for zero automatically,return,1113 "Learning Python, 5th Edition",return an object that supports the context manage-,return,1114 "Learning Python, 5th Edition",return a value,return,1114 "Learning Python, 5th Edition",return self,return,1117 "Learning Python, 5th Edition",return False # Propagate,return,1117 "Learning Python, 5th Edition","return statement would have the same effect, as the default None return",return,1117 "Learning Python, 5th Edition",return a,return,1117 "Learning Python, 5th Edition",return 'Not called!',return,1136 "Learning Python, 5th Edition",return 'Called!',return,1136 "Learning Python, 5th Edition",return an empty string at the end of a,return,1146 "Learning Python, 5th Edition",return an empty string—an empty string,return,1146 "Learning Python, 5th Edition","return try:",return,1147 "Learning Python, 5th Edition","return a sentinel value to designate success or failure. In a widely applicable function,",return,1147 "Learning Python, 5th Edition","return values, it’s impossible for any",return,1147 "Learning Python, 5th Edition",return value to signal a failure condition. Exceptions provide a way to signal results,return,1147 "Learning Python, 5th Edition",return value:,return,1147 "Learning Python, 5th Edition",return ...founditem...,return,1147 "Learning Python, 5th Edition","return values, are the generally preferred way to signal such conditions.",return,1147 "Learning Python, 5th Edition",return bytes results,return,1190 "Learning Python, 5th Edition","return file content to you raw, as a sequence of integers",return,1196 "Learning Python, 5th Edition",return a str for reads,return,1196 "Learning Python, 5th Edition",return a bytes for reads and expect one (or,return,1196 "Learning Python, 5th Edition",return content as str strings. The only major difference is that text files automat-,return,1197 "Learning Python, 5th Edition","return contents as a bytes object, but accept either a bytes or",return,1198 "Learning Python, 5th Edition",return corrupted data in the,return,1201 "Learning Python, 5th Edition",return an object’s pickle string:,return,1209 "Learning Python, 5th Edition",return self.name.transform(),return,1220 "Learning Python, 5th Edition",return nothing,return,1222 "Learning Python, 5th Edition",return self._name,return,1222 "Learning Python, 5th Edition",return self.value ** 2,return,1224 "Learning Python, 5th Edition",return a copy of the,return,1225 "Learning Python, 5th Edition",return self._name,return,1225 "Learning Python, 5th Edition",return instance._name,return,1230 "Learning Python, 5th Edition",return instance._name,return,1231 "Learning Python, 5th Edition",return self.value ** 2,return,1232 "Learning Python, 5th Edition",return self.value * 10,return,1233 "Learning Python, 5th Edition",return instance._X * 10,return,1234 "Learning Python, 5th Edition","return '%s, %s' % (self.data, instance.data)",return,1235 "Learning Python, 5th Edition",return self.fget(instance) # Pass instance to self,return,1236 "Learning Python, 5th Edition",return the property object (self should suffice). Since the prop,return,1237 "Learning Python, 5th Edition","return an attribute’s value, and the other two return nothing",return,1239 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate fetch",return,1239 "Learning Python, 5th Edition",return self._name # Does not loop: real attr,return,1241 "Learning Python, 5th Edition","return object.__getattribute__(self, attr) # Avoid looping here",return,1243 "Learning Python, 5th Edition","return object.__getattribute__(self, attr)",return,1244 "Learning Python, 5th Edition",return 3,return,1245 "Learning Python, 5th Edition","return object.__getattribute__(self, attr)",return,1245 "Learning Python, 5th Edition",return self._square ** 2,return,1246 "Learning Python, 5th Edition",return self._cube ** 3,return,1246 "Learning Python, 5th Edition",return instance._square ** 2,return,1247 "Learning Python, 5th Edition",return instance._cube ** 3,return,1247 "Learning Python, 5th Edition","return object.__getattribute__(self, name)",return,1248 "Learning Python, 5th Edition",return 42,return,1250 "Learning Python, 5th Edition",return lambda *args: None,return,1250 "Learning Python, 5th Edition",return 42,return,1250 "Learning Python, 5th Edition",return lambda *args: None,return,1250 "Learning Python, 5th Edition",return self.name.split()[-1],return,1253 "Learning Python, 5th Edition","return '[Person: %s, %s]' % (self.name, self.pay)",return,1253 "Learning Python, 5th Edition","return getattr(self.person, attr) # Delegate all other attrs",return,1254 "Learning Python, 5th Edition",return str(self.person) # Must overload again (in 3.X),return,1254 "Learning Python, 5th Edition","return getattr(self.person, attr) # Delegate all other attrs",return,1254 "Learning Python, 5th Edition","return getattr(self.person, attr) # Delegate all others",return,1255 "Learning Python, 5th Edition","return getattr(person, attr)",return,1256 "Learning Python, 5th Edition",return str(person),return,1256 "Learning Python, 5th Edition",return self.__name,return,1257 "Learning Python, 5th Edition",return self.__age,return,1257 "Learning Python, 5th Edition",return self.__acct[:-3] + '***',return,1258 "Learning Python, 5th Edition",return self.retireage - self.age # Unless already using as attr,return,1258 "Learning Python, 5th Edition",return module.CardHolder,return,1258 "Learning Python, 5th Edition",return self.name,return,1260 "Learning Python, 5th Edition",return self.age # Use descriptor data,return,1260 "Learning Python, 5th Edition",return self.acct[:-3] + '***',return,1260 "Learning Python, 5th Edition",return instance.retireage - instance.age # Triggers Age.__get__,return,1260 "Learning Python, 5th Edition",return instance.__name,return,1262 "Learning Python, 5th Edition",return instance.__age # Use descriptor data,return,1262 "Learning Python, 5th Edition",return instance.__acct[:-3] + '***',return,1262 "Learning Python, 5th Edition",return instance.retireage - instance.age # Triggers Age.__get__,return,1262 "Learning Python, 5th Edition","return self._acct[:-3] + '***' # name, age, addr are defined",return,1264 "Learning Python, 5th Edition","return superget(self, 'acct')[:-3] + '***'",return,1266 "Learning Python, 5th Edition","return superget(self, name) # name, age, addr: stored",return,1266 "Learning Python, 5th Edition",return the aug-,return,1267 "Learning Python, 5th Edition",return any type of callable: any,return,1274 "Learning Python, 5th Edition",return F,return,1274 "Learning Python, 5th Edition",return a different object than the original function—a proxy for,return,1274 "Learning Python, 5th Edition",return wrapper,return,1275 "Learning Python, 5th Edition",return wrapper,return,1276 "Learning Python, 5th Edition",return the original class,return,1277 "Learning Python, 5th Edition",return C,return,1278 "Learning Python, 5th Edition",return a,return,1278 "Learning Python, 5th Edition","return getattr(self.wrapped, name)",return,1278 "Learning Python, 5th Edition",return Wrapper,return,1278 "Learning Python, 5th Edition","return callables, classes that use __init__ or __call__ methods",return,1278 "Learning Python, 5th Edition",return self,return,1279 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname)",return,1279 "Learning Python, 5th Edition",return Wrapper,return,1279 "Learning Python, 5th Edition",return Wrapper(C(*args)) # Embed instance in instance,return,1279 "Learning Python, 5th Edition",return onCall,return,1279 "Learning Python, 5th Edition",return value types after function calls. You can use,return,1279 "Learning Python, 5th Edition",return either the original class or an inserted wrapper,return,1280 "Learning Python, 5th Edition",return the decorated func-,return,1281 "Learning Python, 5th Edition",return F,return,1281 "Learning Python, 5th Edition",return F,return,1281 "Learning Python, 5th Edition",return F,return,1281 "Learning Python, 5th Edition",return lambda: 'X' + F(),return,1281 "Learning Python, 5th Edition",return lambda: 'Y' + F(),return,1281 "Learning Python, 5th Edition",return lambda: 'Z' + F(),return,1281 "Learning Python, 5th Edition",return 'spam',return,1281 "Learning Python, 5th Edition",return callable,return,1282 "Learning Python, 5th Edition",return actualDecorator,return,1282 "Learning Python, 5th Edition",return O,return,1282 "Learning Python, 5th Edition","return the original decorated object this way instead of a proxy, we can",return,1283 "Learning Python, 5th Edition","return results, but we’ll fix these shortcomings later in this sec-",return,1283 "Learning Python, 5th Edition","return self.func(*args, **kwargs)",return,1285 "Learning Python, 5th Edition","return func(*args, **kwargs)",return,1286 "Learning Python, 5th Edition",return wrapper,return,1286 "Learning Python, 5th Edition","return func(*args, **kwargs)",return,1287 "Learning Python, 5th Edition",return wrapper,return,1287 "Learning Python, 5th Edition","return func(*args, **kwargs)",return,1288 "Learning Python, 5th Edition",return wrapper,return,1288 "Learning Python, 5th Edition","return self.func(*args, **kwargs)",return,1289 "Learning Python, 5th Edition",return self.name.split()[-1],return,1290 "Learning Python, 5th Edition","return func(*args, **kwargs)",return,1291 "Learning Python, 5th Edition",return onCall,return,1291 "Learning Python, 5th Edition",return 2 ** N,return,1291 "Learning Python, 5th Edition",return self.name.split()[-1],return,1292 "Learning Python, 5th Edition","return self.func(*args, **kwargs)",return,1293 "Learning Python, 5th Edition","return wrapper(self, instance)",return,1293 "Learning Python, 5th Edition","return self.desc(self.subj, *args, **kwargs) # Runs tracer.__call__",return,1293 "Learning Python, 5th Edition","return self.func(*args, **kwargs)",return,1294 "Learning Python, 5th Edition","return self(instance, *args, **kwargs) # Runs __call__",return,1294 "Learning Python, 5th Edition",return wrapper,return,1294 "Learning Python, 5th Edition","return self.meth(instance, *args, **kwargs)",return,1295 "Learning Python, 5th Edition",return wrapper,return,1295 "Learning Python, 5th Edition",return result,return,1296 "Learning Python, 5th Edition",return [x * 2 for x in range(N)],return,1296 "Learning Python, 5th Edition","return force(map((lambda x: x * 2), range(N)))",return,1296 "Learning Python, 5th Edition","return value, cumulative time for each function,",return,1296 "Learning Python, 5th Edition",return onCall,return,1298 "Learning Python, 5th Edition",return decorator # Returns the actual decorator,return,1298 "Learning Python, 5th Edition",return result,return,1299 "Learning Python, 5th Edition",return Timer,return,1299 "Learning Python, 5th Edition",return [x * 2 for x in range(N)] # listcomp(...) triggers Timer.__call__,return,1299 "Learning Python, 5th Edition","return force(map((lambda x: x * 2), range(N)))",return,1300 "Learning Python, 5th Edition",return [x * 2 for x in range(N)],return,1300 "Learning Python, 5th Edition",return [x * 2 for x in range(N)],return,1301 "Learning Python, 5th Edition",return instances[aClass],return,1302 "Learning Python, 5th Edition",return onCall,return,1302 "Learning Python, 5th Edition",return self.hours * self.rate,return,1302 "Learning Python, 5th Edition",return instance,return,1303 "Learning Python, 5th Edition",return onCall,return,1303 "Learning Python, 5th Edition",return onCall.instance,return,1303 "Learning Python, 5th Edition",return onCall,return,1303 "Learning Python, 5th Edition",return self.instance,return,1303 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate fetch",return,1304 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate to wrapped obj",return,1305 "Learning Python, 5th Edition",return Wrapper,return,1305 "Learning Python, 5th Edition",return self.hours * self.rate # In-method accesses not traced,return,1305 "Learning Python, 5th Edition",return self,return,1308 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname)",return,1308 "Learning Python, 5th Edition",return instances[aClass],return,1309 "Learning Python, 5th Edition",return instances[aClass],return,1309 "Learning Python, 5th Edition","return obj # Return obj itself, not a wrapper",return,1312 "Learning Python, 5th Edition",return str(self.data),return,1312 "Learning Python, 5th Edition",return func,return,1313 "Learning Python, 5th Edition",return a + b,return,1314 "Learning Python, 5th Edition",return func,return,1314 "Learning Python, 5th Edition",return decorate,return,1314 "Learning Python, 5th Edition",return a + b,return,1314 "Learning Python, 5th Edition","return getattr(self.wrapped, attr)",return,1315 "Learning Python, 5th Edition",return onDecorator,return,1315 "Learning Python, 5th Edition",return len(self.data) # Methods run with no checking,return,1316 "Learning Python, 5th Edition","return getattr(self.__wrapped, attr)",return,1319 "Learning Python, 5th Edition",return onInstance,return,1319 "Learning Python, 5th Edition",return onDecorator,return,1319 "Learning Python, 5th Edition",return accessControl(failIf=(lambda attr: attr in attributes)),return,1320 "Learning Python, 5th Edition",return accessControl(failIf=(lambda attr: attr not in attributes)),return,1320 "Learning Python, 5th Edition",return 'Person: ' + str(self.age),return,1323 "Learning Python, 5th Edition",return 'Person: ' + str(self.age),return,1323 "Learning Python, 5th Edition",return str(self.__wrapped),return,1324 "Learning Python, 5th Edition","return self.__wrapped + other # Or getattr(x, '__add__')(y)",return,1324 "Learning Python, 5th Edition",return self.__wrapped[index] # If needed,return,1324 "Learning Python, 5th Edition","return self.__wrapped(*args, **kargs) # If needed",return,1324 "Learning Python, 5th Edition",return onInstance,return,1325 "Learning Python, 5th Edition",return onDecorator,return,1325 "Learning Python, 5th Edition",return self._wrapped + other # Assume a _wrapped,return,1325 "Learning Python, 5th Edition",return str(self._wrapped),return,1325 "Learning Python, 5th Edition",return self._wrapped[index],return,1325 "Learning Python, 5th Edition","return self._wrapped(*args, **kargs)",return,1326 "Learning Python, 5th Edition","return self.reroute('__add__', other)",return,1326 "Learning Python, 5th Edition",return self.reroute('__str__'),return,1326 "Learning Python, 5th Edition","return self.reroute('__getitem__', index)",return,1326 "Learning Python, 5th Edition","return self.reroute('__call__', *args, **kargs)",return,1326 "Learning Python, 5th Edition","return getattr(instance._wrapped, self.attrname) # Assume a _wrapped",return,1326 "Learning Python, 5th Edition","return object.__getattribute__(self, attr)",return,1328 "Learning Python, 5th Edition","return object.__setattr__(self, attr, value)",return,1328 "Learning Python, 5th Edition",return aClass # Return original class,return,1328 "Learning Python, 5th Edition",return onDecorator,return,1328 "Learning Python, 5th Edition",return func # No-op: call original directly,return,1331 "Learning Python, 5th Edition",return func(*args),return,1331 "Learning Python, 5th Edition",return onCall,return,1331 "Learning Python, 5th Edition",return onDecorator,return,1331 "Learning Python, 5th Edition",return func # Wrap if debugging; else use original,return,1333 "Learning Python, 5th Edition","return func(*pargs, **kargs) # OK: run original call",return,1334 "Learning Python, 5th Edition",return onCall,return,1334 "Learning Python, 5th Edition",return onDecorator,return,1334 "Learning Python, 5th Edition","return values, by coding them in the def header line itself; Python",return,1340 "Learning Python, 5th Edition","return func(*pargs, **kargs)",return,1341 "Learning Python, 5th Edition",return onCall,return,1341 "Learning Python, 5th Edition",return onDecorator,return,1341 "Learning Python, 5th Edition","return func(*pargs, **kargs)",return,1341 "Learning Python, 5th Edition",return onCall,return,1341 "Learning Python, 5th Edition","return func(*pargs, **kargs)",return,1343 "Learning Python, 5th Edition",return onCall,return,1343 "Learning Python, 5th Edition",return onDecorator,return,1343 "Learning Python, 5th Edition",return result,return,1345 "Learning Python, 5th Edition",return onCall,return,1345 "Learning Python, 5th Edition",return onDecorator,return,1345 "Learning Python, 5th Edition",return [x * 2 for x in range(N)] # listcomp(...) triggers onCall,return,1346 "Learning Python, 5th Edition","return force(map((lambda x: x * 2), range(N))) # list() for 3.X views",return,1346 "Learning Python, 5th Edition","return self.name.split()[-1] # alltime per class, not instance",return,1346 "Learning Python, 5th Edition","return the original class in optimized mode (–O), so at-",return,1347 "Learning Python, 5th Edition","return getattr(self.__wrapped, attr)",return,1347 "Learning Python, 5th Edition",return onInstance,return,1347 "Learning Python, 5th Edition",return onDecorator,return,1348 "Learning Python, 5th Edition",return accessControl(failIf=(lambda attr: attr in attributes)),return,1348 "Learning Python, 5th Edition",return accessControl(failIf=(lambda attr: attr not in attributes)),return,1348 "Learning Python, 5th Edition","return self.reroute('__add__', other)",return,1348 "Learning Python, 5th Edition",return self.reroute('__str__'),return,1348 "Learning Python, 5th Edition","return self.reroute('__getitem__', index)",return,1348 "Learning Python, 5th Edition","return self.reroute('__call__', *args, **kargs)",return,1348 "Learning Python, 5th Edition","return '%s: %s' % (self.name, self.age)",return,1349 "Learning Python, 5th Edition","return argtest(argchecks, lambda arg, vals: arg < vals[0] or arg > vals[1])",return,1350 "Learning Python, 5th Edition","return argtest(argchecks, lambda arg, type: not isinstance(arg, type))",return,1350 "Learning Python, 5th Edition","return argtest(argchecks, lambda arg, tester: not tester(arg))",return,1350 "Learning Python, 5th Edition",return func,return,1351 "Learning Python, 5th Edition","return func(*pargs, **kargs) # OK: run original call",return,1351 "Learning Python, 5th Edition",return onCall,return,1351 "Learning Python, 5th Edition",return onDecorator,return,1351 "Learning Python, 5th Edition",return a * 1000,return,1353 "Learning Python, 5th Edition",return a * 1000,return,1353 "Learning Python, 5th Edition","return the new client class. Therefore, they are often used for managing or augmenting",return,1359 "Learning Python, 5th Edition","return the augmented class,",return,1361 "Learning Python, 5th Edition",return any type of object that implements the,return,1362 "Learning Python, 5th Edition",return Class,return,1362 "Learning Python, 5th Edition",return Class,return,1362 "Learning Python, 5th Edition",return to in the next chapter’s final words.,return,1364 "Learning Python, 5th Edition",return self.data + arg,return,1368 "Learning Python, 5th Edition",return self.data + arg,return,1370 "Learning Python, 5th Edition",return the new class object:,return,1371 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1371 "Learning Python, 5th Edition",return self.data + arg,return,1371 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1372 "Learning Python, 5th Edition",return self.data + arg,return,1372 "Learning Python, 5th Edition","return type(classname, supers, classdict)",return,1373 "Learning Python, 5th Edition",return self.data + arg,return,1373 "Learning Python, 5th Edition",return Class,return,1374 "Learning Python, 5th Edition","return type(classname, supers, classdict)",return,1374 "Learning Python, 5th Edition",return self.data + arg,return,1374 "Learning Python, 5th Edition",return Class,return,1375 "Learning Python, 5th Edition","return type(classname, supers, classdict)",return,1375 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1376 "Learning Python, 5th Edition",return self.data + arg,return,1376 "Learning Python, 5th Edition","return type.__call__(meta, classname, supers, classdict)",return,1378 "Learning Python, 5th Edition","return arbitrary objects, instead of type subclasses.",return,1379 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1379 "Learning Python, 5th Edition",return 'toast',return,1379 "Learning Python, 5th Edition",return 'spam',return,1380 "Learning Python, 5th Edition",return 'eggs' # But not from metaclasses,return,1380 "Learning Python, 5th Edition",return a value found in step a,return,1386 "Learning Python, 5th Edition",return a value found in step a,return,1386 "Learning Python, 5th Edition",return cls.x,return,1389 "Learning Python, 5th Edition","return cls.data[i] # Built-ins skip class, use meta",return,1390 "Learning Python, 5th Edition","return getattr(cls.data, name) # But not run same by built-ins",return,1390 "Learning Python, 5th Edition",return self.value * 2,return,1392 "Learning Python, 5th Edition",return obj.value * 4,return,1392 "Learning Python, 5th Edition",return value + 'ham',return,1392 "Learning Python, 5th Edition",return obj.value * 4,return,1393 "Learning Python, 5th Edition",return value + 'ham',return,1393 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1393 "Learning Python, 5th Edition",return self.value * 2,return,1393 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1394 "Learning Python, 5th Edition",return obj.value * 4,return,1395 "Learning Python, 5th Edition",return value + 'ham',return,1395 "Learning Python, 5th Edition",return aClass,return,1395 "Learning Python, 5th Edition",return self.value * 2,return,1395 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate to wrapped object",return,1396 "Learning Python, 5th Edition",return Wrapper,return,1396 "Learning Python, 5th Edition",return self.hours * self.rate,return,1396 "Learning Python, 5th Edition","return getattr(self.wrapped, attrname) # Delegate to wrapped object",return,1397 "Learning Python, 5th Edition",return Wrapper,return,1397 "Learning Python, 5th Edition",return self.hours * self.rate,return,1397 "Learning Python, 5th Edition",return an instance,return,1397 "Learning Python, 5th Edition","return type.__new__(meta, clsname, supers, attrdict)",return,1398 "Learning Python, 5th Edition",return self.x + self.y,return,1398 "Learning Python, 5th Edition","return decorator(type(clsname, supers, attrdict))",return,1399 "Learning Python, 5th Edition",return a type instance either—any object,return,1399 "Learning Python, 5th Edition",return 'spam',return,1399 "Learning Python, 5th Edition",return 'spam',return,1399 "Learning Python, 5th Edition","return func(*args, **kwargs)",return,1400 "Learning Python, 5th Edition",return onCall,return,1400 "Learning Python, 5th Edition",return result,return,1400 "Learning Python, 5th Edition",return onCall,return,1400 "Learning Python, 5th Edition",return onDecorator,return,1400 "Learning Python, 5th Edition",return self.name.split()[-1],return,1401 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict) # Make class",return,1402 "Learning Python, 5th Edition",return self.name.split()[-1],return,1402 "Learning Python, 5th Edition","return type.__new__(meta, classname, supers, classdict)",return,1403 "Learning Python, 5th Edition",return MetaDecorate,return,1403 "Learning Python, 5th Edition",return self.name.split()[-1],return,1403 "Learning Python, 5th Edition",return aClass,return,1405 "Learning Python, 5th Edition",return DecoDecorate,return,1405 "Learning Python, 5th Edition",return self.name.split()[-1],return,1405 "Learning Python, 5th Edition",return the original class objects. Metaclasses aug-,return,1408 "Learning Python, 5th Edition",return types to be anno-,return,1453 "Learning Python, 5th Edition",return a new object of the same type as the,return,1471 "Learning Python, 5th Edition",return x + y,return,1476 "Learning Python, 5th Edition",return sum,return,1476 "Learning Python, 5th Edition",return sum,return,1476 "Learning Python, 5th Edition",return good + bad + ugly,return,1477 "Learning Python, 5th Edition",return tot,return,1477 "Learning Python, 5th Edition",return tot,return,1477 "Learning Python, 5th Edition",return tot,return,1477 "Learning Python, 5th Edition",return adder1(*args.values()),return,1477 "Learning Python, 5th Edition",return new,return,1478 "Learning Python, 5th Edition",return new,return,1478 "Learning Python, 5th Edition","return values, instead of printing",return,1480 "Learning Python, 5th Edition",return res,return,1481 "Learning Python, 5th Edition",return res,return,1481 "Learning Python, 5th Edition",return res,return,1481 "Learning Python, 5th Edition",return {i: i for i in range(I)},return,1482 "Learning Python, 5th Edition",return new,return,1482 "Learning Python, 5th Edition",return N,return,1484 "Learning Python, 5th Edition",return N * fact0(N-1),return,1484 "Learning Python, 5th Edition","return N if N == 1 else N * fact1(N-1) # Recursive, one-liner",return,1484 "Learning Python, 5th Edition","return reduce(lambda x, y: x * y, range(1, N+1))",return,1484 "Learning Python, 5th Edition",return res,return,1484 "Learning Python, 5th Edition","return math.factorial(N) # Stdlib ""batteries""",return,1484 "Learning Python, 5th Edition",return S[-1] + rev1(S[:-1]) # Recursive: 10x slower in CPython today,return,1485 "Learning Python, 5th Edition","return ''.join(reversed(S)) # Nonrecursive iterable: simpler, faster",return,1485 "Learning Python, 5th Edition",return S[::-1] # Even better?: sequence reversal by slice,return,1485 "Learning Python, 5th Edition",return len(file.readlines()),return,1485 "Learning Python, 5th Edition","return countLines(name), countChars(name) # Or return a dictionary",return,1485 "Learning Python, 5th Edition",return tot,return,1485 "Learning Python, 5th Edition",return tot,return,1486 "Learning Python, 5th Edition",return len(file.readlines()),return,1486 "Learning Python, 5th Edition","return countLines(file), countChars(file) # Open file only once",return,1486 "Learning Python, 5th Edition",return len(file.readlines()),return,1487 "Learning Python, 5th Edition","return countLines(name), countChars(name) # Or return a dictionary",return,1487 "Learning Python, 5th Edition","return self.add(self.data, other) # Or return type?",return,1489 "Learning Python, 5th Edition",return x + y,return,1489 "Learning Python, 5th Edition",return new,return,1489 "Learning Python, 5th Edition",return self.add(other) # The left side is in self,return,1490 "Learning Python, 5th Edition",return self.data + y,return,1490 "Learning Python, 5th Edition",return d,return,1490 "Learning Python, 5th Edition",return MyList(self.wrapped + other),return,1491 "Learning Python, 5th Edition",return MyList(self.wrapped * time),return,1491 "Learning Python, 5th Edition",return self.wrapped[offset] # For iteration if no __iter__,return,1491 "Learning Python, 5th Edition",return len(self.wrapped),return,1491 "Learning Python, 5th Edition",return MyList(self.wrapped[low:high]),return,1491 "Learning Python, 5th Edition","return getattr(self.wrapped, name)",return,1491 "Learning Python, 5th Edition",return repr(self.wrapped),return,1491 "Learning Python, 5th Edition","return MyList.__add__(self, other)",return,1492 "Learning Python, 5th Edition","return self.calls, self.adds # All adds, my adds",return,1492 "Learning Python, 5th Edition","return a value to make them work. As noted in Chapter 32 and elsewhere,",return,1492 "Learning Python, 5th Edition",return Set(res),return,1494 "Learning Python, 5th Edition",return Set(res),return,1494 "Learning Python, 5th Edition","return '<Instance of %s(%s), address %s:\n%s>' % (",return,1495 "Learning Python, 5th Edition","return ', '.join(names)",return,1495 "Learning Python, 5th Edition",return Food(foodName),return,1496 "Learning Python, 5th Edition","return ""that's one ex-bird!""",return,1497 "Learning Python, 5th Edition","return ""no it isn't...""",return,1497 "Learning Python, 5th Edition",return None,return,1497 "Learning Python, 5th Edition","return callee(*pargs, **kargs)",return,1499 "Learning Python, 5th Edition",return callproxy,return,1499 "Learning Python, 5th Edition","return statement, 592–597",return,1519 "Learning Python, 5th Edition",return statement,return,1532 "Learning Python, 5th Edition","return statement versus, 592–597",return,1540 "Learning Python, 5th Edition",if this doesn’t work right away for you):,simpleif,56 "Learning Python, 5th Edition","if not 'f' in D: print('missing')",simpleif,117 "Learning Python, 5th Edition",if statement squeezed onto a single line. Here are a few examples:,simpleif,118 "Learning Python, 5th Edition",if you provide the proper encoding name:,simpleif,125 "Learning Python, 5th Edition",if present (more on this later in the book):,simpleif,125 "Learning Python, 5th Edition",if needed:,simpleif,206 "Learning Python, 5th Edition","if desired, assign the result back to the string’s original name:",simpleif,208 "Learning Python, 5th Edition",if there’s a clash:,simpleif,255 "Learning Python, 5th Edition",if needed:,simpleif,280 "Learning Python, 5th Edition","if you want to scan a text file line by line, file iterators are often your best option:",simpleif,286 "Learning Python, 5th Edition","if we wish to perform math on these: >>> int(parts[1]) # Convert from string to int",simpleif,289 "Learning Python, 5th Edition",if we pickle in other data protocol modes):,simpleif,290 "Learning Python, 5th Edition",if needed:,simpleif,311 "Learning Python, 5th Edition",if a sequence is as long as you expect:,simpleif,314 "Learning Python, 5th Edition","if statement, coded in a C-like language:",simpleif,322 "Learning Python, 5th Edition","if x > y: x = 1",simpleif,322 "Learning Python, 5th Edition","if x > y: x = 1",simpleif,324 "Learning Python, 5th Edition","if x: if y:",simpleif,326 "Learning Python, 5th Edition",if all tests prove false. The general form of an if statement looks like this:,simpleif,371 "Learning Python, 5th Edition","if 1: ... print('true')",simpleif,372 "Learning Python, 5th Edition","if not 1: ... print('true')",simpleif,372 "Learning Python, 5th Edition","if x == 'roger': ... print(""shave and a haircut"")",simpleif,372 "Learning Python, 5th Edition","if x == 'bugs': ... print(""what's up doc?"")",simpleif,372 "Learning Python, 5th Edition",if logic in your script:,simpleif,373 "Learning Python, 5th Edition","if statement might look like the following:",simpleif,373 "Learning Python, 5th Edition","if choice == 'ham': ... print(1.99)",simpleif,373 "Learning Python, 5th Edition","if choice == 'eggs': ... print(0.99)",simpleif,373 "Learning Python, 5th Edition","if choice == 'bacon': ... print(1.10)",simpleif,373 "Learning Python, 5th Edition",if statement can have the same default effect:,simpleif,374 "Learning Python, 5th Edition","if choice in branch: ... print(branch[choice])",simpleif,374 "Learning Python, 5th Edition","if x: y = 2",simpleif,376 "Learning Python, 5th Edition","if y: print('block2')",simpleif,376 "Learning Python, 5th Edition","if x.endswith('NI'): x *= 2",simpleif,377 "Learning Python, 5th Edition","if x.endswith('NI'): x *= 2",simpleif,377 "Learning Python, 5th Edition","if A is true (or nonempty), and to default otherwise:",simpleif,384 "Learning Python, 5th Edition",if the short-circuit rule takes effect:,simpleif,384 "Learning Python, 5th Edition",if no specific type is required:,simpleif,390 "Learning Python, 5th Edition","if x: ...process x...",simpleif,394 "Learning Python, 5th Edition",if you want them to be:,simpleif,403 "Learning Python, 5th Edition","if you shuffle a list, you create reordered lists:",simpleif,405 "Learning Python, 5th Edition","if parts and parts[0].lower() == 'system type': ... print(parts[1].strip())",simpleif,412 "Learning Python, 5th Edition","if line[0] == 'p': ... res.append(line.rstrip())",simpleif,428 "Learning Python, 5th Edition",if tests:,simpleif,432 "Learning Python, 5th Edition",if you plan to operate heavy machinery anytime soon!):,simpleif,433 "Learning Python, 5th Edition",if you require more list tools):,simpleif,435 "Learning Python, 5th Edition","if 2 ** X == L[i]: found = True",simpleif,468 "Learning Python, 5th Edition","if test: def func(): # Define func this way",simpleif,477 "Learning Python, 5th Edition",if they are already there:,simpleif,511 "Learning Python, 5th Edition",if used:,simpleif,539 "Learning Python, 5th Edition",if passed:,simpleif,541 "Learning Python, 5th Edition","if arg < res: res = arg",simpleif,543 "Learning Python, 5th Edition","if arg < first: first = arg",simpleif,543 "Learning Python, 5th Edition","if test(arg, res): res = arg",simpleif,544 "Learning Python, 5th Edition","if not x in res: res.append(x) # Add new items to result",simpleif,545 "Learning Python, 5th Edition","if not L: return 0",simpleif,555 "Learning Python, 5th Edition","if not isinstance(x, list): tot += x # Add numbers directly",simpleif,558 "Learning Python, 5th Edition","if state not in visited: visited.add(state) # x.add(state), x[state]=True, or x.append(state)",simpleif,560 "Learning Python, 5th Edition",if we recoded the prior def with a lambda:,simpleif,572 "Learning Python, 5th Edition","if x > 0: res.append(x)",simpleif,576 "Learning Python, 5th Edition","if x % 2 == 0: res.append(x)",simpleif,583 "Learning Python, 5th Edition","if selections on nested for clauses applied to numeric objects rather than strings:",simpleif,585 "Learning Python, 5th Edition","if x % 2 == 0: for y in range(5):",simpleif,585 "Learning Python, 5th Edition","if y % 2 == 1: res.append((x, y))",simpleif,585 "Learning Python, 5th Edition","if the code using it produces all results with a tool like join:",simpleif,603 "Learning Python, 5th Edition","if len(x) > 1: yield x.upper()",simpleif,603 "Learning Python, 5th Edition","if name.startswith('call'): print(root, name)",simpleif,607 "Learning Python, 5th Edition",if you want to run it live):,simpleif,618 "Learning Python, 5th Edition",if left in:,simpleif,636 "Learning Python, 5th Edition",if omitted; in Python 3.3:,simpleif,640 "Learning Python, 5th Edition","if required by your shell:",simpleif,646 "Learning Python, 5th Edition","if not pythons: # Run stmt on this python: API call",simpleif,648 "Learning Python, 5th Edition","if not pythons: ...",simpleif,655 "Learning Python, 5th Edition","if you add an assignment to X after the reference:",simpleif,657 "Learning Python, 5th Edition","if you mean to print the global X, you need to declare it in a global statement:",simpleif,657 "Learning Python, 5th Edition",if nothing else was found along the way:,simpleif,740 "Learning Python, 5th Edition","if test(arg, res): res = arg",simpleif,750 "Learning Python, 5th Edition","if test(arg, res): res = arg",simpleif,750 "Learning Python, 5th Edition","if len(sys.argv) == 1: selftest()",simpleif,752 "Learning Python, 5th Edition","if verbose: print(sepline)",simpleif,760 "Learning Python, 5th Edition","if attr.startswith('__'): print('<built-in name>') # Skip __file__, etc.",simpleif,760 "Learning Python, 5th Edition","if verbose: print(sepline)",simpleif,760 "Learning Python, 5th Edition","if type(obj) == types.ModuleType and obj not in visited: status(obj)",simpleif,767 "Learning Python, 5th Edition",if the names in the original module are later reset:,simpleif,774 "Learning Python, 5th Edition",if you want to inspect it:,simpleif,811 "Learning Python, 5th Edition",if you try to call a method without any instance:,simpleif,864 "Learning Python, 5th Edition",if you need a refresher on slicing):,simpleif,891 "Learning Python, 5th Edition",if omitted:,simpleif,892 "Learning Python, 5th Edition",if it’s defined:,simpleif,895 "Learning Python, 5th Edition","if self.value == self.stop: raise StopIteration",simpleif,905 "Learning Python, 5th Edition","if attrname == 'age': return 40",simpleif,910 "Learning Python, 5th Edition","if attr == 'age': self.__dict__[attr] = value + 10 # Not self.name=val or setattr",simpleif,911 "Learning Python, 5th Edition","if attrname in self.privates: raise PrivateExc(attrname, self) # Make, raise user-define except",simpleif,912 "Learning Python, 5th Edition","if attr.startswith('__') and attr.endswith('__'): result += spaces + '{0}\n'.format(attr)",simpleif,967 "Learning Python, 5th Edition","if aClass in self.__visited: return '\n{0}<Class {1}:, address {2}: (see above)>\n'.format(",simpleif,967 "Learning Python, 5th Edition","if attr.startswith('__') and attr.endswith('__'): # result += spaces + '{0}\n'.format(attr)",simpleif,971 "Learning Python, 5th Edition","if not x in res: res.append(x)",simpleif,980 "Learning Python, 5th Edition","if not x in self.data: self.data.append(x)",simpleif,980 "Learning Python, 5th Edition",if not x in self:,simpleif,982 "Learning Python, 5th Edition",if no other built-in type is appropriate to use:,simpleif,984 "Learning Python, 5th Edition",if not withobject:,simpleif,1005 "Learning Python, 5th Edition","if name == 'age': return 40",simpleif,1020 "Learning Python, 5th Edition","if name == 'age': return 40",simpleif,1022 "Learning Python, 5th Edition","if name == 'age': self.__dict__['_age'] = value # Or object.__setattr__()",simpleif,1022 "Learning Python, 5th Edition",if the exception goes uncaught:,simpleif,1111 "Learning Python, 5th Edition","if exc_type is None: print('exited normally\n')",simpleif,1117 "Learning Python, 5th Edition",if enabled):,simpleif,1117 "Learning Python, 5th Edition","if line1 != line2: print('%s\n%r\n%r' % (linenum, line1, line2))",simpleif,1118 "Learning Python, 5th Edition",if needed:,simpleif,1145 "Learning Python, 5th Edition",if needed:,simpleif,1192 "Learning Python, 5th Edition","if node2.nodeType == Node.TEXT_NODE: print(node2.data)",simpleif,1212 "Learning Python, 5th Edition","if name == 'title': self.inTitle = True",simpleif,1212 "Learning Python, 5th Edition","if self.inTitle: print(data)",simpleif,1212 "Learning Python, 5th Edition","if name == 'title': self.inTitle = False",simpleif,1212 "Learning Python, 5th Edition","if node2.nodeType == Node.TEXT_NODE: node2.data",simpleif,1213 "Learning Python, 5th Edition","if not valid(): raise TypeError('cannot fetch name')",simpleif,1220 "Learning Python, 5th Edition","if not valid(value): raise TypeError('cannot change name')",simpleif,1220 "Learning Python, 5th Edition",if we use a nested class:,simpleif,1231 "Learning Python, 5th Edition","if instance is None: return self",simpleif,1236 "Learning Python, 5th Edition","if self.fget is None: raise AttributeError(""can't get attribute"")",simpleif,1236 "Learning Python, 5th Edition","if self.fset is None: raise AttributeError(""can't set attribute"")",simpleif,1236 "Learning Python, 5th Edition","if self.fdel is None: raise AttributeError(""can't delete attribute"")",simpleif,1236 "Learning Python, 5th Edition","if attr == 'name': attr = '_name' # Set internal name",simpleif,1242 "Learning Python, 5th Edition","if attr == 'name': attr = '_name' # Avoid looping here too",simpleif,1242 "Learning Python, 5th Edition","if attr == 'X': return self.value ** 2 # value is not undefined",simpleif,1243 "Learning Python, 5th Edition","if attr == 'X': attr = 'value'",simpleif,1244 "Learning Python, 5th Edition","if attr == 'X': return self.value ** 2 # Triggers __getattribute__ again!",simpleif,1244 "Learning Python, 5th Edition","if attr == 'X': attr = 'value'",simpleif,1244 "Learning Python, 5th Edition","if attr == 'X': return object.__getattribute__(self, 'value') ** 2",simpleif,1245 "Learning Python, 5th Edition","if attr == 'attr3': return 3",simpleif,1245 "Learning Python, 5th Edition","if name == 'square': return self._square ** 2",simpleif,1247 "Learning Python, 5th Edition","if name == 'cube': return self._cube ** 3",simpleif,1247 "Learning Python, 5th Edition",if name == 'square':,simpleif,1247 "Learning Python, 5th Edition","if name == 'square': return object.__getattribute__(self, '_square') ** 2",simpleif,1248 "Learning Python, 5th Edition","if name == 'cube': return object.__getattribute__(self, '_cube') ** 3",simpleif,1248 "Learning Python, 5th Edition","if name == 'square': object.__setattr__(self, '_square', value) # Or use __dict__",simpleif,1248 "Learning Python, 5th Edition","if attr == '__str__': return lambda *args: '[Getattr str]'",simpleif,1250 "Learning Python, 5th Edition","if attr == '__str__': return lambda *args: '[GetAttribute str]'",simpleif,1250 "Learning Python, 5th Edition","if attr in ['person', 'giveRaise']: return object.__getattribute__(self, attr) # Fetch my attrs",simpleif,1255 "Learning Python, 5th Edition","if attr == 'giveRaise': return lambda percent: person.giveRaise(percent+.10)",simpleif,1256 "Learning Python, 5th Edition","if value < 0 or value > 150: raise ValueError('invalid age')",simpleif,1257 "Learning Python, 5th Edition","if len(value) != self.acctlen: raise TypeError('invald acct number')",simpleif,1258 "Learning Python, 5th Edition",if present):,simpleif,1260 "Learning Python, 5th Edition","if value < 0 or value > 150: raise ValueError('invalid age')",simpleif,1260 "Learning Python, 5th Edition","if value < 0 or value > 150: raise ValueError('invalid age')",simpleif,1262 "Learning Python, 5th Edition","if name == 'remain': return self.retireage - self.age # Doesn't trigger __getattr__",simpleif,1264 "Learning Python, 5th Edition","if value < 0 or value > 150: raise ValueError('invalid age')",simpleif,1265 "Learning Python, 5th Edition","if name == 'acct': name = '_acct'",simpleif,1265 "Learning Python, 5th Edition","if len(value) != self.acctlen: raise TypeError('invald acct number')",simpleif,1265 "Learning Python, 5th Edition","if name == 'remain': raise TypeError('cannot set remain')",simpleif,1265 "Learning Python, 5th Edition","if name == 'remain': return superget(self, 'retireage') - superget(self, 'age')",simpleif,1266 "Learning Python, 5th Edition","if name == 'age': if value < 0 or value > 150:",simpleif,1266 "Learning Python, 5th Edition","if name == 'acct': value = value.replace('-', '')",simpleif,1266 "Learning Python, 5th Edition","if len(value) != self.acctlen: raise TypeError('invald acct number')",simpleif,1266 "Learning Python, 5th Edition","if name == 'remain': raise TypeError('cannot set remain')",simpleif,1266 "Learning Python, 5th Edition","if trace: format = '%s %s: %.5f, %.5f'",simpleif,1299 "Learning Python, 5th Edition","if instance == None: instance = aClass(*args, **kwargs) # One scope per class",simpleif,1303 "Learning Python, 5th Edition","if onCall.instance == None: onCall.instance = aClass(*args, **kwargs) # One function per class",simpleif,1303 "Learning Python, 5th Edition","if self.instance == None: self.instance = self.aClass(*args, **kwargs) # One instance per class",simpleif,1303 "Learning Python, 5th Edition","if aClass not in instances: instances[aClass] = aClass(*args, **kwargs)",simpleif,1309 "Learning Python, 5th Edition","if aClass not in instances: instances[aClass] = object",simpleif,1309 "Learning Python, 5th Edition","if attr in privates: raise TypeError('private attribute fetch: ' + attr)",simpleif,1315 "Learning Python, 5th Edition","if attr in privates: raise TypeError('private attribute change: ' + attr)",simpleif,1315 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute fetch: ' + attr)",simpleif,1319 "Learning Python, 5th Edition","if attr == '_onInstance__wrapped': self.__dict__[attr] = value",simpleif,1319 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute change: ' + attr)",simpleif,1319 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute fetch: ' + attr)",simpleif,1328 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute change: ' + attr)",simpleif,1328 "Learning Python, 5th Edition","if or assert statements in the method itself, using inline tests:",simpleif,1330 "Learning Python, 5th Edition","if percent < 0.0 or percent > 1.0: raise TypeError, 'percent invalid'",simpleif,1330 "Learning Python, 5th Edition","if args[ix] < low or args[ix] > high: errmsg = 'Argument %s not in %s..%s' % (ix, low, high)",simpleif,1331 "Learning Python, 5th Edition","if kargs[argname] < low or kargs[argname] > high: errmsg = '{0} argument ""{1}"" not in {2}..{3}'",simpleif,1334 "Learning Python, 5th Edition","if pargs[position] < low or pargs[position] > high: errmsg = '{0} argument ""{1}"" not in {2}..{3}'",simpleif,1334 "Learning Python, 5th Edition","if trace: print('Argument ""{0}"" defaulted'.format(argname))",simpleif,1334 "Learning Python, 5th Edition",if they are to be validated otherwise:,simpleif,1334 "Learning Python, 5th Edition","if argname in kargs: if not isinstance(kargs[argname], type):",simpleif,1342 "Learning Python, 5th Edition","if argname in positionals: position = positionals.index(argname)",simpleif,1342 "Learning Python, 5th Edition","if not isinstance(pargs[position], type): ...",simpleif,1343 "Learning Python, 5th Edition","if trace: format = '%s%s: %.5f, %.5f'",simpleif,1345 "Learning Python, 5th Edition","if not __debug__: return aClass",simpleif,1347 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute fetch: ' + attr)",simpleif,1347 "Learning Python, 5th Edition","if attr == '_onInstance__wrapped': self.__dict__[attr] = value",simpleif,1347 "Learning Python, 5th Edition","if failIf(attr): raise TypeError('private attribute change: ' + attr)",simpleif,1347 "Learning Python, 5th Edition","if failif(kargs[argname], criteria): onError(argname, criteria)",simpleif,1351 "Learning Python, 5th Edition","if failif(pargs[position], criteria): onError(argname, criteria)",simpleif,1351 "Learning Python, 5th Edition","if trace: print('Argument ""%s"" defaulted' % argname)",simpleif,1351 "Learning Python, 5th Edition","if required(): Client1.extra = extra",simpleif,1360 "Learning Python, 5th Edition","if required(): Client2.extra = extra",simpleif,1360 "Learning Python, 5th Edition","if required(): Client3.extra = extra",simpleif,1360 "Learning Python, 5th Edition","if required(): Class.extra = extra",simpleif,1360 "Learning Python, 5th Edition","if required(): Class.extra = extra",simpleif,1361 "Learning Python, 5th Edition","if required(): Class.extra = extra",simpleif,1362 "Learning Python, 5th Edition","if required(): Class.extra = extra",simpleif,1362 "Learning Python, 5th Edition",if fetched through the class but bound when fetched through the instance:,simpleif,1380 "Learning Python, 5th Edition","if sometest(): classdict['eggs'] = eggsfunc1",simpleif,1394 "Learning Python, 5th Edition","if someothertest(): classdict['ham'] = hamfunc",simpleif,1394 "Learning Python, 5th Edition","if trace: format = '%s%s: %.5f, %.5f'",simpleif,1400 "Learning Python, 5th Edition","if type(attrval) is FunctionType: classdict[attr] = decorator(attrval)",simpleif,1403 "Learning Python, 5th Edition","if type(attrval) is FunctionType: setattr(aClass, attr, decorator(attrval)) # Not __dict__",simpleif,1405 "Learning Python, 5th Edition","if browser: webbrowser.open(saveto, new=True)",simpleif,1416 "Learning Python, 5th Edition","if sys.platform.startswith('win'): input('[Press Enter]') # Keep window open if clicked on Windows",simpleif,1416 "Learning Python, 5th Edition","if N == 0: print('stop') # 2.X: print 'stop'",simpleif,1483 "Learning Python, 5th Edition","if N == 0: yield 'stop'",simpleif,1483 "Learning Python, 5th Edition","if len(S) == 1: return S",simpleif,1485 "Learning Python, 5th Edition","if mymod’s defs appeared in myclient). For example, another file can say:",simpleif,1487 "Learning Python, 5th Edition","if not x in res: res.append(x) # Add new items to result",simpleif,1494 "Learning Python, 5th Edition",if desired):,simpleif,1494 "Learning Python, 5th Edition","if filename.endswith('.py'): fullname = os.path.join(thisDir, filename)",simpleif,1500 "Learning Python, 5th Edition","if thisDir.upper() in visited: continue",simpleif,1500 "Learning Python, 5th Edition","if filename.endswith('.py'): pypath = os.path.join(thisDir, filename)",simpleif,1500 "Learning Python, 5th Edition","if not os.path.exists(result): open(result, 'w').write(output)",simpleif,1501 "Learning Python, 5th Edition","if output != priorresult: print('FAILED:', testcase['script'])",simpleif,1501 "Learning Python, 5th Edition","if self.growing: self.fontsize += 5",simpleif,1503 "Learning Python, 5th Edition","if input('Print?') in ['y', 'Y']:",simpleif,1503 "Learning Python, 5th Edition","if input('Delete?') in ['y', 'Y']: print('deleting')",simpleif,1504 "Learning Python, 5th Edition",print('hello world'),printfunc,28 "Learning Python, 5th Edition",print(2 ** 100),printfunc,28 "Learning Python, 5th Edition",print('Hello world!'),printfunc,49 "Learning Python, 5th Edition",print(2 ** 8),printfunc,49 "Learning Python, 5th Edition",print(x),printfunc,53 "Learning Python, 5th Edition",print(x),printfunc,54 "Learning Python, 5th Edition",print('done'),printfunc,54 "Learning Python, 5th Edition",print('done'),printfunc,54 "Learning Python, 5th Edition",print(sys.platform),printfunc,55 "Learning Python, 5th Edition",print(2 ** 100),printfunc,55 "Learning Python, 5th Edition",print(x * 8),printfunc,55 "Learning Python, 5th Edition",print('The Bright Side ' + 'of Life...'),printfunc,59 "Learning Python, 5th Edition","print('Run', 'away!...')",printfunc,61 "Learning Python, 5th Edition",print(sys.platform),printfunc,63 "Learning Python, 5th Edition",print(2 ** 100),printfunc,63 "Learning Python, 5th Edition",print(x * 8),printfunc,63 "Learning Python, 5th Edition",print(sys.platform),printfunc,64 "Learning Python, 5th Edition",print(2 ** 100),printfunc,64 "Learning Python, 5th Edition",print(x * 8),printfunc,64 "Learning Python, 5th Edition","print(a, b, c) # Also used in this file (in 2.X: print a, b, c)",printfunc,70 "Learning Python, 5th Edition",print('Hello module world!'),printfunc,87 "Learning Python, 5th Edition",print(3.1415 * 2),printfunc,98 "Learning Python, 5th Edition",print(D['name']),printfunc,114 "Learning Python, 5th Edition",print('missing'),printfunc,117 "Learning Python, 5th Edition","print('no, really...')",printfunc,117 "Learning Python, 5th Edition","print(key, '=>', D[key]) # <== press Enter twice here (3.X print)",printfunc,118 "Learning Python, 5th Edition","print(key, '=>', D[key])",printfunc,119 "Learning Python, 5th Edition",print(c.upper()),printfunc,119 "Learning Python, 5th Edition",print('spam!' * x),printfunc,119 "Learning Python, 5th Edition",print(text),printfunc,123 "Learning Python, 5th Edition",print(X),printfunc,128 "Learning Python, 5th Edition",print('yes'),printfunc,128 "Learning Python, 5th Edition",print('yes'),printfunc,128 "Learning Python, 5th Edition",print('yes'),printfunc,128 "Learning Python, 5th Edition",print(b / (2.0 + a)),printfunc,143 "Learning Python, 5th Edition",print(num),printfunc,144 "Learning Python, 5th Edition",print(0.1 + 0.1 + 0.1 - 0.3),printfunc,158 "Learning Python, 5th Edition",print(y),printfunc,160 "Learning Python, 5th Edition",print(item * 3),printfunc,165 "Learning Python, 5th Edition",print(x),printfunc,192 "Learning Python, 5th Edition",print(s),printfunc,194 "Learning Python, 5th Edition",print(S),printfunc,196 "Learning Python, 5th Edition",print(path),printfunc,197 "Learning Python, 5th Edition",print(path),printfunc,197 "Learning Python, 5th Edition",print(mantra),printfunc,198 "Learning Python, 5th Edition",print(os.getcwd()),printfunc,199 "Learning Python, 5th Edition",print('------- ...more... ---'),printfunc,200 "Learning Python, 5th Edition",print('-' * 80),printfunc,200 "Learning Python, 5th Edition","print(c, end=' ') # Step through items, print each (3.X form)",printfunc,201 "Learning Python, 5th Edition",print(sys.argv),printfunc,204 "Learning Python, 5th Edition","print(str('spam'), repr('spam')) # 2.X: print str('spam'), repr('spam')",printfunc,205 "Learning Python, 5th Edition",print(reply % values),printfunc,221 "Learning Python, 5th Edition","print('%s=%s' % ('spam', 42))",printfunc,227 "Learning Python, 5th Edition","print('{0}={1}'.format('spam', 42))",printfunc,227 "Learning Python, 5th Edition","print('{}={}'.format('spam', 42))",printfunc,227 "Learning Python, 5th Edition",print(x),printfunc,241 "Learning Python, 5th Edition","print(x, end=' ') # Iteration (2.X uses: print x,)",printfunc,242 "Learning Python, 5th Edition",print(D.get('toast')),printfunc,255 "Learning Python, 5th Edition",print(year + '\t' + table[year]),printfunc,257 "Learning Python, 5th Edition","print(Matrix[(2, 3, 6)])",printfunc,260 "Learning Python, 5th Edition",print(0),printfunc,260 "Learning Python, 5th Edition",print(0),printfunc,260 "Learning Python, 5th Edition",print(rec['name']),printfunc,261 "Learning Python, 5th Edition",print(k),printfunc,267 "Learning Python, 5th Edition",print(key) # Still no need to call keys(),printfunc,267 "Learning Python, 5th Edition","print(k, D[k]) # sorted()",printfunc,269 "Learning Python, 5th Edition","print(k, D[k])",printfunc,270 "Learning Python, 5th Edition","print('present', D['c'])",printfunc,270 "Learning Python, 5th Edition",print(D.get('c')),printfunc,270 "Learning Python, 5th Edition",print(D.get('x')),printfunc,270 "Learning Python, 5th Edition",print(x),printfunc,277 "Learning Python, 5th Edition","print(x) # Iteration context (Chapters 14, 20)",printfunc,282 "Learning Python, 5th Edition",print(bob[x]),printfunc,282 "Learning Python, 5th Edition",print(x),printfunc,282 "Learning Python, 5th Edition","print(line, end='')",printfunc,286 "Learning Python, 5th Edition",print(chars),printfunc,288 "Learning Python, 5th Edition",print(row),printfunc,293 "Learning Python, 5th Edition","print('The Killer', joke)",printfunc,320 "Learning Python, 5th Edition",print(text),printfunc,320 "Learning Python, 5th Edition",print(x),printfunc,320 "Learning Python, 5th Edition",print(a+b+c+d[0]),printfunc,320 "Learning Python, 5th Edition",print('action error'),printfunc,321 "Learning Python, 5th Edition",print('spam' * 3),printfunc,328 "Learning Python, 5th Edition",print(x),printfunc,329 "Learning Python, 5th Edition",print(int(reply) ** 2),printfunc,331 "Learning Python, 5th Edition",print('Bye'),printfunc,331 "Learning Python, 5th Edition",print(int(reply) ** 2),printfunc,332 "Learning Python, 5th Edition",print('Bye'),printfunc,332 "Learning Python, 5th Edition",print(num ** 2),printfunc,333 "Learning Python, 5th Edition",print('Bye'),printfunc,333 "Learning Python, 5th Edition",print(float(reply) ** 2),printfunc,334 "Learning Python, 5th Edition",print('Bad!' * 8),printfunc,334 "Learning Python, 5th Edition",print('Bye'),printfunc,334 "Learning Python, 5th Edition",print(num ** 2),printfunc,335 "Learning Python, 5th Edition",print('Bye'),printfunc,335 "Learning Python, 5th Edition","print(front, L)",printfunc,344 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,345 "Learning Python, 5th Edition","print(front, L)",printfunc,346 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,347 "Learning Python, 5th Edition","print(a, b, c, d, e)",printfunc,347 "Learning Python, 5th Edition","print(a, b, c, d, e)",printfunc,347 "Learning Python, 5th Edition","print(a, b, c, sep='')",printfunc,356 "Learning Python, 5th Edition",print(x),printfunc,357 "Learning Python, 5th Edition",print(L),printfunc,357 "Learning Python, 5th Edition","print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout][, flush=False])",printfunc,359 "Learning Python, 5th Edition",print(),printfunc,360 "Learning Python, 5th Edition","print(x, y, z)",printfunc,360 "Learning Python, 5th Edition","print(x, y, z, sep='')",printfunc,360 "Learning Python, 5th Edition","print(x, y, z, sep=', ')",printfunc,360 "Learning Python, 5th Edition","print(x, y, z, end='')",printfunc,361 "Learning Python, 5th Edition","print(x, y, z, end=''); print(x, y, z)",printfunc,361 "Learning Python, 5th Edition","print(x, y, z, end='...\n')",printfunc,361 "Learning Python, 5th Edition","print(x, y, z, sep='...', end='!\n')",printfunc,361 "Learning Python, 5th Edition","print(x, y, z, end='!\n', sep='...')",printfunc,361 "Learning Python, 5th Edition","print(x, y, z)",printfunc,361 "Learning Python, 5th Edition",print(text),printfunc,361 "Learning Python, 5th Edition","print('%s: %-.4f, %05d' % ('Result', 3.14159, 42))",printfunc,361 "Learning Python, 5th Edition","print(x, y)",printfunc,362 "Learning Python, 5th Edition","print(x, y, end='')",printfunc,362 "Learning Python, 5th Edition","print(x, y, file=afile)",printfunc,362 "Learning Python, 5th Edition",print('hello world'),printfunc,363 "Learning Python, 5th Edition","print(X, Y)",printfunc,364 "Learning Python, 5th Edition","print(x, y, x)",printfunc,364 "Learning Python, 5th Edition",print('spam'),printfunc,365 "Learning Python, 5th Edition","print(1, 2, 3)",printfunc,365 "Learning Python, 5th Edition",print('back here'),printfunc,365 "Learning Python, 5th Edition","print(x, y, z, file=log)",printfunc,365 "Learning Python, 5th Edition","print(a, b, c)",printfunc,365 "Learning Python, 5th Edition","print(1, 2, 3, file=log)",printfunc,365 "Learning Python, 5th Edition","print(4, 5, 6, file=log)",printfunc,365 "Learning Python, 5th Edition","print(7, 8, 9)",printfunc,365 "Learning Python, 5th Edition","print('Bad!' * 8, file=sys.stderr)",printfunc,366 "Learning Python, 5th Edition","print(X, Y)",printfunc,366 "Learning Python, 5th Edition",print('spam'),printfunc,367 "Learning Python, 5th Edition","print('spam', 'ham', 'eggs')",printfunc,367 "Learning Python, 5th Edition",print('spam'),printfunc,367 "Learning Python, 5th Edition","print('spam', 'ham', 'eggs')",printfunc,367 "Learning Python, 5th Edition",print(),printfunc,367 "Learning Python, 5th Edition",print(''),printfunc,368 "Learning Python, 5th Edition","print('%s %s %s' % ('spam', 'ham', 'eggs'))",printfunc,368 "Learning Python, 5th Edition","print('{0} {1} {2}'.format('spam', 'ham', 'eggs'))",printfunc,368 "Learning Python, 5th Edition",print('answer: ' + str(42)),printfunc,368 "Learning Python, 5th Edition",print(someObjects),printfunc,369 "Learning Python, 5th Edition","print(someObjects, file=myobj)",printfunc,369 "Learning Python, 5th Edition",print('false'),printfunc,372 "Learning Python, 5th Edition",print('Run away! Run away!'),printfunc,372 "Learning Python, 5th Edition",print(1.25),printfunc,373 "Learning Python, 5th Edition",print('Bad choice'),printfunc,373 "Learning Python, 5th Edition","print(branch.get('spam', 'Bad choice'))",printfunc,373 "Learning Python, 5th Edition","print(branch.get('bacon', 'Bad choice'))",printfunc,374 "Learning Python, 5th Edition",print('Bad choice'),printfunc,374 "Learning Python, 5th Edition",print('Bad choice'),printfunc,374 "Learning Python, 5th Edition",print('block1'),printfunc,376 "Learning Python, 5th Edition",print('block0'),printfunc,376 "Learning Python, 5th Edition",print(x * 8),printfunc,377 "Learning Python, 5th Edition",print(x),printfunc,377 "Learning Python, 5th Edition",print(x * 8),printfunc,377 "Learning Python, 5th Edition",print(x),printfunc,377 "Learning Python, 5th Edition",print('olde'),printfunc,379 "Learning Python, 5th Edition",print('new'),printfunc,379 "Learning Python, 5th Edition",print('hello'),printfunc,380 "Learning Python, 5th Edition",print('Type Ctrl-C to stop me!'),printfunc,388 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,388 "Learning Python, 5th Edition","print(a, end=' ')",printfunc,388 "Learning Python, 5th Edition","print(y, 'is prime')",printfunc,392 "Learning Python, 5th Edition",print('Not found'),printfunc,393 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,396 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,396 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,396 "Learning Python, 5th Edition","print(a, b)",printfunc,397 "Learning Python, 5th Edition","print(key, '=>', D[key])",printfunc,397 "Learning Python, 5th Edition","print(key, '=>', value)",printfunc,397 "Learning Python, 5th Edition","print(a, b) # 2.X: prints with enclosing tuple ""()",printfunc,397 "Learning Python, 5th Edition","print(a, b, c)",printfunc,398 "Learning Python, 5th Edition","print(a, b, c)",printfunc,398 "Learning Python, 5th Edition","print(a, b, c)",printfunc,398 "Learning Python, 5th Edition","print(a, b, c)",printfunc,399 "Learning Python, 5th Edition","print(a, b, c)",printfunc,399 "Learning Python, 5th Edition","print(key, ""was found"")",printfunc,399 "Learning Python, 5th Edition","print(key, ""not found!"")",printfunc,399 "Learning Python, 5th Edition","print(key, ""was found"")",printfunc,400 "Learning Python, 5th Edition","print(key, ""not found!"")",printfunc,400 "Learning Python, 5th Edition",print(chunk),printfunc,401 "Learning Python, 5th Edition",print(line.rstrip()),printfunc,401 "Learning Python, 5th Edition",print(line.rstrip()),printfunc,401 "Learning Python, 5th Edition","print(i, 'Pythons')",printfunc,403 "Learning Python, 5th Edition","print(item, end=' ')",printfunc,403 "Learning Python, 5th Edition","print(X[i], end=' ')",printfunc,404 "Learning Python, 5th Edition","print(X[i], end=' ')",printfunc,404 "Learning Python, 5th Edition","print(item, end=' ')",printfunc,404 "Learning Python, 5th Edition","print(S, end=' ')",printfunc,405 "Learning Python, 5th Edition","print(X, end=' ')",printfunc,405 "Learning Python, 5th Edition","print(X, end=' ')",printfunc,405 "Learning Python, 5th Edition","print(S[i], end=' ')",printfunc,405 "Learning Python, 5th Edition","print(c, end=' ')",printfunc,406 "Learning Python, 5th Edition","print(x, y, '--', x+y)",printfunc,408 "Learning Python, 5th Edition","print(item, 'appears at offset', offset)",printfunc,410 "Learning Python, 5th Edition","print(item, 'appears at offset', offset)",printfunc,411 "Learning Python, 5th Edition","print('%s) %s' % (i, l.rstrip()))",printfunc,411 "Learning Python, 5th Edition",print(line.rstrip()),printfunc,412 "Learning Python, 5th Edition","print('%05d) %s' % (i, line.rstrip()))",printfunc,412 "Learning Python, 5th Edition",print(val),printfunc,413 "Learning Python, 5th Edition",print(item),printfunc,413 "Learning Python, 5th Edition","print(awker('input.txt', 7))",printfunc,413 "Learning Python, 5th Edition","print(','.join(awker('input.txt', 7)))",printfunc,413 "Learning Python, 5th Edition",print(line),printfunc,413 "Learning Python, 5th Edition","print(x ** 2, end=' ')",printfunc,416 "Learning Python, 5th Edition","print(x ** 3, end=' ')",printfunc,416 "Learning Python, 5th Edition","print(x * 2, end=' ')",printfunc,416 "Learning Python, 5th Edition",print(sys.path),printfunc,417 "Learning Python, 5th Edition",print(x ** 32),printfunc,417 "Learning Python, 5th Edition",print(sys.path),printfunc,417 "Learning Python, 5th Edition",print(x ** 32),printfunc,417 "Learning Python, 5th Edition",print(sys.path),printfunc,417 "Learning Python, 5th Edition",print(x ** 32),printfunc,417 "Learning Python, 5th Edition","print(line.upper(), end='')",printfunc,418 "Learning Python, 5th Edition","print(line.upper(), end='')",printfunc,418 "Learning Python, 5th Edition","print(line.upper(), end='')",printfunc,418 "Learning Python, 5th Edition",print(sys.path),printfunc,419 "Learning Python, 5th Edition",print(sys.path),printfunc,419 "Learning Python, 5th Edition","print(X ** 2, end=' ')",printfunc,421 "Learning Python, 5th Edition","print(X ** 2, end=' ')",printfunc,422 "Learning Python, 5th Edition","print(key, D[key])",printfunc,422 "Learning Python, 5th Edition","print(key, D[key])",printfunc,423 "Learning Python, 5th Edition","print(sys.path)'], ['x', '=', '2'], ['print(x', '**', '32)",printfunc,427 "Learning Python, 5th Edition","print(sys.path)\n', 'x!=!2\n', 'print(x!**!32)",printfunc,427 "Learning Python, 5th Edition","print(sys.path)', 'print(x ** 32)",printfunc,427 "Learning Python, 5th Edition","print(sys.path)', 'print(x ** 32)",printfunc,428 "Learning Python, 5th Edition","print(line.upper(), end='')",printfunc,429 "Learning Python, 5th Edition","print(sys.path)\n', 'print(sys.path)\n')",printfunc,430 "Learning Python, 5th Edition",print(x ** 32)\n'),printfunc,430 "Learning Python, 5th Edition",print(x ** 32)\n'),printfunc,431 "Learning Python, 5th Edition","print(x ** 32)\n', 'import sys\n', 'print(sys.path)",printfunc,432 "Learning Python, 5th Edition","print(x ** 32)\n', 'import sys\n', 'print(sys.path)",printfunc,432 "Learning Python, 5th Edition","print(x ** 32)\n', 'print(sys.path)",printfunc,432 "Learning Python, 5th Edition","print(sys.path)\n', 3: 'print(x ** 32)",printfunc,432 "Learning Python, 5th Edition","print(a, b, c, d, sep='&')",printfunc,433 "Learning Python, 5th Edition",print(sys.path),printfunc,433 "Learning Python, 5th Edition",print(x ** 32),printfunc,433 "Learning Python, 5th Edition",print(i),printfunc,435 "Learning Python, 5th Edition","print(i) # Unlike 2.X lists, one pass only (zip too)",printfunc,435 "Learning Python, 5th Edition",print(x) # Iteration contexts auto call next(),printfunc,436 "Learning Python, 5th Edition",print(pair),printfunc,437 "Learning Python, 5th Edition",print(pair),printfunc,437 "Learning Python, 5th Edition","print(next(I1), next(I1), next(I1))",printfunc,438 "Learning Python, 5th Edition","print(k, end=' ')",printfunc,439 "Learning Python, 5th Edition","print(k, v, end=' ')",printfunc,440 "Learning Python, 5th Edition","print(key, end=' ') # Still no need to call keys()",printfunc,440 "Learning Python, 5th Edition","print(k, D[k], end=' ')",printfunc,440 "Learning Python, 5th Edition","print(k, D[k], end=' ')",printfunc,440 "Learning Python, 5th Edition",print(square(4)),printfunc,447 "Learning Python, 5th Edition",print(square.__doc__),printfunc,447 "Learning Python, 5th Edition",print(docstrings.__doc__),printfunc,447 "Learning Python, 5th Edition",print(docstrings.square.__doc__),printfunc,447 "Learning Python, 5th Edition",print(docstrings.Employee.__doc__),printfunc,447 "Learning Python, 5th Edition",print(sys.__doc__),printfunc,448 "Learning Python, 5th Edition",print(sys.getrefcount.__doc__),printfunc,448 "Learning Python, 5th Edition",print(int.__doc__),printfunc,449 "Learning Python, 5th Edition",print(map.__doc__),printfunc,449 "Learning Python, 5th Edition",print('hello %d\n\a' % i),printfunc,467 "Learning Python, 5th Edition","print(X, 'not found')",printfunc,468 "Learning Python, 5th Edition",print('Hello ' + message),printfunc,473 "Learning Python, 5th Edition",print(X),printfunc,493 "Learning Python, 5th Edition",print(X),printfunc,495 "Learning Python, 5th Edition",print(first.X),printfunc,497 "Learning Python, 5th Edition",print(var),printfunc,499 "Learning Python, 5th Edition",print(var),printfunc,499 "Learning Python, 5th Edition",print(X),printfunc,500 "Learning Python, 5th Edition",print(X),printfunc,501 "Learning Python, 5th Edition",print(x),printfunc,504 "Learning Python, 5th Edition",print(x),printfunc,505 "Learning Python, 5th Edition",print(x(2)),printfunc,505 "Learning Python, 5th Edition",print(x),printfunc,507 "Learning Python, 5th Edition","print(label, state)",printfunc,510 "Learning Python, 5th Edition","print(label, state)",printfunc,510 "Learning Python, 5th Edition","print(label, state)",printfunc,510 "Learning Python, 5th Edition","print(label, state)",printfunc,511 "Learning Python, 5th Edition","print(label, state)",printfunc,511 "Learning Python, 5th Edition","print('Current=', spam)",printfunc,511 "Learning Python, 5th Edition","print(label, state)",printfunc,512 "Learning Python, 5th Edition","print(label, state)",printfunc,513 "Learning Python, 5th Edition","print(label, self.state)",printfunc,514 "Learning Python, 5th Edition","print(label, self.state) # So .nested()",printfunc,514 "Learning Python, 5th Edition","print(label, nested.state)",printfunc,516 "Learning Python, 5th Edition","print(label, state[0])",printfunc,517 "Learning Python, 5th Edition","print('Custom open call %r:' % id , kargs, pargs)",printfunc,518 "Learning Python, 5th Edition","print('Custom open call %r:' % self.id, kargs, pargs)",printfunc,518 "Learning Python, 5th Edition",print(X),printfunc,519 "Learning Python, 5th Edition",print(X),printfunc,519 "Learning Python, 5th Edition",print(X),printfunc,519 "Learning Python, 5th Edition",print(X),printfunc,519 "Learning Python, 5th Edition",print(X),printfunc,520 "Learning Python, 5th Edition",print(X),printfunc,520 "Learning Python, 5th Edition",print(X),printfunc,520 "Learning Python, 5th Edition",print(b),printfunc,524 "Learning Python, 5th Edition",print(X),printfunc,525 "Learning Python, 5th Edition",print(L),printfunc,525 "Learning Python, 5th Edition","print(a, b, c)",printfunc,532 "Learning Python, 5th Edition","print(a, b, c)",printfunc,533 "Learning Python, 5th Edition","print((spam, eggs, toast, ham))",printfunc,534 "Learning Python, 5th Edition",print(args),printfunc,534 "Learning Python, 5th Edition",print(args),printfunc,535 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,535 "Learning Python, 5th Edition","print('calling:', func.__name__)",printfunc,537 "Learning Python, 5th Edition","print(tracer(func, 1, 2, c=3, d=4))",printfunc,537 "Learning Python, 5th Edition","print(a, b, c)",printfunc,539 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,540 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,541 "Learning Python, 5th Edition","print(min1(3, 4, 1, 2))",printfunc,543 "Learning Python, 5th Edition","print(min2(""bb"", ""aa""))",printfunc,543 "Learning Python, 5th Edition","print(min3([2,2], [1,1], [3,3]))",printfunc,543 "Learning Python, 5th Edition","print(minmax(lessthan, 4, 2, 1, 5, 6, 3))",printfunc,544 "Learning Python, 5th Edition","print(minmax(grtrthan, 4, 2, 1, 5, 6, 3))",printfunc,544 "Learning Python, 5th Edition",print(items),printfunc,546 "Learning Python, 5th Edition",print(sorted(func(*items))),printfunc,546 "Learning Python, 5th Edition","print(a, b, c)",printfunc,551 "Learning Python, 5th Edition","print(a, b, c)",printfunc,551 "Learning Python, 5th Edition","print(a, pargs)",printfunc,551 "Learning Python, 5th Edition","print(a, kargs)",printfunc,551 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,551 "Learning Python, 5th Edition",print(L),printfunc,556 "Learning Python, 5th Edition",print(sumtree(L)),printfunc,558 "Learning Python, 5th Edition","print(sumtree([1, [2, [3, [4, [5]]]]])) # Prints 15 (right-heavy)",printfunc,558 "Learning Python, 5th Edition","print(sumtree([[[[[1], 2], 3], 4], 5])) # Prints 15 (left-heavy)",printfunc,558 "Learning Python, 5th Edition",print(message),printfunc,562 "Learning Python, 5th Edition",print(label + ':' + message),printfunc,563 "Learning Python, 5th Edition","print(arg, '=>', func.__annotations__[arg])",printfunc,566 "Learning Python, 5th Edition",print(f(2)),printfunc,569 "Learning Python, 5th Edition",print(L[0](3)),printfunc,569 "Learning Python, 5th Edition",print(f(2)),printfunc,570 "Learning Python, 5th Edition",print(L[0](3)),printfunc,570 "Learning Python, 5th Edition",print(X),printfunc,571 "Learning Python, 5th Edition","print(i, end=' : ')",printfunc,593 "Learning Python, 5th Edition","print(x, end=' : ')",printfunc,595 "Learning Python, 5th Edition","print(x, end=' : ')",printfunc,595 "Learning Python, 5th Edition",print(X),printfunc,596 "Learning Python, 5th Edition","print('%s, %s' % (num, num / 2.0))",printfunc,598 "Learning Python, 5th Edition","print(key, D[key])",printfunc,606 "Learning Python, 5th Edition","print(line, end='')",printfunc,606 "Learning Python, 5th Edition","print('%s, %s, and %s' % (a, b, c))",printfunc,607 "Learning Python, 5th Edition","print(x.upper(), end=' ')",printfunc,608 "Learning Python, 5th Edition","print(x.upper(), end=' ') for x in 'spam')",printfunc,608 "Learning Python, 5th Edition",print(*(x.upper() for x in 'spam')),printfunc,608 "Learning Python, 5th Edition","print(S, end=' ')",printfunc,609 "Learning Python, 5th Edition","print(L, end=' ')",printfunc,610 "Learning Python, 5th Edition","print(X, end=' ')",printfunc,610 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,610 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,611 "Learning Python, 5th Edition","print(x, end=' ')",printfunc,611 "Learning Python, 5th Edition",print(args),printfunc,612 "Learning Python, 5th Edition",print(sorted(func(*args))),printfunc,612 "Learning Python, 5th Edition",print(x),printfunc,613 "Learning Python, 5th Edition",print(sys.path)\nprint(sys.path),printfunc,617 "Learning Python, 5th Edition",print(sys.path)\nprint(sys.path),printfunc,617 "Learning Python, 5th Edition","print(mymap(abs, [-2, −1, 0, 1, 2]))",printfunc,618 "Learning Python, 5th Edition","print(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))",printfunc,618 "Learning Python, 5th Edition","print(mymap(abs, [−2, −1, 0, 1, 2]))",printfunc,618 "Learning Python, 5th Edition","print(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))",printfunc,618 "Learning Python, 5th Edition","print(list(mymap(abs, [−2, −1, 0, 1, 2])))",printfunc,618 "Learning Python, 5th Edition","print(list(mymap(pow, [1, 2, 3], [2, 3, 4, 5])))",printfunc,618 "Learning Python, 5th Edition","print(myzip(S1, S2))",printfunc,619 "Learning Python, 5th Edition","print(mymapPad(S1, S2))",printfunc,619 "Learning Python, 5th Edition","print(mymapPad(S1, S2, pad=99))",printfunc,619 "Learning Python, 5th Edition","print(list(myzip(S1, S2)))",printfunc,620 "Learning Python, 5th Edition","print(list(mymapPad(S1, S2)))",printfunc,620 "Learning Python, 5th Edition","print(list(mymapPad(S1, S2, pad=99)))",printfunc,620 "Learning Python, 5th Edition","print(myzip(S1, S2))",printfunc,620 "Learning Python, 5th Edition","print(mymapPad(S1, S2))",printfunc,620 "Learning Python, 5th Edition","print(mymapPad(S1, S2, pad=99))",printfunc,620 "Learning Python, 5th Edition","print(list(myzip(S1, S2))) # Go!... [('a', 'x'), ('b', 'y'), ('c', 'z')",printfunc,621 "Learning Python, 5th Edition",print(''.join(Z for Z in X + Y)),printfunc,623 "Learning Python, 5th Edition",print(sys.version),printfunc,634 "Learning Python, 5th Edition",print(sys.version),printfunc,648 "Learning Python, 5th Edition","print('%.4f [%r]' % (best, stmt[:70]))",printfunc,648 "Learning Python, 5th Edition",print('-' * 80),printfunc,648 "Learning Python, 5th Edition",print('[%r]' % stmt),printfunc,648 "Learning Python, 5th Edition",print(python),printfunc,648 "Learning Python, 5th Edition",print(cmd),printfunc,648 "Learning Python, 5th Edition",print(X),printfunc,657 "Learning Python, 5th Edition",print(X),printfunc,657 "Learning Python, 5th Edition",print(X),printfunc,657 "Learning Python, 5th Edition",print(__main__.X),printfunc,658 "Learning Python, 5th Edition",print(X),printfunc,658 "Learning Python, 5th Edition",print(x),printfunc,658 "Learning Python, 5th Edition",print(x),printfunc,659 "Learning Python, 5th Edition",print(saver.x),printfunc,660 "Learning Python, 5th Edition",print(x),printfunc,660 "Learning Python, 5th Edition",print(x),printfunc,660 "Learning Python, 5th Edition",print(list),printfunc,660 "Learning Python, 5th Edition","print(a, b)",printfunc,664 "Learning Python, 5th Edition","print(a, b)",printfunc,664 "Learning Python, 5th Edition","print(a, b)",printfunc,664 "Learning Python, 5th Edition","print(a, b, c)",printfunc,664 "Learning Python, 5th Edition","print(a, b, c)",printfunc,664 "Learning Python, 5th Edition","print(y, 'is prime')",printfunc,664 "Learning Python, 5th Edition","print(text, 'spam')",printfunc,671 "Learning Python, 5th Edition",print(x),printfunc,687 "Learning Python, 5th Edition",print('hello'),printfunc,690 "Learning Python, 5th Edition",print('starting to load...'),printfunc,695 "Learning Python, 5th Edition",print('done loading.'),printfunc,696 "Learning Python, 5th Edition","print(X, moda.X)",printfunc,698 "Learning Python, 5th Edition","print(X, end=' ')",printfunc,699 "Learning Python, 5th Edition",print(mod3.X),printfunc,699 "Learning Python, 5th Edition","print(X, end=' ')",printfunc,699 "Learning Python, 5th Edition","print(mod2.X, end=' ')",printfunc,699 "Learning Python, 5th Edition",print(mod2.mod3.X),printfunc,699 "Learning Python, 5th Edition",print(message),printfunc,702 "Learning Python, 5th Edition","print('reloaded:', message)",printfunc,702 "Learning Python, 5th Edition",print('dir1 init'),printfunc,711 "Learning Python, 5th Edition",print('dir2 init'),printfunc,711 "Learning Python, 5th Edition",print('in mod.py'),printfunc,712 "Learning Python, 5th Edition",print('string' * 8),printfunc,724 "Learning Python, 5th Edition",print(string),printfunc,724 "Learning Python, 5th Edition",print(eggs.X),printfunc,725 "Learning Python, 5th Edition",print(string),printfunc,725 "Learning Python, 5th Edition",print(eggs.X),printfunc,725 "Learning Python, 5th Edition",print(string),printfunc,725 "Learning Python, 5th Edition",print('string' * 8),printfunc,726 "Learning Python, 5th Edition",print(eggs.X),printfunc,726 "Learning Python, 5th Edition",print(string),printfunc,726 "Learning Python, 5th Edition",print(string),printfunc,726 "Learning Python, 5th Edition",print('Ni' * 8),printfunc,726 "Learning Python, 5th Edition",print(string),printfunc,727 "Learning Python, 5th Edition",print('Ni' * 8),printfunc,727 "Learning Python, 5th Edition",print('string' * 8),printfunc,727 "Learning Python, 5th Edition",print(string),printfunc,728 "Learning Python, 5th Edition",print('Ni' * 8),printfunc,728 "Learning Python, 5th Edition",print('string' * 8),printfunc,728 "Learning Python, 5th Edition",print(string),printfunc,728 "Learning Python, 5th Edition",print('Ni' * 8),printfunc,728 "Learning Python, 5th Edition",print('Eggs' * 4),printfunc,730 "Learning Python, 5th Edition",print('Eggs' * 4),printfunc,731 "Learning Python, 5th Edition",print('Eggs' * 4),printfunc,731 "Learning Python, 5th Edition",print('Eggs' * 4),printfunc,732 "Learning Python, 5th Edition",print('m1.somefunc'),printfunc,732 "Learning Python, 5th Edition",print('m2.somefunc'),printfunc,732 "Learning Python, 5th Edition",print(r'dir1\sub\mod1'),printfunc,737 "Learning Python, 5th Edition",print(r'dir2\sub\mod2'),printfunc,737 "Learning Python, 5th Edition",print(r'dir1\sub\mod1'),printfunc,738 "Learning Python, 5th Edition",print(r'dir2\sub\lower\mod3'),printfunc,739 "Learning Python, 5th Edition",print(r'dir1\sub\pkg\__init__.py'),printfunc,739 "Learning Python, 5th Edition",print(r'ns3\dir\ns2.py!'),printfunc,740 "Learning Python, 5th Edition","print(""It's Christmas in Heaven..."")",printfunc,749 "Learning Python, 5th Edition","print(minmax(lessthan, 4, 2, 1, 5, 6, 3))",printfunc,750 "Learning Python, 5th Edition","print(minmax(grtrthan, 4, 2, 1, 5, 6, 3))",printfunc,750 "Learning Python, 5th Edition","print('I am:', __name__)",printfunc,750 "Learning Python, 5th Edition","print(minmax(lessthan, 4, 2, 1, 5, 6, 3))",printfunc,751 "Learning Python, 5th Edition","print(minmax(grtrthan, 4, 2, 1, 5, 6, 3))",printfunc,751 "Learning Python, 5th Edition",print(commas(test)),printfunc,752 "Learning Python, 5th Edition",print(''),printfunc,752 "Learning Python, 5th Edition","print('%s [%s]' % (money(test, 17), test))",printfunc,752 "Learning Python, 5th Edition","print(money(float(sys.argv[1]), int(sys.argv[2])))",printfunc,753 "Learning Python, 5th Edition","print(money(X), money(X, 0, ''))",printfunc,754 "Learning Python, 5th Edition","print(money(X, currency=u'\xA3'), money(X, currency=u'\u00A5'))",printfunc,754 "Learning Python, 5th Edition","print(money(X, currency=b'\xA3'.decode('latin-1')))",printfunc,754 "Learning Python, 5th Edition","print(money(X, currency=u'\u20AC'), money(X, 0, b'\xA4'.decode('iso-8859-15')))",printfunc,754 "Learning Python, 5th Edition","print(money(X, currency=b'\xA4'.decode('latin-1')))",printfunc,754 "Learning Python, 5th Edition","print(u'\xA5' + '1', '%s2' % u'\u00A3')",printfunc,756 "Learning Python, 5th Edition","print('\xA5' + '1', '%s2' % '\u00A3')",printfunc,756 "Learning Python, 5th Edition","print('name:', module.__name__, 'file:', module.__file__)",printfunc,760 "Learning Python, 5th Edition",print(sepline),printfunc,760 "Learning Python, 5th Edition","print('%02d) %s' % (count, attr), end = ' ')",printfunc,760 "Learning Python, 5th Edition","print(module.__name__, 'has %d names' % count)",printfunc,760 "Learning Python, 5th Edition",print(sepline),printfunc,760 "Learning Python, 5th Edition",print('reloading ' + module.__name__),printfunc,764 "Learning Python, 5th Edition",print('FAILED: %s' % module),printfunc,764 "Learning Python, 5th Edition",print(func2()),printfunc,772 "Learning Python, 5th Edition",print(X),printfunc,772 "Learning Python, 5th Edition",print(I1.name),printfunc,790 "Learning Python, 5th Edition",print(I1.name),printfunc,791 "Learning Python, 5th Edition",print(emp.computeSalary()),printfunc,793 "Learning Python, 5th Edition",print(self.data),printfunc,799 "Learning Python, 5th Edition","print('Current value = ""%s""' % self.data)",printfunc,802 "Learning Python, 5th Edition",print(a),printfunc,807 "Learning Python, 5th Edition",print(b),printfunc,807 "Learning Python, 5th Edition",print(a),printfunc,807 "Learning Python, 5th Edition",print(rec.name),printfunc,809 "Learning Python, 5th Edition",print(rec[0]),printfunc,812 "Learning Python, 5th Edition",print(rec['name']),printfunc,812 "Learning Python, 5th Edition",print(rec.name),printfunc,813 "Learning Python, 5th Edition","print(bob.name, bob.pay)",printfunc,820 "Learning Python, 5th Edition","print(sue.name, sue.pay)",printfunc,820 "Learning Python, 5th Edition","print(bob.name, bob.pay)",printfunc,821 "Learning Python, 5th Edition","print(sue.name, sue.pay)",printfunc,821 "Learning Python, 5th Edition","print('{0} {1}'.format(bob.name, bob.pay))",printfunc,822 "Learning Python, 5th Edition","print('%s %s' % (bob.name, bob.pay))",printfunc,822 "Learning Python, 5th Edition",print('%.2f' % pay),printfunc,823 "Learning Python, 5th Edition","print(bob.name, bob.pay)",printfunc,823 "Learning Python, 5th Edition","print(sue.name, sue.pay)",printfunc,823 "Learning Python, 5th Edition",print(bob.name.split()[-1]),printfunc,823 "Learning Python, 5th Edition",print('%.2f' % sue.pay),printfunc,823 "Learning Python, 5th Edition","print(bob.name, bob.pay)",printfunc,824 "Learning Python, 5th Edition","print(sue.name, sue.pay)",printfunc,824 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,824 "Learning Python, 5th Edition",print(sue.pay),printfunc,824 "Learning Python, 5th Edition",print(sue),printfunc,826 "Learning Python, 5th Edition",print(bob),printfunc,827 "Learning Python, 5th Edition",print(sue),printfunc,827 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,827 "Learning Python, 5th Edition",print(sue),printfunc,827 "Learning Python, 5th Edition",print(bob),printfunc,831 "Learning Python, 5th Edition",print(sue),printfunc,831 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,831 "Learning Python, 5th Edition",print(sue),printfunc,831 "Learning Python, 5th Edition",print(tom.lastName()),printfunc,831 "Learning Python, 5th Edition",print(tom),printfunc,831 "Learning Python, 5th Edition",print('--All three--'),printfunc,832 "Learning Python, 5th Edition",print(obj),printfunc,832 "Learning Python, 5th Edition",print(tom),printfunc,833 "Learning Python, 5th Edition",print(bob),printfunc,835 "Learning Python, 5th Edition",print(sue),printfunc,835 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,835 "Learning Python, 5th Edition",print(sue),printfunc,835 "Learning Python, 5th Edition",print(tom.lastName()),printfunc,835 "Learning Python, 5th Edition",print(tom),printfunc,835 "Learning Python, 5th Edition",print(person),printfunc,838 "Learning Python, 5th Edition",print(bob),printfunc,841 "Learning Python, 5th Edition","print(key, '=>', getattr(bob, key))",printfunc,841 "Learning Python, 5th Edition",print(X),printfunc,843 "Learning Python, 5th Edition",print(Y),printfunc,843 "Learning Python, 5th Edition",print(bob),printfunc,846 "Learning Python, 5th Edition",print(sue),printfunc,846 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,846 "Learning Python, 5th Edition",print(sue),printfunc,846 "Learning Python, 5th Edition",print(tom.lastName()),printfunc,846 "Learning Python, 5th Edition",print(tom),printfunc,846 "Learning Python, 5th Edition","print(key, '=>', db[key])",printfunc,851 "Learning Python, 5th Edition","print(key, '=>', db[key])",printfunc,851 "Learning Python, 5th Edition","print(key, '\t=>', db[key])",printfunc,852 "Learning Python, 5th Edition","print(self.data, MixedNames.data)",printfunc,861 "Learning Python, 5th Edition",print(self.message),printfunc,863 "Learning Python, 5th Edition",print('in Super.method'),printfunc,867 "Learning Python, 5th Edition",print('starting Sub.method'),printfunc,867 "Learning Python, 5th Edition",print('ending Sub.method'),printfunc,867 "Learning Python, 5th Edition",print('in Super.method'),printfunc,868 "Learning Python, 5th Edition",print('in Replacer.method'),printfunc,868 "Learning Python, 5th Edition",print('starting Extender.method'),printfunc,868 "Learning Python, 5th Edition",print('ending Extender.method'),printfunc,868 "Learning Python, 5th Edition",print('in Provider.action'),printfunc,868 "Learning Python, 5th Edition",print('\n' + klass.__name__ + '...'),printfunc,868 "Learning Python, 5th Edition",print('\nProvider...'),printfunc,868 "Learning Python, 5th Edition",print('spam'),printfunc,870 "Learning Python, 5th Edition",print('spam'),printfunc,871 "Learning Python, 5th Edition",print(X) # Access global X (11),printfunc,873 "Learning Python, 5th Edition",print(X),printfunc,873 "Learning Python, 5th Edition",print(X) # 11: module (a.k.a. manynames.X outside file),printfunc,874 "Learning Python, 5th Edition",print(X),printfunc,874 "Learning Python, 5th Edition",print(obj.X),printfunc,874 "Learning Python, 5th Edition",print(obj.X),printfunc,874 "Learning Python, 5th Edition",print(C.X) # 33: class (a.k.a. obj.X if no X in instance),printfunc,874 "Learning Python, 5th Edition",print(C.m.X),printfunc,874 "Learning Python, 5th Edition",print(g.X),printfunc,874 "Learning Python, 5th Edition",print(X),printfunc,874 "Learning Python, 5th Edition",print(manynames.X),printfunc,874 "Learning Python, 5th Edition",print(manynames.C.X),printfunc,874 "Learning Python, 5th Edition",print(I.X),printfunc,874 "Learning Python, 5th Edition",print(I.X),printfunc,875 "Learning Python, 5th Edition",print(X) # Reference global in module (11),printfunc,875 "Learning Python, 5th Edition",print(X) # Reference local in enclosing scope (33),printfunc,875 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print('-'*40),printfunc,876 "Learning Python, 5th Edition",print(X),printfunc,876 "Learning Python, 5th Edition",print(X) # In enclosing def (nester),printfunc,876 "Learning Python, 5th Edition",print(X) # In enclosing def (nester),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print('-'*40),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print(X) # In enclosing def (not 3 in class!),printfunc,877 "Learning Python, 5th Edition",print(self.X),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print(self.X),printfunc,877 "Learning Python, 5th Edition",print(X),printfunc,877 "Learning Python, 5th Edition",print('-'*40),printfunc,877 "Learning Python, 5th Edition",print('.' * indent + cls.__name__),printfunc,880 "Learning Python, 5th Edition",print('Tree of %s' % inst),printfunc,880 "Learning Python, 5th Edition",print(self.__doc__),printfunc,882 "Learning Python, 5th Edition",print(self.method.__doc__),printfunc,882 "Learning Python, 5th Edition","print(X), repr(X), str(X)",printfunc,889 "Learning Python, 5th Edition","print(X[i], end=' ') # Runs __getitem__(X, i)",printfunc,891 "Learning Python, 5th Edition","print('getitem:', index)",printfunc,892 "Learning Python, 5th Edition","print('indexing', index)",printfunc,892 "Learning Python, 5th Edition","print('slicing', index.start, index.stop, index.step)",printfunc,892 "Learning Python, 5th Edition","print(item, end=' ')",printfunc,895 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,896 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,898 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,898 "Learning Python, 5th Edition","print(x + y, end=' ')",printfunc,899 "Learning Python, 5th Edition","print(next(I), next(I), next(I))",printfunc,900 "Learning Python, 5th Edition","print(x + y, end=' ')",printfunc,900 "Learning Python, 5th Edition","print(x + y, end=' ')",printfunc,901 "Learning Python, 5th Edition","print(x + y, end=' ')",printfunc,901 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,902 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,903 "Learning Python, 5th Edition","print('%s:%s' % (i, j), end=' ')",printfunc,904 "Learning Python, 5th Edition","print(i, end=' ')",printfunc,905 "Learning Python, 5th Edition","print('%s:%s' % (i, j), end=' ')",printfunc,905 "Learning Python, 5th Edition","print(x + y, end=' ')",printfunc,906 "Learning Python, 5th Edition","print('get[%s]:' % i, end='')",printfunc,907 "Learning Python, 5th Edition","print('iter=> ', end='')",printfunc,907 "Learning Python, 5th Edition","print('next:', end='')",printfunc,907 "Learning Python, 5th Edition","print('contains: ', end='')",printfunc,907 "Learning Python, 5th Edition",print(3 in X),printfunc,907 "Learning Python, 5th Edition","print(i, end=' | ')",printfunc,907 "Learning Python, 5th Edition",print(),printfunc,907 "Learning Python, 5th Edition",print([i ** 2 for i in X]),printfunc,907 "Learning Python, 5th Edition","print( list(map(bin, X)) )",printfunc,907 "Learning Python, 5th Edition","print('get[%s]:' % i, end='')",printfunc,908 "Learning Python, 5th Edition","print('iter=> next:', end='')",printfunc,908 "Learning Python, 5th Edition","print('next:', end='')",printfunc,908 "Learning Python, 5th Edition","print('contains: ', end='')",printfunc,908 "Learning Python, 5th Edition",print(x.name),printfunc,913 "Learning Python, 5th Edition",print(y.age),printfunc,913 "Learning Python, 5th Edition",print(x),printfunc,914 "Learning Python, 5th Edition",print(x),printfunc,914 "Learning Python, 5th Edition",print(x),printfunc,915 "Learning Python, 5th Edition",print(x),printfunc,915 "Learning Python, 5th Edition",print(x),printfunc,916 "Learning Python, 5th Edition",print(objs),printfunc,916 "Learning Python, 5th Edition",print(objs),printfunc,916 "Learning Python, 5th Edition","print('add', self.val, other)",printfunc,917 "Learning Python, 5th Edition","print('radd', self.val, other)",printfunc,918 "Learning Python, 5th Edition","print('add', self.val, other)",printfunc,918 "Learning Python, 5th Edition","print('add', self.val, other)",printfunc,918 "Learning Python, 5th Edition","print('add', self.val, other)",printfunc,919 "Learning Python, 5th Edition",print(x + 10),printfunc,919 "Learning Python, 5th Edition",print(10 + y),printfunc,919 "Learning Python, 5th Edition",print(z),printfunc,919 "Learning Python, 5th Edition",print(z + 10),printfunc,919 "Learning Python, 5th Edition",print(z + z),printfunc,919 "Learning Python, 5th Edition",print(z + z + 1),printfunc,919 "Learning Python, 5th Edition",print(z),printfunc,920 "Learning Python, 5th Edition",print(z + 10),printfunc,920 "Learning Python, 5th Edition",print(z + z),printfunc,920 "Learning Python, 5th Edition",print(z + z + 1),printfunc,920 "Learning Python, 5th Edition",print('-' * 60),printfunc,920 "Learning Python, 5th Edition",print(x + 1),printfunc,920 "Learning Python, 5th Edition",print(1 + y),printfunc,920 "Learning Python, 5th Edition",print(x + y),printfunc,920 "Learning Python, 5th Edition","print('Called:', pargs, kargs)",printfunc,922 "Learning Python, 5th Edition","print('turn', self.color)",printfunc,923 "Learning Python, 5th Edition","print('turn', color)",printfunc,924 "Learning Python, 5th Edition",print(cb4()),printfunc,924 "Learning Python, 5th Edition","print('turn', self.color)",printfunc,925 "Learning Python, 5th Edition",print(X > 'ham') # True (runs __gt__),printfunc,926 "Learning Python, 5th Edition",print(X < 'ham') # False (runs __lt__),printfunc,926 "Learning Python, 5th Edition",print(X > 'ham') # True (runs __cmp__),printfunc,926 "Learning Python, 5th Edition",print(X < 'ham') # False (runs __cmp__),printfunc,926 "Learning Python, 5th Edition",print('yes!'),printfunc,927 "Learning Python, 5th Edition",print('no!'),printfunc,927 "Learning Python, 5th Edition",print('yes!'),printfunc,928 "Learning Python, 5th Edition",print('in bool'),printfunc,928 "Learning Python, 5th Edition",print(99),printfunc,928 "Learning Python, 5th Edition",print('in bool'),printfunc,929 "Learning Python, 5th Edition",print(99),printfunc,929 "Learning Python, 5th Edition",print('in nonzero'),printfunc,929 "Learning Python, 5th Edition",print(99),printfunc,929 "Learning Python, 5th Edition",print('Hello ' + name),printfunc,929 "Learning Python, 5th Edition",print(self.name),printfunc,929 "Learning Python, 5th Edition",print('Goodbye ' + self.name),printfunc,929 "Learning Python, 5th Edition","print(self.name, ""does stuff"")",printfunc,935 "Learning Python, 5th Edition","print(self.name, ""makes food"")",printfunc,936 "Learning Python, 5th Edition","print(self.name, ""interfaces with customer"")",printfunc,936 "Learning Python, 5th Edition","print(self.name, ""makes pizza"")",printfunc,936 "Learning Python, 5th Edition",print(bob),printfunc,936 "Learning Python, 5th Edition","print(self.name, ""orders from"", server)",printfunc,937 "Learning Python, 5th Edition","print(self.name, ""pays for item to"", server)",printfunc,937 "Learning Python, 5th Edition","print(""oven bakes"")",printfunc,937 "Learning Python, 5th Edition",print('...'),printfunc,938 "Learning Python, 5th Edition",print('<PRE>%s</PRE>' % line.rstrip()),printfunc,940 "Learning Python, 5th Edition",print('Trace: ' + attrname),printfunc,942 "Learning Python, 5th Edition",print(self.X),printfunc,945 "Learning Python, 5th Edition",print(self.X),printfunc,946 "Learning Python, 5th Edition",print(self.__X),printfunc,946 "Learning Python, 5th Edition",print(self.__X),printfunc,946 "Learning Python, 5th Edition",print(message),printfunc,948 "Learning Python, 5th Edition",print(n),printfunc,949 "Learning Python, 5th Edition",print(act()),printfunc,951 "Learning Python, 5th Edition",print(act(5)),printfunc,952 "Learning Python, 5th Edition",print(act(5)),printfunc,953 "Learning Python, 5th Edition","print('{0:2} => {1}'.format(key, value))",printfunc,953 "Learning Python, 5th Edition",print(message),printfunc,955 "Learning Python, 5th Edition",print(X) # Default: class name + address (id),printfunc,958 "Learning Python, 5th Edition",print() or str(),printfunc,959 "Learning Python, 5th Edition",print(x) # print() and str(),printfunc,960 "Learning Python, 5th Edition",print(X),printfunc,961 "Learning Python, 5th Edition",print(instance) # Run mixed-in __str__ (or via str(x)),printfunc,962 "Learning Python, 5th Edition",print('-' * 80),printfunc,962 "Learning Python, 5th Edition",print(x),printfunc,963 "Learning Python, 5th Edition","print(), str()",printfunc,967 "Learning Python, 5th Edition","print(), str()",printfunc,971 "Learning Python, 5th Edition",print(B),printfunc,973 "Learning Python, 5th Edition",print(S[:1000]),printfunc,974 "Learning Python, 5th Edition","print(x.union(Set([1, 4, 7])))",printfunc,981 "Learning Python, 5th Edition","print(x | Set([1, 4, 6]))",printfunc,981 "Learning Python, 5th Edition","print('(indexing %s at %s)' % (self, offset))",printfunc,981 "Learning Python, 5th Edition",print(list('abc')),printfunc,981 "Learning Python, 5th Edition",print(x),printfunc,981 "Learning Python, 5th Edition",print(x[1]),printfunc,981 "Learning Python, 5th Edition",print(x[3]),printfunc,981 "Learning Python, 5th Edition",print(x),printfunc,981 "Learning Python, 5th Edition",print(x),printfunc,981 "Learning Python, 5th Edition","print(x, y, len(x))",printfunc,983 "Learning Python, 5th Edition","print(x.intersect(y), y.union(x))",printfunc,983 "Learning Python, 5th Edition","print(x & y, x | y)",printfunc,983 "Learning Python, 5th Edition",print(x),printfunc,983 "Learning Python, 5th Edition",print(name),printfunc,988 "Learning Python, 5th Edition",print(X),printfunc,989 "Learning Python, 5th Edition",print(X),printfunc,989 "Learning Python, 5th Edition",print('getattr: ' + name),printfunc,990 "Learning Python, 5th Edition",print('getattr: ' + name),printfunc,990 "Learning Python, 5th Edition",print('getitem: ' + str(i)),printfunc,990 "Learning Python, 5th Edition",print('add: ' + other),printfunc,990 "Learning Python, 5th Edition",print('A.meth'),printfunc,999 "Learning Python, 5th Edition",print('C.meth'),printfunc,999 "Learning Python, 5th Edition",print(label + pprint.pformat(X) + end),printfunc,1005 "Learning Python, 5th Edition","print('Classic classes in 2.X, new-style in 3.X')",printfunc,1006 "Learning Python, 5th Edition",print('Py=>%s' % I.attr1),printfunc,1006 "Learning Python, 5th Edition",print('New-style classes in 2.X and 3.X'),printfunc,1006 "Learning Python, 5th Edition",print('Py=>%s' % I.attr1),printfunc,1006 "Learning Python, 5th Edition","print(attr, '=>', getattr(X, attr))",printfunc,1013 "Learning Python, 5th Edition","print(attr, '=>', getattr(X, attr))",printfunc,1013 "Learning Python, 5th Edition","print(attr, '=>', getattr(X, attr))",printfunc,1014 "Learning Python, 5th Edition","print(a, getattr(I, a))",printfunc,1015 "Learning Python, 5th Edition",print(X),printfunc,1018 "Learning Python, 5th Edition",print(X),printfunc,1018 "Learning Python, 5th Edition","print('Slots =>', end=' ')",printfunc,1019 "Learning Python, 5th Edition","print(min(timeit.repeat(stmt, number=1000, repeat=3)))",printfunc,1019 "Learning Python, 5th Edition","print('Nonslots=>', end=' ')",printfunc,1019 "Learning Python, 5th Edition","print(min(timeit.repeat(stmt, number=1000, repeat=3)))",printfunc,1019 "Learning Python, 5th Edition",print('set age: %s' % value),printfunc,1021 "Learning Python, 5th Edition","print('set: %s %s' % (name, value))",printfunc,1022 "Learning Python, 5th Edition","print(""Number of instances created: %s"" % Spam.numInstances)",printfunc,1026 "Learning Python, 5th Edition","print(""Number of instances created: %s"" % Spam.numInstances)",printfunc,1027 "Learning Python, 5th Edition","print(""Number of instances created: %s"" % Spam.numInstances)",printfunc,1028 "Learning Python, 5th Edition","print([self, x])",printfunc,1029 "Learning Python, 5th Edition",print([x]),printfunc,1029 "Learning Python, 5th Edition","print([cls, x])",printfunc,1029 "Learning Python, 5th Edition","print(""Number of instances: %s"" % Spam.numInstances)",printfunc,1030 "Learning Python, 5th Edition","print(""Extra stuff..."")",printfunc,1031 "Learning Python, 5th Edition","print(""Number of instances: %s"" % cls.numInstances)",printfunc,1032 "Learning Python, 5th Edition","print(""Number of instances: %s %s"" % (cls.numInstances, cls))",printfunc,1032 "Learning Python, 5th Edition","print(""Extra stuff..."", cls)",printfunc,1032 "Learning Python, 5th Edition","print(""Number of instances created: %s"" % Spam.numInstances)",printfunc,1036 "Learning Python, 5th Edition","print([self, x])",printfunc,1036 "Learning Python, 5th Edition",print([x]),printfunc,1036 "Learning Python, 5th Edition","print([cls, x])",printfunc,1036 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1037 "Learning Python, 5th Edition","print(spam(1, 2, 3))",printfunc,1037 "Learning Python, 5th Edition","print(spam('a', 'b', 'c'))",printfunc,1037 "Learning Python, 5th Edition","print('call %s to %s' % (oncall.calls, func.__name__))",printfunc,1038 "Learning Python, 5th Edition","print(x.spam(1, 2, 3))",printfunc,1038 "Learning Python, 5th Edition","print(x.spam('a', 'b', 'c')) # Same output as tracer1 (in tracer2.py)",printfunc,1038 "Learning Python, 5th Edition",print('spam'),printfunc,1042 "Learning Python, 5th Edition",print('eggs'),printfunc,1043 "Learning Python, 5th Edition",print('spam'),printfunc,1043 "Learning Python, 5th Edition",print('eggs'),printfunc,1043 "Learning Python, 5th Edition",print(proxy),printfunc,1044 "Learning Python, 5th Edition",print('A'),printfunc,1044 "Learning Python, 5th Edition",print('B'),printfunc,1044 "Learning Python, 5th Edition",print('C index'),printfunc,1047 "Learning Python, 5th Edition",print('D index'),printfunc,1047 "Learning Python, 5th Edition",print('spam'),printfunc,1048 "Learning Python, 5th Edition",print('eggs'),printfunc,1048 "Learning Python, 5th Edition",print('eggs'),printfunc,1048 "Learning Python, 5th Edition",print('eggs'),printfunc,1048 "Learning Python, 5th Edition",print('X.m'),printfunc,1049 "Learning Python, 5th Edition",print('Y.m'),printfunc,1050 "Learning Python, 5th Edition",print('A.method'); super().method(),printfunc,1056 "Learning Python, 5th Edition",print('B.method'); super().method(),printfunc,1056 "Learning Python, 5th Edition",print('C.method'),printfunc,1056 "Learning Python, 5th Edition",print('D.method'); super().method(),printfunc,1056 "Learning Python, 5th Edition",print('B.method'),printfunc,1056 "Learning Python, 5th Edition",print('D.method'); super().method(),printfunc,1056 "Learning Python, 5th Edition",print('D.method'); B.method(self); C.method(self),printfunc,1056 "Learning Python, 5th Edition",print('A.other'),printfunc,1057 "Learning Python, 5th Edition",print('Mixin.other'); super().other(),printfunc,1057 "Learning Python, 5th Edition",print('B.method'),printfunc,1057 "Learning Python, 5th Edition",print('C.method'); super().other(); super().method(),printfunc,1057 "Learning Python, 5th Edition",print('C.method'); super().other(); super().method(),printfunc,1057 "Learning Python, 5th Edition",print('A.other'),printfunc,1058 "Learning Python, 5th Edition",print('Mixin.other'); super().other(),printfunc,1058 "Learning Python, 5th Edition",print('B.method'),printfunc,1058 "Learning Python, 5th Edition",print('C.method'); super().other(); super().method(),printfunc,1058 "Learning Python, 5th Edition",print('C.method'); super().other(); super().method(),printfunc,1058 "Learning Python, 5th Edition",print('C.method'); Mixin.other(self); B.method(self),printfunc,1059 "Learning Python, 5th Edition",print('A.method'),printfunc,1059 "Learning Python, 5th Edition",print('Mixin.method'); super().method(),printfunc,1059 "Learning Python, 5th Edition",print('B.method'),printfunc,1059 "Learning Python, 5th Edition",print('C.method'); super().method(),printfunc,1059 "Learning Python, 5th Edition",print('A.method'),printfunc,1059 "Learning Python, 5th Edition",print('Mixin.method'); A.method(self),printfunc,1059 "Learning Python, 5th Edition",print('C.method'); Mixin.method(self),printfunc,1059 "Learning Python, 5th Edition",print(X.i),printfunc,1065 "Learning Python, 5th Edition","print(Spam.count) # Visible in generate's scope, per LEGB rule (E)",printfunc,1068 "Learning Python, 5th Edition",print(Spam.count) # Works: in global (enclosing module),printfunc,1068 "Learning Python, 5th Edition","print(""%s=%s"" % (label, Spam.count))",printfunc,1069 "Learning Python, 5th Edition",print('got exception'),printfunc,1084 "Learning Python, 5th Edition",print('got exception'),printfunc,1085 "Learning Python, 5th Edition",print('continuing'),printfunc,1085 "Learning Python, 5th Edition",print('after fetch'),printfunc,1087 "Learning Python, 5th Edition",print('after try?'),printfunc,1087 "Learning Python, 5th Edition",print('after fetch'),printfunc,1088 "Learning Python, 5th Edition",print('after try?'),printfunc,1088 "Learning Python, 5th Edition","print(gobad(x, 0))",printfunc,1099 "Learning Python, 5th Edition","print(gobad(x, 0))",printfunc,1099 "Learning Python, 5th Edition",print(x + y),printfunc,1100 "Learning Python, 5th Edition",print('Hello world!'),printfunc,1100 "Learning Python, 5th Edition",print('resuming here'),printfunc,1100 "Learning Python, 5th Edition",print('not reached'),printfunc,1102 "Learning Python, 5th Edition",print(sep + 'EXCEPTION RAISED AND CAUGHT'),printfunc,1105 "Learning Python, 5th Edition",print('finally run'),printfunc,1105 "Learning Python, 5th Edition",print('after run'),printfunc,1105 "Learning Python, 5th Edition","print(sep + 'NO EXCEPTION RAISED, WITH ELSE')",printfunc,1105 "Learning Python, 5th Edition",print('else run'),printfunc,1106 "Learning Python, 5th Edition",print('finally run'),printfunc,1106 "Learning Python, 5th Edition",print('after run'),printfunc,1106 "Learning Python, 5th Edition",print(sep + 'EXCEPTION RAISED BUT NOT CAUGHT'),printfunc,1106 "Learning Python, 5th Edition",print('finally run'),printfunc,1106 "Learning Python, 5th Edition",print('after run'),printfunc,1106 "Learning Python, 5th Edition",print(line),printfunc,1115 "Learning Python, 5th Edition",print('running ' + arg),printfunc,1116 "Learning Python, 5th Edition",print('starting with block'),printfunc,1117 "Learning Python, 5th Edition",print('raise an exception! ' + str(exc_type)),printfunc,1117 "Learning Python, 5th Edition",print('reached'),printfunc,1117 "Learning Python, 5th Edition",print('not reached'),printfunc,1117 "Learning Python, 5th Edition",print(pair),printfunc,1118 "Learning Python, 5th Edition",print(sys.path)\n'),printfunc,1118 "Learning Python, 5th Edition","print(sys.platform)\n', 'x = 2\n')",printfunc,1118 "Learning Python, 5th Edition","print(2 ** 32) # Raise 2 to a power\n', 'print(x ** 32)\n')",printfunc,1118 "Learning Python, 5th Edition",print(pair),printfunc,1118 "Learning Python, 5th Edition",print('caught'),printfunc,1124 "Learning Python, 5th Edition",print('caught: %s' % sys.exc_info()[0]),printfunc,1126 "Learning Python, 5th Edition",print(I),printfunc,1134 "Learning Python, 5th Edition",print(I),printfunc,1134 "Learning Python, 5th Edition",print(X),printfunc,1134 "Learning Python, 5th Edition",print(X.args),printfunc,1134 "Learning Python, 5th Edition",print(repr(X)),printfunc,1134 "Learning Python, 5th Edition","print('Error at:', self.file, self.line, file=log)",printfunc,1138 "Learning Python, 5th Edition",print(1 + []),printfunc,1143 "Learning Python, 5th Edition",print('finally run'),printfunc,1144 "Learning Python, 5th Edition",print('...'),printfunc,1144 "Learning Python, 5th Edition",print('continuing'),printfunc,1145 "Learning Python, 5th Edition",print(B),printfunc,1183 "Learning Python, 5th Edition","print('Default encoding:', sys.getdefaultencoding())",printfunc,1188 "Learning Python, 5th Edition","print('{0}, strlen={1}, '.format(aStr, len(aStr)), end='')",printfunc,1188 "Learning Python, 5th Edition","print('byteslen1={0}, byteslen2={1}'.format(len(bytes1), len(bytes2)))",printfunc,1188 "Learning Python, 5th Edition",print(text),printfunc,1196 "Learning Python, 5th Edition",print(title),printfunc,1212 "Learning Python, 5th Edition",print(E.text),printfunc,1213 "Learning Python, 5th Edition","print(i, sys.exc_info()[0])",printfunc,1214 "Learning Python, 5th Edition",print('fetch...'),printfunc,1222 "Learning Python, 5th Edition",print('change...'),printfunc,1222 "Learning Python, 5th Edition",print('remove...'),printfunc,1222 "Learning Python, 5th Edition",print(bob.name),printfunc,1222 "Learning Python, 5th Edition",print(bob.name),printfunc,1222 "Learning Python, 5th Edition",print('-'*20),printfunc,1223 "Learning Python, 5th Edition",print(sue.name),printfunc,1223 "Learning Python, 5th Edition",print(Person.name.__doc__) # Or help(Person.name),printfunc,1223 "Learning Python, 5th Edition",print(P.X),printfunc,1224 "Learning Python, 5th Edition",print(P.X),printfunc,1224 "Learning Python, 5th Edition",print(Q.X) # 32 ** 2 (1024),printfunc,1224 "Learning Python, 5th Edition",print('fetch...'),printfunc,1225 "Learning Python, 5th Edition",print('change...'),printfunc,1225 "Learning Python, 5th Edition",print('remove...'),printfunc,1225 "Learning Python, 5th Edition",print(bob.name) # Runs name getter (name 1),printfunc,1225 "Learning Python, 5th Edition",print(bob.name),printfunc,1225 "Learning Python, 5th Edition",print('-'*20),printfunc,1225 "Learning Python, 5th Edition",print(sue.name),printfunc,1225 "Learning Python, 5th Edition",print(Person.name.__doc__) # Or help(Person.name),printfunc,1225 "Learning Python, 5th Edition","print(self, instance, owner, sep='\n')",printfunc,1228 "Learning Python, 5th Edition",print('fetch...'),printfunc,1230 "Learning Python, 5th Edition",print('change...'),printfunc,1230 "Learning Python, 5th Edition",print('remove...'),printfunc,1230 "Learning Python, 5th Edition",print(bob.name),printfunc,1230 "Learning Python, 5th Edition",print(bob.name),printfunc,1230 "Learning Python, 5th Edition",print('-'*20),printfunc,1230 "Learning Python, 5th Edition",print(sue.name),printfunc,1230 "Learning Python, 5th Edition",print(Name.__doc__) # Or help(Name),printfunc,1230 "Learning Python, 5th Edition",print('fetch...'),printfunc,1231 "Learning Python, 5th Edition",print('change...'),printfunc,1231 "Learning Python, 5th Edition",print('remove...'),printfunc,1231 "Learning Python, 5th Edition",print(Person.Name.__doc__),printfunc,1231 "Learning Python, 5th Edition",print(c1.X),printfunc,1232 "Learning Python, 5th Edition",print(c1.X),printfunc,1232 "Learning Python, 5th Edition",print(c2.X) # 32 ** 2 (1024),printfunc,1232 "Learning Python, 5th Edition",print('DescState get'),printfunc,1233 "Learning Python, 5th Edition",print('DescState set'),printfunc,1233 "Learning Python, 5th Edition","print(obj.X, obj.Y, obj.Z)",printfunc,1233 "Learning Python, 5th Edition","print(obj.X, obj.Y, obj.Z)",printfunc,1233 "Learning Python, 5th Edition","print(obj2.X, obj2.Y, obj2.Z)",printfunc,1233 "Learning Python, 5th Edition",print('InstState get'),printfunc,1234 "Learning Python, 5th Edition",print('InstState set'),printfunc,1234 "Learning Python, 5th Edition","print(obj.X, obj.Y, obj.Z)",printfunc,1234 "Learning Python, 5th Edition","print(obj.X, obj.Y, obj.Z)",printfunc,1234 "Learning Python, 5th Edition","print(obj2.X, obj2.Y, obj2.Z)",printfunc,1234 "Learning Python, 5th Edition","print('%s => %s' % (attr, getattr(I, attr)))",printfunc,1235 "Learning Python, 5th Edition",print('getName...'),printfunc,1236 "Learning Python, 5th Edition",print('setName...'),printfunc,1236 "Learning Python, 5th Edition",print('Get: %s' % name),printfunc,1239 "Learning Python, 5th Edition","print('Set: %s %s' % (name, value))",printfunc,1239 "Learning Python, 5th Edition",print('Get: %s' % name),printfunc,1239 "Learning Python, 5th Edition",print('Trace: ' + attrname),printfunc,1239 "Learning Python, 5th Edition",print(X.wrapped),printfunc,1239 "Learning Python, 5th Edition",print('get: ' + attr),printfunc,1241 "Learning Python, 5th Edition",print('set: ' + attr),printfunc,1242 "Learning Python, 5th Edition",print('del: ' + attr),printfunc,1242 "Learning Python, 5th Edition",print(bob.name),printfunc,1242 "Learning Python, 5th Edition",print(bob.name),printfunc,1242 "Learning Python, 5th Edition",print('-'*20),printfunc,1242 "Learning Python, 5th Edition",print(sue.name),printfunc,1242 "Learning Python, 5th Edition",print(Person.name.__doc__),printfunc,1242 "Learning Python, 5th Edition",print('get: ' + attr),printfunc,1243 "Learning Python, 5th Edition",print(A.X),printfunc,1244 "Learning Python, 5th Edition",print(A.X),printfunc,1244 "Learning Python, 5th Edition",print(B.X) # 32 ** 2 (1024),printfunc,1244 "Learning Python, 5th Edition",print('get: ' + attr),printfunc,1245 "Learning Python, 5th Edition",print(X.attr1),printfunc,1245 "Learning Python, 5th Edition",print(X.attr2),printfunc,1245 "Learning Python, 5th Edition",print(X.attr3),printfunc,1245 "Learning Python, 5th Edition",print('-'*20),printfunc,1245 "Learning Python, 5th Edition",print('get: ' + attr),printfunc,1245 "Learning Python, 5th Edition",print(X.attr1),printfunc,1245 "Learning Python, 5th Edition",print(X.attr2),printfunc,1245 "Learning Python, 5th Edition",print(X.attr3),printfunc,1245 "Learning Python, 5th Edition",print(X.square),printfunc,1246 "Learning Python, 5th Edition",print(X.cube),printfunc,1246 "Learning Python, 5th Edition",print(X.square),printfunc,1246 "Learning Python, 5th Edition",print(X.square),printfunc,1247 "Learning Python, 5th Edition",print(X.cube),printfunc,1247 "Learning Python, 5th Edition",print(X.square),printfunc,1247 "Learning Python, 5th Edition",print(X.square),printfunc,1248 "Learning Python, 5th Edition",print(X.cube),printfunc,1248 "Learning Python, 5th Edition",print(X.square),printfunc,1248 "Learning Python, 5th Edition",print(X.square),printfunc,1248 "Learning Python, 5th Edition",print(X.cube),printfunc,1248 "Learning Python, 5th Edition",print(X.square),printfunc,1248 "Learning Python, 5th Edition",print('__len__: 42'),printfunc,1250 "Learning Python, 5th Edition",print('getattr: ' + attr),printfunc,1250 "Learning Python, 5th Edition",print('__len__: 42'),printfunc,1250 "Learning Python, 5th Edition",print('getattribute: ' + attr),printfunc,1250 "Learning Python, 5th Edition","print('\n' + Class.__name__.ljust(50, '='))",printfunc,1250 "Learning Python, 5th Edition",print(sue.lastName()),printfunc,1254 "Learning Python, 5th Edition",print(sue),printfunc,1254 "Learning Python, 5th Edition",print(tom.lastName()),printfunc,1254 "Learning Python, 5th Edition",print(tom),printfunc,1254 "Learning Python, 5th Edition","print('**', attr)",printfunc,1255 "Learning Python, 5th Edition","print('**', attr)",printfunc,1255 "Learning Python, 5th Edition",print('[Using: %s]' % module.CardHolder) # No need for getattr(),printfunc,1258 "Learning Python, 5th Edition","print(who.acct, who.name, who.age, who.remain, who.addr, sep=' / ')",printfunc,1258 "Learning Python, 5th Edition",print('Bad age for Sue'),printfunc,1258 "Learning Python, 5th Edition","print('bob:', bob.name, bob.acct, bob.age, bob.addr)",printfunc,1261 "Learning Python, 5th Edition","print('sue:', sue.name, sue.acct, sue.age, sue.addr)",printfunc,1261 "Learning Python, 5th Edition","print('bob:', bob.name, bob.acct, bob.age, bob.addr)",printfunc,1261 "Learning Python, 5th Edition",print(x.attr),printfunc,1278 "Learning Python, 5th Edition",print('spam'),printfunc,1281 "Learning Python, 5th Edition",print(func()),printfunc,1281 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1283 "Learning Python, 5th Edition",print(a + b + c),printfunc,1283 "Learning Python, 5th Edition","print('call %s to %s' % (calls, func.__name__))",printfunc,1284 "Learning Python, 5th Edition","print(a, b, c)",printfunc,1284 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1285 "Learning Python, 5th Edition",print(a + b + c),printfunc,1285 "Learning Python, 5th Edition",print(x ** y),printfunc,1285 "Learning Python, 5th Edition","print('call %s to %s' % (calls, func.__name__))",printfunc,1286 "Learning Python, 5th Edition",print(a + b + c),printfunc,1286 "Learning Python, 5th Edition",print(x ** y),printfunc,1286 "Learning Python, 5th Edition","print('call %s to %s' % (calls, func.__name__))",printfunc,1287 "Learning Python, 5th Edition",print(a + b + c),printfunc,1287 "Learning Python, 5th Edition",print(x ** y),printfunc,1287 "Learning Python, 5th Edition","print('call %s to %s' % (wrapper.calls, func.__name__))",printfunc,1288 "Learning Python, 5th Edition",print(a + b + c),printfunc,1288 "Learning Python, 5th Edition",print(x ** y),printfunc,1288 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1289 "Learning Python, 5th Edition",print(a + b + c),printfunc,1289 "Learning Python, 5th Edition",print(bob.lastName()) # Runs tracer.__call__(???),printfunc,1290 "Learning Python, 5th Edition","print('call %s to %s' % (calls, func.__name__))",printfunc,1291 "Learning Python, 5th Edition",print(a + b + c),printfunc,1291 "Learning Python, 5th Edition",print(eggs(32)),printfunc,1291 "Learning Python, 5th Edition",print('methods...'),printfunc,1292 "Learning Python, 5th Edition","print(bob.name, sue.name)",printfunc,1292 "Learning Python, 5th Edition",print(int(sue.pay)),printfunc,1292 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName()) # Runs onCall(bob)",printfunc,1292 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1293 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.func.__name__))",printfunc,1294 "Learning Python, 5th Edition","print('call %s to %s' % (self.calls, self.meth.__name__))",printfunc,1295 "Learning Python, 5th Edition","print('%s: %.5f, %.5f' % (self.func.__name__, elapsed, self.alltime))",printfunc,1296 "Learning Python, 5th Edition",print(result),printfunc,1296 "Learning Python, 5th Edition",print('allTime = %s' % listcomp.alltime),printfunc,1296 "Learning Python, 5th Edition",print(''),printfunc,1296 "Learning Python, 5th Edition",print(result),printfunc,1296 "Learning Python, 5th Edition",print('allTime = %s' % mapcall.alltime),printfunc,1296 "Learning Python, 5th Edition","print('\n**map/comp = %s' % round(mapcall.alltime / listcomp.alltime, 3))",printfunc,1296 "Learning Python, 5th Edition",print(format % values),printfunc,1299 "Learning Python, 5th Edition",print(result),printfunc,1300 "Learning Python, 5th Edition",print('allTime = %s\n' % func.alltime),printfunc,1300 "Learning Python, 5th Edition","print('**map/comp = %s' % round(mapcall.alltime / listcomp.alltime, 3))",printfunc,1300 "Learning Python, 5th Edition","print(bob.name, bob.pay())",printfunc,1302 "Learning Python, 5th Edition","print(sue.name, sue.pay())",printfunc,1302 "Learning Python, 5th Edition","print(X.attr, Y.attr)",printfunc,1302 "Learning Python, 5th Edition","print('Trace:', attrname)",printfunc,1304 "Learning Python, 5th Edition",print('Trace: ' + attrname),printfunc,1305 "Learning Python, 5th Edition",print('Spam!' * 8),printfunc,1305 "Learning Python, 5th Edition",print([food.fetches]),printfunc,1305 "Learning Python, 5th Edition",print(bob.name),printfunc,1305 "Learning Python, 5th Edition",print(bob.pay()),printfunc,1305 "Learning Python, 5th Edition",print(''),printfunc,1305 "Learning Python, 5th Edition",print(sue.name),printfunc,1305 "Learning Python, 5th Edition",print(sue.pay()),printfunc,1305 "Learning Python, 5th Edition",print(bob.name),printfunc,1305 "Learning Python, 5th Edition",print(bob.pay()),printfunc,1305 "Learning Python, 5th Edition","print([bob.fetches, sue.fetches])",printfunc,1305 "Learning Python, 5th Edition",print('Trace: ' + attrname),printfunc,1308 "Learning Python, 5th Edition",print('Spam!' * 8),printfunc,1308 "Learning Python, 5th Edition",print(bob.name),printfunc,1308 "Learning Python, 5th Edition",print(sue.name),printfunc,1308 "Learning Python, 5th Edition",print(bob.name),printfunc,1308 "Learning Python, 5th Edition",print('Registry:'),printfunc,1313 "Learning Python, 5th Edition","print(name, '=>', registry[name], type(registry[name]))",printfunc,1313 "Learning Python, 5th Edition",print('\nManual calls:'),printfunc,1313 "Learning Python, 5th Edition",print(spam(2)),printfunc,1313 "Learning Python, 5th Edition",print(ham(2)),printfunc,1313 "Learning Python, 5th Edition",print(X),printfunc,1313 "Learning Python, 5th Edition",print('\nRegistry calls:'),printfunc,1313 "Learning Python, 5th Edition","print(name, '=>', registry[name](2))",printfunc,1313 "Learning Python, 5th Edition","print('[' + ' '.join(map(str, args)) + ']')",printfunc,1315 "Learning Python, 5th Edition","print('%s => %s' % (self.label, self.data))",printfunc,1316 "Learning Python, 5th Edition",print(X.label),printfunc,1316 "Learning Python, 5th Edition",print(Y.label),printfunc,1316 "Learning Python, 5th Edition",print(X.size()),printfunc,1316 "Learning Python, 5th Edition",print(X.data),printfunc,1316 "Learning Python, 5th Edition",print(Y.data),printfunc,1316 "Learning Python, 5th Edition",print(Y.size()),printfunc,1316 "Learning Python, 5th Edition","print('[' + ' '.join(map(str, args)) + ']')",printfunc,1319 "Learning Python, 5th Edition",print(X),printfunc,1323 "Learning Python, 5th Edition",print(X),printfunc,1323 "Learning Python, 5th Edition",print(X),printfunc,1323 "Learning Python, 5th Edition",print(X),printfunc,1323 "Learning Python, 5th Edition",print(__debug__),printfunc,1332 "Learning Python, 5th Edition","print('%s is %s years old' % (name, age))",printfunc,1332 "Learning Python, 5th Edition","print(sue.pay) # Or giveRaise(self, .10)",printfunc,1332 "Learning Python, 5th Edition",print(sue.pay),printfunc,1332 "Learning Python, 5th Edition","print('%s is %s years old' % (name, age))",printfunc,1334 "Learning Python, 5th Edition","print(bob.pay, sue.pay)",printfunc,1335 "Learning Python, 5th Edition","print(a, b, c, d)",printfunc,1335 "Learning Python, 5th Edition",print(a + b + c),printfunc,1340 "Learning Python, 5th Edition",print(a + b + c),printfunc,1341 "Learning Python, 5th Edition",print(argchecks),printfunc,1341 "Learning Python, 5th Edition",print(a + b + c),printfunc,1341 "Learning Python, 5th Edition",print(argchecks),printfunc,1341 "Learning Python, 5th Edition",print(a + b + c),printfunc,1341 "Learning Python, 5th Edition",print(format % values),printfunc,1345 "Learning Python, 5th Edition",print('---------------------------------------------------'),printfunc,1345 "Learning Python, 5th Edition",print(result),printfunc,1346 "Learning Python, 5th Edition",print('allTime = %s\n' % func.alltime),printfunc,1346 "Learning Python, 5th Edition",print('---------------------------------------------------'),printfunc,1346 "Learning Python, 5th Edition","print(int(bob.pay), int(sue.pay))",printfunc,1346 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName()) # runs onCall(bob)",printfunc,1346 "Learning Python, 5th Edition","print('%.5f %.5f' % (Person.giveRaise.alltime, Person.lastName.alltime))",printfunc,1346 "Learning Python, 5th Edition","print('[' + ' '.join(map(str, args)) + ']')",printfunc,1347 "Learning Python, 5th Edition",print('---------------------------------------------------------'),printfunc,1348 "Learning Python, 5th Edition",print(X.name),printfunc,1349 "Learning Python, 5th Edition",print(X.name),printfunc,1349 "Learning Python, 5th Edition",print(X),printfunc,1349 "Learning Python, 5th Edition",print('[%s]' % sys.exc_info()[1]),printfunc,1351 "Learning Python, 5th Edition",print('?%s?' % result),printfunc,1351 "Learning Python, 5th Edition",print('--------------------------------------------------------------------'),printfunc,1351 "Learning Python, 5th Edition","print('date = %s/%s/%s' % (m, d, y))",printfunc,1351 "Learning Python, 5th Edition",print(a + b + c + d),printfunc,1351 "Learning Python, 5th Edition",print('--------------------------------------------------------------------'),printfunc,1351 "Learning Python, 5th Edition","print('%s %s %s' % (label, word1, word2))",printfunc,1352 "Learning Python, 5th Edition",print('--------------------------------------------------------------------'),printfunc,1352 "Learning Python, 5th Edition",print(A + B),printfunc,1352 "Learning Python, 5th Edition",print('--------------------------------------------------------------------'),printfunc,1352 "Learning Python, 5th Edition","print(nester(1, 2, 'spam'))",printfunc,1352 "Learning Python, 5th Edition","print('In MetaOne.new:', meta, classname, supers, classdict, sep='\n...')",printfunc,1371 "Learning Python, 5th Edition",print('making class'),printfunc,1371 "Learning Python, 5th Edition",print('making instance'),printfunc,1371 "Learning Python, 5th Edition","print('data:', X.data, X.meth(2))",printfunc,1371 "Learning Python, 5th Edition","print('In MetaTwo.new: ', classname, supers, classdict, sep='\n...')",printfunc,1372 "Learning Python, 5th Edition","print('In MetaTwo.init:', classname, supers, classdict, sep='\n...')",printfunc,1372 "Learning Python, 5th Edition",print('making class'),printfunc,1372 "Learning Python, 5th Edition",print('making instance'),printfunc,1372 "Learning Python, 5th Edition","print('data:', X.data, X.meth(2))",printfunc,1372 "Learning Python, 5th Edition","print('In MetaFunc: ', classname, supers, classdict, sep='\n...')",printfunc,1373 "Learning Python, 5th Edition",print('making class'),printfunc,1373 "Learning Python, 5th Edition",print('making instance'),printfunc,1373 "Learning Python, 5th Edition","print('data:', X.data, X.meth(2))",printfunc,1373 "Learning Python, 5th Edition","print('In MetaObj.call: ', classname, supers, classdict, sep='\n...')",printfunc,1374 "Learning Python, 5th Edition","print('In MetaObj.new: ', classname, supers, classdict, sep='\n...')",printfunc,1374 "Learning Python, 5th Edition","print('In MetaObj.init:', classname, supers, classdict, sep='\n...')",printfunc,1374 "Learning Python, 5th Edition",print('making class'),printfunc,1374 "Learning Python, 5th Edition",print('making instance'),printfunc,1374 "Learning Python, 5th Edition","print('data:', X.data, X.meth(2))",printfunc,1374 "Learning Python, 5th Edition","print('In SuperMetaObj.call: ', classname, supers, classdict, sep='\n...')",printfunc,1375 "Learning Python, 5th Edition","print('In SubMetaObj.new: ', classname, supers, classdict, sep='\n...')",printfunc,1375 "Learning Python, 5th Edition","print('In SubMetaObj.init:', classname, supers, classdict, sep='\n...')",printfunc,1375 "Learning Python, 5th Edition","print('In SubMeta.new: ', classname, supers, classdict, sep='\n...')",printfunc,1376 "Learning Python, 5th Edition","print('In SubMeta init:', classname, supers, classdict, sep='\n...')",printfunc,1376 "Learning Python, 5th Edition",print('making class'),printfunc,1376 "Learning Python, 5th Edition",print('making instance'),printfunc,1376 "Learning Python, 5th Edition","print('data:', X.data, X.meth(2))",printfunc,1377 "Learning Python, 5th Edition","print('In SuperMeta.call:', classname)",printfunc,1378 "Learning Python, 5th Edition","print('In SubMeta init:', classname)",printfunc,1378 "Learning Python, 5th Edition",print([n.__name__ for n in SubMeta.__mro__]),printfunc,1378 "Learning Python, 5th Edition",print(),printfunc,1378 "Learning Python, 5th Edition",print(SubMeta.__call__),printfunc,1378 "Learning Python, 5th Edition",print(),printfunc,1378 "Learning Python, 5th Edition",print(),printfunc,1378 "Learning Python, 5th Edition","print('In MetaOne.new:', classname)",printfunc,1379 "Learning Python, 5th Edition",print([x.__name__ for x in k.__mro__]),printfunc,1388 "Learning Python, 5th Edition","print('ay', cls)",printfunc,1388 "Learning Python, 5th Edition","print('by', self) # A normal class (normal instances)",printfunc,1388 "Learning Python, 5th Edition","print('bz', self)",printfunc,1388 "Learning Python, 5th Edition",print(X.spam()),printfunc,1392 "Learning Python, 5th Edition",print(X.eggs()),printfunc,1392 "Learning Python, 5th Edition",print(X.ham('bacon')),printfunc,1392 "Learning Python, 5th Edition",print(Y.eggs()),printfunc,1392 "Learning Python, 5th Edition",print(Y.ham('bacon')),printfunc,1392 "Learning Python, 5th Edition",print(X.spam()),printfunc,1393 "Learning Python, 5th Edition",print(X.eggs()),printfunc,1393 "Learning Python, 5th Edition",print(X.ham('bacon')),printfunc,1393 "Learning Python, 5th Edition",print(Y.eggs()),printfunc,1393 "Learning Python, 5th Edition",print(Y.ham('bacon')),printfunc,1393 "Learning Python, 5th Edition",print(X.spam()),printfunc,1395 "Learning Python, 5th Edition",print(X.eggs()),printfunc,1395 "Learning Python, 5th Edition",print(X.ham('bacon')),printfunc,1395 "Learning Python, 5th Edition",print(Y.eggs()),printfunc,1395 "Learning Python, 5th Edition",print(Y.ham('bacon')),printfunc,1395 "Learning Python, 5th Edition","print('Trace:', attrname)",printfunc,1396 "Learning Python, 5th Edition",print(bob.name),printfunc,1396 "Learning Python, 5th Edition",print(bob.pay()),printfunc,1396 "Learning Python, 5th Edition","print('Trace:', attrname)",printfunc,1397 "Learning Python, 5th Edition",print(bob.name),printfunc,1397 "Learning Python, 5th Edition",print(bob.pay()),printfunc,1397 "Learning Python, 5th Edition",print('In M.__new__:'),printfunc,1398 "Learning Python, 5th Edition","print([clsname, supers, list(attrdict.keys())])",printfunc,1398 "Learning Python, 5th Edition","print('call %s to %s' % (calls, func.__name__))",printfunc,1400 "Learning Python, 5th Edition",print(format % values),printfunc,1400 "Learning Python, 5th Edition","print(bob.name, sue.name)",printfunc,1401 "Learning Python, 5th Edition",print('%.2f' % sue.pay),printfunc,1401 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName()) # Runs onCall(bob)",printfunc,1401 "Learning Python, 5th Edition","print(bob.name, sue.name)",printfunc,1402 "Learning Python, 5th Edition",print('%.2f' % sue.pay),printfunc,1402 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,1402 "Learning Python, 5th Edition","print(bob.name, sue.name)",printfunc,1403 "Learning Python, 5th Edition",print('%.2f' % sue.pay),printfunc,1403 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,1403 "Learning Python, 5th Edition",print('-'*40),printfunc,1404 "Learning Python, 5th Edition",print('%.5f' % Person.__init__.alltime),printfunc,1404 "Learning Python, 5th Edition",print('%.5f' % Person.giveRaise.alltime),printfunc,1404 "Learning Python, 5th Edition",print('%.5f' % Person.lastName.alltime),printfunc,1404 "Learning Python, 5th Edition","print(bob.name, sue.name)",printfunc,1405 "Learning Python, 5th Edition",print('%.2f' % sue.pay),printfunc,1405 "Learning Python, 5th Edition","print(bob.lastName(), sue.lastName())",printfunc,1405 "Learning Python, 5th Edition",print('-'*40),printfunc,1406 "Learning Python, 5th Edition",print('%.5f' % Person.__init__.alltime),printfunc,1406 "Learning Python, 5th Edition",print('%.5f' % Person.giveRaise.alltime),printfunc,1406 "Learning Python, 5th Edition",print('%.5f' % Person.lastName.alltime),printfunc,1406 "Learning Python, 5th Edition","print(c, end=' ')",printfunc,1415 "Learning Python, 5th Edition",print(),printfunc,1415 "Learning Python, 5th Edition","print(text, file=file)",printfunc,1415 "Learning Python, 5th Edition","print(tags, file=file)",printfunc,1416 "Learning Python, 5th Edition","print('[File: %s]' % saveto, end='')",printfunc,1416 "Learning Python, 5th Edition",print(sys.argv),printfunc,1432 "Learning Python, 5th Edition",print(2 ** 100),printfunc,1433 "Learning Python, 5th Edition",print(1 / X),printfunc,1435 "Learning Python, 5th Edition",print(1 / X),printfunc,1435 "Learning Python, 5th Edition",print(sys.version.split()[0]),printfunc,1441 "Learning Python, 5th Edition",print(sys.version.split()[0]),printfunc,1442 "Learning Python, 5th Edition",print(sys.version.split()[0]),printfunc,1445 "Learning Python, 5th Edition",print(sys.argv),printfunc,1445 "Learning Python, 5th Edition",print(99),printfunc,1445 "Learning Python, 5th Edition","print(x, y)",printfunc,1461 "Learning Python, 5th Edition","print(x, y, file=F)",printfunc,1461 "Learning Python, 5th Edition","print(x, y, end=' ')",printfunc,1461 "Learning Python, 5th Edition",print('Hello module world!'),printfunc,1465 "Learning Python, 5th Edition",print('Hello module world!'),printfunc,1466 "Learning Python, 5th Edition",print(ord(c)),printfunc,1473 "Learning Python, 5th Edition","print(key, '=>', D[key])",printfunc,1474 "Learning Python, 5th Edition","print(key, '=>', D[key])",printfunc,1474 "Learning Python, 5th Edition","print(X, 'not found')",printfunc,1474 "Learning Python, 5th Edition","print((2 ** X), 'was found at', L.index(2 ** X))",printfunc,1475 "Learning Python, 5th Edition","print(X, 'not found')",printfunc,1475 "Learning Python, 5th Edition",print(L),printfunc,1475 "Learning Python, 5th Edition","print((2 ** X), 'was found at', L.index(2 ** X))",printfunc,1475 "Learning Python, 5th Edition","print(X, 'not found')",printfunc,1475 "Learning Python, 5th Edition",print(L) # list(),printfunc,1475 "Learning Python, 5th Edition","print((2 ** X), 'was found at', L.index(2 ** X))",printfunc,1475 "Learning Python, 5th Edition","print(X, 'not found')",printfunc,1475 "Learning Python, 5th Edition",print(x),printfunc,1475 "Learning Python, 5th Edition","print(adder(2, 3))",printfunc,1476 "Learning Python, 5th Edition","print(adder('spam', 'eggs'))",printfunc,1476 "Learning Python, 5th Edition","print(adder(['a', 'b'], ['c', 'd']))",printfunc,1476 "Learning Python, 5th Edition","print('adder1', end=' ')",printfunc,1476 "Learning Python, 5th Edition","print('adder2', end=' ')",printfunc,1476 "Learning Python, 5th Edition","print(func(2, 3, 4))",printfunc,1476 "Learning Python, 5th Edition","print(func('spam', 'eggs', 'toast'))",printfunc,1476 "Learning Python, 5th Edition","print(func(['a', 'b'], ['c', 'd'], ['e', 'f']))",printfunc,1476 "Learning Python, 5th Edition",print(adder()),printfunc,1477 "Learning Python, 5th Edition",print(adder(5)),printfunc,1477 "Learning Python, 5th Edition","print(adder(5, 6))",printfunc,1477 "Learning Python, 5th Edition","print(adder(5, 6, 7))",printfunc,1477 "Learning Python, 5th Edition","print(adder(ugly=7, good=6, bad=5))",printfunc,1477 "Learning Python, 5th Edition","print(adder1(1, 2, 3), adder1('aa', 'bb', 'cc'))",printfunc,1477 "Learning Python, 5th Edition","print(adder2(a=1, b=2, c=3), adder2(a='aa', b='bb', c='cc'))",printfunc,1478 "Learning Python, 5th Edition","print(adder3(a=1, b=2, c=3), adder3(a='aa', b='bb', c='cc'))",printfunc,1478 "Learning Python, 5th Edition","print(adder4(a=1, b=2, c=3), adder4(a='aa', b='bb', c='cc'))",printfunc,1478 "Learning Python, 5th Edition","print(a, b)",printfunc,1478 "Learning Python, 5th Edition","print(a, b)",printfunc,1478 "Learning Python, 5th Edition","print(a, b)",printfunc,1478 "Learning Python, 5th Edition","print(a, b, c)",printfunc,1478 "Learning Python, 5th Edition","print(a, b, c)",printfunc,1479 "Learning Python, 5th Edition","print(y, 'not prime')",printfunc,1479 "Learning Python, 5th Edition","print(y, 'is prime')",printfunc,1479 "Learning Python, 5th Edition",print(sys.version),printfunc,1481 "Learning Python, 5th Edition","print(N, end=' ')",printfunc,1483 "Learning Python, 5th Edition","print(fact0(6), fact1(6), fact2(6), fact3(6), fact4(6))",printfunc,1484 "Learning Python, 5th Edition",print(fact0(500) == fact1(500) == fact2(500) == fact3(500) == fact4(500)),printfunc,1484 "Learning Python, 5th Edition","print(test.__name__, min(repeat(stmt=lambda: test(500), number=20, repeat=3)))",printfunc,1484 "Learning Python, 5th Edition",print(test('mymod.py')),printfunc,1487 "Learning Python, 5th Edition",print(test(input('Enter file name:')) # Console (raw_input in 2.X),printfunc,1487 "Learning Python, 5th Edition",print(test(sys.argv[1])),printfunc,1487 "Learning Python, 5th Edition","print(countLines('mymod.py'), countChars('mymod.py'))",printfunc,1487 "Learning Python, 5th Edition",print('not implemented!'),printfunc,1489 "Learning Python, 5th Edition",print('not implemented!'),printfunc,1490 "Learning Python, 5th Edition",print(y),printfunc,1490 "Learning Python, 5th Edition",print(z),printfunc,1490 "Learning Python, 5th Edition",print(x),printfunc,1491 "Learning Python, 5th Edition",print(x[2]),printfunc,1491 "Learning Python, 5th Edition",print(x[1:]),printfunc,1491 "Learning Python, 5th Edition",print(x + ['eggs']),printfunc,1491 "Learning Python, 5th Edition",print(x * 3),printfunc,1491 "Learning Python, 5th Edition",print(' '.join(c for c in x)),printfunc,1491 "Learning Python, 5th Edition",print('add: ' + str(other)),printfunc,1492 "Learning Python, 5th Edition",print(x[2]),printfunc,1492 "Learning Python, 5th Edition",print(x[1:]),printfunc,1492 "Learning Python, 5th Edition",print(x + ['eggs']),printfunc,1492 "Learning Python, 5th Edition",print(x + ['toast']),printfunc,1492 "Learning Python, 5th Edition",print(y + ['bar']),printfunc,1492 "Learning Python, 5th Edition",print(x.stats()),printfunc,1492 "Learning Python, 5th Edition",print('get %s' % name),printfunc,1492 "Learning Python, 5th Edition","print('set %s %s' % (name, value))",printfunc,1492 "Learning Python, 5th Edition","print(c, end=' ') # __iter__ (else __getitem__)",printfunc,1493 "Learning Python, 5th Edition",print(self.food.name),printfunc,1496 "Learning Python, 5th Edition",print('spam'),printfunc,1496 "Learning Python, 5th Edition",print('huh?'),printfunc,1496 "Learning Python, 5th Edition",print('meow'),printfunc,1496 "Learning Python, 5th Edition",print('bark'),printfunc,1496 "Learning Python, 5th Edition",print('Hello world!'),printfunc,1496 "Learning Python, 5th Edition","print(self.name + ':', repr(self.says()))",printfunc,1497 "Learning Python, 5th Edition",print('no error caught...'),printfunc,1497 "Learning Python, 5th Edition","print('Got %s %s' % (sys.exc_info()[0], sys.exc_info()[1]))",printfunc,1499 "Learning Python, 5th Edition",print(allsizes[:2]),printfunc,1499 "Learning Python, 5th Edition",print(allsizes[-2:]),printfunc,1499 "Learning Python, 5th Edition",print(allsizes[:2]),printfunc,1500 "Learning Python, 5th Edition",print(allsizes[-2:]),printfunc,1500 "Learning Python, 5th Edition","print('skipping', pypath)",printfunc,1500 "Learning Python, 5th Edition",print(allsizes[:3]),printfunc,1500 "Learning Python, 5th Edition",print(allsizes[-3:]),printfunc,1500 "Learning Python, 5th Edition","print(key, '=', sums[key])",printfunc,1501 "Learning Python, 5th Edition",print(totals),printfunc,1501 "Learning Python, 5th Edition","print('Created:', result)",printfunc,1501 "Learning Python, 5th Edition",print(output),printfunc,1501 "Learning Python, 5th Edition","print('Passed:', testcase['script'])",printfunc,1501 "Learning Python, 5th Edition",print(text),printfunc,1501 "Learning Python, 5th Edition",print('Connecting...'),printfunc,1503 "Learning Python, 5th Edition",print(server.getwelcome()),printfunc,1503 "Learning Python, 5th Edition","print('There are', msgCount, 'mail messages, size ', mboxSize)",printfunc,1503 "Learning Python, 5th Edition",print(msginfo),printfunc,1503 "Learning Python, 5th Edition",print('-'*80),printfunc,1503 "Learning Python, 5th Edition","print('[%d: octets=%d, size=%s]' % (msgnum, octets, msgsize))",printfunc,1503 "Learning Python, 5th Edition",print(line),printfunc,1503 "Learning Python, 5th Edition",print(line),printfunc,1504 "Learning Python, 5th Edition",print('skipping'),printfunc,1504 "Learning Python, 5th Edition","print(""Content-type: text/html\n"")",printfunc,1504 "Learning Python, 5th Edition","print(""<HTML>"")",printfunc,1504 "Learning Python, 5th Edition","print(""<title>Reply Page</title>"")",printfunc,1504 "Learning Python, 5th Edition","print(""<BODY>"")",printfunc,1504 "Learning Python, 5th Edition","print(""<h1>Hello <i>%s</i>!</h1>"" % cgi.escape(form['user'].value))",printfunc,1504 "Learning Python, 5th Edition","print(""</BODY></HTML>"")",printfunc,1504 "Learning Python, 5th Edition","print(key, '=>', db[key])",printfunc,1504 "Learning Python, 5th Edition",print(row),printfunc,1505 "Learning Python, 5th Edition",print(curs.description),printfunc,1505 "Learning Python, 5th Edition",print('Connecting...'),printfunc,1506 "Learning Python, 5th Edition",print('Downloading...'),printfunc,1506 "Learning Python, 5th Edition",print('Playing...'),printfunc,1506 "Learning Python, 5th Edition","T = (1, 2, 3, 4)",simpleTuple,121 "Learning Python, 5th Edition","T = (2,)",simpleTuple,121 "Learning Python, 5th Edition","In this interaction, X and Y should be == (same value), but not is (same object)",simpleTuple,184 "Learning Python, 5th Edition","T = (0,)",simpleTuple,276 "Learning Python, 5th Edition","T = (0, 'Ni', 1.2, 3)",simpleTuple,276 "Learning Python, 5th Edition","T = ('Bob', ('dev', 'mgr'))",simpleTuple,277 "Learning Python, 5th Edition","T = (1, 2, 3, 4)",simpleTuple,277 "Learning Python, 5th Edition","y = (40,)",simpleTuple,278 "Learning Python, 5th Edition","T = ('cc', 'aa', 'dd', 'bb')",simpleTuple,278 "Learning Python, 5th Edition","T = (1, 2, 3, 4, 5)",simpleTuple,279 "Learning Python, 5th Edition","T = (1, 2, 3, 2, 4, 2)",simpleTuple,279 "Learning Python, 5th Edition","T = (1, [2, 3], 4)",simpleTuple,279 "Learning Python, 5th Edition","bob = ('Bob', 40.5, ['dev', 'mgr'])",simpleTuple,280 "Learning Python, 5th Edition","T = (1, 2, 3)",simpleTuple,311 "Learning Python, 5th Edition","generate a new tuple with the desired value. Given T = (4, 5, 6)",simpleTuple,312 "Learning Python, 5th Edition","the first item by making a new tuple from its parts by slicing and concatenating: T = (1,) + T[1:]. (Recall that single-item tuples require a trailing comma.)",simpleTuple,312 "Learning Python, 5th Edition","a, b, c] = (1, 2, 3)",simpleTuple,342 "Learning Python, 5th Edition","a, b), c) = ('SP', 'AM')",simpleTuple,343 "Learning Python, 5th Edition","a, *b, c = (1, 2, 3, 4)",simpleTuple,348 "Learning Python, 5th Edition","a, b, c = (1, 2, 3)",simpleTuple,348 "Learning Python, 5th Edition","T = (""and"", ""I'm"", ""okay"")",simpleTuple,396 "Learning Python, 5th Edition","Here, the first time through the loop is like writing (a,b) = (1,2)",simpleTuple,397 "Learning Python, 5th Edition","like writing (a,b) = (3,4)",simpleTuple,397 "Learning Python, 5th Edition","a, b), c) = ((1, 2), 3)",simpleTuple,398 "Learning Python, 5th Edition","a, b, c = (1, 2, 3)",simpleTuple,398 "Learning Python, 5th Edition","a, *b, c = (1, 2, 3, 4)",simpleTuple,398 "Learning Python, 5th Edition","assignment statement (x, y) = (1, 5)",simpleTuple,408 "Learning Python, 5th Edition","T1, T2, T3 = (1,2,3), (4,5,6), (7,8,9)",simpleTuple,408 "Learning Python, 5th Edition","X = (1, 2)",simpleTuple,433 "Learning Python, 5th Edition","Y = (3, 4)",simpleTuple,433 "Learning Python, 5th Edition","action = (lambda n, x=x: x ** n)",simpleTuple,505 "Learning Python, 5th Edition","args = (1, 2)",simpleTuple,535 "Learning Python, 5th Edition","args += (3, 4)",simpleTuple,535 "Learning Python, 5th Edition","args = (2,3)",simpleTuple,537 "Learning Python, 5th Edition","args += (4,)",simpleTuple,537 "Learning Python, 5th Edition","x = (lambda a=""fee"", b=""fie"", c=""foe"": a + b + c)",simpleTuple,568 "Learning Python, 5th Edition","lower = (lambda x, y: x if x < y else y)",simpleTuple,571 "Learning Python, 5th Edition","a, b, c = (x + '\n' for x in 'aaa,bbb,ccc'.split(','))",simpleTuple,598 "Learning Python, 5th Edition","G = ((x, x * x) for x in range(10))",simpleTuple,625 "Learning Python, 5th Edition","result = (last3 + ',' + result)",simpleTuple,752 "Learning Python, 5th Edition","tests += (2 ** 100), −(2 ** 100)",simpleTuple,752 "Learning Python, 5th Edition","rec = ('Bob', 40.5, ['dev', 'mgr'])",simpleTuple,812 "Learning Python, 5th Edition","C.__bases__ = (B,)",simpleTuple,971 "Learning Python, 5th Edition","C.__bases__ = (Y,)",simpleTuple,1050 "Learning Python, 5th Edition","C.__bases__ = (Y,) # Same effect, without super()",simpleTuple,1050 "Learning Python, 5th Edition","values = (label, self.func.__name__, elapsed, self.alltime)",simpleTuple,1299 "Learning Python, 5th Edition","values = (label, func.__name__, elapsed, onCall.alltime)",simpleTuple,1345 "Learning Python, 5th Edition","rangetest(X=(1, 10))",simpleTuple,1352 "Learning Python, 5th Edition","values = (label, func.__name__, elapsed, onCall.alltime)",simpleTuple,1400 "Learning Python, 5th Edition","L.config(font=('arial', fontsize, 'italic'))",simpleTuple,1502 "Learning Python, 5th Edition","font=('arial', fontsize, 'italic')",simpleTuple,1502 "Learning Python, 5th Edition","Button(win, text='press', command=(lambda: reply('red'))).pack(side=BOTTOM, fill=X)",simpleTuple,1502 "Learning Python, 5th Edition","font=('courier', self.fontsize, 'bold italic'))",simpleTuple,1502 "Learning Python, 5th Edition","userinfo = (user, getpass('Pswd?'))",simpleTuple,1506 "Learning Python, 5th Edition","L = [1, 2]",simpleList,88 "Learning Python, 5th Edition","L = [123, 'spam', 1.23]",simpleList,109 "Learning Python, 5th Edition","M = ['bb', 'aa', 'cc']",simpleList,110 "Learning Python, 5th Edition","M = [[1, 2, 3]",simpleList,111 "Learning Python, 5th Edition",doubles = [c * 2 for c in 'spam'],simpleList,112 "Learning Python, 5th Edition",squares = [],simpleList,120 "Learning Python, 5th Edition",L = [None],simpleList,128 "Learning Python, 5th Edition","suits = ['hearts', 'clubs', 'diamonds', 'spades']",simpleList,157 "Learning Python, 5th Edition","L = [1, 2, 1, 3, 2, 4, 5]",simpleList,169 "Learning Python, 5th Edition","L1, L2 = [1, 3, 5, 2, 4], [2, 5, 3, 4, 1]",simpleList,170 "Learning Python, 5th Edition","x = [1, 2, 3]",simpleList,179 "Learning Python, 5th Edition","L1 = [2, 3, 4]",simpleList,182 "Learning Python, 5th Edition","L1 = [2, 3, 4]",simpleList,182 "Learning Python, 5th Edition","L1 = [2, 3, 4]",simpleList,183 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,184 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,184 "Learning Python, 5th Edition","M = [1, 2, 3]",simpleList,184 "Learning Python, 5th Edition","A = [""spam""]",simpleList,186 "Learning Python, 5th Edition","A = [""spam""]",simpleList,186 "Learning Python, 5th Edition","motto}, {0} and {food}'.format(42, motto=3.14, food=[1, 2]",simpleList,223 "Learning Python, 5th Edition","X = '{motto}, {0} and {food}'.format(42, motto=3.14, food=[1, 2]",simpleList,223 "Learning Python, 5th Edition","first=S, last=M, middle=['P', 'A']",simpleList,224 "Learning Python, 5th Edition","first=S, last=M, middle=['P', 'A']",simpleList,228 "Learning Python, 5th Edition",L = [],simpleList,240 "Learning Python, 5th Edition",L[i:j] = [],simpleList,241 "Learning Python, 5th Edition","L[i:j] = [4,5,6]",simpleList,241 "Learning Python, 5th Edition",res = [c * 4 for c in 'SPAM'],simpleList,243 "Learning Python, 5th Edition",res = [],simpleList,243 "Learning Python, 5th Edition","L = ['spam', 'Spam', 'SPAM!']",simpleList,243 "Learning Python, 5th Edition","matrix = [[1, 2, 3]",simpleList,244 "Learning Python, 5th Edition","L = ['spam', 'Spam', 'SPAM!']",simpleList,244 "Learning Python, 5th Edition","L[0:2] = ['eat', 'more']",simpleList,244 "Learning Python, 5th Edition","or more items, an assignment L[1:2]=[4,5]",simpleList,245 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,245 "Learning Python, 5th Edition","L[1:2] = [4, 5]",simpleList,245 "Learning Python, 5th Edition","L[1:1] = [6, 7]",simpleList,245 "Learning Python, 5th Edition",L[1:2] = [],simpleList,245 "Learning Python, 5th Edition",L = [1],simpleList,246 "Learning Python, 5th Edition","L[:0] = [2, 3, 4]",simpleList,246 "Learning Python, 5th Edition","L[len(L):] = [5, 6, 7]",simpleList,246 "Learning Python, 5th Edition","L = ['eat', 'more', 'SPAM!']",simpleList,246 "Learning Python, 5th Edition",can also mimic append with the clever slice assignments of the prior section: L[len(L):]=[X],simpleList,246 "Learning Python, 5th Edition","L.append(X), and L[:0]=[X]",simpleList,246 "Learning Python, 5th Edition","L = ['abc', 'ABD', 'aBe']",simpleList,247 "Learning Python, 5th Edition","L = ['abc', 'ABD', 'aBe']",simpleList,247 "Learning Python, 5th Edition","L = ['abc', 'ABD', 'aBe']",simpleList,247 "Learning Python, 5th Edition","L = ['abc', 'ABD', 'aBe']",simpleList,248 "Learning Python, 5th Edition","L = ['abc', 'ABD', 'aBe']",simpleList,248 "Learning Python, 5th Edition","L = [1, 2]",simpleList,248 "Learning Python, 5th Edition",L = [],simpleList,249 "Learning Python, 5th Edition","L = ['spam', 'eggs', 'ham']",simpleList,249 "Learning Python, 5th Edition","L = ['spam', 'eggs', 'ham', 'toast']",simpleList,249 "Learning Python, 5th Edition",L # Same as L[1:] = [],simpleList,249 "Learning Python, 5th Edition",delete a section of a list by assigning an empty list to a slice (L[i:j]=[],simpleList,249 "Learning Python, 5th Edition","L = ['Already', 'got', 'one']",simpleList,250 "Learning Python, 5th Edition",L[1:] = [],simpleList,250 "Learning Python, 5th Edition",L[0] = [],simpleList,250 "Learning Python, 5th Edition","D['ham'] = ['grill', 'bake', 'fry']",simpleList,254 "Learning Python, 5th Edition","L = ['aa', 'bb', 'cc', 'dd']",simpleList,255 "Learning Python, 5th Edition",L = [],simpleList,259 "Learning Python, 5th Edition",db = [],simpleList,261 "Learning Python, 5th Edition","D = dict(name='Bob', age=40.5, jobs=['dev', 'mgr']",simpleList,263 "Learning Python, 5th Edition","bob = dict(name='Bob', age=40.5, jobs=['dev', 'mgr']",simpleList,280 "Learning Python, 5th Edition","bob = Rec('Bob', age=40.5, jobs=['dev', 'mgr']",simpleList,281 "Learning Python, 5th Edition","Rec(name='Bob', age=40.5, jobs=['dev', 'mgr']",simpleList,281 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,288 "Learning Python, 5th Edition","rec = dict(name=name, job=['dev', 'mgr']",simpleList,291 "Learning Python, 5th Edition","X = [1, 2, 3]",simpleList,298 "Learning Python, 5th Edition","L = ['a', X, 'b']",simpleList,298 "Learning Python, 5th Edition","L = [1,2,3]",simpleList,299 "Learning Python, 5th Edition","X = [1, 2, 3]",simpleList,300 "Learning Python, 5th Edition","L1 = [1, ('a', 3)]",simpleList,300 "Learning Python, 5th Edition","L2 = [1, ('a', 3)]",simpleList,300 "Learning Python, 5th Edition","L1 = [1, ('a', 3)]",simpleList,301 "Learning Python, 5th Edition","L2 = [1, ('a', 2)]",simpleList,301 "Learning Python, 5th Edition",L = [None],simpleList,305 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,308 "Learning Python, 5th Edition","M = ['X', L, 'Y']",simpleList,308 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,309 "Learning Python, 5th Edition","L = [4, 5, 6]",simpleList,309 "Learning Python, 5th Edition","L = [4, 5, 6]",simpleList,310 "Learning Python, 5th Edition",Y = [list(L)],simpleList,310 "Learning Python, 5th Edition","L = [4, 5, 6]",simpleList,310 "Learning Python, 5th Edition",L = ['grail'],simpleList,310 "Learning Python, 5th Edition","L = [1,2,3] + [4,5,6]",simpleList,313 "Learning Python, 5th Edition","four strings or numbers (e.g., L=[0,1,2,3]",simpleList,314 "Learning Python, 5th Edition",assigning to this slice (L[3:1]=['?'],simpleList,314 "Learning Python, 5th Edition","list to one of its offsets (e.g., L[2]=[]",simpleList,314 "Learning Python, 5th Edition",to a slice (L[2:3]=[],simpleList,314 "Learning Python, 5th Edition",staticData = [],simpleList,321 "Learning Python, 5th Edition","spam, ham] = ['yum', 'YUM']",simpleList,340 "Learning Python, 5th Edition","C, D] = [nudge, wink]",simpleList,341 "Learning Python, 5th Edition","L = [1, 2, 3, 4]",simpleList,344 "Learning Python, 5th Edition","seq = [1, 2, 3, 4]",simpleList,345 "Learning Python, 5th Edition","L = [1, 2, 3, 4]",simpleList,346 "Learning Python, 5th Edition","seq = [1, 2, 3, 4]",simpleList,346 "Learning Python, 5th Edition",a = b = [],simpleList,349 "Learning Python, 5th Edition",a = [],simpleList,349 "Learning Python, 5th Edition",b = [],simpleList,349 "Learning Python, 5th Edition","a, b = [], []",simpleList,349 "Learning Python, 5th Edition","L = [1, 2]",simpleList,351 "Learning Python, 5th Edition","L += [9, 10] # Mapped to L.extend([9, 10]",simpleList,351 "Learning Python, 5th Edition",L = [],simpleList,351 "Learning Python, 5th Edition","2. As suggested in Chapter 6, we can also use slice assignment (e.g., L[len(L):] = [11,12,13]",simpleList,351 "Learning Python, 5th Edition","L = [1, 2]",simpleList,352 "Learning Python, 5th Edition","L = [1, 2]",simpleList,352 "Learning Python, 5th Edition","x = [1, 2, 3]",simpleList,355 "Learning Python, 5th Edition","L = [1, 2]",simpleList,357 "Learning Python, 5th Edition",z = ['eggs'],simpleList,360 "Learning Python, 5th Edition",A = B = C = [],simpleList,370 "Learning Python, 5th Edition","A = [Z, Y][bool(X)]",simpleList,383 "Learning Python, 5th Edition","T = [(1, 2), (3, 4), (5, 6)]",simpleList,397 "Learning Python, 5th Edition","items = [""aaa"", 111, (4, 5), 2.01]",simpleList,399 "Learning Python, 5th Edition","tests = [(4, 5), 3.14]",simpleList,399 "Learning Python, 5th Edition",res = [],simpleList,400 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,405 "Learning Python, 5th Edition","L = [1, 2, 3, 4, 5]",simpleList,406 "Learning Python, 5th Edition","L = [1, 2, 3, 4, 5]",simpleList,406 "Learning Python, 5th Edition","L1 = [1,2,3,4]",simpleList,407 "Learning Python, 5th Edition","L2 = [5,6,7,8]",simpleList,407 "Learning Python, 5th Edition",res = [],simpleList,409 "Learning Python, 5th Edition","keys = ['spam', 'eggs', 'toast']",simpleList,410 "Learning Python, 5th Edition","vals = [1, 3, 5]",simpleList,410 "Learning Python, 5th Edition","keys = ['spam', 'eggs', 'toast']",simpleList,410 "Learning Python, 5th Edition","vals = [1, 3, 5]",simpleList,410 "Learning Python, 5th Edition",col7 = [],simpleList,413 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,420 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,421 "Learning Python, 5th Edition","L = [1, 2, 3]",simpleList,421 "Learning Python, 5th Edition","L = [1, 2, 3, 4, 5]",simpleList,424 "Learning Python, 5th Edition",res = [],simpleList,425 "Learning Python, 5th Edition",res = [],simpleList,428 "Learning Python, 5th Edition",res = [],simpleList,429 "Learning Python, 5th Edition","L = [11, 22, 33, 44]",simpleList,431 "Learning Python, 5th Edition",L = [11],simpleList,431 "Learning Python, 5th Edition",L = [11],simpleList,432 "Learning Python, 5th Edition",to be careful about using mutables in a multiple-target assignment (a = b = [],simpleList,464 "Learning Python, 5th Edition","as well as in an augmented assignment (a += [1, 2]",simpleList,464 "Learning Python, 5th Edition","L = [1, 2, 4, 8, 16, 32, 64]",simpleList,467 "Learning Python, 5th Edition","funcs = [lambda x: x**2, lambda x: x**3]",simpleList,474 "Learning Python, 5th Edition",res = [],simpleList,481 "Learning Python, 5th Edition",acts = [],simpleList,506 "Learning Python, 5th Edition",acts = [],simpleList,507 "Learning Python, 5th Edition","mutable objects like lists and dictionaries for default arguments (e.g., def f(a=[]",simpleList,507 "Learning Python, 5th Edition",state = [start],simpleList,517 "Learning Python, 5th Edition","L = [1, 2]",simpleList,525 "Learning Python, 5th Edition","L = [1, 2]",simpleList,525 "Learning Python, 5th Edition","L = [1, 2]",simpleList,526 "Learning Python, 5th Edition","L = [1, 2]",simpleList,527 "Learning Python, 5th Edition","y = [3, 4]",simpleList,527 "Learning Python, 5th Edition","L = [1, 2]",simpleList,527 "Learning Python, 5th Edition","a default to be a mutable object (e.g., def f(a=[]",simpleList,534 "Learning Python, 5th Edition",res = [],simpleList,545 "Learning Python, 5th Edition",res = [],simpleList,545 "Learning Python, 5th Edition","L = [1, 2, 3, 4, 5]",simpleList,557 "Learning Python, 5th Edition","L = [1, 2, 3, 4, 5]",simpleList,558 "Learning Python, 5th Edition","schedule = [ (echo, 'Spam!'), (echo, 'Ham!') ]",simpleList,563 "Learning Python, 5th Edition","L = [f1, f2, f3]",simpleList,570 "Learning Python, 5th Edition","counters = [1, 2, 3, 4]",simpleList,574 "Learning Python, 5th Edition",updated = [],simpleList,574 "Learning Python, 5th Edition",res = [],simpleList,575 "Learning Python, 5th Edition",res = [],simpleList,576 "Learning Python, 5th Edition","L = [1,2,3,4]",simpleList,577 "Learning Python, 5th Edition",res = [],simpleList,582 "Learning Python, 5th Edition",res = [ord(x) for x in 'spam'],simpleList,582 "Learning Python, 5th Edition",res = [],simpleList,583 "Learning Python, 5th Edition",res = [],simpleList,584 "Learning Python, 5th Edition",res = [],simpleList,585 "Learning Python, 5th Edition","M = [[1, 2, 3]",simpleList,586 "Learning Python, 5th Edition","N = [[2, 2, 2]",simpleList,586 "Learning Python, 5th Edition",res = [],simpleList,587 "Learning Python, 5th Edition",res = [],simpleList,587 "Learning Python, 5th Edition",tmp = [],simpleList,587 "Learning Python, 5th Edition",res = [],simpleList,588 "Learning Python, 5th Edition",tmp = [],simpleList,588 "Learning Python, 5th Edition",res = [],simpleList,588 "Learning Python, 5th Edition",tmp = [],simpleList,588 "Learning Python, 5th Edition","listoftuple = [('bob', 35, 'mgr'), ('sue', 40, 'dev')]",simpleList,590 "Learning Python, 5th Edition",res = [],simpleList,595 "Learning Python, 5th Edition","L = [1, 2, 3, 4]",simpleList,605 "Learning Python, 5th Edition","L, S = [1, 2, 3]",simpleList,609 "Learning Python, 5th Edition",res = [],simpleList,610 "Learning Python, 5th Edition",res = [],simpleList,613 "Learning Python, 5th Edition",res = [],simpleList,617 "Learning Python, 5th Edition",res = [],simpleList,618 "Learning Python, 5th Edition",res = [],simpleList,619 "Learning Python, 5th Edition",res = [],simpleList,634 "Learning Python, 5th Edition",res = [],simpleList,637 "Learning Python, 5th Edition","c:\code> py −3 -m timeit -n 1000 -r 3 ""L = [1,2,3,4,5]",simpleList,646 "Learning Python, 5th Edition","0, 0, ""res=[]",simpleList,649 "Learning Python, 5th Edition",0.5655 ['res=[]\nfor x in range(1000): res.append(x ** 2)'],simpleList,649 "Learning Python, 5th Edition",0.1285 ['res=[]\nfor x in range(1000): res.append(x ** 2)'],simpleList,649 "Learning Python, 5th Edition",0.0102 ['res=[]\nfor x in range(1000): res.append(x ** 2)'],simpleList,649 "Learning Python, 5th Edition",res=[]\nfor x in range(1000): res.append(x ** 2)'],simpleList,650 "Learning Python, 5th Edition","0, 0, ""res=[]",simpleList,652 "Learning Python, 5th Edition","1.3471 [""res=[]\nfor x in 'spam' * 2500: res.append(ord(x))""]",simpleList,652 "Learning Python, 5th Edition","stmts = [ (0, 0, ""def f(x): return x\n[f(x) for x in 'spam' * 2500]",simpleList,653 "Learning Python, 5th Edition","0, 0, ""def f(x): return x\nres=[]",simpleList,653 "Learning Python, 5th Edition","2.0506 [""def f(x): return x\nres=[]\nfor x in 'spam' * 2500: res.append(f(x))""]",simpleList,653 "Learning Python, 5th Edition",0.5657 ['res=[]\nfor x in range(1000): res.append(x ** 2)'],simpleList,654 "Learning Python, 5th Edition","0, 0, """", ""res=[]",simpleList,655 "Learning Python, 5th Edition",res=[],simpleList,655 "Learning Python, 5th Edition",res=[],simpleList,655 "Learning Python, 5th Edition","C:\python33\python -m timeit -n 1000 -r 5 -s ""def f(x):"" -s "" return x"" ""res=[]",simpleList,655 "Learning Python, 5th Edition",x = [],simpleList,659 "Learning Python, 5th Edition",saver.x = [],simpleList,660 "Learning Python, 5th Edition","list = [1, 2, 3]",simpleList,660 "Learning Python, 5th Edition","y = [1, 2]",simpleList,691 "Learning Python, 5th Edition","__all__ = ['a', '_c']",simpleList,747 "Learning Python, 5th Edition",sys.path = [r'd:\temp'],simpleList,757 "Learning Python, 5th Edition","company = [bob, sue, tom]",simpleList,793 "Learning Python, 5th Edition","rec['jobs'] = ['dev', 'mgr']",simpleList,812 "Learning Python, 5th Edition","rec.jobs = ['dev', 'mgr']",simpleList,812 "Learning Python, 5th Edition","pers1.jobs = ['dev', 'mgr']",simpleList,813 "Learning Python, 5th Edition","pers2.jobs = ['dev', 'cto']",simpleList,813 "Learning Python, 5th Edition","rec = dict(name='Bob', age=40.5, jobs=['dev', 'mgr']",simpleList,814 "Learning Python, 5th Edition",attrs = [],simpleList,842 "Learning Python, 5th Edition","L = [5, 6, 7, 8, 9]",simpleList,891 "Learning Python, 5th Edition","data = [5, 6, 7, 8, 9]",simpleList,892 "Learning Python, 5th Edition",privates = ['age'],simpleList,912 "Learning Python, 5th Edition","privates = ['name', 'pay']",simpleList,912 "Learning Python, 5th Edition","objs = [Printer(2), Printer(3)]",simpleList,916 "Learning Python, 5th Edition","objs = [Printer(2), Printer(3)]",simpleList,916 "Learning Python, 5th Edition",y += [2],simpleList,921 "Learning Python, 5th Edition",y += [3],simpleList,921 "Learning Python, 5th Edition","acts = [x.double, y.double, y.triple, z.double]",simpleList,951 "Learning Python, 5th Edition","actions = [square, sobject, pobject.method]",simpleList,952 "Learning Python, 5th Edition","actions = [square, sobject, pobject.method, Negate]",simpleList,953 "Learning Python, 5th Edition",_tclCommands=[],simpleList,974 "Learning Python, 5th Edition",res = [],simpleList,980 "Learning Python, 5th Edition",res = [],simpleList,982 "Learning Python, 5th Edition",here = [cls],simpleList,1005 "Learning Python, 5th Edition",class C: __slots__ = ['a'],simpleList,1017 "Learning Python, 5th Edition",class C: __slots__ = ['a'],simpleList,1017 "Learning Python, 5th Edition",class C: __slots__ = ['a'],simpleList,1017 "Learning Python, 5th Edition",class C: __slots__ = ['a'],simpleList,1017 "Learning Python, 5th Edition",class A: __slots__ = ['a'],simpleList,1018 "Learning Python, 5th Edition",class A: __slots__ = ['a'],simpleList,1018 "Learning Python, 5th Edition","class B(A, ListTree): __slots__ = ['b']",simpleList,1018 "Learning Python, 5th Edition",class C: __slots__ = ['a'],simpleList,1018 "Learning Python, 5th Edition",Is = [],simpleList,1019 "Learning Python, 5th Edition",shared = [],simpleList,1066 "Learning Python, 5th Edition","excs = [IndexError, TypeError]",simpleList,1107 "Learning Python, 5th Edition","X.data = [1, 1, 1]",simpleList,1316 "Learning Python, 5th Edition","builtins = ['add', 'str', 'getitem', 'call']",simpleList,1326 "Learning Python, 5th Edition","B.data = [1, 2, 3]",simpleList,1391 "Learning Python, 5th Edition",tags = ['<i>%s</i>' % htmlescape(line) if line[:1],simpleList,1416 "Learning Python, 5th Edition","L = [1, 2]",simpleList,1466 "Learning Python, 5th Edition","L = [1,2,3] + [4,5,6]",simpleList,1468 "Learning Python, 5th Edition","L = [1, 2, 3, 4]",simpleList,1469 "Learning Python, 5th Edition",L[3:1] = ['?'],simpleList,1469 "Learning Python, 5th Edition","L = [1,2,3,4]",simpleList,1470 "Learning Python, 5th Edition",L[2] = [],simpleList,1470 "Learning Python, 5th Edition",L[2:3] = [],simpleList,1470 "Learning Python, 5th Edition","L = [0, 1]",simpleList,1471 "Learning Python, 5th Edition","L = ['s', 'p']",simpleList,1472 "Learning Python, 5th Edition",x = [],simpleList,1473 "Learning Python, 5th Edition","L = [1, 2, 4, 8, 16, 32, 64]",simpleList,1474 "Learning Python, 5th Edition","L = [1, 2, 4, 8, 16, 32, 64]",simpleList,1475 "Learning Python, 5th Edition",L = [],simpleList,1475 "Learning Python, 5th Edition","values = [2, 4, 9, 16, 25]",simpleList,1480 "Learning Python, 5th Edition",res = [],simpleList,1480 "Learning Python, 5th Edition",res = [],simpleList,1494 "Learning Python, 5th Edition",res = [],simpleList,1494 "Learning Python, 5th Edition",names = [],simpleList,1495 "Learning Python, 5th Edition",allsizes = [],simpleList,1499 "Learning Python, 5th Edition",allsizes = [],simpleList,1500 "Learning Python, 5th Edition",allsizes = [],simpleList,1500 "Learning Python, 5th Edition",totals = [0],simpleList,1501 "Learning Python, 5th Edition","totals = [(x + y) for (x, y) in zip(totals, nums)]",simpleList,1501 "Learning Python, 5th Edition","colors = ['red', 'green', 'blue', 'yellow', 'orange', 'white', 'cyan', 'purple']",simpleList,1501 "Learning Python, 5th Edition","colors = ['blue', 'green', 'orange', 'red', 'brown', 'yellow']",simpleList,1502 "Learning Python, 5th Edition","colors = ['black', 'purple']",simpleList,1503 "Learning Python, 5th Edition",for key in Ks:,forsimple,118 "Learning Python, 5th Edition",for key in sorted(D):,forsimple,119 "Learning Python, 5th Edition","for integers, use float to guarantee that one operand is a float around a / when run in 2.X:",forsimple,148 "Learning Python, 5th Edition",for item in set('abc'):,forsimple,165 "Learning Python, 5th Edition",for equality in a Python program. Let’s create a shared reference to demonstrate:,forsimple,183 "Learning Python, 5th Edition",for x in S:,forsimple,192 "Learning Python, 5th Edition",for c in myjob:,forsimple,201 "Learning Python, 5th Edition",for use in other roles:,forsimple,218 "Learning Python, 5th Edition",for x in L:,forsimple,241 "Learning Python, 5th Edition","for the result. Index assignment in Python works much as it does in C and most other languages:",forsimple,245 "Learning Python, 5th Edition",for year in table: # Same as:,forsimple,257 "Learning Python, 5th Edition",for more in this chapter’s sidebar “Why You Will Care:,forsimple,262 "Learning Python, 5th Edition",for k in D.keys():,forsimple,267 "Learning Python, 5th Edition",for key in D:,forsimple,267 "Learning Python, 5th Edition","for k in Ks: print(k, D[k]) # 2.X:",forsimple,269 "Learning Python, 5th Edition",for k in sorted(Ks):,forsimple,269 "Learning Python, 5th Edition",for k in sorted(D):,forsimple,270 "Learning Python, 5th Edition",for x in T:,forsimple,277 "Learning Python, 5th Edition",for x in bob:,forsimple,282 "Learning Python, 5th Edition",for x in bob:,forsimple,282 "Learning Python, 5th Edition",for x in bob.values():,forsimple,282 "Learning Python, 5th Edition",for row in rdr:,forsimple,293 "Learning Python, 5th Edition",for line in myfile:,forsimple,294 "Learning Python, 5th Edition",for x in mylist:,forsimple,320 "Learning Python, 5th Edition",for continuation lines when the prior line ends in a backslash:,forsimple,328 "Learning Python, 5th Edition",for this example is in interact.py in the book’s examples package:,forsimple,330 "Learning Python, 5th Edition","for example, any number of objects may be listed in the call’s parentheses:",forsimple,367 "Learning Python, 5th Edition",for related discussion in operator overloading in Part VI:,forsimple,385 "Learning Python, 5th Edition","for code to be filled in later—a sort of Python “TBD”:",forsimple,390 "Learning Python, 5th Edition",for x in obj:,forsimple,394 "Learning Python, 5th Edition",for loop is a generic iterator in Python:,forsimple,395 "Learning Python, 5th Edition",for target in object:,forsimple,395 "Learning Python, 5th Edition",for target in object:,forsimple,395 "Learning Python, 5th Edition",for x in S:,forsimple,396 "Learning Python, 5th Edition",for x in T:,forsimple,396 "Learning Python, 5th Edition",for key in D:,forsimple,397 "Learning Python, 5th Edition",for both in T:,forsimple,397 "Learning Python, 5th Edition","for each key in the objects list and reports on the search’s outcome:",forsimple,399 "Learning Python, 5th Edition",for key in tests:,forsimple,399 "Learning Python, 5th Edition",for item in items:,forsimple,399 "Learning Python, 5th Edition",for key in tests:,forsimple,400 "Learning Python, 5th Edition",for x in seq1:,forsimple,400 "Learning Python, 5th Edition",for i in range(3):,forsimple,403 "Learning Python, 5th Edition",for item in X:,forsimple,403 "Learning Python, 5th Edition",for i in range(len(X)):,forsimple,404 "Learning Python, 5th Edition","for loop form in Python:",forsimple,404 "Learning Python, 5th Edition",for item in X:,forsimple,404 "Learning Python, 5th Edition","for slicing in the second:",forsimple,405 "Learning Python, 5th Edition",for i in range(len(S)):,forsimple,405 "Learning Python, 5th Edition",for i in range(len(S)):,forsimple,405 "Learning Python, 5th Edition",for i in range(len(L)):,forsimple,405 "Learning Python, 5th Edition","for i in range(0, len(S), 2):",forsimple,405 "Learning Python, 5th Edition",for c in S[::2]:,forsimple,406 "Learning Python, 5th Edition",for x in L:,forsimple,406 "Learning Python, 5th Edition",for i in range(len(L)):,forsimple,406 "Learning Python, 5th Edition",for x in L:,forsimple,407 "Learning Python, 5th Edition",for item in S:,forsimple,410 "Learning Python, 5th Edition",for item in col7:,forsimple,413 "Learning Python, 5th Edition","for loop can work on any sequence type in Python, including lists, tuples, and strings, like this:",forsimple,416 "Learning Python, 5th Edition",for X in L:,forsimple,421 "Learning Python, 5th Edition",for key in D.keys():,forsimple,422 "Learning Python, 5th Edition",for key in D:,forsimple,423 "Learning Python, 5th Edition",for i in range(len(L)):,forsimple,424 "Learning Python, 5th Edition",for x in L:,forsimple,425 "Learning Python, 5th Edition",for the last line in a file):,forsimple,426 "Learning Python, 5th Edition",for every line in the file:,forsimple,426 "Learning Python, 5th Edition",for tips on using the following’s 3.X print in 2.X as usual):,forsimple,433 "Learning Python, 5th Edition",for i in M:,forsimple,435 "Learning Python, 5th Edition",for i in M:,forsimple,435 "Learning Python, 5th Edition",for x in M: print(x) # map iterator is now empty:,forsimple,436 "Learning Python, 5th Edition",for x in M:,forsimple,436 "Learning Python, 5th Edition",for pair in Z:,forsimple,437 "Learning Python, 5th Edition",for pair in Z:,forsimple,437 "Learning Python, 5th Edition",for k in D.keys():,forsimple,439 "Learning Python, 5th Edition",for key in D:,forsimple,440 "Learning Python, 5th Edition",for k in sorted(D.keys()):,forsimple,440 "Learning Python, 5th Edition",for k in sorted(D):,forsimple,440 "Learning Python, 5th Edition","for help on an actual string object directly (e.g., help('')) doesn’t work in recent Pythons:",forsimple,451 "Learning Python, 5th Edition","for loop (e.g., for x in seq:",forsimple,464 "Learning Python, 5th Edition",for k in D.keys().sort():,forsimple,464 "Learning Python, 5th Edition",for k in Ks:,forsimple,464 "Learning Python, 5th Edition",for c in S]? Why? (Hint:,forsimple,467 "Learning Python, 5th Edition",for i in range(50):,forsimple,467 "Learning Python, 5th Edition",for x in seq1:,forsimple,481 "Learning Python, 5th Edition","for it in this order:",forsimple,489 "Learning Python, 5th Edition",for a custom open in the sidebar “Why You Will Care:,forsimple,494 "Learning Python, 5th Edition",for i in range(5):,forsimple,506 "Learning Python, 5th Edition",for i in range(5):,forsimple,507 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,543 "Learning Python, 5th Edition",for arg in rest:,forsimple,543 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,544 "Learning Python, 5th Edition",for x in args[0]:,forsimple,545 "Learning Python, 5th Edition",for other in args[1:]:,forsimple,545 "Learning Python, 5th Edition",for seq in args:,forsimple,545 "Learning Python, 5th Edition",for x in seq:,forsimple,545 "Learning Python, 5th Edition",for i in range(len(items)):,forsimple,546 "Learning Python, 5th Edition",for args in scramble(items):,forsimple,547 "Learning Python, 5th Edition",for arg in args:,forsimple,548 "Learning Python, 5th Edition",for arg in args:,forsimple,549 "Learning Python, 5th Edition",for arg in args:,forsimple,549 "Learning Python, 5th Edition","for arg in pargs:",forsimple,552 "Learning Python, 5th Edition",for key in kargs:,forsimple,552 "Learning Python, 5th Edition",for x in L:,forsimple,558 "Learning Python, 5th Edition","for repeats as it goes. We will use this scheme in later recursive examples in this book:",forsimple,560 "Learning Python, 5th Edition",for arg in func.__annotations__:,forsimple,566 "Learning Python, 5th Edition",for f in L:,forsimple,569 "Learning Python, 5th Edition",for f in L:,forsimple,570 "Learning Python, 5th Edition",for x in counters:,forsimple,574 "Learning Python, 5th Edition",for x in seq:,forsimple,575 "Learning Python, 5th Edition","for x in range(−5, 5):",forsimple,576 "Learning Python, 5th Edition",for x in L[1:]:,forsimple,577 "Learning Python, 5th Edition",for next in sequence[1:]:,forsimple,577 "Learning Python, 5th Edition",for x in range(5):,forsimple,583 "Learning Python, 5th Edition",for x in range(5):,forsimple,585 "Learning Python, 5th Edition",for row in M:,forsimple,587 "Learning Python, 5th Edition",for col in row:,forsimple,587 "Learning Python, 5th Edition",for row in M:,forsimple,587 "Learning Python, 5th Edition",for col in row:,forsimple,587 "Learning Python, 5th Edition",for row in range(3):,forsimple,588 "Learning Python, 5th Edition",for col in range(3):,forsimple,588 "Learning Python, 5th Edition",for i in range(N):,forsimple,593 "Learning Python, 5th Edition",for i in gensquares(5):,forsimple,593 "Learning Python, 5th Edition","for us in 3.X (and X.next() in 2.X):",forsimple,594 "Learning Python, 5th Edition",for i in range(n):,forsimple,595 "Learning Python, 5th Edition","for x in buildsquares(5): print(x, end=' :",forsimple,595 "Learning Python, 5th Edition","for x in map((lambda n: n ** 2), range(5)):",forsimple,595 "Learning Python, 5th Edition","for sub in line.split(','):",forsimple,596 "Learning Python, 5th Edition",for i in range(10):,forsimple,596 "Learning Python, 5th Edition",for x in range(4)] # List comprehension:,forsimple,597 "Learning Python, 5th Edition",for x in range(4)) # Generator expression:,forsimple,597 "Learning Python, 5th Edition",for x in line.split():,forsimple,602 "Learning Python, 5th Edition","for example, repeats each character in a string four times:",forsimple,602 "Learning Python, 5th Edition",for c in S:,forsimple,603 "Learning Python, 5th Edition",for x in line.split():,forsimple,603 "Learning Python, 5th Edition",for c in S:,forsimple,604 "Learning Python, 5th Edition",for key in D:,forsimple,606 "Learning Python, 5th Edition",for name in files:,forsimple,607 "Learning Python, 5th Edition",for i in range(len(S)):,forsimple,609 "Learning Python, 5th Edition",for i in range(len(L)):,forsimple,610 "Learning Python, 5th Edition",for i in range(len(S)):,forsimple,610 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,610 "Learning Python, 5th Edition","for x in scramble((1, 2, 3)):",forsimple,610 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,610 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,611 "Learning Python, 5th Edition","for x in scramble((1, 2, 3)):",forsimple,611 "Learning Python, 5th Edition","for x in F((1, 2, 3)):",forsimple,611 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,612 "Learning Python, 5th Edition",for args in scramble(items): # Use generator (or:,forsimple,612 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,613 "Learning Python, 5th Edition",for x in permute1(rest):,forsimple,613 "Learning Python, 5th Edition",for i in range(len(seq)):,forsimple,613 "Learning Python, 5th Edition",for x in permute2(rest):,forsimple,613 "Learning Python, 5th Edition",for x in permute2('abc'):,forsimple,613 "Learning Python, 5th Edition",for args in zip(*seqs):,forsimple,617 "Learning Python, 5th Edition",for args in zip(*seqs):,forsimple,618 "Learning Python, 5th Edition",for x in range(10)] # List comprehension:,forsimple,622 "Learning Python, 5th Edition",for x in range(10)) # Generator expression:,forsimple,623 "Learning Python, 5th Edition",for X in range(5)] # 3.X:,forsimple,623 "Learning Python, 5th Edition",for Y in range(5):,forsimple,623 "Learning Python, 5th Edition",for X in range(5)] # 2.X:,forsimple,624 "Learning Python, 5th Edition",for Y in range(5):,forsimple,624 "Learning Python, 5th Edition",for x in range(10):,forsimple,624 "Learning Python, 5th Edition",for x in range(10):,forsimple,625 "Learning Python, 5th Edition",for i in range(1000):,forsimple,630 "Learning Python, 5th Edition",for i in repslist:,forsimple,631 "Learning Python, 5th Edition",for i in range(reps):,forsimple,631 "Learning Python, 5th Edition",for x in repslist:,forsimple,634 "Learning Python, 5th Edition",for x in repslist:,forsimple,634 "Learning Python, 5th Edition",for x in repslist:,forsimple,637 "Learning Python, 5th Edition",for x in repslist:,forsimple,637 "Learning Python, 5th Edition",for i in repslist:,forsimple,639 "Learning Python, 5th Edition",for i in range(_reps):,forsimple,639 "Learning Python, 5th Edition",for i in range(_reps):,forsimple,641 "Learning Python, 5th Edition",for i in range(_reps):,forsimple,641 "Learning Python, 5th Edition",for variety in the first two of these commands):,forsimple,643 "Learning Python, 5th Edition",for i in range(10000):,forsimple,649 "Learning Python, 5th Edition",for i in range(10000):,forsimple,649 "Learning Python, 5th Edition",for i in range(10000):,forsimple,649 "Learning Python, 5th Edition",for i in range(10000):,forsimple,650 "Learning Python, 5th Edition",for i in range(10000):,forsimple,651 "Learning Python, 5th Edition",for line in f:,forsimple,653 "Learning Python, 5th Edition",for i in range(10000):,forsimple,654 "Learning Python, 5th Edition",for x in range(1000):,forsimple,655 "Learning Python, 5th Edition",for __all__ in Chapter 25:,forsimple,711 "Learning Python, 5th Edition",for program mode only in 3.X:,forsimple,729 "Learning Python, 5th Edition",for variety use the 3.3 Windows launcher covered in Appendix B):,forsimple,730 "Learning Python, 5th Edition","for space; see the file dualpkg\results.txt in the book’s examples for the full listing):",forsimple,732 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,750 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,750 "Learning Python, 5th Edition",for test in tests:,forsimple,752 "Learning Python, 5th Edition",for test in tests:,forsimple,752 "Learning Python, 5th Edition","for longer names, and to avoid name clashes when you are already using a name in your script that would otherwise be overwritten by a normal import statement:",forsimple,758 "Learning Python, 5th Edition","for arg in args: # For all passed in if type(arg) == types.ModuleType:",forsimple,764 "Learning Python, 5th Edition",for obj in objects:,forsimple,767 "Learning Python, 5th Edition",for emp in company:,forsimple,793 "Learning Python, 5th Edition","for pay because according to Python’s syntax rules and Chapter 18, any arguments in a function’s header after the first default must all have defaults, too:",forsimple,819 "Learning Python, 5th Edition","for easier changes in the future, not altered its behavior:",forsimple,825 "Learning Python, 5th Edition",for person in self.members:,forsimple,838 "Learning Python, 5th Edition",for person in self.members:,forsimple,838 "Learning Python, 5th Edition",for key in db:,forsimple,851 "Learning Python, 5th Edition",for key in sorted(db):,forsimple,851 "Learning Python, 5th Edition","for objects based on OOP’s inheritance model, even when they live in a file:",forsimple,852 "Learning Python, 5th Edition",for key in sorted(db):,forsimple,852 "Learning Python, 5th Edition",for supercls in cls.__bases__:,forsimple,880 "Learning Python, 5th Edition",for more about this difference in Chapter 32):,forsimple,883 "Learning Python, 5th Edition",for i in range(5):,forsimple,891 "Learning Python, 5th Edition",for item in X:,forsimple,895 "Learning Python, 5th Edition","for i in Squares(1, 5):",forsimple,896 "Learning Python, 5th Edition",for n in X] # Exhausts items:,forsimple,897 "Learning Python, 5th Edition",for n in X] # Now it's empty:,forsimple,897 "Learning Python, 5th Edition","for i in range(start, stop + 1):",forsimple,898 "Learning Python, 5th Edition","for i in gsquares(1, 5):",forsimple,898 "Learning Python, 5th Edition",for x in skipper:,forsimple,900 "Learning Python, 5th Edition",for y in skipper:,forsimple,900 "Learning Python, 5th Edition","for value in range(self.start, self.stop + 1):",forsimple,902 "Learning Python, 5th Edition","for i in Squares(1, 5):",forsimple,902 "Learning Python, 5th Edition","for value in range(self.start, self.stop + 1):",forsimple,903 "Learning Python, 5th Edition","for i in Squares(1, 5).gen():",forsimple,903 "Learning Python, 5th Edition",for i in S:,forsimple,904 "Learning Python, 5th Edition",for j in S:,forsimple,904 "Learning Python, 5th Edition","for i in Squares(1, 5):",forsimple,905 "Learning Python, 5th Edition",for i in S:,forsimple,905 "Learning Python, 5th Edition",for j in S:,forsimple,905 "Learning Python, 5th Edition",for x in skipper: # Each for calls __iter__:,forsimple,906 "Learning Python, 5th Edition",for y in skipper:,forsimple,906 "Learning Python, 5th Edition",for i in X:,forsimple,907 "Learning Python, 5th Edition",for x in self.data:,forsimple,908 "Learning Python, 5th Edition",for iterators (and fully covered in Part VII):,forsimple,910 "Learning Python, 5th Edition",for x in objs:,forsimple,916 "Learning Python, 5th Edition",for x in objs: print(x) # No __str__:,forsimple,916 "Learning Python, 5th Edition","for klass in Employee, Chef, Server, PizzaRobot:",forsimple,936 "Learning Python, 5th Edition",for act in acts:,forsimple,951 "Learning Python, 5th Edition",for act in actions:,forsimple,952 "Learning Python, 5th Edition",for act in actions:,forsimple,953 "Learning Python, 5th Edition",for attr in dir(self):,forsimple,964 "Learning Python, 5th Edition",for super in aClass.__bases__:,forsimple,967 "Learning Python, 5th Edition",for super in aClass.__bases__:,forsimple,968 "Learning Python, 5th Edition",for x in self.data:,forsimple,980 "Learning Python, 5th Edition",for x in other:,forsimple,980 "Learning Python, 5th Edition",for x in value:,forsimple,980 "Learning Python, 5th Edition",for x in self:,forsimple,982 "Learning Python, 5th Edition",for x in value:,forsimple,982 "Learning Python, 5th Edition","for new-style classes always used in 3.X, and available as an option in 2.X:",forsimple,1002 "Learning Python, 5th Edition",for all classic classes in 2.X):,forsimple,1003 "Learning Python, 5th Edition",for sup in cls.__bases__:,forsimple,1005 "Learning Python, 5th Edition",for i in range(1000):,forsimple,1019 "Learning Python, 5th Edition","for portability, but could leverage variables and nonlocal instead in 3.X only:",forsimple,1038 "Learning Python, 5th Edition","for either subclass in isolation, since its MRO includes just itself and its actual superclass:",forsimple,1060 "Learning Python, 5th Edition",for X.i in range(Y.a):,forsimple,1065 "Learning Python, 5th Edition",for line in myfile:,forsimple,1115 "Learning Python, 5th Edition",for line in fin:,forsimple,1118 "Learning Python, 5th Edition","for pair in zip(f1, f2):",forsimple,1118 "Learning Python, 5th Edition",for line in fin:,forsimple,1119 "Learning Python, 5th Edition",for line in fin:,forsimple,1119 "Learning Python, 5th Edition","for aStr in myStr1, myStr2, myStr3:",forsimple,1188 "Learning Python, 5th Edition","for example, is unlikely to work in 3.X even if you use the correct object types:",forsimple,1201 "Learning Python, 5th Edition",for title in found:,forsimple,1212 "Learning Python, 5th Edition",for E in tree.findall('title'):,forsimple,1213 "Learning Python, 5th Edition",for the fetch in __setattr__ (the first time originating in __init__):,forsimple,1243 "Learning Python, 5th Edition","for Class in GetAttr, GetAttribute:",forsimple,1250 "Learning Python, 5th Edition","for readers working with the book examples package, some filenames in this chapter are again implied by the command-lines that follow their listings):",forsimple,1285 "Learning Python, 5th Edition","for descriptors in Python 2.X, but not 3.X:",forsimple,1292 "Learning Python, 5th Edition","for instance, might be useful in a general-purpose tool like this. Decorator arguments come in handy here:",forsimple,1298 "Learning Python, 5th Edition","for reference, all the code in this section is in the file singletons.py):",forsimple,1302 "Learning Python, 5th Edition",for name in registry:,forsimple,1313 "Learning Python, 5th Edition",for name in registry:,forsimple,1313 "Learning Python, 5th Edition",for i in range(self.size()):,forsimple,1316 "Learning Python, 5th Edition",for attr in builtins:,forsimple,1327 "Learning Python, 5th Edition","for attr, attrval in classdict.items():",forsimple,1402 "Learning Python, 5th Edition","for attr, attrval in classdict.items():",forsimple,1403 "Learning Python, 5th Edition",for PDFs and other document tools such as Sphinx surveyed in Chapter 15. But hey:,forsimple,1416 "Learning Python, 5th Edition","for path files in C:\PythonNM and C:",forsimple,1431 "Learning Python, 5th Edition",for packages enabled in 3.0:,forsimple,1460 "Learning Python, 5th Edition",for line in file:,forsimple,1461 "Learning Python, 5th Edition",for c in S:,forsimple,1473 "Learning Python, 5th Edition",for c in S:,forsimple,1473 "Learning Python, 5th Edition",for key in D:,forsimple,1474 "Learning Python, 5th Edition",for key in keys:,forsimple,1474 "Learning Python, 5th Edition",for key in sorted(D):,forsimple,1474 "Learning Python, 5th Edition",for i in range(7):,forsimple,1475 "Learning Python, 5th Edition",for arg in args:,forsimple,1476 "Learning Python, 5th Edition",for next in args[1:]:,forsimple,1476 "Learning Python, 5th Edition",for x in args.keys():,forsimple,1477 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,1477 "Learning Python, 5th Edition",for key in argskeys[1:]:,forsimple,1477 "Learning Python, 5th Edition",for arg in args[1:]:,forsimple,1477 "Learning Python, 5th Edition",for key in old.keys():,forsimple,1478 "Learning Python, 5th Edition",for key in d1.keys():,forsimple,1478 "Learning Python, 5th Edition",for key in d2.keys():,forsimple,1478 "Learning Python, 5th Edition",for x in values:,forsimple,1480 "Learning Python, 5th Edition",for i in repslist:,forsimple,1481 "Learning Python, 5th Edition",for i in repslist:,forsimple,1481 "Learning Python, 5th Edition",for i in repslist:,forsimple,1481 "Learning Python, 5th Edition",for i in range(I):,forsimple,1482 "Learning Python, 5th Edition",for or yield from here (yield from works in 3.3 and later only):,forsimple,1483 "Learning Python, 5th Edition",for x in countdown2(N-1): yield x # 3.3+:,forsimple,1483 "Learning Python, 5th Edition","for i in range(1, N+1):",forsimple,1484 "Learning Python, 5th Edition",for k in x.keys():,forsimple,1489 "Learning Python, 5th Edition",for k in y.keys():,forsimple,1489 "Learning Python, 5th Edition",for c in z:,forsimple,1493 "Learning Python, 5th Edition",for x in self:,forsimple,1494 "Learning Python, 5th Edition",for other in others:,forsimple,1494 "Learning Python, 5th Edition",for seq in args:,forsimple,1494 "Learning Python, 5th Edition",for x in seq:,forsimple,1494 "Learning Python, 5th Edition",for filename in allpy:,forsimple,1499 "Learning Python, 5th Edition",for filename in filesHere:,forsimple,1500 "Learning Python, 5th Edition",for srcdir in sys.path:,forsimple,1500 "Learning Python, 5th Edition",for filename in filesHere:,forsimple,1500 "Learning Python, 5th Edition",for key in sorted(sums):,forsimple,1501 "Learning Python, 5th Edition",for testcase in testscripts:,forsimple,1501 "Learning Python, 5th Edition",for i in range(msgCount):,forsimple,1503 "Learning Python, 5th Edition",for line in hdrlines:,forsimple,1503 "Learning Python, 5th Edition",for line in server.retr(msgnum)[1]:,forsimple,1504 "Learning Python, 5th Edition",for key in db:,forsimple,1504 "Learning Python, 5th Edition",for row in curs.fetchall():,forsimple,1505 "Learning Python, 5th Edition",pay = decimal.Decimal(str(1999 + 1.33)),assignwithSum,159 "Learning Python, 5th Edition","Fraction(17, 6) # 5/2 + 1/3 = 15/6 + 2/6",assignwithSum,162 "Learning Python, 5th Edition",a = x + Fraction(*(4.0 / 3).as_integer_ratio()),assignwithSum,163 "Learning Python, 5th Edition",a = a + 2,assignwithSum,181 "Learning Python, 5th Edition",no effect on A. The same would be true if the last statement here were B = B +,assignwithSum,186 "Learning Python, 5th Edition",S = chr(ord(S) + 1),assignwithSum,207 "Learning Python, 5th Edition",S = chr(ord(S) + 1),assignwithSum,207 "Learning Python, 5th Edition",I = I * 2 + (ord(B[0]) - ord('0')),assignwithSum,207 "Learning Python, 5th Edition","S = S + 'SPAM!' # To change a string, make a new one",assignwithSum,208 "Learning Python, 5th Edition",S = S[:4] + 'Burger' + S[−1],assignwithSum,208 "Learning Python, 5th Edition",S = S[:3] + 'xx' + S[5:] # Slice sections from S,assignwithSum,211 "Learning Python, 5th Edition",S = S[:where] + 'EGGS' + S[(where+4):],assignwithSum,212 "Learning Python, 5th Edition","x = S.replace('+', 'spam')",assignwithSum,215 "Learning Python, 5th Edition","y = string.replace(S, '+', 'spam')",assignwithSum,216 "Learning Python, 5th Edition",D1 == D2 # Dictionary equality: 2.X + 3.X,assignwithSum,303 "Learning Python, 5th Edition","X = L * 4 # Like [4, 5, 6] + [4, 5, 6] + ...",assignwithSum,309 "Learning Python, 5th Edition","T = T[:2] + (4,) # OK: (1, 2, 4)",assignwithSum,311 "Learning Python, 5th Edition",a = 1; b = 2; print(a + b) # Three statements on one line,assignwithSum,327 "Learning Python, 5th Edition",X = A + B + \,assignwithSum,328 "Learning Python, 5th Edition",Augmented assignment (equivalent to spams = spams + 42),assignwithSum,340 "Learning Python, 5th Edition","a, b, c = list(string[:2]) + [string[2:]] # Slice and concatenate",assignwithSum,343 "Learning Python, 5th Edition",b = b + 1,assignwithSum,349 "Learning Python, 5th Edition",X = X + Y # Traditional form,assignwithSum,350 "Learning Python, 5th Edition",x = x + 1 # Traditional,assignwithSum,350 "Learning Python, 5th Edition","nation instead. Thus, the second line here is equivalent to typing the longer S = S +",assignwithSum,350 "Learning Python, 5th Edition","the long form, X = X + Y, X appears twice and must be run twice. Because of this,",assignwithSum,351 "Learning Python, 5th Edition",L = L + [3] # Concatenate: slower,assignwithSum,351 "Learning Python, 5th Edition","L = L + [5, 6] # Concatenate: slower",assignwithSum,351 "Learning Python, 5th Edition",L = L + 'spam',assignwithSum,352 "Learning Python, 5th Edition","L = L + [3, 4] # Concatenation makes a new object",assignwithSum,352 "Learning Python, 5th Edition",Compound statements = header + “:” + indented statements. All Python com-,assignwithSum,375 "Learning Python, 5th Edition",x = 1 + 2 + 3 \ # Omitting the \ makes this very different!,assignwithSum,379 "Learning Python, 5th Edition",sum = sum + x,assignwithSum,396 "Learning Python, 5th Edition",S = S[1:] + S[:1] # Move front item to end,assignwithSum,405 "Learning Python, 5th Edition",X = S[i:] + S[:i] # Rear part + front part,assignwithSum,405 "Learning Python, 5th Edition",X = L[i:] + L[:i] # Works on any sequence type,assignwithSum,405 "Learning Python, 5th Edition",i = i+1,assignwithSum,468 "Learning Python, 5th Edition",Z = X + Y # X is a global,assignwithSum,490 "Learning Python, 5th Edition","x = y + z # No need to declare y, z: LEGB rule",assignwithSum,495 "Learning Python, 5th Edition","tmp = list(args) # Or, in Python 2.4+: return sorted(args)[0]",assignwithSum,543 "Learning Python, 5th Edition",items = items[1:] + items[:1],assignwithSum,546 "Learning Python, 5th Edition","func(1, c=10) # 1 + 5 + 10 (keywords work normally)",assignwithSum,567 "Learning Python, 5th Edition","f = lambda x, y, z: x + y + z",assignwithSum,568 "Learning Python, 5th Edition",res = res + x,assignwithSum,577 "Learning Python, 5th Edition","of the assignment statement. For example, X = yield Y is OK, as is X = (yield Y) + 42.",assignwithSum,596 "Learning Python, 5th Edition",S = S[1:] + S[:1] # Move front item to the end,assignwithSum,609 "Learning Python, 5th Edition",L = L[1:] + L[:1] # Slice so any sequence type works,assignwithSum,610 "Learning Python, 5th Edition",X = S[i:] + S[:i] # Rear part + front part (same effect),assignwithSum,610 "Learning Python, 5th Edition",seq = seq[1:] + seq[:1] # Generator function,assignwithSum,611 "Learning Python, 5th Edition",F = lambda seq: (seq[i:] + seq[:i] for i in range(len(seq))),assignwithSum,611 "Learning Python, 5th Edition",scramble2 = lambda seq: (seq[i:] + seq[:i] for i in range(len(seq))),assignwithSum,612 "Learning Python, 5th Edition",rest = seq[:i] + seq[i+1:] # Delete current node,assignwithSum,613 "Learning Python, 5th Edition",rest = seq[:i] + seq[i+1:] # Delete current node,assignwithSum,613 "Learning Python, 5th Edition",start = timer() # Or perf_counter/other in 3.3+,assignwithSum,631 "Learning Python, 5th Edition","import pkg.eggs # <== Full package paths work in all cases, 2.X+3.X",assignwithSum,732 "Learning Python, 5th Edition",b = a + 'xyz' # __add__: makes a new instance,assignwithSum,807 "Learning Python, 5th Edition",class = data + logic,assignwithSum,813 "Learning Python, 5th Edition","110000.00 # Or: pay = pay + (pay * .10), if you _really_ do!",assignwithSum,823 "Learning Python, 5th Edition",attr] = value + 10 # OK: doesn't loop,assignwithSum,911 "Learning Python, 5th Edition",z = x + y # Not nested: doesn't recur to __radd__,assignwithSum,919 "Learning Python, 5th Edition",z = x + y # With isinstance test commented-out,assignwithSum,920 "Learning Python, 5th Edition",y = Number([1]) # In-place change faster than +,assignwithSum,921 "Learning Python, 5th Edition",B2 = Button(command=cb2.changeColor) # Remembers function + self pair,assignwithSum,925 "Learning Python, 5th Edition",x = object1.doit # Bound method object: instance+function,assignwithSum,949 "Learning Python, 5th Edition",y = Number(3) # State + methods,assignwithSum,951 "Learning Python, 5th Edition","display = str(getattr(self, attr))[:82-(len(indent) + len(attr))]",assignwithSum,965 "Learning Python, 5th Edition",X.__add__ = lambda(y): 88 + y,assignwithSum,989 "Learning Python, 5th Edition",X.__add__ = lambda(y): 88 + y,assignwithSum,989 "Learning Python, 5th Edition",t = X.a + X.b + X.c + X.d,assignwithSum,1019 "Learning Python, 5th Edition",Spam.numInstances = Spam.numInstances + 1,assignwithSum,1026 "Learning Python, 5th Edition",Spam.numInstances = Spam.numInstances + 1,assignwithSum,1027 "Learning Python, 5th Edition",Spam.numInstances = Spam.numInstances + 1,assignwithSum,1028 "Learning Python, 5th Edition",Spam.numInstances = Spam.numInstances + 1,assignwithSum,1036 "Learning Python, 5th Edition",Y.a = X.a + X.b + X.c,assignwithSum,1065 "Learning Python, 5th Edition",U = u'spam' # 2.X Unicode literal accepted in 3.3+,assignwithSum,1176 "Learning Python, 5th Edition",C = bytearray(S) # A back-port from 3.X in 2.6+,assignwithSum,1193 "Learning Python, 5th Edition",start = time.clock() # State is scopes + func attr,assignwithSum,1345 "Learning Python, 5th Edition","x = type('Spam', (), {'data': 1, 'meth': (lambda x, y: x.data + y)})",assignwithSum,1368 "Learning Python, 5th Edition",cls.x = cls.y + cls.z,assignwithSum,1389 "Learning Python, 5th Edition",start = time.clock() # State is scopes + func attr,assignwithSum,1400 "Learning Python, 5th Edition",tags = '<html><body bgcolor=beige>' + tags + foot + '</body></html>',assignwithSum,1416 "Learning Python, 5th Edition",S = S[0] + 'l' + S[2:],assignwithSum,1472 "Learning Python, 5th Edition",S = S[0] + 'l' + S[2] + S[3],assignwithSum,1472 "Learning Python, 5th Edition",sum = sum + arg,assignwithSum,1476 "Learning Python, 5th Edition","y = x + [4, 5, 6]",assignwithSum,1490 "Learning Python, 5th Edition",z = DictAdder(dict(name='Bob')) + {'a':1},assignwithSum,1490 "Learning Python, 5th Edition",allpy = glob.glob(dirname + os.sep + '*.py'),assignwithSum,1499 "Learning Python, 5th Edition","sums[ix] = sums.get(ix, 0) + num",assignwithSum,1501 "Learning Python, 5th Edition",result = testcase['script'] + '.result',assignwithSum,1501 "Learning Python, 5th Edition",msgnum = i+1,assignwithSum,1503 "Learning Python, 5th Edition",input() # <== ADDED,simpleAssign,64 "Learning Python, 5th Edition","Returns to your script a line of text read as a string (e.g., nextinput = input())",simpleAssign,65 "Learning Python, 5th Edition",x = 999,simpleAssign,73 "Learning Python, 5th Edition","food': 'spam', 'taste': 'yum'}, dict(hours=10)",simpleAssign,96 "Learning Python, 5th Edition",3.1415 * 2 # repr: as code (Pythons >= 2.7 and 3.1),simpleAssign,98 "Learning Python, 5th Edition",L = list(S) # Expand to a list: [...],simpleAssign,102 "Learning Python, 5th Edition",B = bytearray(b'spam') # A bytes/list hybrid (ahead),simpleAssign,102 "Learning Python, 5th Edition",B # B[i] = ord(c) works here too,simpleAssign,102 "Learning Python, 5th Edition","match = re.match('Hello[ \t]*(.*)world', 'Hello Python world')",simpleAssign,108 "Learning Python, 5th Edition","match = re.match('[/:](.*)[/:](.*)[/:](.*)', '/usr/home:lumberjack')",simpleAssign,108 "Learning Python, 5th Edition",L[99] = 1,simpleAssign,110 "Learning Python, 5th Edition",row[1] for row in M if row[1] % 2 == 0] # Filter out odd items,simpleAssign,112 "Learning Python, 5th Edition",D['age'] = 40,simpleAssign,114 "Learning Python, 5th Edition","either keyword arguments (a special name=value syntax in function calls), or the result",simpleAssign,114 "Learning Python, 5th Edition","bob1 = dict(name='Bob', job='dev', age=40) # Keywords",simpleAssign,114 "Learning Python, 5th Edition","bob2 = dict(zip(['name', 'job', 'age'], ['Bob', 'dev', 40])) # Zipping",simpleAssign,115 "Learning Python, 5th Edition",rec = 0 # Now the object's space is reclaimed,simpleAssign,116 "Learning Python, 5th Edition",D['e'] = 99 # Assigning new keys grows dictionaries,simpleAssign,117 "Learning Python, 5th Edition","value = D.get('x', 0) # Index but with a default",simpleAssign,118 "Learning Python, 5th Edition",value = D['x'] if 'x' in D else 0 # if/else expression form,simpleAssign,118 "Learning Python, 5th Edition",Ks = list(D.keys()) # Unordered keys list,simpleAssign,118 "Learning Python, 5th Edition",x = 4,simpleAssign,119 "Learning Python, 5th Edition",x -= 1,simpleAssign,119 "Learning Python, 5th Edition",T[0] = 2 # Tuples are immutable,simpleAssign,121 "Learning Python, 5th Edition","packed = struct.pack('>i4sh', 7, b'spam', 8) # Create packed binary data",simpleAssign,124 "Learning Python, 5th Edition",X = set('spam') # Make a set out of a sequence in 2.X and 3.X,simpleAssign,126 "Learning Python, 5th Edition",set('spam') == set('asmp') # Order-neutral equality tests (== is False),simpleAssign,127 "Learning Python, 5th Edition",d = decimal.Decimal('3.141'),simpleAssign,127 "Learning Python, 5th Edition",decimal.getcontext().prec = 2,simpleAssign,127 "Learning Python, 5th Edition","f = Fraction(2, 3)",simpleAssign,127 "Learning Python, 5th Edition",X = None # None placeholder,simpleAssign,128 "Learning Python, 5th Edition","if type(L) == type([]): # Type testing, if you must...",simpleAssign,128 "Learning Python, 5th Edition",if type(L) == list: # Using the type name,simpleAssign,128 "Learning Python, 5th Edition","bob = Worker('Bob Smith', 50000) # Make two instances",simpleAssign,129 "Learning Python, 5th Edition","sue = Worker('Sue Jones', 60000) # Each has name and pay attrs",simpleAssign,129 "Learning Python, 5th Edition","x < y, x <= y, x > y, x >= y",simpleAssign,137 "Learning Python, 5th Edition","x == y, x != y",simpleAssign,137 "Learning Python, 5th Edition","In Python 2.X, value inequality can be written as either X != Y or X <> Y. In Python",simpleAssign,138 "Learning Python, 5th Edition",best practice is to use X != Y for all value inequality tests.,simpleAssign,138 "Learning Python, 5th Edition",a = 3 # Name created: not declared ahead of time,simpleAssign,141 "Learning Python, 5th Edition",b = 4,simpleAssign,141 "Learning Python, 5th Edition",b / (2.0 + a) # Pythons <= 2.6: echoes give more (or fewer) digits,simpleAssign,143 "Learning Python, 5th Edition",num = 1 / 3.0,simpleAssign,144 "Learning Python, 5th Edition",2.0 >= 1 # Greater than or equal: mixed-type 1 converted to 1.0,simpleAssign,145 "Learning Python, 5th Edition",2.0 == 2.0 # Equal value,simpleAssign,145 "Learning Python, 5th Edition",2.0 != 2.0 # Not equal value,simpleAssign,145 "Learning Python, 5th Edition",X = 2,simpleAssign,145 "Learning Python, 5th Edition",Y = 4,simpleAssign,145 "Learning Python, 5th Edition",Z = 6,simpleAssign,145 "Learning Python, 5th Edition",1 == 2 < 3 # Same as: 1 == 2 and 2 < 3,simpleAssign,145 "Learning Python, 5th Edition",Python does not compare the 1 == 2 expression’s False result to 3—this would tech-,simpleAssign,146 "Learning Python, 5th Edition",1.1 + 2.2 == 3.3 # Shouldn't this be True?...,simpleAssign,146 "Learning Python, 5th Edition","int(1.1 + 2.2) == int(3.3) # OK if convert: see also round, floor, trunc ahead",simpleAssign,146 "Learning Python, 5th Edition","X = Y // Z # Always truncates, always an int result for ints in 2.X and 3.X",simpleAssign,148 "Learning Python, 5th Edition",X = Y / float(Z) # Guarantees float division with remainder in either 2.X or 3.X,simpleAssign,148 "Learning Python, 5th Edition",X = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF,simpleAssign,153 "Learning Python, 5th Edition",x = 1 # 1 decimal is 0001 in bits,simpleAssign,153 "Learning Python, 5th Edition",x | 2 # Bitwise OR (either bit=1): 0011,simpleAssign,154 "Learning Python, 5th Edition",x & 1 # Bitwise AND (both bits=1): 0001,simpleAssign,154 "Learning Python, 5th Edition",0010 = 0011) and a binary AND to select common bits (0001&0001 = 0001). Such bit-,simpleAssign,154 "Learning Python, 5th Edition",X = 0b0001 # Binary literals,simpleAssign,154 "Learning Python, 5th Edition",X = 0xFF # Hex literals,simpleAssign,154 "Learning Python, 5th Edition",X = 99,simpleAssign,154 "Learning Python, 5th Edition",decimal.getcontext().prec = 4 # Fixed precision,simpleAssign,159 "Learning Python, 5th Edition",decimal.getcontext().prec = 2,simpleAssign,159 "Learning Python, 5th Edition",ctx.prec = 2,simpleAssign,159 "Learning Python, 5th Edition","x = Fraction(1, 3) # Numerator, denominator",simpleAssign,160 "Learning Python, 5th Edition","y = Fraction(4, 6) # Simplified to 2, 3 by gcd",simpleAssign,160 "Learning Python, 5th Edition",a = 1 / 3.0 # Only as accurate as floating-point hardware,simpleAssign,161 "Learning Python, 5th Edition",b = 4 / 6.0 # Can lose precision over many calculations,simpleAssign,161 "Learning Python, 5th Edition",decimal.getcontext().prec = 2,simpleAssign,161 "Learning Python, 5th Edition",f = 2.5,simpleAssign,162 "Learning Python, 5th Edition",z = Fraction(*f.as_integer_ratio()) # Convert float -> fraction: two args,simpleAssign,162 "Learning Python, 5th Edition",x = set('abcde'),simpleAssign,164 "Learning Python, 5th Edition",y = set('bdxyz'),simpleAssign,164 "Learning Python, 5th Edition","set(['a', 'c', 'b', 'e', 'd']) # Pythons <= 2.6 display format",simpleAssign,164 "Learning Python, 5th Edition",z = x.intersection(y) # Same as x & y,simpleAssign,165 "Learning Python, 5th Edition","S = set([1, 2, 3])",simpleAssign,165 "Learning Python, 5th Edition",S = set() # Initialize an empty set,simpleAssign,167 "Learning Python, 5th Edition",L = list(set(L)) # Remove duplicates,simpleAssign,169 "Learning Python, 5th Edition",L1 == L2 # Order matters in sequences,simpleAssign,170 "Learning Python, 5th Edition",set(L1) == set(L2) # Order-neutral equality,simpleAssign,170 "Learning Python, 5th Edition",sorted(L1) == sorted(L2) # Similar but results ordered,simpleAssign,170 "Learning Python, 5th Edition","spam' == 'asmp', set('spam') == set('asmp'), sorted('spam') == sorted('asmp')",simpleAssign,170 "Learning Python, 5th Edition","Similarly, flags can be initialized more clearly with flag = False. We’ll discuss these",simpleAssign,171 "Learning Python, 5th Edition",True == 1 # Same value,simpleAssign,172 "Learning Python, 5th Edition","When we type a = 3 in an interactive session or program file, for instance, how does",simpleAssign,175 "Learning Python, 5th Edition","assignment statement such as a = 3 in Python, it works even if you’ve never told Python",simpleAssign,176 "Learning Python, 5th Edition",a = 3 # Assign a name to an object,simpleAssign,176 "Learning Python, 5th Edition",Figure 6-1. Names and objects after running the assignment a = 3. Variable a becomes a reference to,simpleAssign,177 "Learning Python, 5th Edition",a = 3 # It's an integer,simpleAssign,178 "Learning Python, 5th Edition",a = 1.23 # Now it's a floating point,simpleAssign,178 "Learning Python, 5th Edition",a = 3,simpleAssign,178 "Learning Python, 5th Edition",x = 42,simpleAssign,179 "Learning Python, 5th Edition",x = 3.1415 # Reclaim 'shrubbery' now,simpleAssign,179 "Learning Python, 5th Edition",a = 3,simpleAssign,180 "Learning Python, 5th Edition",b = a,simpleAssign,180 "Learning Python, 5th Edition",Figure 6-2. Names and objects after next running the assignment b = a. Variable b becomes a reference,simpleAssign,180 "Learning Python, 5th Edition",a = 3,simpleAssign,180 "Learning Python, 5th Edition",b = a,simpleAssign,180 "Learning Python, 5th Edition",a = 3,simpleAssign,181 "Learning Python, 5th Edition",b = a,simpleAssign,181 "Learning Python, 5th Edition",L2 = L1,simpleAssign,182 "Learning Python, 5th Edition",L1 = 24,simpleAssign,182 "Learning Python, 5th Edition",L2 = L1 # Make a reference to the same object,simpleAssign,182 "Learning Python, 5th Edition",L1[0] = 24 # An in-place change,simpleAssign,182 "Learning Python, 5th Edition","L2 = L1[:] # Make a copy of L1 (or list(L1), copy.copy(L1), etc.)",simpleAssign,183 "Learning Python, 5th Edition",L1[0] = 24,simpleAssign,183 "Learning Python, 5th Edition","X = copy.copy(Y) # Make top-level ""shallow"" copy of any object Y",simpleAssign,183 "Learning Python, 5th Edition",X = copy.deepcopy(Y) # Make deep copy of any object Y: copy all nested parts,simpleAssign,183 "Learning Python, 5th Edition",x = 42,simpleAssign,183 "Learning Python, 5th Edition",M = L # M and L reference the same object,simpleAssign,184 "Learning Python, 5th Edition",L == M # Same values,simpleAssign,184 "Learning Python, 5th Edition","The first technique here, the == operator, tests whether the two referenced objects have",simpleAssign,184 "Learning Python, 5th Edition",L == M # Same values,simpleAssign,184 "Learning Python, 5th Edition",X = 42,simpleAssign,184 "Learning Python, 5th Edition",Y = 42 # Should be two different objects,simpleAssign,184 "Learning Python, 5th Edition",X == Y,simpleAssign,184 "Learning Python, 5th Edition",B = A,simpleAssign,186 "Learning Python, 5th Edition",B = A,simpleAssign,186 "Learning Python, 5th Edition",B = A[:],simpleAssign,186 "Learning Python, 5th Edition",S = r'\temp\spam',simpleAssign,191 "Learning Python, 5th Edition",B = b'sp\xc4m',simpleAssign,191 "Learning Python, 5th Edition",U = u'sp\u00c4m',simpleAssign,191 "Learning Python, 5th Edition",path = r'C:\new\text.dat',simpleAssign,197 "Learning Python, 5th Edition",X = 1,simpleAssign,199 "Learning Python, 5th Edition",Y = 2,simpleAssign,199 "Learning Python, 5th Edition",I = 1,simpleAssign,206 "Learning Python, 5th Edition",I = 0,simpleAssign,207 "Learning Python, 5th Edition",B = B[1:],simpleAssign,207 "Learning Python, 5th Edition","S = S.replace('pl', 'pamal')",simpleAssign,208 "Learning Python, 5th Edition",result = S.find('pa') # Call the find method to look for 'pa' in string S,simpleAssign,210 "Learning Python, 5th Edition","S = S.replace('mm', 'xx') # Replace all mm with xx in S",simpleAssign,211 "Learning Python, 5th Edition",where = S.find('SPAM') # Search for position,simpleAssign,212 "Learning Python, 5th Edition",L = list(S),simpleAssign,212 "Learning Python, 5th Edition",col1 = line[0:3],simpleAssign,213 "Learning Python, 5th Edition",col3 = line[8:],simpleAssign,213 "Learning Python, 5th Edition",cols = line.split(),simpleAssign,213 "Learning Python, 5th Edition",line[-len(sub):] == sub,simpleAssign,215 "Learning Python, 5th Edition",x = 1234,simpleAssign,220 "Learning Python, 5th Edition",x = 1.23456789,simpleAssign,220 "Learning Python, 5th Edition",qty = 10,simpleAssign,221 "Learning Python, 5th Edition","Y = X.replace('and', 'but under no circumstances')",simpleAssign,223 "Learning Python, 5th Edition",somelist = list('SPAM'),simpleAssign,224 "Learning Python, 5th Edition","first=S, third=A'",simpleAssign,224 "Learning Python, 5th Edition","first=S, last=M'",simpleAssign,224 "Learning Python, 5th Edition","parts = somelist[0], somelist[-1], somelist[1:3] # [1:3] fails in fmt",simpleAssign,224 "Learning Python, 5th Edition",spam = 123.4567',simpleAssign,225 "Learning Python, 5th Edition",spam = 123.4567 ',simpleAssign,225 "Learning Python, 5th Edition",win32 = laptop ',simpleAssign,225 "Learning Python, 5th Edition",spam = 123.4567',simpleAssign,226 "Learning Python, 5th Edition",spam = 123.4567 ',simpleAssign,226 "Learning Python, 5th Edition",win32 = laptop ',simpleAssign,226 "Learning Python, 5th Edition","My %(kind)s runs %(platform)s' % dict(kind='laptop', platform=sys.platform)",simpleAssign,227 "Learning Python, 5th Edition",somelist = list('SPAM'),simpleAssign,227 "Learning Python, 5th Edition","parts = somelist[0], somelist[-1], somelist[1:3]",simpleAssign,228 "Learning Python, 5th Edition",spam = 123.4567',simpleAssign,228 "Learning Python, 5th Edition",spam = 123.4567 ',simpleAssign,228 "Learning Python, 5th Edition","plat)10s = %(kind)-10s' % dict(plat=sys.platform, kind='laptop')",simpleAssign,228 "Learning Python, 5th Edition",win32 = laptop ',simpleAssign,228 "Learning Python, 5th Edition","My %(kind)-8s runs %(plat)8s' % dict(kind='laptop', plat=sys.platform)",simpleAssign,228 "Learning Python, 5th Edition","data = dict(platform=sys.platform, kind='laptop')",simpleAssign,229 "Learning Python, 5th Edition",unpacks a dictionary of keys and values into individual “name=value” keyword argu-,simpleAssign,229 "Learning Python, 5th Edition","D = dict(name='Bob', job='dev')",simpleAssign,232 "Learning Python, 5th Edition","num)i = %(title)s' % dict(num=7, title='Strings')",simpleAssign,234 "Learning Python, 5th Edition",7 = Strings',simpleAssign,234 "Learning Python, 5th Edition","format(num=7, title='Strings')",simpleAssign,235 "Learning Python, 5th Edition",7 = Strings',simpleAssign,235 "Learning Python, 5th Edition","num} = {title}'.format(**dict(num=7, title='Strings'))",simpleAssign,235 "Learning Python, 5th Edition",7 = Strings',simpleAssign,235 "Learning Python, 5th Edition",t = string.Template('$num = $title'),simpleAssign,235 "Learning Python, 5th Edition",7 = Strings',simpleAssign,235 "Learning Python, 5th Edition","t.substitute(num=7, title='Strings')",simpleAssign,235 "Learning Python, 5th Edition",7 = Strings',simpleAssign,235 "Learning Python, 5th Edition","t.substitute(dict(num=7, title='Strings'))",simpleAssign,235 "Learning Python, 5th Edition",7 = Strings',simpleAssign,235 "Learning Python, 5th Edition",L = list('spam'),simpleAssign,240 "Learning Python, 5th Edition","L = list(range(-4, 4))",simpleAssign,240 "Learning Python, 5th Edition",L[i] = 3,simpleAssign,241 "Learning Python, 5th Edition",1. Deletion. The slice you specify to the left of the = is deleted.,simpleAssign,245 "Learning Python, 5th Edition",2. Insertion. The new items contained in the iterable object to the right of the = are,simpleAssign,245 "Learning Python, 5th Edition","L[2:5]=L[3:6], for instance, works fine because the value to be inserted is fetched before the deletion",simpleAssign,245 "Learning Python, 5th Edition",arguments—a special “name=value” syntax in function calls that specifies passing by,simpleAssign,247 "Learning Python, 5th Edition",L.sort(key=str.lower) # Normalize to lowercase,simpleAssign,247 "Learning Python, 5th Edition","L.sort(key=str.lower, reverse=True) # Change sort order",simpleAssign,247 "Learning Python, 5th Edition",around is to use the key=func keyword argument to code value trans-,simpleAssign,247 "Learning Python, 5th Edition","formations during the sort, and use the reverse=True keyword argument",simpleAssign,247 "Learning Python, 5th Edition","None). If you say something like L=L.append(X), you won’t get the modified value of L",simpleAssign,248 "Learning Python, 5th Edition","sorted(L, key=str.lower, reverse=True) # Sorting built-in",simpleAssign,248 "Learning Python, 5th Edition","sorted([x.lower() for x in L], reverse=True) # Pretransform items: differs!",simpleAssign,248 "Learning Python, 5th Edition","D = dict(name='Bob', age=40)",simpleAssign,252 "Learning Python, 5th Edition","D = dict([('name', 'Bob'), ('age', 40)])",simpleAssign,252 "Learning Python, 5th Edition","D = dict(zip(keyslist, valueslist))",simpleAssign,252 "Learning Python, 5th Edition","D = dict.fromkeys(['name', 'age'])",simpleAssign,252 "Learning Python, 5th Edition",D[key] = 42,simpleAssign,252 "Learning Python, 5th Edition",Change entry (value=list),simpleAssign,254 "Learning Python, 5th Edition",movie = table[year] # dictionary[Key] => Value,simpleAssign,256 "Learning Python, 5th Edition","key for (key, value) in table.items() if value == V] # Value=>Key",simpleAssign,258 "Learning Python, 5th Edition",key for key in table.keys() if table[key] == V] # Ditto,simpleAssign,258 "Learning Python, 5th Edition","Matrix[(2, 3, 4)] = 88",simpleAssign,259 "Learning Python, 5th Edition","Matrix[(7, 8, 9)] = 99",simpleAssign,259 "Learning Python, 5th Edition",X = 2; Y = 3; Z = 4 # ; separates statements: see Chapter 10,simpleAssign,259 "Learning Python, 5th Edition",rec['age'] = 40.5,simpleAssign,261 "Learning Python, 5th Edition","db['bob'] = rec # A dictionary ""database""",simpleAssign,261 "Learning Python, 5th Edition",db['sue'] = other,simpleAssign,262 "Learning Python, 5th Edition",D['age'] = 40,simpleAssign,262 "Learning Python, 5th Edition","dict(name='Bob', age=40) # dict keyword argument form",simpleAssign,262 "Learning Python, 5th Edition",D['state1'] = True # A visited-state dictionary,simpleAssign,264 "Learning Python, 5th Edition",S = set(),simpleAssign,264 "Learning Python, 5th Edition","D = dict(zip(['a', 'b', 'c'], [1, 2, 3])) # Make a dict from zip result",simpleAssign,265 "Learning Python, 5th Edition","D = dict.fromkeys(['a', 'b', 'c'], 0) # Initialize dict from keys",simpleAssign,266 "Learning Python, 5th Edition","D = dict.fromkeys('spam') # Other iterables, default value",simpleAssign,266 "Learning Python, 5th Edition","D = dict(a=1, b=2, c=3)",simpleAssign,267 "Learning Python, 5th Edition","K = D.keys() # Makes a view object in 3.X, not a list",simpleAssign,267 "Learning Python, 5th Edition",V = D.values() # Ditto for values and items views,simpleAssign,267 "Learning Python, 5th Edition",K = D.keys(),simpleAssign,268 "Learning Python, 5th Edition",V = D.values(),simpleAssign,268 "Learning Python, 5th Edition",Ks = D.keys() # Sorting a view object doesn't work!,simpleAssign,269 "Learning Python, 5th Edition",Ks = list(Ks) # Force it to be a list and then sort,simpleAssign,269 "Learning Python, 5th Edition",Ks = D.keys() # Or you can use sorted() on the keys,simpleAssign,269 "Learning Python, 5th Edition","Dictionary equality tests (e.g., D1 == D2) still work in 3.X, though. Since we’ll revisit",simpleAssign,270 "Learning Python, 5th Edition","if D.get('c') != None: print('present', D['c']) # Another option",simpleAssign,270 "Learning Python, 5th Edition",data = file['key'] # Fetch data by key,simpleAssign,271 "Learning Python, 5th Edition",form = cgi.FieldStorage() # Parse form data,simpleAssign,271 "Learning Python, 5th Edition","D['a'] = 0, and D['b'] = 0 would create the desired dictionary. You can also",simpleAssign,272 "Learning Python, 5th Edition","use the newer and simpler-to-code dict(a=0, b=0) keyword form, or the more",simpleAssign,272 "Learning Python, 5th Edition","T = 0, 'Ni', 1.2, 3",simpleAssign,276 "Learning Python, 5th Edition",T = tuple('spam'),simpleAssign,277 "Learning Python, 5th Edition",tmp = list(T) # Make a list from a tuple's items,simpleAssign,278 "Learning Python, 5th Edition",T = tuple(tmp) # Make a tuple from the list's items,simpleAssign,278 "Learning Python, 5th Edition","Rec = namedtuple('Rec', ['name', 'age', 'jobs']) # Make a generated class",simpleAssign,281 "Learning Python, 5th Edition",O = bob._asdict() # Dictionary-like form,simpleAssign,281 "Learning Python, 5th Edition","bob = Rec('Bob', 40.5, ['dev', 'mgr']) # For both tuples and named tuples",simpleAssign,282 "Learning Python, 5th Edition","name, age, jobs = bob # Tuple assignment (Chapter 11)",simpleAssign,282 "Learning Python, 5th Edition","job, name, age = bob.values()",simpleAssign,282 "Learning Python, 5th Edition",aList = input.readlines(),simpleAssign,283 "Learning Python, 5th Edition",Open binary file: rb=read binary,simpleAssign,287 "Learning Python, 5th Edition","X, Y, Z = 43, 44, 45 # Native Python objects",simpleAssign,288 "Learning Python, 5th Edition","parts = line.split(',') # Split (parse) on commas",simpleAssign,289 "Learning Python, 5th Edition",parts = line.split('$') # Split (parse) on $,simpleAssign,289 "Learning Python, 5th Edition",E = pickle.load(F) # Load any object from file,simpleAssign,290 "Learning Python, 5th Edition","name = dict(first='Bob', last='Smith')",simpleAssign,291 "Learning Python, 5th Edition",age=40.5),simpleAssign,291 "Learning Python, 5th Edition",S = json.dumps(rec),simpleAssign,291 "Learning Python, 5th Edition",O = json.loads(S),simpleAssign,292 "Learning Python, 5th Edition",O == rec,simpleAssign,292 "Learning Python, 5th Edition","data = struct.pack('>i4sh', 7, b'spam', 8) # Make packed binary data",simpleAssign,293 "Learning Python, 5th Edition","values = struct.unpack('>i4sh', data) # Convert to Python objects",simpleAssign,293 "Learning Python, 5th Edition","self[index]=value assignments). Although it’s beyond this book’s scope, it’s also pos-",simpleAssign,297 "Learning Python, 5th Edition",A = L[:] # Instead of A = L (or list(L)),simpleAssign,299 "Learning Python, 5th Edition",B = D.copy() # Instead of B = D (ditto for sets),simpleAssign,299 "Learning Python, 5th Edition",X = copy.deepcopy(Y) # Fully copy an arbitrarily nested object Y,simpleAssign,300 "Learning Python, 5th Edition","L1 == L2, L1 is L2 # Equivalent? Same object?",simpleAssign,301 "Learning Python, 5th Edition","The == operator tests value equivalence. Python performs an equivalence test,",simpleAssign,301 "Learning Python, 5th Edition","In the preceding example, L1 and L2 pass the == test (they have equivalent values because",simpleAssign,301 "Learning Python, 5th Edition","S1 == S2, S1 is S2",simpleAssign,301 "Learning Python, 5th Edition","S1 == S2, S1 is S2",simpleAssign,301 "Learning Python, 5th Edition","As a rule of thumb, the == operator is what you will want to use for almost all equality",simpleAssign,301 "Learning Python, 5th Edition","L1 < L2, L1 == L2, L1 > L2 # Less, equal, greater: tuple of results",simpleAssign,301 "Learning Python, 5th Edition","str(11) >= '11', 11 >= int('11') # Manual conversions force the issue",simpleAssign,303 "Learning Python, 5th Edition",D1 == D2,simpleAssign,303 "Learning Python, 5th Edition",type([1]) == type([]) # Compare to type of another list,simpleAssign,306 "Learning Python, 5th Edition",type([1]) == list # Compare to list type name,simpleAssign,306 "Learning Python, 5th Edition",type(f) == types.FunctionType,simpleAssign,306 "Learning Python, 5th Edition",L[1] = 0 # Changes M too,simpleAssign,309 "Learning Python, 5th Edition","L[1] = 0 # Changes only L, not M",simpleAssign,309 "Learning Python, 5th Edition",L[1] = 0 # Impacts Y but not X,simpleAssign,309 "Learning Python, 5th Edition",L[1] = 0,simpleAssign,310 "Learning Python, 5th Edition",Y[0][1] = 99 # All four copies are still the same,simpleAssign,310 "Learning Python, 5th Edition",Y[0][1] = 99,simpleAssign,310 "Learning Python, 5th Edition",T[2] = 4 # Error!,simpleAssign,311 "Learning Python, 5th Edition","line: for example, X=1;X assigns and then prints a variable (more on statement",simpleAssign,313 "Learning Python, 5th Edition",D['w'] = 0,simpleAssign,313 "Learning Python, 5th Edition","D[(1,2,3)] = 4",simpleAssign,313 "Learning Python, 5th Edition",L[1:])? What happens when you assign a nonsequence to a slice (L[1:2]=1)?,simpleAssign,314 "Learning Python, 5th Edition","X, Y = Y, X",simpleAssign,314 "Learning Python, 5th Edition",x = 1;,simpleAssign,322 "Learning Python, 5th Edition",y = 2;,simpleAssign,322 "Learning Python, 5th Edition",y = 2,simpleAssign,322 "Learning Python, 5th Edition",x = 1;,simpleAssign,323 "Learning Python, 5th Edition",x = 1,simpleAssign,323 "Learning Python, 5th Edition",x = 1;,simpleAssign,324 "Learning Python, 5th Edition",y = 2;,simpleAssign,324 "Learning Python, 5th Edition",y = 2,simpleAssign,324 "Learning Python, 5th Edition",if (A == 1 and,simpleAssign,328 "Learning Python, 5th Edition",B == 2 and,simpleAssign,328 "Learning Python, 5th Edition",C == 3):,simpleAssign,328 "Learning Python, 5th Edition",if sys.version[0] == '2': input = raw_input # 2.X compatible,simpleAssign,331 "Learning Python, 5th Edition","cerned with the = statement, but assignment occurs in many contexts in Python.",simpleAssign,340 "Learning Python, 5th Edition",spam = ham = 'lunch',simpleAssign,340 "Learning Python, 5th Edition","coded ham = 'lunch' followed by spam = ham, as ham evaluates to the original string",simpleAssign,341 "Learning Python, 5th Edition",nudge = 1 # Basic assignment,simpleAssign,341 "Learning Python, 5th Edition",wink = 2,simpleAssign,341 "Learning Python, 5th Edition","A, B = nudge, wink # Tuple assignment",simpleAssign,341 "Learning Python, 5th Edition","A, B # Like A = nudge; B = wink",simpleAssign,341 "Learning Python, 5th Edition",nudge = 1,simpleAssign,342 "Learning Python, 5th Edition",wink = 2,simpleAssign,342 "Learning Python, 5th Edition","nudge, wink = wink, nudge # Tuples: swaps values",simpleAssign,342 "Learning Python, 5th Edition","nudge, wink # Like T = nudge; nudge = wink; wink = T",simpleAssign,342 "Learning Python, 5th Edition","Although we can mix and match sequence types around the = symbol, we must generally",simpleAssign,342 "Learning Python, 5th Edition","a, b, c, d = string # Same number on both sides",simpleAssign,342 "Learning Python, 5th Edition","a, b, c = string # Error if not",simpleAssign,342 "Learning Python, 5th Edition","a, b, c = string[0], string[1], string[2:] # Index and slice",simpleAssign,343 "Learning Python, 5th Edition","a, b = string[:2] # Same, but simpler",simpleAssign,343 "Learning Python, 5th Edition",c = string[2:],simpleAssign,343 "Learning Python, 5th Edition","a, b), c = string[:2], string[2:] # Nested sequences",simpleAssign,343 "Learning Python, 5th Edition","red, green, blue = range(3)",simpleAssign,344 "Learning Python, 5th Edition","front, L = L[0], L[1:] # See next section for 3.X * alternative",simpleAssign,344 "Learning Python, 5th Edition",front = L[0],simpleAssign,344 "Learning Python, 5th Edition",L = L[1:],simpleAssign,344 "Learning Python, 5th Edition","also be achieved with the append and pop methods of list objects; here, front = L.pop(0) would have much the same effect as the tuple assignment statement, but it",simpleAssign,344 "Learning Python, 5th Edition","a, b, c, d = seq",simpleAssign,345 "Learning Python, 5th Edition","a, b = seq",simpleAssign,345 "Learning Python, 5th Edition","a, *b = seq",simpleAssign,345 "Learning Python, 5th Edition","a, b = seq",simpleAssign,345 "Learning Python, 5th Edition","a, *b, c = seq",simpleAssign,345 "Learning Python, 5th Edition","a, b, *c = seq",simpleAssign,345 "Learning Python, 5th Edition","a, *b, c = range(4)",simpleAssign,346 "Learning Python, 5th Edition","front, *L = L # Get first, rest without slicing",simpleAssign,346 "Learning Python, 5th Edition","a, b, c, *d = seq",simpleAssign,347 "Learning Python, 5th Edition","a, b, c, d, *e = seq",simpleAssign,347 "Learning Python, 5th Edition","a, b, *e, c, d = seq",simpleAssign,347 "Learning Python, 5th Edition","a, *b, c, *d = seq",simpleAssign,347 "Learning Python, 5th Edition","a, b = seq",simpleAssign,347 "Learning Python, 5th Edition",a = seq,simpleAssign,347 "Learning Python, 5th Edition","a, = seq",simpleAssign,347 "Learning Python, 5th Edition","a, *b = seq # First, rest",simpleAssign,347 "Learning Python, 5th Edition","a, b = seq[0], seq[1:] # First, rest: traditional",simpleAssign,347 "Learning Python, 5th Edition","a, b = seq # Rest, last",simpleAssign,348 "Learning Python, 5th Edition","a, b = seq[:-1], seq[-1] # Rest, last: traditional",simpleAssign,348 "Learning Python, 5th Edition","a, b, c = all[0], all[1:3], all[3]",simpleAssign,348 "Learning Python, 5th Edition",a = b = c = 'spam',simpleAssign,349 "Learning Python, 5th Edition",b = c,simpleAssign,349 "Learning Python, 5th Edition",a = b,simpleAssign,349 "Learning Python, 5th Edition",a = b = 0,simpleAssign,349 "Learning Python, 5th Edition",X *= Y,simpleAssign,350 "Learning Python, 5th Edition",X %= Y,simpleAssign,350 "Learning Python, 5th Edition",X &= Y,simpleAssign,350 "Learning Python, 5th Edition",X ^= Y,simpleAssign,350 "Learning Python, 5th Edition",X <<= Y,simpleAssign,350 "Learning Python, 5th Edition",X −= Y,simpleAssign,350 "Learning Python, 5th Edition",X /= Y,simpleAssign,350 "Learning Python, 5th Edition",X **= Y,simpleAssign,350 "Learning Python, 5th Edition",X |= Y,simpleAssign,350 "Learning Python, 5th Edition",X >>= Y,simpleAssign,350 "Learning Python, 5th Edition",X //= Y,simpleAssign,350 "Learning Python, 5th Edition",x = 1,simpleAssign,350 "Learning Python, 5th Edition","side). For instance, X *= Y multiplies and assigns, X >>= Y shifts right and assigns, and",simpleAssign,350 "Learning Python, 5th Edition",so on. X //= Y (for floor division) was added in version 2.2.,simpleAssign,350 "Learning Python, 5th Edition",M = L # L and M reference the same object,simpleAssign,352 "Learning Python, 5th Edition",M = L,simpleAssign,352 "Learning Python, 5th Edition","of this book, you cannot redefine reserved words by assignment (e.g., and = 1 results",simpleAssign,353 "Learning Python, 5th Edition","built-ins, which are predefined but not reserved (and so can be reassigned: open = 42",simpleAssign,355 "Learning Python, 5th Edition",x = 0 # x bound to an integer object,simpleAssign,355 "Learning Python, 5th Edition",x = print('spam') # print is a function call expression in 3.X,simpleAssign,357 "Learning Python, 5th Edition",change a variable by typing = when you really mean to use the == equality test. You’ll,simpleAssign,357 "Learning Python, 5th Edition","L = L.append(4) # But append returns None, not L",simpleAssign,357 "Learning Python, 5th Edition","given call, and values after = give argument defaults. In English, this built-in function",simpleAssign,359 "Learning Python, 5th Edition","arguments—that is, you must use a special “name=value” syntax to pass the arguments",simpleAssign,359 "Learning Python, 5th Edition",y = 99,simpleAssign,360 "Learning Python, 5th Edition",temp = sys.stdout # Save for restoring later,simpleAssign,365 "Learning Python, 5th Edition",sys.stdout = temp # Restore original stream,simpleAssign,365 "Learning Python, 5th Edition",X = 1; Y = 2,simpleAssign,366 "Learning Python, 5th Edition",sys.stdout = FileFaker(),simpleAssign,369 "Learning Python, 5th Edition",myobj = FileFaker() # 3.X: Redirect to object for one print,simpleAssign,369 "Learning Python, 5th Edition",myobj = FileFaker() # 2.X: same effect,simpleAssign,369 "Learning Python, 5th Edition",3. What’s wrong with saying L = L.sort()?,simpleAssign,370 "Learning Python, 5th Edition","1. You can use multiple-target assignments (A = B = C = 0), sequence assignment",simpleAssign,370 "Learning Python, 5th Edition","A, B, C = 0, 0, 0), or multiple assignment statements on three separate lines (A = 0, B = 0, and C = 0). With the latter technique, as introduced in Chapter 10, you",simpleAssign,370 "Learning Python, 5th Edition",them with semicolons (A = 0; B = 0; C = 0).,simpleAssign,370 "Learning Python, 5th Edition","4. To print to a file for a single print operation, you can use 3.X’s print(X, file=F)",simpleAssign,370 "Learning Python, 5th Edition",x = 1,simpleAssign,376 "Learning Python, 5th Edition",if a == b and c == d and \,simpleAssign,379 "Learning Python, 5th Edition",d == e and f == g:,simpleAssign,379 "Learning Python, 5th Edition",if (a == b and c == d and,simpleAssign,379 "Learning Python, 5th Edition",d == e and e == f):,simpleAssign,379 "Learning Python, 5th Edition",x = 1; y = 2; print(x) # More than one simple statement,simpleAssign,380 "Learning Python, 5th Edition",A = Z,simpleAssign,382 "Learning Python, 5th Edition",A = Y if X else Z,simpleAssign,383 "Learning Python, 5th Edition",A = Y if X else Z,simpleAssign,383 "Learning Python, 5th Edition",X = A or B or C or None,simpleAssign,384 "Learning Python, 5th Edition",X = A or default,simpleAssign,384 "Learning Python, 5th Edition","tmp1, tmp2 = f1(), f2()",simpleAssign,384 "Learning Python, 5th Edition","X = False), for loop tests (while True:), and for displaying results at the interactive",simpleAssign,385 "Learning Python, 5th Edition",x = x[1:] # Strip first character off x,simpleAssign,388 "Learning Python, 5th Edition",a=0; b=10,simpleAssign,388 "Learning Python, 5th Edition",x = 10,simpleAssign,391 "Learning Python, 5th Edition",found = False,simpleAssign,393 "Learning Python, 5th Edition",while ((x = next(obj)) != NULL) {...process x...},simpleAssign,394 "Learning Python, 5th Edition","type = in Python when you mean ==. If you need similar behavior, though, there are at",simpleAssign,394 "Learning Python, 5th Edition",x = True,simpleAssign,394 "Learning Python, 5th Edition",x = next(obj),simpleAssign,394 "Learning Python, 5th Edition",x = next(obj),simpleAssign,394 "Learning Python, 5th Edition",x = next(obj),simpleAssign,394 "Learning Python, 5th Edition",sum = 0,simpleAssign,396 "Learning Python, 5th Edition",prod = 1,simpleAssign,396 "Learning Python, 5th Edition",prod *= item,simpleAssign,396 "Learning Python, 5th Edition","a, b = both # Manual assignment equivalent",simpleAssign,397 "Learning Python, 5th Edition","a, b, c = all[0], all[1:3], all[3]",simpleAssign,399 "Learning Python, 5th Edition",if item == key: # Check for match,simpleAssign,399 "Learning Python, 5th Edition",i = 0,simpleAssign,404 "Learning Python, 5th Edition",i = 0,simpleAssign,407 "Learning Python, 5th Edition",D1['spam'] = 1,simpleAssign,409 "Learning Python, 5th Edition",D1['eggs'] = 3,simpleAssign,409 "Learning Python, 5th Edition",D1['toast'] = 5,simpleAssign,409 "Learning Python, 5th Edition",D2[k] = v,simpleAssign,410 "Learning Python, 5th Edition","D3 = dict(zip(keys, vals))",simpleAssign,410 "Learning Python, 5th Edition",offset = 0,simpleAssign,410 "Learning Python, 5th Edition",E = enumerate(S),simpleAssign,411 "Learning Python, 5th Edition",if i == 4: break,simpleAssign,412 "Learning Python, 5th Edition",parts = line.split(':'),simpleAssign,412 "Learning Python, 5th Edition",cols = line.split(),simpleAssign,413 "Learning Python, 5th Edition",x = 2,simpleAssign,417 "Learning Python, 5th Edition",import sys\nprint(sys.path)\nx = 2\nprint(x ** 32)\n',simpleAssign,417 "Learning Python, 5th Edition",x = 2\n',simpleAssign,417 "Learning Python, 5th Edition",x = 2\n',simpleAssign,417 "Learning Python, 5th Edition",X = 2,simpleAssign,418 "Learning Python, 5th Edition",X = 2,simpleAssign,418 "Learning Python, 5th Edition",I = iter(L) # Obtain an iterator object from an iterable,simpleAssign,420 "Learning Python, 5th Edition",I = iter(L),simpleAssign,421 "Learning Python, 5th Edition",I = iter(L) # Manual iteration: what for loops usually do,simpleAssign,422 "Learning Python, 5th Edition",I = iter(D),simpleAssign,422 "Learning Python, 5th Edition",I = iter(P),simpleAssign,423 "Learning Python, 5th Edition",R = range(5),simpleAssign,423 "Learning Python, 5th Edition",I = iter(R) # Use iteration protocol to produce results,simpleAssign,423 "Learning Python, 5th Edition",E = enumerate('spam') # enumerate is an iterable too,simpleAssign,424 "Learning Python, 5th Edition",I = iter(E),simpleAssign,424 "Learning Python, 5th Edition",lines = f.readlines(),simpleAssign,426 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n']",simpleAssign,426 "Learning Python, 5th Edition","import sys', 'print(sys.path)', 'x = 2', 'print(x ** 32)']",simpleAssign,426 "Learning Python, 5th Edition","import sys', 'print(sys.path)', 'x = 2', 'print(x ** 32)']",simpleAssign,426 "Learning Python, 5th Edition","IMPORT SYS\n', 'PRINT(SYS.PATH)\n', 'X = 2\n', 'PRINT(X ** 32)\n']",simpleAssign,427 "Learning Python, 5th Edition","IMPORT SYS', 'PRINT(SYS.PATH)', 'X = 2', 'PRINT(X ** 32)']",simpleAssign,427 "Learning Python, 5th Edition","True, 'impor'), (True, 'print'), (False, 'x = 2'), (False, 'print')]",simpleAssign,427 "Learning Python, 5th Edition",x = 2'],simpleAssign,428 "Learning Python, 5th Edition",fname = r'd:\books\5e\lp5e\draft1typos.txt',simpleAssign,428 "Learning Python, 5th Edition",X = 2,simpleAssign,430 "Learning Python, 5th Edition","IMPORT SYS\n', 'PRINT(SYS.PATH)\n', 'X = 2\n', 'PRINT(X ** 32)\n']",simpleAssign,430 "Learning Python, 5th Edition","IMPORT SYS\n', 'PRINT(SYS.PATH)\n', 'X = 2\n', 'PRINT(X ** 32)\n']",simpleAssign,430 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'print(x ** 32)\n', 'x = 2\n']",simpleAssign,430 "Learning Python, 5th Edition","x = 2\n', 'x = 2\n'), ('print(x ** 32)\n', 'print(x ** 32)\n')]",simpleAssign,430 "Learning Python, 5th Edition","0, 'import sys\n'), (1, 'print(sys.path)\n'), (2, 'x = 2\n'),",simpleAssign,430 "Learning Python, 5th Edition",nonempty=True,simpleAssign,430 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n']",simpleAssign,430 "Learning Python, 5th Edition",import sys\nprint(sys.path)\nx = 2\nprint(x ** 32)\n',simpleAssign,430 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n']",simpleAssign,431 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n')",simpleAssign,431 "Learning Python, 5th Edition",import sys\n&&print(sys.path)\n&&x = 2\n&&print(x ** 32)\n',simpleAssign,431 "Learning Python, 5th Edition","import sys\n', ['print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n'])",simpleAssign,431 "Learning Python, 5th Edition","11, 'import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n', 44]",simpleAssign,431 "Learning Python, 5th Edition","11, 'import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n']",simpleAssign,432 "Learning Python, 5th Edition","import sys\n', 'print(sys.path)\n', 'x = 2\n', 'print(x ** 32)\n']",simpleAssign,432 "Learning Python, 5th Edition","n', 'x = 2\n'}",simpleAssign,432 "Learning Python, 5th Edition","n', 'x = 2\n'}",simpleAssign,432 "Learning Python, 5th Edition","0: 'import sys\n', 1: 'print(sys.path)\n', 2: 'x = 2\n', 3: 'print(x ** 32)\n'}",simpleAssign,432 "Learning Python, 5th Edition","IMPORT SYS\n', 'PRINT(SYS.PATH)\n', 'X = 2\n', 'PRINT(X ** 32)\n']",simpleAssign,432 "Learning Python, 5th Edition",x = 2\n',simpleAssign,433 "Learning Python, 5th Edition",x = 2,simpleAssign,433 "Learning Python, 5th Edition","A, B = zip(*zip(X, Y)) # Unzip a zip!",simpleAssign,434 "Learning Python, 5th Edition","Z = zip((1, 2), (3, 4)) # Unlike 2.X lists, cannot index, etc.",simpleAssign,434 "Learning Python, 5th Edition","M = map(lambda x: 2 ** x, range(3))",simpleAssign,435 "Learning Python, 5th Edition","R = range(10) # range returns an iterable, not a list",simpleAssign,435 "Learning Python, 5th Edition",I = iter(R) # Make an iterator from the range iterable,simpleAssign,435 "Learning Python, 5th Edition","M = map(abs, (-1, 0, 1)) # map returns an iterable, not a list",simpleAssign,436 "Learning Python, 5th Edition","M = map(abs, (-1, 0, 1)) # Make a new iterable/iterator to scan again",simpleAssign,436 "Learning Python, 5th Edition","Z = zip((1, 2, 3), (10, 20, 30)) # zip is the same: a one-pass iterator",simpleAssign,437 "Learning Python, 5th Edition","Z = zip((1, 2, 3), (10, 20, 30))",simpleAssign,437 "Learning Python, 5th Edition","Z = zip((1, 2, 3), (10, 20, 30)) # Manual iteration (iter() not needed)",simpleAssign,437 "Learning Python, 5th Edition",R = range(3) # range allows multiple iterators,simpleAssign,438 "Learning Python, 5th Edition",I1 = iter(R),simpleAssign,438 "Learning Python, 5th Edition",I2 = iter(R) # Two iterators on one range,simpleAssign,438 "Learning Python, 5th Edition","Z = zip((1, 2, 3), (10, 11, 12))",simpleAssign,438 "Learning Python, 5th Edition",I1 = iter(Z),simpleAssign,438 "Learning Python, 5th Edition",I2 = iter(Z) # Two iterators on one zip,simpleAssign,438 "Learning Python, 5th Edition","M = map(abs, (-1, 0, 1)) # Ditto for map (and filter)",simpleAssign,438 "Learning Python, 5th Edition",I1 = iter(M); I2 = iter(M),simpleAssign,438 "Learning Python, 5th Edition",R = range(3) # But range allows many iterators,simpleAssign,438 "Learning Python, 5th Edition","I1, I2 = iter(R), iter(R)",simpleAssign,438 "Learning Python, 5th Edition","D = dict(a=1, b=2, c=3)",simpleAssign,439 "Learning Python, 5th Edition","K = D.keys() # A view object in 3.X, not a list",simpleAssign,439 "Learning Python, 5th Edition","I = iter(K) # View iterables have an iterator,",simpleAssign,439 "Learning Python, 5th Edition",K = D.keys(),simpleAssign,439 "Learning Python, 5th Edition",V = D.values() # Ditto for values() and items() views,simpleAssign,439 "Learning Python, 5th Edition",I = iter(D),simpleAssign,440 "Learning Python, 5th Edition","dir(str) == dir('') # Same result, type name or literal",simpleAssign,446 "Learning Python, 5th Edition",dir(list) == dir([]),simpleAssign,446 "Learning Python, 5th Edition",spam = 40,simpleAssign,447 "Learning Python, 5th Edition",__displayhook__ = displayhook(...),simpleAssign,450 "Learning Python, 5th Edition",spam = 40,simpleAssign,452 "Learning Python, 5th Edition","type parentheses around tests in if and while headers (e.g., if (X==1):). You can,",simpleAssign,464 "Learning Python, 5th Edition",beginners to say something like mylist = mylist.append(X) to try to get the result,simpleAssign,464 "Learning Python, 5th Edition","list, or split the method calls out to statements: Ks = list(D.keys()), then",simpleAssign,464 "Learning Python, 5th Edition",X = 5,simpleAssign,467 "Learning Python, 5th Edition",found = False,simpleAssign,467 "Learning Python, 5th Edition",i = 0,simpleAssign,467 "Learning Python, 5th Edition","myfunc('spam', 'eggs', meat=ham, *rest)",simpleAssign,473 "Learning Python, 5th Edition","name=value keyword syntax, and unpack arbitrarily many arguments to send with",simpleAssign,476 "Learning Python, 5th Edition",One way to understand this code is to realize that the def is much like an = statement:,simpleAssign,478 "Learning Python, 5th Edition",othername = func # Assign function object,simpleAssign,478 "Learning Python, 5th Edition",func.attr = value # Attach attributes,simpleAssign,478 "Learning Python, 5th Edition","x = times(3.14, 4) # Save the result object",simpleAssign,479 "Learning Python, 5th Edition","x = intersect([1, 2, 3], (1, 4)) # Mixed types",simpleAssign,482 "Learning Python, 5th Edition","For example, in the following module file, the X = 99 assignment creates a global vari-",simpleAssign,486 "Learning Python, 5th Edition","able named X (visible everywhere in this file), but the X = 88 assignment creates a",simpleAssign,486 "Learning Python, 5th Edition",X = 99 # Global (module) scope X,simpleAssign,486 "Learning Python, 5th Edition",X = 88 # Local (function) scope X: a different variable,simpleAssign,486 "Learning Python, 5th Edition","includes = statements, module names in import, function names in def, function argu-",simpleAssign,487 "Learning Python, 5th Edition","module, a statement L = X within a function will classify L as a local, but L.append(X)",simpleAssign,488 "Learning Python, 5th Edition",X = 99 # X and func assigned in module: global,simpleAssign,490 "Learning Python, 5th Edition",func(1) # func in module: result=100,simpleAssign,491 "Learning Python, 5th Edition",they are both assigned values in the function definition: Z by virtue of the = state-,simpleAssign,491 "Learning Python, 5th Edition","open = 99 # Assign in global scope, hides built-in here too",simpleAssign,492 "Learning Python, 5th Edition",X = 88 # Global X,simpleAssign,493 "Learning Python, 5th Edition","X = 99 # Local X: hides global, but we want this here",simpleAssign,493 "Learning Python, 5th Edition",it’s possible to reassign them with a statement like True = False. Don’t worry: you,simpleAssign,494 "Learning Python, 5th Edition","For more fun, though, in Python 2.X you could say __builtin__.True = False, to reset",simpleAssign,494 "Learning Python, 5th Edition",X = 88 # Global X,simpleAssign,495 "Learning Python, 5th Edition",X = 99 # Global X: outside def,simpleAssign,495 "Learning Python, 5th Edition","y, z = 1, 2 # Global variables in module",simpleAssign,495 "Learning Python, 5th Edition",X = 99,simpleAssign,496 "Learning Python, 5th Edition",X = 88,simpleAssign,496 "Learning Python, 5th Edition",X = 77,simpleAssign,496 "Learning Python, 5th Edition",X = 99 # This code doesn't know about second.py,simpleAssign,497 "Learning Python, 5th Edition",first.X = 88 # But changing it can be too subtle and implicit,simpleAssign,497 "Learning Python, 5th Edition",X = 99,simpleAssign,498 "Learning Python, 5th Edition",X = new,simpleAssign,498 "Learning Python, 5th Edition",var = 99 # Global variable == module attribute,simpleAssign,498 "Learning Python, 5th Edition",var = 0 # Change local var,simpleAssign,499 "Learning Python, 5th Edition",var = 0 # Change local var,simpleAssign,499 "Learning Python, 5th Edition",var = 0 # Change local var,simpleAssign,499 "Learning Python, 5th Edition",glob = sys.modules['thismod'] # Get module object (or use __name__),simpleAssign,499 "Learning Python, 5th Edition",An assignment (X = value) creates or changes the name X in the current local,simpleAssign,500 "Learning Python, 5th Edition",X = 99 # Global scope name: not used,simpleAssign,500 "Learning Python, 5th Edition",X = 88 # Enclosing def local,simpleAssign,500 "Learning Python, 5th Edition",X = 88,simpleAssign,501 "Learning Python, 5th Edition","action = f1() # Make, return function",simpleAssign,501 "Learning Python, 5th Edition",f = maker(2) # Pass 2 to argument N,simpleAssign,502 "Learning Python, 5th Edition","g = maker(3) # g remembers 3, f remembers 2",simpleAssign,502 "Learning Python, 5th Edition",h = maker(3),simpleAssign,502 "Learning Python, 5th Edition",x = 88,simpleAssign,504 "Learning Python, 5th Edition","ment, which is why it remains worth studying today. In short, the syntax arg=val in a",simpleAssign,504 "Learning Python, 5th Edition","Specifically, in the modified f2 here, the x=x means that the argument x will default to",simpleAssign,504 "Learning Python, 5th Edition",x = 88 # Pass x along instead of nesting,simpleAssign,505 "Learning Python, 5th Edition",x = 4,simpleAssign,505 "Learning Python, 5th Edition",x = func(),simpleAssign,505 "Learning Python, 5th Edition",x = 4,simpleAssign,505 "Learning Python, 5th Edition",acts = makeActions(),simpleAssign,506 "Learning Python, 5th Edition","acts[0](2) # All are 4 ** 2, 4=value of last i",simpleAssign,506 "Learning Python, 5th Edition","acts.append(lambda x, i=i: i ** x) # Remember current i",simpleAssign,507 "Learning Python, 5th Edition",acts = makeActions(),simpleAssign,507 "Learning Python, 5th Edition",x = 99,simpleAssign,507 "Learning Python, 5th Edition",state = start # Referencing nonlocals works normally,simpleAssign,510 "Learning Python, 5th Edition",F = tester(0),simpleAssign,510 "Learning Python, 5th Edition",state = start,simpleAssign,510 "Learning Python, 5th Edition",F = tester(0),simpleAssign,510 "Learning Python, 5th Edition",state = start # Each call gets its own state,simpleAssign,510 "Learning Python, 5th Edition",F = tester(0),simpleAssign,510 "Learning Python, 5th Edition",G = tester(42) # Make a new tester that starts at 42,simpleAssign,511 "Learning Python, 5th Edition",state = 0,simpleAssign,511 "Learning Python, 5th Edition",state = 0 # This creates the name in the module now,simpleAssign,511 "Learning Python, 5th Edition",F = tester(0),simpleAssign,511 "Learning Python, 5th Edition",spam = 99,simpleAssign,511 "Learning Python, 5th Edition",state = start # Each call gets its own state,simpleAssign,512 "Learning Python, 5th Edition",F = tester(0),simpleAssign,512 "Learning Python, 5th Edition",state = start # global allows changes in module scope,simpleAssign,513 "Learning Python, 5th Edition",F = tester(0),simpleAssign,513 "Learning Python, 5th Edition",G = tester(42) # Resets state's single copy in global scope,simpleAssign,513 "Learning Python, 5th Edition","F = tester(0) # Create instance, invoke __init__",simpleAssign,514 "Learning Python, 5th Edition",G = tester(42) # Each instance gets new copy of state,simpleAssign,514 "Learning Python, 5th Edition",H = tester(99),simpleAssign,514 "Learning Python, 5th Edition",nested.state = start # Initial state after func defined,simpleAssign,516 "Learning Python, 5th Edition",F = tester(0),simpleAssign,516 "Learning Python, 5th Edition","G = tester(42) # G has own state, doesn't overwrite F's",simpleAssign,516 "Learning Python, 5th Edition",original = builtins.open,simpleAssign,518 "Learning Python, 5th Edition",builtins.open = custom,simpleAssign,518 "Learning Python, 5th Edition",import sys\nprint(sys.path)\nx = 2\nprint(x ** 32)\n',simpleAssign,518 "Learning Python, 5th Edition",import sys\nprint(sys.path)\nx = 2\nprint(x ** 32)\n',simpleAssign,518 "Learning Python, 5th Edition",import sys\nprint(sys.path)\nx = 2\nprint(x ** 32)\n',simpleAssign,518 "Learning Python, 5th Edition",builtins.open = self,simpleAssign,518 "Learning Python, 5th Edition",a = 99 # Changes local variable a only,simpleAssign,524 "Learning Python, 5th Edition",b = 88,simpleAssign,524 "Learning Python, 5th Edition","inside a function (e.g., a=99) does not magically change a variable like b in the scope of",simpleAssign,524 "Learning Python, 5th Edition",a = 2 # Changes local name's value only,simpleAssign,525 "Learning Python, 5th Edition",X = 1,simpleAssign,525 "Learning Python, 5th Edition",X = 1,simpleAssign,525 "Learning Python, 5th Edition",a = X # They share the same object,simpleAssign,525 "Learning Python, 5th Edition","a = 2 # Resets 'a' only, 'X' is still 1",simpleAssign,525 "Learning Python, 5th Edition",b = L # They share the same object,simpleAssign,525 "Learning Python, 5th Edition",b = b[:] # Copy input list so we don't impact caller,simpleAssign,527 "Learning Python, 5th Edition",a = 2,simpleAssign,527 "Learning Python, 5th Edition",x = 2 # Changes local names only,simpleAssign,527 "Learning Python, 5th Edition",X = 1,simpleAssign,527 "Learning Python, 5th Edition","X, L = multiple(X, L) # Assign results to caller's names",simpleAssign,527 "Learning Python, 5th Edition","def f(T): (a, (b, c)) = T",simpleAssign,528 "Learning Python, 5th Edition","value by using the argument’s name in the call, with the name=value syntax.",simpleAssign,529 "Learning Python, 5th Edition","passes too few values, again using the name=value syntax.",simpleAssign,529 "Learning Python, 5th Edition",func(name=value),simpleAssign,530 "Learning Python, 5th Edition",def func(name=value),simpleAssign,530 "Learning Python, 5th Edition","def func(*, name=value)",simpleAssign,530 "Learning Python, 5th Edition","position, but using the name=value form tells Python to match by name to argu-",simpleAssign,530 "Learning Python, 5th Edition","name depending on how the caller passes it, but the name=value form specifies a",simpleAssign,530 "Learning Python, 5th Edition",value); followed by a combination of any keyword arguments (name=value) and,simpleAssign,531 "Learning Python, 5th Edition",name); followed by any default arguments (name=value); followed by the *name (or,simpleAssign,531 "Learning Python, 5th Edition",in 3.X) form; followed by any name or name=value keyword-only arguments (in,simpleAssign,531 "Learning Python, 5th Edition","annotation values, specified as name:value (or name:value=default when",simpleAssign,532 "Learning Python, 5th Edition","f(c=3, b=2, a=1)",simpleAssign,532 "Learning Python, 5th Edition","The c=3 in this call, for example, means send 3 to the argument named c. More formally,",simpleAssign,532 "Learning Python, 5th Edition","f(1, c=3, b=2) # a gets 1 by position, b and c passed by name",simpleAssign,532 "Learning Python, 5th Edition","func(name='Bob', age=40, job='dev')",simpleAssign,533 "Learning Python, 5th Edition",f(a=1),simpleAssign,533 "Learning Python, 5th Edition","f(1, c=6) # Choose defaults",simpleAssign,533 "Learning Python, 5th Edition",Be careful not to confuse the special name=value syntax in a function header and a,simpleAssign,533 "Learning Python, 5th Edition","func(1, ham=1, eggs=0) # Output: (1, 0, 0, 1)",simpleAssign,534 "Learning Python, 5th Edition","func(spam=1, eggs=0) # Output: (1, 0, 0, 0)",simpleAssign,534 "Learning Python, 5th Edition","func(toast=1, eggs=2, spam=3) # Output: (3, 2, 1, 0)",simpleAssign,534 "Learning Python, 5th Edition","name. Again, keep in mind that the form name=value means different things in the call",simpleAssign,534 "Learning Python, 5th Edition","f(a=1, b=2)",simpleAssign,535 "Learning Python, 5th Edition",args['d'] = 4,simpleAssign,535 "Learning Python, 5th Edition","func(**args) # Same as func(a=1, b=2, c=3, d=4)",simpleAssign,536 "Learning Python, 5th Edition","func(*(1, 2), **{'d': 4, 'c': 3}) # Same as func(1, 2, d=4, c=3)",simpleAssign,536 "Learning Python, 5th Edition","func(1, *(2, 3), **{'d': 4}) # Same as func(1, 2, 3, d=4)",simpleAssign,536 "Learning Python, 5th Edition","func(1, c=3, *(2,), **{'d': 4}) # Same as func(1, 2, c=3, d=4)",simpleAssign,536 "Learning Python, 5th Edition","func(1, *(2, 3), d=4) # Same as func(1, 2, 3, d=4)",simpleAssign,536 "Learning Python, 5th Edition","func(1, *(2,), c=3, **{'d':4}) # Same as func(1, 2, c=3, d=4)",simpleAssign,536 "Learning Python, 5th Edition","ter 11 (e.g., x, *y = z), though that star usage always creates lists, not",simpleAssign,536 "Learning Python, 5th Edition","action, args = func2, (1, 2, 3) # Call func2 with three args here",simpleAssign,537 "Learning Python, 5th Edition","echo(0, c=5, *pargs, **kargs) # Normal, keyword, *sequence, **dictionary",simpleAssign,538 "Learning Python, 5th Edition","kwonly(1, c=3)",simpleAssign,539 "Learning Python, 5th Edition",kwonly(a=1),simpleAssign,539 "Learning Python, 5th Edition","kwonly(c=3, b=2, a=1)",simpleAssign,539 "Learning Python, 5th Edition","f(1, 2, 3, c=7, x=4, y=5) # Anywhere in keywords",simpleAssign,541 "Learning Python, 5th Edition","f(1, *(2, 3), **dict(x=4, y=5)) # Unpack args at call",simpleAssign,541 "Learning Python, 5th Edition","f(1, *(2, 3), **dict(x=4, y=5), c=7) # Keywords before **args!",simpleAssign,541 "Learning Python, 5th Edition","f(1, *(2, 3), c=7, **dict(x=4, y=5)) # Override default",simpleAssign,541 "Learning Python, 5th Edition","f(1, c=7, *(2, 3), **dict(x=4, y=5)) # After or before *",simpleAssign,541 "Learning Python, 5th Edition","f(1, *(2, 3), **dict(x=4, y=5, c=7)) # Keyword-only in **",simpleAssign,541 "Learning Python, 5th Edition","process(X, Y, notify=True) # Override flag default",simpleAssign,541 "Learning Python, 5th Edition",res = args[0],simpleAssign,543 "Learning Python, 5th Edition",res = args[0],simpleAssign,544 "Learning Python, 5th Edition","Call signature: print3(*args, sep=' ', end='\n', file=sys.stdout)",simpleAssign,547 "Learning Python, 5th Edition","sep = kargs.get('sep', ' ') # Keyword arg defaults",simpleAssign,547 "Learning Python, 5th Edition","end = kargs.get('end', '\n')",simpleAssign,548 "Learning Python, 5th Edition","file = kargs.get('file', sys.stdout)",simpleAssign,548 "Learning Python, 5th Edition",first = True,simpleAssign,548 "Learning Python, 5th Edition",first = False,simpleAssign,548 "Learning Python, 5th Edition","print3(1, 2, 3, sep='??', end='.\n', file=sys.stderr) # Redirect to file",simpleAssign,548 "Learning Python, 5th Edition",first = True,simpleAssign,549 "Learning Python, 5th Edition",first = False,simpleAssign,549 "Learning Python, 5th Edition","sep = kargs.pop('sep', ' ')",simpleAssign,549 "Learning Python, 5th Edition","end = kargs.pop('end', '\n')",simpleAssign,549 "Learning Python, 5th Edition","file = kargs.pop('file', sys.stdout)",simpleAssign,549 "Learning Python, 5th Edition",first = True,simpleAssign,549 "Learning Python, 5th Edition",first = False,simpleAssign,549 "Learning Python, 5th Edition","widget = Button(text=""Press me"", command=someFunction)",simpleAssign,550 "Learning Python, 5th Edition","sorted(iterable, key=None, reverse=False)",simpleAssign,550 "Learning Python, 5th Edition","func(1, c=3, b=2)",simpleAssign,551 "Learning Python, 5th Edition","func(a=1, c=3, b=2)",simpleAssign,551 "Learning Python, 5th Edition","def func(a, b, c): a = 2; b[0] = 'x'; c['a'] = 'y'",simpleAssign,551 "Learning Python, 5th Edition","first, *rest = L",simpleAssign,556 "Learning Python, 5th Edition",sum = 0,simpleAssign,557 "Learning Python, 5th Edition",L = L[1:],simpleAssign,557 "Learning Python, 5th Edition",sum = 0,simpleAssign,558 "Learning Python, 5th Edition",tot = 0,simpleAssign,558 "Learning Python, 5th Edition",tot = 0,simpleAssign,559 "Learning Python, 5th Edition",items = list(L) # Start with copy of top level,simpleAssign,559 "Learning Python, 5th Edition",items[:0] = front # <== Prepend all in nested list,simpleAssign,559 "Learning Python, 5th Edition","as if it had appeared on the left of an = sign. After a def runs, the function name is simply",simpleAssign,562 "Learning Python, 5th Edition",x = echo # Now x references the function too,simpleAssign,562 "Learning Python, 5th Edition",F = make('Spam') # Label in enclosing scope is retained,simpleAssign,563 "Learning Python, 5th Edition",func.count = 0,simpleAssign,564 "Learning Python, 5th Edition","and its = character). In the following, for example, a: 'spam' = 4 means that argument",simpleAssign,566 "Learning Python, 5th Edition",act = knights(),simpleAssign,569 "Learning Python, 5th Edition",msg = act('robin') # 'robin' passed to x,simpleAssign,569 "Learning Python, 5th Edition","showall = lambda x: list(map(sys.stdout.write, x)) # 3.X: must use list",simpleAssign,572 "Learning Python, 5th Edition","t = showall(['spam\n', 'toast\n', 'eggs\n']) # 3.X: can use print",simpleAssign,572 "Learning Python, 5th Edition","t = showall(('bright\n', 'side\n', 'of\n', 'life\n'))",simpleAssign,572 "Learning Python, 5th Edition","showall = lambda x: [print(line, end='') for line in x] # Same: 3.X only",simpleAssign,572 "Learning Python, 5th Edition","showall = lambda x: print(*x, sep='', end='') # Same: 3.X only",simpleAssign,572 "Learning Python, 5th Edition",act = action(99),simpleAssign,572 "Learning Python, 5th Edition",act = action(99),simpleAssign,573 "Learning Python, 5th Edition",x = Button(,simpleAssign,573 "Learning Python, 5th Edition",res = L[0],simpleAssign,577 "Learning Python, 5th Edition",tally = sequence[0],simpleAssign,577 "Learning Python, 5th Edition","tally = function(tally, next)",simpleAssign,577 "Learning Python, 5th Edition","res = list(map(ord, 'spam')) # Apply function to sequence (or other)",simpleAssign,582 "Learning Python, 5th Edition",x for x in range(5) if x % 2 == 0],simpleAssign,583 "Learning Python, 5th Edition","list(filter((lambda x: x % 2 == 0), range(5)))",simpleAssign,583 "Learning Python, 5th Edition",x ** 2 for x in range(10) if x % 2 == 0],simpleAssign,584 "Learning Python, 5th Edition","list( map((lambda x: x**2), filter((lambda x: x % 2 == 0), range(10))) )",simpleAssign,584 "Learning Python, 5th Edition","x, y) for x in range(5) if x % 2 == 0 for y in range(5) if y % 2 == 1]",simpleAssign,585 "Learning Python, 5th Edition",x = gensquares(4),simpleAssign,594 "Learning Python, 5th Edition",y = gensquares(5) # Returns a generator which is its own iterator,simpleAssign,594 "Learning Python, 5th Edition",X = yield i,simpleAssign,596 "Learning Python, 5th Edition",G = gen(),simpleAssign,596 "Learning Python, 5th Edition","sorted((x ** 2 for x in range(4)), reverse=True) # Parens required",simpleAssign,599 "Learning Python, 5th Edition",G = timesfour('spam'),simpleAssign,603 "Learning Python, 5th Edition",I = iter(G) # Iterate manually (expression),simpleAssign,603 "Learning Python, 5th Edition",G = timesfour('spam'),simpleAssign,603 "Learning Python, 5th Edition",I = iter(G) # Iterate manually (function),simpleAssign,603 "Learning Python, 5th Edition",I1 = iter(G) # Iterate manually,simpleAssign,604 "Learning Python, 5th Edition",I2 = iter(G) # Second iterator at same position!,simpleAssign,604 "Learning Python, 5th Edition",I3 = iter(G) # Ditto for new iterators,simpleAssign,604 "Learning Python, 5th Edition",I3 = iter(c * 4 for c in 'SPAM') # New generator to start over,simpleAssign,604 "Learning Python, 5th Edition",G = timesfour('spam') # Generator functions work the same way,simpleAssign,605 "Learning Python, 5th Edition","I1, I2 = iter(G), iter(G)",simpleAssign,605 "Learning Python, 5th Edition","I1, I2 = iter(L), iter(L)",simpleAssign,605 "Learning Python, 5th Edition",x = iter(D),simpleAssign,606 "Learning Python, 5th Edition",G = os.walk(r'C:\code\pkg'),simpleAssign,607 "Learning Python, 5th Edition",I = iter(G),simpleAssign,607 "Learning Python, 5th Edition","D = dict(a='Bob', b='dev', c=40.5); D",simpleAssign,608 "Learning Python, 5th Edition","f(a='Bob', b='dev', c=40.5) # Normal keywords",simpleAssign,608 "Learning Python, 5th Edition",f(**D) # Unpack dict: key=value,simpleAssign,608 "Learning Python, 5th Edition",G = permute2('abc') # Iterate (iter() not needed),simpleAssign,613 "Learning Python, 5th Edition",permute1('spam') == list(permute2('spam')),simpleAssign,614 "Learning Python, 5th Edition",seq = list(range(10)),simpleAssign,615 "Learning Python, 5th Edition",p1 = permute1(seq) # 37 seconds on a 2GHz quad-core machine,simpleAssign,615 "Learning Python, 5th Edition",p2 = permute2(seq) # Returns generator immediately,simpleAssign,615 "Learning Python, 5th Edition","p2 = list(permute2(seq)) # About 28 seconds, though still impractical",simpleAssign,615 "Learning Python, 5th Edition",p1 == p2 # Same set of results generated,simpleAssign,615 "Learning Python, 5th Edition",p3 = permute2(list(range(50))),simpleAssign,615 "Learning Python, 5th Edition",seq = list(range(20)),simpleAssign,616 "Learning Python, 5th Edition",p = permute2(seq),simpleAssign,616 "Learning Python, 5th Edition",p = permute2(seq),simpleAssign,616 "Learning Python, 5th Edition",minlen = min(len(S) for S in seqs),simpleAssign,620 "Learning Python, 5th Edition",maxlen = max(len(S) for S in seqs),simpleAssign,620 "Learning Python, 5th Edition",index = range(maxlen),simpleAssign,620 "Learning Python, 5th Edition",minlen = min(len(S) for S in seqs),simpleAssign,621 "Learning Python, 5th Edition","iters = map(iter, args)",simpleAssign,621 "Learning Python, 5th Edition","iters = list(map(iter, args)) # Allow multiple scans",simpleAssign,622 "Learning Python, 5th Edition",X = 99,simpleAssign,623 "Learning Python, 5th Edition",Y = 99,simpleAssign,623 "Learning Python, 5th Edition",X = 99,simpleAssign,624 "Learning Python, 5th Edition",Y = 99,simpleAssign,624 "Learning Python, 5th Edition",res = set(),simpleAssign,624 "Learning Python, 5th Edition",res[x] = x * x,simpleAssign,625 "Learning Python, 5th Edition",x * x for x in range(10) if x % 2 == 0] # Lists are ordered,simpleAssign,625 "Learning Python, 5th Edition",x * x for x in range(10) if x % 2 == 0} # But sets are not,simpleAssign,625 "Learning Python, 5th Edition",x: x * x for x in range(10) if x % 2 == 0} # Neither are dict keys,simpleAssign,625 "Learning Python, 5th Edition",start = time.clock(),simpleAssign,630 "Learning Python, 5th Edition",timer = time.clock if sys.platform[:3] == 'win' else time.time,simpleAssign,630 "Learning Python, 5th Edition","repslist = list(range(reps)) # Hoist out, equalize 2.x, 3.x",simpleAssign,631 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,631 "Learning Python, 5th Edition",elapsed = timer() - start,simpleAssign,631 "Learning Python, 5th Edition",best = 2 ** 32 # 136 years seems large enough,simpleAssign,631 "Learning Python, 5th Edition",start = timer(),simpleAssign,631 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,631 "Learning Python, 5th Edition",elapsed = timer() - start # Or call total() with reps=1,simpleAssign,631 "Learning Python, 5th Edition",if elapsed < best: best = elapsed # Or add to list and take min(),simpleAssign,631 "Learning Python, 5th Edition",timer = time.clock if sys.platform[:3] == 'win' else time.time,simpleAssign,633 "Learning Python, 5th Edition",timer = time.clock if sys.platform[:3] == 'win' else time.time,simpleAssign,634 "Learning Python, 5th Edition",reps = 10000,simpleAssign,634 "Learning Python, 5th Edition","repslist = list(range(reps)) # Hoist out, list in both 2.X/3.X",simpleAssign,634 "Learning Python, 5th Edition","bestof, (total, result)) = timer.bestoftotal(5, 1000, test)",simpleAssign,634 "Learning Python, 5th Edition","total(spam, 1, 2, a=3, b=4, _reps=1000) calls and times spam(1, 2, a=3, b=4)",simpleAssign,639 "Learning Python, 5th Edition","bestof(spam, 1, 2, a=3, b=4, _reps=5) runs best-of-N timer to attempt to",simpleAssign,639 "Learning Python, 5th Edition","bestoftotal(spam 1, 2, a=3, b=4, _rep1=5, reps=1000) runs best-of-totals",simpleAssign,639 "Learning Python, 5th Edition",timer = time.clock if sys.platform[:3] == 'win' else time.time,simpleAssign,639 "Learning Python, 5th Edition","_reps = kargs.pop('_reps', 1000) # Passed-in or default reps",simpleAssign,639 "Learning Python, 5th Edition",repslist = list(range(_reps)) # Hoist range out for 2.X lists,simpleAssign,639 "Learning Python, 5th Edition",start = timer(),simpleAssign,639 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,639 "Learning Python, 5th Edition",elapsed = timer() - start,simpleAssign,639 "Learning Python, 5th Edition","_reps = kargs.pop('_reps', 5)",simpleAssign,639 "Learning Python, 5th Edition",best = 2 ** 32,simpleAssign,639 "Learning Python, 5th Edition",start = timer(),simpleAssign,639 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,639 "Learning Python, 5th Edition",elapsed = timer() - start,simpleAssign,639 "Learning Python, 5th Edition",if elapsed < best: best = elapsed,simpleAssign,639 "Learning Python, 5th Edition","_reps1 = kargs.pop('_reps1', 5)",simpleAssign,639 "Learning Python, 5th Edition","total, result) = timer2.bestoftotal(test, _reps1=5, _reps=1000)",simpleAssign,640 "Learning Python, 5th Edition","total, result) = timer2.bestoftotal(test)",simpleAssign,640 "Learning Python, 5th Edition","total, result) = timer2.bestof(test, _reps=5)",simpleAssign,640 "Learning Python, 5th Edition","total, result) = timer2.total(test, _reps=1000)",simpleAssign,640 "Learning Python, 5th Edition","bestof, (total, result)) = timer2.bestof(timer2.total, test, _reps=5)",simpleAssign,640 "Learning Python, 5th Edition","total(pow, 2, 1000, _reps=1000)[0] # 2 ** 1000, 1K reps",simpleAssign,640 "Learning Python, 5th Edition","total(pow, 2, 1000, _reps=1000000)[0] # 2 ** 1000, 1M reps",simpleAssign,640 "Learning Python, 5th Edition","bestof(pow, 2, 1000000, _reps=30)[0] # 2 ** 1M, best of 30",simpleAssign,640 "Learning Python, 5th Edition","bestoftotal(str.upper, 'spam', _reps1=30, _reps=1000) # Best of 30, tot of 1K",simpleAssign,640 "Learning Python, 5th Edition","bestof(total, str.upper, 'spam', _reps=30) # Nested calls work too",simpleAssign,640 "Learning Python, 5th Edition","total(spam, 1, 2, c=3, d=4, _reps=1000)",simpleAssign,640 "Learning Python, 5th Edition","bestof(spam, 1, 2, c=3, d=4, _reps=1000)",simpleAssign,640 "Learning Python, 5th Edition","bestoftotal(spam, 1, 2, c=3, d=4, _reps1=1000, _reps=1000)",simpleAssign,640 "Learning Python, 5th Edition","bestoftotal(spam, *(1, 2), _reps1=1000, _reps=1000, **dict(c=3, d=4))",simpleAssign,640 "Learning Python, 5th Edition",timer = time.clock if sys.platform[:3] == 'win' else time.time,simpleAssign,641 "Learning Python, 5th Edition",start = timer(),simpleAssign,641 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,641 "Learning Python, 5th Edition",elapsed = timer() - start,simpleAssign,641 "Learning Python, 5th Edition",best = 2 ** 32,simpleAssign,641 "Learning Python, 5th Edition",start = timer(),simpleAssign,641 "Learning Python, 5th Edition","ret = func(*pargs, **kargs)",simpleAssign,641 "Learning Python, 5th Edition",elapsed = timer() - start,simpleAssign,641 "Learning Python, 5th Edition",if elapsed < best: best = elapsed,simpleAssign,641 "Learning Python, 5th Edition","elapsed, ret) = total(func, *pargs, _reps=1, **kargs)",simpleAssign,641 "Learning Python, 5th Edition","min(timeit.repeat(stmt=""[x ** 2 for x in range(1000)]"", number=1000, repeat=5))",simpleAssign,643 "Learning Python, 5th Edition","min(timeit.repeat(stmt=""[x ** 2 for x in range(1000)]"", number=1000, repeat=5))",simpleAssign,643 "Learning Python, 5th Edition","min(timeit.repeat(stmt=""[x ** 2 for x in range(1000)]"", number=1000, repeat=5))",simpleAssign,643 "Learning Python, 5th Edition","min(timeit.repeat(number=10000, repeat=3,",simpleAssign,645 "Learning Python, 5th Edition","min(timeit.repeat(number=10000, repeat=3,",simpleAssign,645 "Learning Python, 5th Edition","min(timeit.repeat(number=10000, repeat=3,",simpleAssign,645 "Learning Python, 5th Edition","i=0"" ""while i < len(L):""",simpleAssign,646 "Learning Python, 5th Edition","min(repeat(number=1000, repeat=3,",simpleAssign,646 "Learning Python, 5th Edition","vals=list(range(1000))',",simpleAssign,646 "Learning Python, 5th Edition","min(repeat(number=1000, repeat=3,",simpleAssign,646 "Learning Python, 5th Edition","timeit.timeit(stmt='[x ** 2 for x in range(1000)]', number=1000) # Total time",simpleAssign,647 "Learning Python, 5th Edition","timeit.repeat(stmt='[x ** 2 for x in range(1000)]', number=1000, repeat=3)",simpleAssign,647 "Learning Python, 5th Edition","min(timeit.repeat(stmt=testcase, number=1000, repeat=3))",simpleAssign,647 "Learning Python, 5th Edition","defnum, defrep= 1000, 5 # May vary per stmt",simpleAssign,648 "Learning Python, 5th Edition","pythons: None=this python only, or [(ispy3?, python-executable-path)]",simpleAssign,648 "Learning Python, 5th Edition",number = number or defnum,simpleAssign,648 "Learning Python, 5th Edition",repeat = repeat or defrep # 0=default,simpleAssign,648 "Learning Python, 5th Edition",ispy3 = sys.version[0] == '3',simpleAssign,648 "Learning Python, 5th Edition","stmt = stmt.replace('$listif3', 'list' if ispy3 else '')",simpleAssign,648 "Learning Python, 5th Edition","best = min(timeit.repeat(stmt=stmt, number=number, repeat=repeat))",simpleAssign,648 "Learning Python, 5th Edition","stmt1 = stmt.replace('$listif3', 'list' if ispy3 else '')",simpleAssign,648 "Learning Python, 5th Edition","stmt1 = stmt1.replace('\t', ' ' * 4)",simpleAssign,648 "Learning Python, 5th Edition",lines = stmt1.split('\n'),simpleAssign,648 "Learning Python, 5th Edition","nfor x in range(1000): res.append(x ** 2)""), # \n=multistmt",simpleAssign,649 "Learning Python, 5th Edition","0, 0, ""$listif3(map(lambda x: x ** 2, range(1000)))""), # \n\t=indent",simpleAssign,649 "Learning Python, 5th Edition","0, 0, ""list(x ** 2 for x in range(1000))""), # $=list or ''",simpleAssign,649 "Learning Python, 5th Edition","pythons = pythons if '-a' in sys.argv else None # -a: all in list, else one?",simpleAssign,649 "Learning Python, 5th Edition","0, 0, ""s=set()\nfor x in range(1000): s.add(x ** 2)""),",simpleAssign,652 "Learning Python, 5th Edition","0, 0, ""d={}\nfor x in range(1000): d[x] = x ** 2""),",simpleAssign,652 "Learning Python, 5th Edition",0.6053 ['s=set()\nfor x in range(1000): s.add(x ** 2)'],simpleAssign,652 "Learning Python, 5th Edition",0.5414 ['d={}\nfor x in range(1000): d[x] = x ** 2'],simpleAssign,652 "Learning Python, 5th Edition","x=line"" ""f.close()""",simpleAssign,653 "Learning Python, 5th Edition","min(timeit.repeat(number=1000, repeat=5,",simpleAssign,653 "Learning Python, 5th Edition",best = min(timeit.repeat(,simpleAssign,655 "Learning Python, 5th Edition","setup=setup, stmt=stmt, number=number, repeat=repeat))",simpleAssign,655 "Learning Python, 5th Edition","setup = setup.replace('\t', ' ' * 4)",simpleAssign,655 "Learning Python, 5th Edition",Pystone(1.1) time for 50000 passes = 0.685303,simpleAssign,656 "Learning Python, 5th Edition",Pystone(1.1) time for 50000 passes = 0.463547,simpleAssign,656 "Learning Python, 5th Edition",Pystone(1.1) time for 50000 passes = 0.099975,simpleAssign,656 "Learning Python, 5th Edition",X = 99,simpleAssign,657 "Learning Python, 5th Edition",X = 88 # X classified as a local name (everywhere),simpleAssign,657 "Learning Python, 5th Edition",X = 88,simpleAssign,657 "Learning Python, 5th Edition",X = 99,simpleAssign,658 "Learning Python, 5th Edition",X = 88 # Unqualified X classified as local,simpleAssign,658 "Learning Python, 5th Edition","x = x or [], which takes advantage of the fact that Python’s or returns one of its",simpleAssign,659 "Learning Python, 5th Edition",x = proc('testing 123...'),simpleAssign,660 "Learning Python, 5th Edition","list = list.append(4) # append is a ""procedure""",simpleAssign,660 "Learning Python, 5th Edition","ments. Does the call adder(ugly=1, good=2) work? Why? Finally, generalize the",simpleAssign,663 "Learning Python, 5th Edition","f1(b=2, a=1)",simpleAssign,664 "Learning Python, 5th Edition","f3(1, x=2, y=3)",simpleAssign,664 "Learning Python, 5th Edition","f4(1, 2, 3, x=2, y=3)",simpleAssign,664 "Learning Python, 5th Edition",x = y // 2 # For some y > 1,simpleAssign,664 "Learning Python, 5th Edition",spam = 1 # Initialize variable,simpleAssign,690 "Learning Python, 5th Edition","In this example, the print and = statements run the first time the module is imported,",simpleAssign,690 "Learning Python, 5th Edition",simple.spam = 2 # Change attribute in module,simpleAssign,691 "Learning Python, 5th Edition",x = 1,simpleAssign,691 "Learning Python, 5th Edition",x = 42 # Changes local x only,simpleAssign,691 "Learning Python, 5th Edition",y[0] = 42 # Changes shared mutable in place,simpleAssign,691 "Learning Python, 5th Edition",x = 42 # Changes my x only,simpleAssign,692 "Learning Python, 5th Edition",small.x = 42 # Changes x in other module,simpleAssign,692 "Learning Python, 5th Edition",name1 = module.name1 # Copy names out by assignment,simpleAssign,692 "Learning Python, 5th Edition",name2 = module.name2,simpleAssign,692 "Learning Python, 5th Edition","For instance, given an assignment statement such as X = 1 at the top level of a module",simpleAssign,695 "Learning Python, 5th Edition",name = 42,simpleAssign,695 "Learning Python, 5th Edition",X = 88 # My X: global to this file only,simpleAssign,698 "Learning Python, 5th Edition",X = 99 # Cannot see names in other modules,simpleAssign,698 "Learning Python, 5th Edition",X = 11 # My X: global to this file only,simpleAssign,698 "Learning Python, 5th Edition",X = 3,simpleAssign,699 "Learning Python, 5th Edition",X = 2,simpleAssign,699 "Learning Python, 5th Edition",X = 1,simpleAssign,699 "Learning Python, 5th Edition",x = 1,simpleAssign,711 "Learning Python, 5th Edition",y = 2,simpleAssign,711 "Learning Python, 5th Edition",z = 3,simpleAssign,712 "Learning Python, 5th Edition",X = 99999,simpleAssign,725 "Learning Python, 5th Edition",X = 99999,simpleAssign,725 "Learning Python, 5th Edition",X = 99999,simpleAssign,726 "Learning Python, 5th Edition","Works if in ""."" = home of main script file",simpleAssign,730 "Learning Python, 5th Edition",import sub.spam # <== Works if move modules to pkg below main file,simpleAssign,731 "Learning Python, 5th Edition",c:\code> set PYTHONPATH=C:\code,simpleAssign,732 "Learning Python, 5th Edition",import dualpkg.m1 as m1 # And: set PYTHONPATH=c:\code,simpleAssign,733 "Learning Python, 5th Edition",c:\code> set PYTHONPATH=C:\code\ns\dir1;C:\code\ns\dir2,simpleAssign,737 "Learning Python, 5th Edition","c:\code> set PYTHONPATH= c:\code> py −3.2",simpleAssign,740 "Learning Python, 5th Edition",c:\code> set PYTHONPATH=C:\code\ns3\dir,simpleAssign,740 "Learning Python, 5th Edition",c:\code> set PYTHONPATH=c:\code\ns4\dir1;c:\code\ns4\dir2,simpleAssign,741 "Learning Python, 5th Edition","a, _b, c, _d = 1, 2, 3, 4",simpleAssign,747 "Learning Python, 5th Edition","a, b, _c, _d = 1, 2, 3, 4",simpleAssign,748 "Learning Python, 5th Edition",res = args[0],simpleAssign,750 "Learning Python, 5th Edition",res = args[0],simpleAssign,750 "Learning Python, 5th Edition",digits = str(N),simpleAssign,752 "Learning Python, 5th Edition","digits, last3 = digits[:-3], digits[-3:]",simpleAssign,752 "Learning Python, 5th Edition","numwidth=0 for no space padding, currency='' to omit symbol,",simpleAssign,752 "Learning Python, 5th Edition","and non-ASCII for others (e.g., pound=u'\xA3' or u'\u00A3').",simpleAssign,752 "Learning Python, 5th Edition",N = abs(N),simpleAssign,752 "Learning Python, 5th Edition",whole = commas(int(N)),simpleAssign,752 "Learning Python, 5th Edition","tests = 0, 1 # fails: −1, 1.23",simpleAssign,752 "Learning Python, 5th Edition","tests = 0, 1, −1, 1.23, 1., 1.2, 3.14159",simpleAssign,752 "Learning Python, 5th Edition",X = 99999999999999999999,simpleAssign,753 "Learning Python, 5th Edition",X = 54321.987,simpleAssign,754 "Learning Python, 5th Edition",c:\code> set PYTHONIOENCODING=utf-8 # Python matches console,simpleAssign,755 "Learning Python, 5th Edition","money(N, numwidth=0, currency='$')",simpleAssign,756 "Learning Python, 5th Edition","numwidth=0 for no space padding, currency='' to omit symbol,",simpleAssign,756 "Learning Python, 5th Edition","and non-ASCII for others (e.g., pound=u'£' or u'£').",simpleAssign,756 "Learning Python, 5th Edition",name = modulename,simpleAssign,758 "Learning Python, 5th Edition","of the global statement. For instance, the effect of global X; X=0 can be simulated (albeit with much",simpleAssign,759 "Learning Python, 5th Edition",more typing!) by saying this inside a function: import sys; glob=sys.modules[__name__]; glob.X=0.,simpleAssign,759 "Learning Python, 5th Edition",seplen = 60,simpleAssign,760 "Learning Python, 5th Edition",sepline = sepchr * seplen,simpleAssign,760 "Learning Python, 5th Edition",count = 0,simpleAssign,760 "Learning Python, 5th Edition",string = __import__(modname),simpleAssign,762 "Learning Python, 5th Edition",string = importlib.import_module(modname),simpleAssign,763 "Learning Python, 5th Edition",visited[module] = True,simpleAssign,764 "Learning Python, 5th Edition",if type(attrobj) == types.ModuleType: # Recur if module,simpleAssign,764 "Learning Python, 5th Edition",if len(sys.argv) > 1: modname = sys.argv[1] # command line (or passed),simpleAssign,765 "Learning Python, 5th Edition",module = importlib.import_module(modname) # Import by name string,simpleAssign,765 "Learning Python, 5th Edition",X = 1,simpleAssign,766 "Learning Python, 5th Edition",Y = 2,simpleAssign,766 "Learning Python, 5th Edition",Z = 3 # File c.py,simpleAssign,766 "Learning Python, 5th Edition",next = modules.pop() # Delete next item at end,simpleAssign,768 "Learning Python, 5th Edition",if type(x) == types.ModuleType and x not in visited),simpleAssign,768 "Learning Python, 5th Edition","res1 == res2, res2 == res3",simpleAssign,770 "Learning Python, 5th Edition","set(res1) == set(res2), set(res2) == set(res3)",simpleAssign,770 "Learning Python, 5th Edition",X = 99,simpleAssign,772 "Learning Python, 5th Edition","X = 88 # Changes my ""X"" only!",simpleAssign,772 "Learning Python, 5th Edition",nested1.X = 88 # OK: change nested1's X,simpleAssign,773 "Learning Python, 5th Edition",X = 1,simpleAssign,775 "Learning Python, 5th Edition",Y = 2,simpleAssign,776 "Learning Python, 5th Edition",I1 = C1() # Make instance objects (rectangles),simpleAssign,789 "Learning Python, 5th Edition",I2 = C1() # Linked to their classes,simpleAssign,789 "Learning Python, 5th Edition",I1 = C1() # Make two instances,simpleAssign,790 "Learning Python, 5th Edition",I2 = C1(),simpleAssign,790 "Learning Python, 5th Edition",I1 = C1('bob') # Sets I1.name to 'bob',simpleAssign,791 "Learning Python, 5th Edition",I2 = C1('sue') # Sets I2.name to 'sue',simpleAssign,791 "Learning Python, 5th Edition",bob = Employee() # Default behavior,simpleAssign,793 "Learning Python, 5th Edition",sue = Employee() # Default behavior,simpleAssign,793 "Learning Python, 5th Edition",tom = Engineer() # Custom salary calculator,simpleAssign,793 "Learning Python, 5th Edition",data = converter(data),simpleAssign,794 "Learning Python, 5th Edition",x = FirstClass() # Make two instances,simpleAssign,799 "Learning Python, 5th Edition",y = FirstClass() # Each is a new namespace,simpleAssign,799 "Learning Python, 5th Edition",z = SecondClass(),simpleAssign,803 "Learning Python, 5th Edition",var = 1 # food.var,simpleAssign,804 "Learning Python, 5th Edition",x = person.person() # Class within module,simpleAssign,804 "Learning Python, 5th Edition",x = person() # Use class name,simpleAssign,804 "Learning Python, 5th Edition",x = person.Person() # Uppercase for classes,simpleAssign,805 "Learning Python, 5th Edition",a = ThirdClass('abc') # __init__ called,simpleAssign,807 "Learning Python, 5th Edition",rec.age = 40,simpleAssign,809 "Learning Python, 5th Edition",x = rec() # Instances inherit class names,simpleAssign,809 "Learning Python, 5th Edition",y = rec(),simpleAssign,809 "Learning Python, 5th Edition",rec.method = uppername # Now it's a class's method!,simpleAssign,811 "Learning Python, 5th Edition","rec['age'] = 40.5 # Or {...}, dict(n=v), etc.",simpleAssign,812 "Learning Python, 5th Edition",rec.age = 40.5,simpleAssign,812 "Learning Python, 5th Edition",pers1 = rec() # Instance-based records,simpleAssign,813 "Learning Python, 5th Edition",pers1.age = 40.5,simpleAssign,813 "Learning Python, 5th Edition",pers2 = rec(),simpleAssign,813 "Learning Python, 5th Edition","rec1 = Person('Bob', ['dev', 'mgr'], 40.5) # Construction calls",simpleAssign,813 "Learning Python, 5th Edition","rec2 = Person('Sue', ['dev', 'cto'])",simpleAssign,813 "Learning Python, 5th Edition","rec = Rec('Bob', 40.5, ['dev', 'mgr']) # Named tuples",simpleAssign,814 "Learning Python, 5th Edition",bob = Person('Bob Smith') # Test the class,simpleAssign,820 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000) # Runs __init__ automatically",simpleAssign,820 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,821 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,821 "Learning Python, 5th Edition","pay = 100000 # Simple variable, outside class",simpleAssign,823 "Learning Python, 5th Edition",pay *= 1.10 # Give a 10% raise,simpleAssign,823 "Learning Python, 5th Edition","Or: pay = pay * 1.10, if you like to type",simpleAssign,823 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,823 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,823 "Learning Python, 5th Edition",sue.pay *= 1.10 # Give this object a raise,simpleAssign,823 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,824 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,824 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,827 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,827 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,831 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,831 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 'mgr', 50000) # Make a Manager: __init__",simpleAssign,831 "Learning Python, 5th Edition",tom = Manager(),simpleAssign,833 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,835 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,835 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 50000) # Job name not needed:",simpleAssign,835 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,838 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,838 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 50000)",simpleAssign,838 "Learning Python, 5th Edition","development = Department(bob, sue) # Embed objects in a composite",simpleAssign,838 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,841 "Learning Python, 5th Edition",instances with their class names and a name=value pair for,simpleAssign,842 "Learning Python, 5th Edition",count = 0,simpleAssign,842 "Learning Python, 5th Edition","X, Y = TopTest(), SubTest() # Make two instances",simpleAssign,843 "Learning Python, 5th Edition","TopTest: attr1=0, attr2=1]",simpleAssign,843 "Learning Python, 5th Edition","SubTest: attr1=2, attr2=3]",simpleAssign,843 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,843 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,846 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,846 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 50000)",simpleAssign,846 "Learning Python, 5th Edition","Person: job=None, name=Bob Smith, pay=0]",simpleAssign,846 "Learning Python, 5th Edition","Person: job=dev, name=Sue Jones, pay=100000]",simpleAssign,846 "Learning Python, 5th Edition","Person: job=dev, name=Sue Jones, pay=110000]",simpleAssign,846 "Learning Python, 5th Edition","Manager: job=mgr, name=Tom Jones, pay=60000]",simpleAssign,846 "Learning Python, 5th Edition",bob = Person(...) # Use name directly,simpleAssign,849 "Learning Python, 5th Edition",bob = Person('Bob Smith') # Re-create objects to be stored,simpleAssign,849 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,849 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 50000)",simpleAssign,849 "Learning Python, 5th Edition",db[obj.name] = obj # Store object on shelve by key,simpleAssign,849 "Learning Python, 5th Edition",bob = db['Bob Smith'] # Fetch bob by key,simpleAssign,850 "Learning Python, 5th Edition","Person: job=None, name=Bob Smith, pay=0]",simpleAssign,850 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=100000]",simpleAssign,851 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,851 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,851 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,851 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=100000]",simpleAssign,851 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,851 "Learning Python, 5th Edition",sue = db['Sue Jones'] # Index by key to fetch,simpleAssign,852 "Learning Python, 5th Edition",db['Sue Jones'] = sue # Assign to key to update in shelve,simpleAssign,852 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,852 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=100000]",simpleAssign,852 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,852 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,852 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=110000]",simpleAssign,852 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,852 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,852 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=121000]",simpleAssign,852 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,852 "Learning Python, 5th Edition","Bob Smith => [Person: job=None, name=Bob Smith, pay=0]",simpleAssign,852 "Learning Python, 5th Edition","Sue Jones => [Person: job=dev, name=Sue Jones, pay=133100]",simpleAssign,852 "Learning Python, 5th Edition","Tom Jones => [Manager: job=mgr, name=Tom Jones, pay=50000]",simpleAssign,852 "Learning Python, 5th Edition",rec = db['Sue Jones'] # Fetch object by key,simpleAssign,852 "Learning Python, 5th Edition","Person: job=dev, name=Sue Jones, pay=146410]",simpleAssign,852 "Learning Python, 5th Edition",attr = value # Shared class data,simpleAssign,860 "Learning Python, 5th Edition",spam = 42 # Generates a class data attribute,simpleAssign,861 "Learning Python, 5th Edition",x = SharedData() # Make two instances,simpleAssign,861 "Learning Python, 5th Edition",y = SharedData(),simpleAssign,861 "Learning Python, 5th Edition",SharedData.spam = 99,simpleAssign,861 "Learning Python, 5th Edition",x.spam = 88,simpleAssign,861 "Learning Python, 5th Edition",contains an = assignment statement; because this assignment assigns the name data,simpleAssign,862 "Learning Python, 5th Edition",x = MixedNames(1) # Make two instance objects,simpleAssign,862 "Learning Python, 5th Edition",y = MixedNames(2) # Each has its own data,simpleAssign,862 "Learning Python, 5th Edition",x = NextClass() # Make instance,simpleAssign,863 "Learning Python, 5th Edition","I = Sub(1, 2)",simpleAssign,864 "Learning Python, 5th Edition",x = Super() # Make a Super instance,simpleAssign,867 "Learning Python, 5th Edition",x = Sub() # Make a Sub instance,simpleAssign,867 "Learning Python, 5th Edition",x = Provider(),simpleAssign,868 "Learning Python, 5th Edition",X = Super(),simpleAssign,870 "Learning Python, 5th Edition",X = Sub(),simpleAssign,870 "Learning Python, 5th Edition",X = Sub(),simpleAssign,870 "Learning Python, 5th Edition",X = Super(),simpleAssign,871 "Learning Python, 5th Edition",X = Sub(),simpleAssign,871 "Learning Python, 5th Edition",X = Sub(),simpleAssign,871 "Learning Python, 5th Edition",Assignment (X = value),simpleAssign,872 "Learning Python, 5th Edition",Assignment (object.X = value),simpleAssign,872 "Learning Python, 5th Edition","X = 11 # Global (module) name/attribute (X, or manynames.X)",simpleAssign,873 "Learning Python, 5th Edition","X = 22 # Local (function) variable (X, hides module X)",simpleAssign,873 "Learning Python, 5th Edition",X = 33 # Class attribute (C.X),simpleAssign,873 "Learning Python, 5th Edition",X = 44 # Local variable in method (X),simpleAssign,873 "Learning Python, 5th Edition",obj = C() # Make instance,simpleAssign,874 "Learning Python, 5th Edition",X = 66,simpleAssign,874 "Learning Python, 5th Edition",I = manynames.C(),simpleAssign,874 "Learning Python, 5th Edition",X = 11 # Global in module,simpleAssign,875 "Learning Python, 5th Edition",X = 22 # Change global in module,simpleAssign,875 "Learning Python, 5th Edition",X = 33 # Local in function,simpleAssign,875 "Learning Python, 5th Edition",X = 33 # Local in function,simpleAssign,875 "Learning Python, 5th Edition",X = 44 # Change local in enclosing scope,simpleAssign,875 "Learning Python, 5th Edition",X = 1,simpleAssign,876 "Learning Python, 5th Edition",X = 3 # Hides global,simpleAssign,876 "Learning Python, 5th Edition",I = C(),simpleAssign,876 "Learning Python, 5th Edition",X = 1,simpleAssign,876 "Learning Python, 5th Edition",X = 2 # Hides global,simpleAssign,876 "Learning Python, 5th Edition",X = 3 # Hides enclosing (nester),simpleAssign,877 "Learning Python, 5th Edition",I = C(),simpleAssign,877 "Learning Python, 5th Edition",X = 1,simpleAssign,877 "Learning Python, 5th Edition",X = 2 # Hides global,simpleAssign,877 "Learning Python, 5th Edition",X = 3 # Class local hides nester's: C.X or I.X (not scoped),simpleAssign,877 "Learning Python, 5th Edition","X = 4 # Hides enclosing (nester, not class)",simpleAssign,877 "Learning Python, 5th Edition",I = C(),simpleAssign,877 "Learning Python, 5th Edition",X = Sub(),simpleAssign,878 "Learning Python, 5th Edition",Y = Sub(),simpleAssign,878 "Learning Python, 5th Edition",bob = Person(),simpleAssign,881 "Learning Python, 5th Edition",x = docstr.spam(),simpleAssign,883 "Learning Python, 5th Edition",2. When a simple assignment statement (X = Y) appears at the top level of a class,simpleAssign,885 "Learning Python, 5th Edition","X = Number(5) # Number.__init__(X, 5)",simpleAssign,888 "Learning Python, 5th Edition","Y = X - 2 # Number.__sub__(X, 2)",simpleAssign,888 "Learning Python, 5th Edition",Object creation: X = Class(args),simpleAssign,889 "Learning Python, 5th Edition","X | Y, X |= Y if no __ior__",simpleAssign,889 "Learning Python, 5th Edition",X.any = value,simpleAssign,889 "Learning Python, 5th Edition","X[key] = value, X[i:j] = iterable",simpleAssign,889 "Learning Python, 5th Edition","X < Y, X > Y, X <= Y, X >= Y, X == Y, X != Y",simpleAssign,889 "Learning Python, 5th Edition","I=iter(X), next(I); for loops, in if no __con",simpleAssign,889 "Learning Python, 5th Edition","X.attr, X.attr = value, del X.attr",simpleAssign,889 "Learning Python, 5th Edition","s ""L = list(range(100))"" ""x = L.__len__()""",simpleAssign,890 "Learning Python, 5th Edition","s ""L = list(range(100))"" ""x = len(L)""",simpleAssign,890 "Learning Python, 5th Edition","s ""L = list(range(100))"" ""x = L.__len__()""",simpleAssign,890 "Learning Python, 5th Edition","s ""L = list(range(100))"" ""x = len(L)""",simpleAssign,890 "Learning Python, 5th Edition",X = Indexer(),simpleAssign,891 "Learning Python, 5th Edition",X = Indexer(),simpleAssign,892 "Learning Python, 5th Edition",X = Indexer(),simpleAssign,892 "Learning Python, 5th Edition",X = C(),simpleAssign,894 "Learning Python, 5th Edition",X = StepperIndex() # X is a StepperIndex object,simpleAssign,894 "Learning Python, 5th Edition","a, b, c, d) = X # Sequence assignments",simpleAssign,895 "Learning Python, 5th Edition",if self.value == self.stop: # Also called by next built-in,simpleAssign,896 "Learning Python, 5th Edition","X = Squares(1, 5) # Iterate manually: what loops do",simpleAssign,897 "Learning Python, 5th Edition",I = iter(X) # iter calls __iter__,simpleAssign,897 "Learning Python, 5th Edition","X = Squares(1, 5)",simpleAssign,897 "Learning Python, 5th Edition","X = Squares(1, 5) # Make an iterable with state",simpleAssign,897 "Learning Python, 5th Edition","a, b, c = Squares(1, 3) # Each calls __iter__ and then __next__",simpleAssign,898 "Learning Python, 5th Edition","X = Squares(1, 5)",simpleAssign,898 "Learning Python, 5th Edition","X = list(Squares(1, 5))",simpleAssign,898 "Learning Python, 5th Edition",if self.offset >= len(self.wrapped): # Terminate iterations,simpleAssign,900 "Learning Python, 5th Edition",item = self.wrapped[self.offset] # else return and skip,simpleAssign,900 "Learning Python, 5th Edition",skipper = SkipObject(alpha) # Make container object,simpleAssign,900 "Learning Python, 5th Edition",I = iter(skipper) # Make an iterator on it,simpleAssign,900 "Learning Python, 5th Edition",next = __next__ # 2.X/3.X compatibility,simpleAssign,900 "Learning Python, 5th Edition",S = S[::2],simpleAssign,901 "Learning Python, 5th Edition",G = gen(5) # Create a generator with __iter__ and __next__,simpleAssign,902 "Learning Python, 5th Edition",G.__iter__() == G # Both methods exist on the same object,simpleAssign,902 "Learning Python, 5th Edition",I = iter(G) # Runs __iter__: generator returns itself,simpleAssign,902 "Learning Python, 5th Edition","S = Squares(1, 5) # Runs __init__: class saves instance state",simpleAssign,903 "Learning Python, 5th Edition",I = iter(S) # Runs __iter__: returns a generator,simpleAssign,903 "Learning Python, 5th Edition","S = Squares(1, 5)",simpleAssign,903 "Learning Python, 5th Edition",I = iter(S.gen()) # Call generator manually for iterable/iterator,simpleAssign,903 "Learning Python, 5th Edition","S = Squares(1, 5)",simpleAssign,904 "Learning Python, 5th Edition",I = iter(S),simpleAssign,904 "Learning Python, 5th Edition","J = iter(S) # With yield, multiple iterators automatic",simpleAssign,904 "Learning Python, 5th Edition","S = Squares(1, 3)",simpleAssign,904 "Learning Python, 5th Edition","S = Squares(1, 5)",simpleAssign,905 "Learning Python, 5th Edition",I = iter(S),simpleAssign,905 "Learning Python, 5th Edition",J = iter(S) # Multiple iterators without yield,simpleAssign,905 "Learning Python, 5th Edition","S = Squares(1, 3)",simpleAssign,905 "Learning Python, 5th Edition",offset = 0,simpleAssign,906 "Learning Python, 5th Edition",item = self.wrapped[offset],simpleAssign,906 "Learning Python, 5th Edition",skipper = SkipObject('abcdef'),simpleAssign,906 "Learning Python, 5th Edition",I = iter(skipper),simpleAssign,906 "Learning Python, 5th Edition",if self.ix == len(self.data): raise StopIteration,simpleAssign,907 "Learning Python, 5th Edition",item = self.data[self.ix],simpleAssign,907 "Learning Python, 5th Edition",next = __next__ # 2.X/3.X compatibility,simpleAssign,907 "Learning Python, 5th Edition","X = Iters([1, 2, 3, 4, 5]) # Make instance",simpleAssign,907 "Learning Python, 5th Edition",I = iter(X) # Manual iteration (what other contexts do),simpleAssign,907 "Learning Python, 5th Edition",X = Iters('spam') # Indexing,simpleAssign,909 "Learning Python, 5th Edition",X = Empty(),simpleAssign,910 "Learning Python, 5th Edition","method is defined or inherited, self.attr = value becomes self.__setattr__('attr',",simpleAssign,910 "Learning Python, 5th Edition","name'] = x, not self.name = x; because you’re not assigning to",simpleAssign,910 "Learning Python, 5th Edition",X = Accesscontrol(),simpleAssign,911 "Learning Python, 5th Edition",X.age = 40 # Calls __setattr__,simpleAssign,911 "Learning Python, 5th Edition","def __setattr__(self, attrname, value): # On self.attrname = value",simpleAssign,912 "Learning Python, 5th Edition",attrname] = value # Avoid loops by using dict key,simpleAssign,912 "Learning Python, 5th Edition",x = Test1(),simpleAssign,913 "Learning Python, 5th Edition",y = Test2(),simpleAssign,913 "Learning Python, 5th Edition",y.age = 30 # Works,simpleAssign,913 "Learning Python, 5th Edition",x.age = 40 # Fails,simpleAssign,913 "Learning Python, 5th Edition",x = adder() # Default displays,simpleAssign,914 "Learning Python, 5th Edition",x = addrepr(2) # Runs __init__,simpleAssign,914 "Learning Python, 5th Edition",x = addstr(3),simpleAssign,915 "Learning Python, 5th Edition",x = addboth(4),simpleAssign,915 "Learning Python, 5th Edition",x = Adder(5),simpleAssign,917 "Learning Python, 5th Edition",x = Commuter1(88),simpleAssign,918 "Learning Python, 5th Edition",y = Commuter1(99),simpleAssign,918 "Learning Python, 5th Edition",__radd__ = __add__ # Alias: cut out the middleman,simpleAssign,919 "Learning Python, 5th Edition",other = other.val,simpleAssign,919 "Learning Python, 5th Edition",x = Commuter5(88),simpleAssign,919 "Learning Python, 5th Edition",y = Commuter5(99),simpleAssign,919 "Learning Python, 5th Edition",x = klass(88),simpleAssign,920 "Learning Python, 5th Edition",y = klass(99),simpleAssign,920 "Learning Python, 5th Edition",x = Number(5),simpleAssign,921 "Learning Python, 5th Edition",x = Number(5),simpleAssign,921 "Learning Python, 5th Edition",C = Callee(),simpleAssign,922 "Learning Python, 5th Edition","C(1, 2, 3, x=4, y=5)",simpleAssign,922 "Learning Python, 5th Edition",X = C(),simpleAssign,922 "Learning Python, 5th Edition","X(a=1, b=2, d=4) # Keywords",simpleAssign,922 "Learning Python, 5th Edition","X(*[1, 2], **dict(c=3, d=4)) # Unpack arbitrary arguments",simpleAssign,922 "Learning Python, 5th Edition","X(1, *(2,), c=3, **dict(d=4)) # Mixed modes",simpleAssign,922 "Learning Python, 5th Edition","x = Prod(2) # ""Remembers"" 2 in state",simpleAssign,922 "Learning Python, 5th Edition",x = Prod(3),simpleAssign,923 "Learning Python, 5th Edition",cb1 = Callback('blue') # Remember blue,simpleAssign,924 "Learning Python, 5th Edition",cb2 = Callback('green') # Remember green,simpleAssign,924 "Learning Python, 5th Edition",B1 = Button(command=cb1) # Register handlers,simpleAssign,924 "Learning Python, 5th Edition",B2 = Button(command=cb2),simpleAssign,924 "Learning Python, 5th Edition",cb3 = callback('yellow') # Handler to be registered,simpleAssign,924 "Learning Python, 5th Edition",cb1 = Callback('blue'),simpleAssign,925 "Learning Python, 5th Edition",cb2 = Callback('yellow'),simpleAssign,925 "Learning Python, 5th Edition","B1 = Button(command=cb1.changeColor) # Bound method: reference, don't call",simpleAssign,925 "Learning Python, 5th Edition",cb1 = Callback('blue'),simpleAssign,925 "Learning Python, 5th Edition",obj = cb1.changeColor # Registered event handler,simpleAssign,925 "Learning Python, 5th Edition","does not imply that != is false, for example, so both __eq__ and __ne__ should",simpleAssign,925 "Learning Python, 5th Edition",X = C(),simpleAssign,926 "Learning Python, 5th Edition",X = C(),simpleAssign,926 "Learning Python, 5th Edition",X = Truth(),simpleAssign,927 "Learning Python, 5th Edition",X = Truth(),simpleAssign,927 "Learning Python, 5th Edition",X = Truth(),simpleAssign,927 "Learning Python, 5th Edition",X = Truth(),simpleAssign,928 "Learning Python, 5th Edition",X = Truth(),simpleAssign,928 "Learning Python, 5th Edition",X = C(),simpleAssign,928 "Learning Python, 5th Edition",X = C(),simpleAssign,929 "Learning Python, 5th Edition",X = C(),simpleAssign,929 "Learning Python, 5th Edition",brian = Life('Brian'),simpleAssign,930 "Learning Python, 5th Edition","Put another way, it’s just as if you say X = 1 and then X = 2; X will be 2. Hence, there",simpleAssign,934 "Learning Python, 5th Edition",if len(args) == 1: # Branch on number arguments,simpleAssign,934 "Learning Python, 5th Edition",elif type(arg[0]) == int: # Branch on argument types (or isinstance()),simpleAssign,934 "Learning Python, 5th Edition",bob = PizzaRobot('bob') # Make a robot named bob,simpleAssign,936 "Learning Python, 5th Edition",obj = klass(klass.__name__),simpleAssign,936 "Learning Python, 5th Edition","Employee: name=bob, salary=50000>",simpleAssign,936 "Learning Python, 5th Edition","Employee: name=bob, salary=60000.0>",simpleAssign,936 "Learning Python, 5th Edition",customer = Customer(name) # Activate other objects,simpleAssign,937 "Learning Python, 5th Edition",scene = PizzaShop() # Make the composite,simpleAssign,938 "Learning Python, 5th Edition","Homer orders from <Employee: name=Pat, salary=40000>",simpleAssign,938 "Learning Python, 5th Edition","Homer pays for item to <Employee: name=Pat, salary=40000>",simpleAssign,938 "Learning Python, 5th Edition","Shaggy orders from <Employee: name=Pat, salary=40000>",simpleAssign,938 "Learning Python, 5th Edition","Shaggy pays for item to <Employee: name=Pat, salary=40000>",simpleAssign,938 "Learning Python, 5th Edition",data = converter(data),simpleAssign,938 "Learning Python, 5th Edition",data = self.converter(data),simpleAssign,939 "Learning Python, 5th Edition",object = SomeClass(),simpleAssign,941 "Learning Python, 5th Edition",object = pickle.load(file) # Fetch it back later,simpleAssign,941 "Learning Python, 5th Edition",object = SomeClass(),simpleAssign,941 "Learning Python, 5th Edition",dbase['key'] = object # Save under key,simpleAssign,941 "Learning Python, 5th Edition",object = dbase['key'] # Fetch it back later,simpleAssign,941 "Learning Python, 5th Edition",shop = PizzaShop(),simpleAssign,941 "Learning Python, 5th Edition","Employee: name=Pat, salary=40000>, <Employee: name=Bob, salary=50000>)",simpleAssign,941 "Learning Python, 5th Edition","Employee: name=Pat, salary=40000>, <Employee: name=Bob, salary=50000>)",simpleAssign,942 "Learning Python, 5th Edition","LSP orders from <Employee: name=Pat, salary=40000>",simpleAssign,942 "Learning Python, 5th Edition","LSP pays for item to <Employee: name=Pat, salary=40000>",simpleAssign,942 "Learning Python, 5th Edition","x = Wrapper([1, 2, 3]) # Wrap a list",simpleAssign,943 "Learning Python, 5th Edition","x = Wrapper({'a': 1, 'b': 2}) # Wrap a dictionary",simpleAssign,943 "Learning Python, 5th Edition",def meth1(self): self.X = 88 # I assume X is mine,simpleAssign,945 "Learning Python, 5th Edition",def metha(self): self.X = 99 # Me too,simpleAssign,946 "Learning Python, 5th Edition",I = C3() # Only 1 X in I!,simpleAssign,946 "Learning Python, 5th Edition",def meth1(self): self.__X = 88 # Now X is mine,simpleAssign,946 "Learning Python, 5th Edition",def metha(self): self.__X = 99 # Me too,simpleAssign,946 "Learning Python, 5th Edition",I = C3() # Two X names in I,simpleAssign,946 "Learning Python, 5th Edition","fully expanded name (e.g., I._C1__X = 77). Moreover, names could still collide if un-",simpleAssign,946 "Learning Python, 5th Edition",object1 = Spam(),simpleAssign,949 "Learning Python, 5th Edition",object1 = Spam(),simpleAssign,949 "Learning Python, 5th Edition",object1 = Spam(),simpleAssign,949 "Learning Python, 5th Edition",t = Spam.doit # Unbound method object (a function in 3.X: see ahead),simpleAssign,949 "Learning Python, 5th Edition",x = self.m1 # Another bound method object,simpleAssign,949 "Learning Python, 5th Edition",X = Selfless(2),simpleAssign,950 "Learning Python, 5th Edition",x = Number(2) # Class instance objects,simpleAssign,951 "Learning Python, 5th Edition",z = Number(4),simpleAssign,951 "Learning Python, 5th Edition",bound = x.double,simpleAssign,952 "Learning Python, 5th Edition",sobject = Sum(2),simpleAssign,952 "Learning Python, 5th Edition",pobject = Product(3),simpleAssign,952 "Learning Python, 5th Edition","widget = Button(text='spam', command=handler)",simpleAssign,953 "Learning Python, 5th Edition","b = Button(text='spam', command=self.handler)",simpleAssign,954 "Learning Python, 5th Edition",object1 = factory(Spam) # Make a Spam object,simpleAssign,955 "Learning Python, 5th Edition","object2 = factory(Person, ""Arthur"", ""King"") # Make a Person object",simpleAssign,955 "Learning Python, 5th Edition","object3 = factory(Person, name='Brian') # Ditto, with keywords and default",simpleAssign,955 "Learning Python, 5th Edition","aclass = getattr(streamtypes, classname) # Fetch from module",simpleAssign,956 "Learning Python, 5th Edition","reader = factory(aclass, classarg) # Or aclass(classarg)",simpleAssign,956 "Learning Python, 5th Edition",X = Spam(),simpleAssign,958 "Learning Python, 5th Edition",x = Spam(),simpleAssign,960 "Learning Python, 5th Edition",data1=food,simpleAssign,960 "Learning Python, 5th Edition",display = str(x) # Print this to interpret escapes,simpleAssign,960 "Learning Python, 5th Edition","Instance of Spam, address 43034496:\n\tdata1=food\n>'",simpleAssign,960 "Learning Python, 5th Edition",X = Sub(),simpleAssign,961 "Learning Python, 5th Edition",data1=spam,simpleAssign,961 "Learning Python, 5th Edition",data2=eggs,simpleAssign,961 "Learning Python, 5th Edition",data3=42,simpleAssign,961 "Learning Python, 5th Edition",instance = Sub() # Return instance with lister's __str__,simpleAssign,962 "Learning Python, 5th Edition",modobject = importlib.import_module(modname) # Import by namestring,simpleAssign,962 "Learning Python, 5th Edition","listerclass = getattr(modobject, classname) # Fetch attr by namestring",simpleAssign,962 "Learning Python, 5th Edition",data1=spam,simpleAssign,962 "Learning Python, 5th Edition",data2=eggs,simpleAssign,962 "Learning Python, 5th Edition",data3=42,simpleAssign,962 "Learning Python, 5th Edition",data1=spam,simpleAssign,962 "Learning Python, 5th Edition",data2=eggs,simpleAssign,962 "Learning Python, 5th Edition",data3=42,simpleAssign,962 "Learning Python, 5th Edition",x = C(),simpleAssign,963 "Learning Python, 5th Edition","x.a, x.b, x.c = 1, 2, 3",simpleAssign,963 "Learning Python, 5th Edition",a=1,simpleAssign,963 "Learning Python, 5th Edition",b=2,simpleAssign,963 "Learning Python, 5th Edition",c=3,simpleAssign,963 "Learning Python, 5th Edition",data1=spam,simpleAssign,964 "Learning Python, 5th Edition",data2=eggs,simpleAssign,964 "Learning Python, 5th Edition",data3=42,simpleAssign,964 "Learning Python, 5th Edition",data1=spam,simpleAssign,965 "Learning Python, 5th Edition",data2=eggs,simpleAssign,965 "Learning Python, 5th Edition",data3=42,simpleAssign,965 "Learning Python, 5th Edition",data1=spam,simpleAssign,965 "Learning Python, 5th Edition",data2=eggs,simpleAssign,965 "Learning Python, 5th Edition",data3=42,simpleAssign,965 "Learning Python, 5th Edition",data1=spam,simpleAssign,966 "Learning Python, 5th Edition",data2=eggs,simpleAssign,966 "Learning Python, 5th Edition",data3=42,simpleAssign,966 "Learning Python, 5th Edition","here = self.__attrnames(aClass, indent)",simpleAssign,967 "Learning Python, 5th Edition","here = self.__attrnames(self, 0)",simpleAssign,967 "Learning Python, 5th Edition",data1=spam,simpleAssign,969 "Learning Python, 5th Edition",data2=eggs,simpleAssign,969 "Learning Python, 5th Edition",data3=42,simpleAssign,969 "Learning Python, 5th Edition",data1=spam,simpleAssign,970 "Learning Python, 5th Edition",data2=eggs,simpleAssign,970 "Learning Python, 5th Edition",data3=42,simpleAssign,970 "Learning Python, 5th Edition",data1=spam,simpleAssign,971 "Learning Python, 5th Edition",data2=eggs,simpleAssign,971 "Learning Python, 5th Edition",data3=42,simpleAssign,971 "Learning Python, 5th Edition",__doc__=None,simpleAssign,971 "Learning Python, 5th Edition",__module__=testmixin,simpleAssign,971 "Learning Python, 5th Edition",__doc__=None,simpleAssign,971 "Learning Python, 5th Edition",__module__=testmixin,simpleAssign,971 "Learning Python, 5th Edition","__doc__= Mix-in that returns an __str__ trace of the entire class tree and all",simpleAssign,971 "Learning Python, 5th Edition",__module__=__main__,simpleAssign,972 "Learning Python, 5th Edition",B = MyButton(text='spam'),simpleAssign,973 "Learning Python, 5th Edition",_name=43363688,simpleAssign,974 "Learning Python, 5th Edition",S = str(B) # Or print just the first part,simpleAssign,974 "Learning Python, 5th Edition",Lister = ListTree # Choose a default lister,simpleAssign,974 "Learning Python, 5th Edition",res = self.data[:] # Copy of my list,simpleAssign,980 "Learning Python, 5th Edition","x = Set([1, 3, 5, 7])",simpleAssign,981 "Learning Python, 5th Edition",x = MyList('abc') # __init__ inherited from list,simpleAssign,981 "Learning Python, 5th Edition",res = Set(self) # Copy me and my list,simpleAssign,982 "Learning Python, 5th Edition","x = Set([1,3,5,7])",simpleAssign,983 "Learning Python, 5th Edition","y = Set([2,1,4,5,6])",simpleAssign,983 "Learning Python, 5th Edition",X = C(),simpleAssign,988 "Learning Python, 5th Edition",X = C() # Built-ins not routed to getattr,simpleAssign,989 "Learning Python, 5th Edition",X = C(),simpleAssign,989 "Learning Python, 5th Edition",X.normal = lambda: 99,simpleAssign,989 "Learning Python, 5th Edition",X = C(),simpleAssign,989 "Learning Python, 5th Edition",X.normal = lambda: 99,simpleAssign,989 "Learning Python, 5th Edition",X = C(),simpleAssign,989 "Learning Python, 5th Edition",X = C(),simpleAssign,990 "Learning Python, 5th Edition",X = C(),simpleAssign,990 "Learning Python, 5th Edition",I = C() # Instances are made from classes,simpleAssign,993 "Learning Python, 5th Edition",I = C() # Type of instance is class it's made from,simpleAssign,993 "Learning Python, 5th Edition",I = C() # All classes are new-style in 3.X,simpleAssign,993 "Learning Python, 5th Edition","c, d = C(), D()",simpleAssign,994 "Learning Python, 5th Edition",type(c) == type(d) # 3.X: compares the instances' classes,simpleAssign,994 "Learning Python, 5th Edition","c1, c2 = C(), C()",simpleAssign,994 "Learning Python, 5th Edition",type(c1) == type(c2),simpleAssign,994 "Learning Python, 5th Edition","c, d = C(), D()",simpleAssign,994 "Learning Python, 5th Edition",type(c) == type(d) # 2.X: all instances are same type!,simpleAssign,994 "Learning Python, 5th Edition","c, d = C(), D()",simpleAssign,995 "Learning Python, 5th Edition",type(c) == type(d) # 2.X new-style: same as all in 3.X,simpleAssign,995 "Learning Python, 5th Edition",X = C(),simpleAssign,995 "Learning Python, 5th Edition",X = C(),simpleAssign,996 "Learning Python, 5th Edition",X = C(),simpleAssign,996 "Learning Python, 5th Edition",class A: attr = 1 # Classic (Python 2.X),simpleAssign,998 "Learning Python, 5th Edition",attr = 2,simpleAssign,998 "Learning Python, 5th Edition",x = D(),simpleAssign,998 "Learning Python, 5th Edition","attr = 1 # New-style (""object"" not required in 3.X)",simpleAssign,998 "Learning Python, 5th Edition",attr = 2,simpleAssign,998 "Learning Python, 5th Edition",x = D(),simpleAssign,998 "Learning Python, 5th Edition",class A: attr = 1 # Classic,simpleAssign,999 "Learning Python, 5th Edition",attr = 2,simpleAssign,999 "Learning Python, 5th Edition","class D(B, C): attr = C.attr # <== Choose C, to the right",simpleAssign,999 "Learning Python, 5th Edition",x = D(),simpleAssign,999 "Learning Python, 5th Edition",attr = 1 # New-style,simpleAssign,999 "Learning Python, 5th Edition",attr = 2,simpleAssign,999 "Learning Python, 5th Edition","class D(B, C): attr = B.attr # <== Choose A.attr, above",simpleAssign,999 "Learning Python, 5th Edition",x = D(),simpleAssign,999 "Learning Python, 5th Edition",x = D() # Will vary per class type,simpleAssign,1000 "Learning Python, 5th Edition","class D(B, C): meth = C.meth # <== Pick C's method: new-style (and 3.X)",simpleAssign,1000 "Learning Python, 5th Edition",x = D(),simpleAssign,1000 "Learning Python, 5th Edition","class D(B, C): meth = B.meth # <== Pick B's method: classic",simpleAssign,1000 "Learning Python, 5th Edition",x = D(),simpleAssign,1000 "Learning Python, 5th Edition",C.meth(self) # <== Pick C's method by calling,simpleAssign,1000 "Learning Python, 5th Edition",D.mro() == list(D.__mro__),simpleAssign,1004 "Learning Python, 5th Edition","filterdictvals(dict(a=1, b=2, c=1), 1) => {'b': 2}",simpleAssign,1005 "Learning Python, 5th Edition","invertdict(dict(a=1, b=2, c=1)) => {1: ['a', 'c'], 2: ['b']}",simpleAssign,1005 "Learning Python, 5th Edition",withobject: False=remove object built-in class attributes.,simpleAssign,1005 "Learning Python, 5th Edition",bysource: True=group result by objects instead of attributes.,simpleAssign,1005 "Learning Python, 5th Edition",inherits = inheritance(instance),simpleAssign,1005 "Learning Python, 5th Edition",attr2obj[attr] = obj,simpleAssign,1005 "Learning Python, 5th Edition","attr2obj = filterdictvals(attr2obj, object)",simpleAssign,1006 "Learning Python, 5th Edition",class A: attr1 = 1,simpleAssign,1006 "Learning Python, 5th Edition",attr2 = 2,simpleAssign,1006 "Learning Python, 5th Edition",attr1 = 3,simpleAssign,1006 "Learning Python, 5th Edition",I = D(),simpleAssign,1006 "Learning Python, 5th Edition",Python's search == ours?,simpleAssign,1006 "Learning Python, 5th Edition","trace(mapattrs(I, bysource=True), 'OBJS\n') # Source => [Attrs]",simpleAssign,1006 "Learning Python, 5th Edition","attr1 = 1 # ""(object)"" optional in 3.X",simpleAssign,1006 "Learning Python, 5th Edition",attr2 = 2,simpleAssign,1006 "Learning Python, 5th Edition",attr1 = 3,simpleAssign,1006 "Learning Python, 5th Edition",I = D(),simpleAssign,1006 "Learning Python, 5th Edition","trace(mapattrs(I, bysource=True), 'OBJS\n')",simpleAssign,1006 "Learning Python, 5th Edition",I = Sub() # Sub inherits from Super and ListInstance roots,simpleAssign,1007 "Learning Python, 5th Edition","trace(mapattrs(I, bysource=True))",simpleAssign,1008 "Learning Python, 5th Edition","trace(mapattrs(I, withobject=True))",simpleAssign,1008 "Learning Python, 5th Edition","amap = mapattrs(I, withobject=True, bysource=True)",simpleAssign,1008 "Learning Python, 5th Edition",x = 2,simpleAssign,1009 "Learning Python, 5th Edition",z = 3,simpleAssign,1009 "Learning Python, 5th Edition",I = D(),simpleAssign,1009 "Learning Python, 5th Edition","trace(mapattrs(I, bysource=True)) # Also: trace(mapattrs(I))",simpleAssign,1009 "Learning Python, 5th Edition",be to index the mapattrs function’s bysource=True dictionary result to obtain an object’s,simpleAssign,1009 "Learning Python, 5th Edition",x = limiter(),simpleAssign,1010 "Learning Python, 5th Edition",x.age = 40 # Looks like instance data,simpleAssign,1011 "Learning Python, 5th Edition",x.ape = 1000 # Illegal: not in __slots__,simpleAssign,1011 "Learning Python, 5th Edition",X = C(),simpleAssign,1012 "Learning Python, 5th Edition",X.a = 1,simpleAssign,1012 "Learning Python, 5th Edition",X = D(),simpleAssign,1012 "Learning Python, 5th Edition",c = 3 # Class attrs work normally,simpleAssign,1013 "Learning Python, 5th Edition",X = D(),simpleAssign,1013 "Learning Python, 5th Edition",X.a = 1,simpleAssign,1013 "Learning Python, 5th Edition",X.b = 2,simpleAssign,1013 "Learning Python, 5th Edition",X = D(),simpleAssign,1014 "Learning Python, 5th Edition","X.a = 1; X.b = 2; X.c = 3 # The instance is the union (slots: a, c)",simpleAssign,1014 "Learning Python, 5th Edition",I = Slotful(3),simpleAssign,1015 "Learning Python, 5th Edition","I.a, I.b = 1, 2",simpleAssign,1015 "Learning Python, 5th Edition",X = D() # But slot name still managed in class,simpleAssign,1016 "Learning Python, 5th Edition",X.a = 1; X.b = 2,simpleAssign,1016 "Learning Python, 5th Edition",X = D() # But slot name still managed in class,simpleAssign,1017 "Learning Python, 5th Edition",X.a = 1; X.b = 2,simpleAssign,1017 "Learning Python, 5th Edition",a = 99 # Bullet 4: no class-level defaults,simpleAssign,1017 "Learning Python, 5th Edition",X = D(),simpleAssign,1017 "Learning Python, 5th Edition",X.a = 1; X.b = 2,simpleAssign,1017 "Learning Python, 5th Edition",X = C() # OK: no __slots__ used,simpleAssign,1017 "Learning Python, 5th Edition",X = C(),simpleAssign,1018 "Learning Python, 5th Edition",X.c = 3,simpleAssign,1018 "Learning Python, 5th Edition",X = C(),simpleAssign,1018 "Learning Python, 5th Edition",X = C(),simpleAssign,1019 "Learning Python, 5th Edition",X.a = 1; X.b = 2; X.c = 3; X.d = 4,simpleAssign,1019 "Learning Python, 5th Edition","class statement (e.g., name=property()), and a special @ syntax we’ll meet later is avail-",simpleAssign,1020 "Learning Python, 5th Edition",x = operators(),simpleAssign,1021 "Learning Python, 5th Edition","age = property(getage, None, None, None) # (get, set, del, docs), or use @",simpleAssign,1021 "Learning Python, 5th Edition",x = properties(),simpleAssign,1021 "Learning Python, 5th Edition","age = property(getage, setage, None, None)",simpleAssign,1021 "Learning Python, 5th Edition",x = properties(),simpleAssign,1021 "Learning Python, 5th Edition",x.age = 42 # Runs setage,simpleAssign,1021 "Learning Python, 5th Edition",name] = value,simpleAssign,1022 "Learning Python, 5th Edition",x = operators(),simpleAssign,1022 "Learning Python, 5th Edition",x.age = 41 # Runs __setattr__,simpleAssign,1022 "Learning Python, 5th Edition",instance._age = value,simpleAssign,1023 "Learning Python, 5th Edition",age = AgeDesc(),simpleAssign,1023 "Learning Python, 5th Edition",x = descriptors(),simpleAssign,1023 "Learning Python, 5th Edition",x.age = 42 # Runs AgeDesc.__set__,simpleAssign,1023 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1026 "Learning Python, 5th Edition",a = Spam() # Cannot call unbound class methods in 2.X,simpleAssign,1026 "Learning Python, 5th Edition",b = Spam() # Methods expect a self object by default,simpleAssign,1026 "Learning Python, 5th Edition",c = Spam(),simpleAssign,1026 "Learning Python, 5th Edition",a = Spam() # Can call functions in class in 3.X,simpleAssign,1027 "Learning Python, 5th Edition",b = Spam() # Calls through instances still pass a self,simpleAssign,1027 "Learning Python, 5th Edition",c = Spam(),simpleAssign,1027 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1027 "Learning Python, 5th Edition",a = spam.Spam(),simpleAssign,1027 "Learning Python, 5th Edition",b = spam.Spam(),simpleAssign,1027 "Learning Python, 5th Edition",c = spam.Spam(),simpleAssign,1027 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1028 "Learning Python, 5th Edition","a, b, c = Spam(), Spam(), Spam()",simpleAssign,1028 "Learning Python, 5th Edition",smeth = staticmethod(smeth) # Make smeth a static method (or @: ahead),simpleAssign,1029 "Learning Python, 5th Edition",cmeth = classmethod(cmeth) # Make cmeth a class method (or @: ahead),simpleAssign,1029 "Learning Python, 5th Edition",obj = Methods() # Callable through instance or class,simpleAssign,1029 "Learning Python, 5th Edition",numInstances = 0 # Use static method for class data,simpleAssign,1030 "Learning Python, 5th Edition",printNumInstances = staticmethod(printNumInstances),simpleAssign,1030 "Learning Python, 5th Edition",a = Spam(),simpleAssign,1030 "Learning Python, 5th Edition",b = Spam(),simpleAssign,1030 "Learning Python, 5th Edition",c = Spam(),simpleAssign,1030 "Learning Python, 5th Edition",printNumInstances = staticmethod(printNumInstances),simpleAssign,1031 "Learning Python, 5th Edition",a = Sub(),simpleAssign,1031 "Learning Python, 5th Edition",b = Sub(),simpleAssign,1031 "Learning Python, 5th Edition",c = Other(),simpleAssign,1031 "Learning Python, 5th Edition",numInstances = 0 # Use class method instead of static,simpleAssign,1032 "Learning Python, 5th Edition",printNumInstances = classmethod(printNumInstances),simpleAssign,1032 "Learning Python, 5th Edition","a, b = Spam(), Spam()",simpleAssign,1032 "Learning Python, 5th Edition",printNumInstances = classmethod(printNumInstances),simpleAssign,1032 "Learning Python, 5th Edition",printNumInstances = classmethod(printNumInstances),simpleAssign,1032 "Learning Python, 5th Edition",x = Sub(),simpleAssign,1032 "Learning Python, 5th Edition",y = Spam(),simpleAssign,1032 "Learning Python, 5th Edition",z = Other() # Call from lower sub's instance,simpleAssign,1033 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1033 "Learning Python, 5th Edition",count = classmethod(count),simpleAssign,1033 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1033 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1033 "Learning Python, 5th Edition",x = Spam(),simpleAssign,1033 "Learning Python, 5th Edition","y1, y2 = Sub(), Sub()",simpleAssign,1033 "Learning Python, 5th Edition","z1, z2, z3 = Other(), Other(), Other()",simpleAssign,1034 "Learning Python, 5th Edition",meth = staticmethod(meth) # Name rebinding equivalent,simpleAssign,1035 "Learning Python, 5th Edition",numInstances = 0,simpleAssign,1036 "Learning Python, 5th Edition",a = Spam(),simpleAssign,1036 "Learning Python, 5th Edition",b = Spam(),simpleAssign,1036 "Learning Python, 5th Edition",c = Spam(),simpleAssign,1036 "Learning Python, 5th Edition",obj = Methods(),simpleAssign,1036 "Learning Python, 5th Edition",oncall.calls = 0,simpleAssign,1038 "Learning Python, 5th Edition",x = C(),simpleAssign,1038 "Learning Python, 5th Edition",C = decorator(C),simpleAssign,1038 "Learning Python, 5th Edition",aClass.numInstances = 0,simpleAssign,1039 "Learning Python, 5th Edition",Spam: ... # Same as Spam = count(Spam),simpleAssign,1039 "Learning Python, 5th Edition",Sub(Spam): ... # numInstances = 0 not needed here,simpleAssign,1039 "Learning Python, 5th Edition",spam(): pass # Like spam = count(spam),simpleAssign,1039 "Learning Python, 5th Edition",Other: pass # Like Other = count(Other),simpleAssign,1039 "Learning Python, 5th Edition",C: ... # Like C = decorator(C),simpleAssign,1039 "Learning Python, 5th Edition","X = C() # Makes a Proxy that wraps a C, and catches later X.attr",simpleAssign,1039 "Learning Python, 5th Edition","my creation routed to Meta... # Like C = Meta('C', (), {...})",simpleAssign,1040 "Learning Python, 5th Edition","classname = Meta(classname, superclasses, attributedict)",simpleAssign,1040 "Learning Python, 5th Edition",X = D(),simpleAssign,1043 "Learning Python, 5th Edition",X = D(),simpleAssign,1043 "Learning Python, 5th Edition",proxy = super() # This form has no meaning outside a method,simpleAssign,1044 "Learning Python, 5th Edition",X = C(),simpleAssign,1045 "Learning Python, 5th Edition",X = C(),simpleAssign,1045 "Learning Python, 5th Edition",X = C(),simpleAssign,1045 "Learning Python, 5th Edition",X = C() # So why use the super() special case at all?,simpleAssign,1045 "Learning Python, 5th Edition",X = C(),simpleAssign,1047 "Learning Python, 5th Edition",X = D(),simpleAssign,1047 "Learning Python, 5th Edition",X = D(),simpleAssign,1048 "Learning Python, 5th Edition",X = D(),simpleAssign,1048 "Learning Python, 5th Edition",X = D(),simpleAssign,1048 "Learning Python, 5th Edition",i = C(),simpleAssign,1050 "Learning Python, 5th Edition",i = C(),simpleAssign,1050 "Learning Python, 5th Edition",x = D() # Runs leftmost only by default,simpleAssign,1051 "Learning Python, 5th Edition",x = D(),simpleAssign,1051 "Learning Python, 5th Edition",x = B(),simpleAssign,1051 "Learning Python, 5th Edition",x = C() # Each super works by itself,simpleAssign,1051 "Learning Python, 5th Edition",x = D(),simpleAssign,1052 "Learning Python, 5th Edition",x = D() # But this now invokes A twice!,simpleAssign,1052 "Learning Python, 5th Edition","x = B() # Runs B.__init__, A is next super in self's B MRO",simpleAssign,1052 "Learning Python, 5th Edition",x = C(),simpleAssign,1052 "Learning Python, 5th Edition","x = D() # Runs B.__init__, C is next super in self's D MRO!",simpleAssign,1052 "Learning Python, 5th Edition",x = B() # object is an implied super at the end of MRO,simpleAssign,1053 "Learning Python, 5th Edition",x = C(),simpleAssign,1053 "Learning Python, 5th Edition","x = D() # Runs B.__init__, C is next super in self's D MRO!",simpleAssign,1053 "Learning Python, 5th Edition",x = D(),simpleAssign,1054 "Learning Python, 5th Edition",X = D(),simpleAssign,1054 "Learning Python, 5th Edition",X = D(),simpleAssign,1055 "Learning Python, 5th Edition",X = D(),simpleAssign,1055 "Learning Python, 5th Edition",X = D(),simpleAssign,1056 "Learning Python, 5th Edition",X = D(),simpleAssign,1056 "Learning Python, 5th Edition",X = C(),simpleAssign,1059 "Learning Python, 5th Edition",bob = Chef1('Bob'),simpleAssign,1060 "Learning Python, 5th Edition",sue = Server1('Sue'),simpleAssign,1060 "Learning Python, 5th Edition",bob = Chef2('Bob'),simpleAssign,1061 "Learning Python, 5th Edition",sue = Server2('Sue'),simpleAssign,1061 "Learning Python, 5th Edition",tom = TwoJobs('Tom'),simpleAssign,1061 "Learning Python, 5th Edition",tom = TwoJobs('Tom'),simpleAssign,1061 "Learning Python, 5th Edition",tom = TwoJobs('Tom'),simpleAssign,1061 "Learning Python, 5th Edition",tom = TwoJobs('Tom'),simpleAssign,1061 "Learning Python, 5th Edition",a = 1 # Class attribute,simpleAssign,1064 "Learning Python, 5th Edition",I = X(),simpleAssign,1064 "Learning Python, 5th Edition",X.a = 2 # May change more than X,simpleAssign,1065 "Learning Python, 5th Edition",J = X() # J inherits from X's runtime values,simpleAssign,1065 "Learning Python, 5th Edition",X.a = 1 # Use class attributes as variables,simpleAssign,1065 "Learning Python, 5th Edition",X.b = 2 # No instances anywhere to be found,simpleAssign,1065 "Learning Python, 5th Edition",X.c = 3,simpleAssign,1065 "Learning Python, 5th Edition",X = Record(),simpleAssign,1065 "Learning Python, 5th Edition",x = C() # Two instances,simpleAssign,1066 "Learning Python, 5th Edition",y = C() # Implicitly share class attrs,simpleAssign,1066 "Learning Python, 5th Edition",x = Sub() # Inheritance searches ListTree before Super,simpleAssign,1067 "Learning Python, 5th Edition",other = Super.other # But explicitly pick Super's version of other,simpleAssign,1067 "Learning Python, 5th Edition",x = Sub() # Inheritance searches Sub before ListTree/Super,simpleAssign,1067 "Learning Python, 5th Edition",__str__ = Lister.__str__ # Explicitly pick Lister.__str__,simpleAssign,1067 "Learning Python, 5th Edition",count = 1,simpleAssign,1068 "Learning Python, 5th Edition",count = 1,simpleAssign,1068 "Learning Python, 5th Edition",count = 1,simpleAssign,1069 "Learning Python, 5th Edition",aclass = generate('Gotchas'),simpleAssign,1069 "Learning Python, 5th Edition",I = aclass(),simpleAssign,1069 "Learning Python, 5th Edition",Gotchas=1,simpleAssign,1069 "Learning Python, 5th Edition",spot = Cat(),simpleAssign,1076 "Learning Python, 5th Edition",data = Hacker() # Animal.reply: calls Primate.speak,simpleAssign,1076 "Learning Python, 5th Edition",if (doFirstThing() == ERROR) # Detect errors everywhere,simpleAssign,1089 "Learning Python, 5th Edition",if (doNextThing() == ERROR),simpleAssign,1089 "Learning Python, 5th Edition",if (doStuff() == ERROR),simpleAssign,1089 "Learning Python, 5th Edition",x = 1 / 0,simpleAssign,1106 "Learning Python, 5th Edition",exc = IndexError() # Create instance ahead of time,simpleAssign,1107 "Learning Python, 5th Edition",lock = threading.Lock() # After: import threading,simpleAssign,1115 "Learning Python, 5th Edition",ctx.prec = 2,simpleAssign,1116 "Learning Python, 5th Edition",x = decimal.Decimal('1.00') / decimal.Decimal('3.00'),simpleAssign,1116 "Learning Python, 5th Edition",X = 2,simpleAssign,1119 "Learning Python, 5th Edition",X = General() # Raise superclass instance,simpleAssign,1126 "Learning Python, 5th Edition",X = Specific1() # Raise subclass instance,simpleAssign,1126 "Learning Python, 5th Edition",X = Specific2() # Raise different subclass instance,simpleAssign,1126 "Learning Python, 5th Edition",I = IndexError('spam') # Available in object attribute,simpleAssign,1134 "Learning Python, 5th Edition",I = E('spam'),simpleAssign,1134 "Learning Python, 5th Edition",B = b'spam' # 3.X bytes literal make a bytes object (8-bit bytes),simpleAssign,1175 "Learning Python, 5th Edition","B = B""""""",simpleAssign,1175 "Learning Python, 5th Edition",B = b'spam' # 3.X bytes literal is just str in 2.6/2.7,simpleAssign,1176 "Learning Python, 5th Edition",U = u'spam' # 2.X Unicode literal makes a distinct type,simpleAssign,1176 "Learning Python, 5th Edition",B = b'spam',simpleAssign,1177 "Learning Python, 5th Edition",U = u'eggs',simpleAssign,1178 "Learning Python, 5th Edition",B = b'\xc4\xe8' # Text encoded per Latin-1,simpleAssign,1181 "Learning Python, 5th Edition",B = b'\xc3\x84\xc3\xa8' # Text encoded per UTF-8,simpleAssign,1181 "Learning Python, 5th Edition",B = b'A\xC4B\xE8C' # bytes recognizes hex but not Unicode,simpleAssign,1183 "Learning Python, 5th Edition",B = b'A\u00C4B\U000000E8C' # Escape sequences taken literally!,simpleAssign,1183 "Learning Python, 5th Edition",B = b'A\xC4B\xE8C' # Use hex escapes for bytes,simpleAssign,1183 "Learning Python, 5th Edition",B = b'AÄBèC',simpleAssign,1183 "Learning Python, 5th Edition","B = b'A\xC4B\xE8C' # Chars must be ASCII, or escapes",simpleAssign,1183 "Learning Python, 5th Edition",B = b'A\xc3\x84B\xc3\xa8C' # Text encoded in UTF-8 format originally,simpleAssign,1184 "Learning Python, 5th Edition",S = B.decode('utf-8') # Decode to Unicode text per UTF-8,simpleAssign,1184 "Learning Python, 5th Edition",T = S.encode('cp500') # Convert to encoded bytes per EBCDIC,simpleAssign,1184 "Learning Python, 5th Edition",U = T.decode('cp500') # Convert back to Unicode per EBCDIC,simpleAssign,1184 "Learning Python, 5th Edition",U = S.decode('latin1') # Decode bytes to Unicode text per latin-1,simpleAssign,1185 "Learning Python, 5th Edition","U = u'A\xC4B\xE8C' # Make Unicode string, hex escapes",simpleAssign,1185 "Learning Python, 5th Edition",U = u'A\xC4B\xE8C' # Hex escapes for non-ASCII,simpleAssign,1186 "Learning Python, 5th Edition",U = u'A\u00C4B\U000000E8C' # Unicode escapes for non-ASCII,simpleAssign,1186 "Learning Python, 5th Edition","U # u'' = 16 bits, U'' = 32 bits",simpleAssign,1186 "Learning Python, 5th Edition",U = u'A\xC4B\xE8C',simpleAssign,1187 "Learning Python, 5th Edition",bytes1 = aStr.encode() # Per default utf-8: 2 bytes for non-ASCII,simpleAssign,1188 "Learning Python, 5th Edition",bytes2 = aStr.encode('latin-1') # One byte per char,simpleAssign,1188 "Learning Python, 5th Edition",bytes3 = aStr.encode('ascii') # ASCII fails: outside 0..127 range,simpleAssign,1188 "Learning Python, 5th Edition","aÄBèC, strlen=5, byteslen1=7, byteslen2=5",simpleAssign,1188 "Learning Python, 5th Edition","AÄBèC, strlen=5, byteslen1=7, byteslen2=5",simpleAssign,1188 "Learning Python, 5th Edition","AÄBèC, strlen=5, byteslen1=7, byteslen2=5",simpleAssign,1188 "Learning Python, 5th Edition",B = b'spam' # b'...' bytes literal,simpleAssign,1190 "Learning Python, 5th Edition",B = b'spam' # A sequence of small ints,simpleAssign,1190 "Learning Python, 5th Edition",B = b'abc' # Literal,simpleAssign,1191 "Learning Python, 5th Edition","B = bytes('abc', 'ascii') # Constructor with encoding name",simpleAssign,1191 "Learning Python, 5th Edition","B = bytes([97, 98, 99]) # Integer iterable",simpleAssign,1191 "Learning Python, 5th Edition",S = B.decode() # bytes.decode() (or str()),simpleAssign,1191 "Learning Python, 5th Edition",B = b'spam',simpleAssign,1192 "Learning Python, 5th Edition",B = B'spam',simpleAssign,1192 "Learning Python, 5th Edition",C = bytearray(S),simpleAssign,1193 "Learning Python, 5th Edition","C = bytearray(S, 'latin1') # A content-specific type in 3.X",simpleAssign,1193 "Learning Python, 5th Edition",B = b'spam' # b'..' != '..' in 3.X (bytes/str),simpleAssign,1193 "Learning Python, 5th Edition",C = bytearray(B),simpleAssign,1193 "Learning Python, 5th Edition",C[0] = b'x',simpleAssign,1193 "Learning Python, 5th Edition",C[0] = ord('x') # Use ord() to get a character's ordinal,simpleAssign,1193 "Learning Python, 5th Edition",C[1] = b'Y'[0] # Or index a byte string,simpleAssign,1194 "Learning Python, 5th Edition",BA = bytearray(b'\x01\x02\x03'),simpleAssign,1198 "Learning Python, 5th Edition",L = S.encode('latin-1') # 5 bytes when encoded as latin-1,simpleAssign,1200 "Learning Python, 5th Edition",U = S.encode('utf-8') # 7 bytes when encoded as utf-8,simpleAssign,1200 "Learning Python, 5th Edition",S = u'A\xc4B\xe8C' # 2.X type,simpleAssign,1204 "Learning Python, 5th Edition",B = b'Bugger all down here on earth!' # Usually from a file,simpleAssign,1206 "Learning Python, 5th Edition",U = u'Bugger all down here on earth!' # Unicode text,simpleAssign,1207 "Learning Python, 5th Edition",B = b'Bugger all down here on earth!',simpleAssign,1207 "Learning Python, 5th Edition","B = struct.pack('>i4sh', 7, b'spam', 8)",simpleAssign,1208 "Learning Python, 5th Edition","vals = struct.unpack('>i4sh', B)",simpleAssign,1208 "Learning Python, 5th Edition","vals = struct.unpack('>i4sh', B.decode())",simpleAssign,1208 "Learning Python, 5th Edition","data = struct.pack('>i4sh', 7, b'spam', 8) # Create packed binary data",simpleAssign,1208 "Learning Python, 5th Edition","values = struct.unpack('>i4sh', data) # Extract packed binary data",simpleAssign,1208 "Learning Python, 5th Edition",Python 3.X default protocol=3=binary,simpleAssign,1210 "Learning Python, 5th Edition",Python 2.X default=0=ASCII,simpleAssign,1210 "Learning Python, 5th Edition","found = re.findall('<title>(.*)</title>', text)",simpleAssign,1212 "Learning Python, 5th Edition",xmltree = parse('mybooks.xml'),simpleAssign,1212 "Learning Python, 5th Edition",parser = xml.sax.make_parser(),simpleAssign,1212 "Learning Python, 5th Edition",handler = BookHandler(),simpleAssign,1212 "Learning Python, 5th Edition",tree = parse('mybooks.xml'),simpleAssign,1213 "Learning Python, 5th Edition",xmltree = parse('mybooks.xml'),simpleAssign,1213 "Learning Python, 5th Edition",x = c.encode(encoding='ascii'),simpleAssign,1214 "Learning Python, 5th Edition",person.name = value # Change attribute value,simpleAssign,1219 "Learning Python, 5th Edition",person = Person(),simpleAssign,1220 "Learning Python, 5th Edition","attribute = property(fget, fset, fdel, doc)",simpleAssign,1222 "Learning Python, 5th Edition","name = property(getName, setName, delName, ""name property docs"")",simpleAssign,1222 "Learning Python, 5th Edition",bob = Person('Bob Smith') # bob has a managed attribute,simpleAssign,1222 "Learning Python, 5th Edition",sue = Person('Sue Jones') # sue inherits property too,simpleAssign,1223 "Learning Python, 5th Edition","name = property(getName, setName, delName, 'name property docs')",simpleAssign,1223 "Learning Python, 5th Edition",bob = Person('Bob Smith'),simpleAssign,1223 "Learning Python, 5th Edition","X = property(getX, setX) # No delete or docs",simpleAssign,1224 "Learning Python, 5th Edition",P = PropSquare(3) # Two instances of class with property,simpleAssign,1224 "Learning Python, 5th Edition",Q = PropSquare(32) # Each has different state information,simpleAssign,1224 "Learning Python, 5th Edition",P.X = 4,simpleAssign,1224 "Learning Python, 5th Edition",func = decorator(func),simpleAssign,1224 "Learning Python, 5th Edition",name(self): ... # Rebinds: name = property(name),simpleAssign,1225 "Learning Python, 5th Edition",name = property(name),simpleAssign,1225 "Learning Python, 5th Edition",name(self): # name = property(name),simpleAssign,1225 "Learning Python, 5th Edition","name(self, value): # name = name.setter(name)",simpleAssign,1225 "Learning Python, 5th Edition",name(self): # name = name.deleter(name),simpleAssign,1225 "Learning Python, 5th Edition",bob = Person('Bob Smith') # bob has a managed attribute,simpleAssign,1225 "Learning Python, 5th Edition",sue = Person('Sue Jones') # sue inherits property too,simpleAssign,1225 "Learning Python, 5th Edition",attr = Descriptor() # Descriptor instance is class attr,simpleAssign,1228 "Learning Python, 5th Edition",X = Subject(),simpleAssign,1228 "Learning Python, 5th Edition",a = D() # Attribute a is a descriptor instance,simpleAssign,1228 "Learning Python, 5th Edition",X = C(),simpleAssign,1228 "Learning Python, 5th Edition","X.a = 99 # Stored on X, hiding C.a!",simpleAssign,1229 "Learning Python, 5th Edition",Y = C(),simpleAssign,1229 "Learning Python, 5th Edition",a = D(),simpleAssign,1229 "Learning Python, 5th Edition",X = C(),simpleAssign,1229 "Learning Python, 5th Edition",X.a = 99 # Routed to C.a.__set__,simpleAssign,1229 "Learning Python, 5th Edition",instance._name = value,simpleAssign,1230 "Learning Python, 5th Edition",name = Name() # Assign descriptor to attr,simpleAssign,1230 "Learning Python, 5th Edition",bob = Person('Bob Smith') # bob has a managed attribute,simpleAssign,1230 "Learning Python, 5th Edition",sue = Person('Sue Jones') # sue inherits descriptor too,simpleAssign,1230 "Learning Python, 5th Edition",name = Name(),simpleAssign,1231 "Learning Python, 5th Edition",instance._name = value,simpleAssign,1231 "Learning Python, 5th Edition",name = Name(),simpleAssign,1231 "Learning Python, 5th Edition",X = DescSquare(3) # Assign descriptor instance to class attr,simpleAssign,1232 "Learning Python, 5th Edition",X = DescSquare(32) # Another instance in another client class,simpleAssign,1232 "Learning Python, 5th Edition",c1 = Client1(),simpleAssign,1232 "Learning Python, 5th Edition",c2 = Client2(),simpleAssign,1232 "Learning Python, 5th Edition",c1.X = 4,simpleAssign,1232 "Learning Python, 5th Edition",X = DescState(2) # Descriptor class attr,simpleAssign,1233 "Learning Python, 5th Edition",Y = 3 # Class attr,simpleAssign,1233 "Learning Python, 5th Edition",obj = CalcAttrs(),simpleAssign,1233 "Learning Python, 5th Edition",obj.X = 5 # X assignment is intercepted,simpleAssign,1233 "Learning Python, 5th Edition",CalcAttrs.Y = 6 # Y reassigned in class,simpleAssign,1233 "Learning Python, 5th Edition",obj.Z = 7 # Z assigned in instance,simpleAssign,1233 "Learning Python, 5th Edition","obj2 = CalcAttrs() # But X uses shared data, like Y!",simpleAssign,1233 "Learning Python, 5th Edition",instance._X = value,simpleAssign,1234 "Learning Python, 5th Edition",X = InstState() # Descriptor class attr,simpleAssign,1234 "Learning Python, 5th Edition",Y = 3 # Class attr,simpleAssign,1234 "Learning Python, 5th Edition",obj = CalcAttrs(),simpleAssign,1234 "Learning Python, 5th Edition",obj.X = 5 # X assignment is intercepted,simpleAssign,1234 "Learning Python, 5th Edition",CalcAttrs.Y = 6 # Y reassigned in class,simpleAssign,1234 "Learning Python, 5th Edition",obj.Z = 7 # Z assigned in instance,simpleAssign,1234 "Learning Python, 5th Edition","obj2 = CalcAttrs() # But X differs now, like Z!",simpleAssign,1234 "Learning Python, 5th Edition",instance.data = value,simpleAssign,1235 "Learning Python, 5th Edition",managed = DescBoth('spam'),simpleAssign,1235 "Learning Python, 5th Edition",I = Client('eggs'),simpleAssign,1235 "Learning Python, 5th Edition","name = Property(getName, setName) # Use like property()",simpleAssign,1236 "Learning Python, 5th Edition",x = Person(),simpleAssign,1236 "Learning Python, 5th Edition","def __setattr__(self, name, value): # On all attribute assignment [obj.name=value]",simpleAssign,1239 "Learning Python, 5th Edition",X = Catcher(),simpleAssign,1239 "Learning Python, 5th Edition","X.pay = 99 # Prints ""Set: pay 99""",simpleAssign,1239 "Learning Python, 5th Edition","X = Wrapper([1, 2, 3])",simpleAssign,1239 "Learning Python, 5th Edition",x = self.other # LOOPS!,simpleAssign,1240 "Learning Python, 5th Edition","x = object.__getattribute__(self, 'other') # Force higher to avoid me",simpleAssign,1240 "Learning Python, 5th Edition",other'] = value # Use attr dict to avoid me,simpleAssign,1240 "Learning Python, 5th Edition","def __setattr__(self, attr, value): # On [obj.any = value]",simpleAssign,1242 "Learning Python, 5th Edition",attr] = value # Avoid looping here,simpleAssign,1242 "Learning Python, 5th Edition",bob = Person('Bob Smith') # bob has a managed attribute,simpleAssign,1242 "Learning Python, 5th Edition",sue = Person('Sue Jones') # sue inherits property too,simpleAssign,1242 "Learning Python, 5th Edition",attr] = value,simpleAssign,1244 "Learning Python, 5th Edition",A = AttrSquare(3) # 2 instances of class with overloading,simpleAssign,1244 "Learning Python, 5th Edition",B = AttrSquare(32) # Each has different state information,simpleAssign,1244 "Learning Python, 5th Edition",A.X = 4,simpleAssign,1244 "Learning Python, 5th Edition",attr1 = 1,simpleAssign,1245 "Learning Python, 5th Edition",X = GetAttr(),simpleAssign,1245 "Learning Python, 5th Edition",attr1 = 1,simpleAssign,1245 "Learning Python, 5th Edition",X = GetAttribute(),simpleAssign,1245 "Learning Python, 5th Edition","square = property(getSquare, setSquare)",simpleAssign,1246 "Learning Python, 5th Edition",cube = property(getCube),simpleAssign,1246 "Learning Python, 5th Edition","X = Powers(3, 4)",simpleAssign,1246 "Learning Python, 5th Edition",3 ** 2 = 9,simpleAssign,1246 "Learning Python, 5th Edition",4 ** 3 = 64,simpleAssign,1246 "Learning Python, 5th Edition",X.square = 5,simpleAssign,1246 "Learning Python, 5th Edition",5 ** 2 = 25,simpleAssign,1246 "Learning Python, 5th Edition",instance._square = value,simpleAssign,1247 "Learning Python, 5th Edition",square = DescSquare(),simpleAssign,1247 "Learning Python, 5th Edition",cube = DescCube(),simpleAssign,1247 "Learning Python, 5th Edition","X = Powers(3, 4)",simpleAssign,1247 "Learning Python, 5th Edition",3 ** 2 = 9,simpleAssign,1247 "Learning Python, 5th Edition",4 ** 3 = 64,simpleAssign,1247 "Learning Python, 5th Edition",X.square = 5,simpleAssign,1247 "Learning Python, 5th Edition",5 ** 2 = 25,simpleAssign,1247 "Learning Python, 5th Edition",_square'] = value # Or use object,simpleAssign,1248 "Learning Python, 5th Edition",name] = value,simpleAssign,1248 "Learning Python, 5th Edition","X = Powers(3, 4)",simpleAssign,1248 "Learning Python, 5th Edition",3 ** 2 = 9,simpleAssign,1248 "Learning Python, 5th Edition",4 ** 3 = 64,simpleAssign,1248 "Learning Python, 5th Edition",X.square = 5,simpleAssign,1248 "Learning Python, 5th Edition",5 ** 2 = 25,simpleAssign,1248 "Learning Python, 5th Edition","X = Powers(3, 4)",simpleAssign,1248 "Learning Python, 5th Edition",3 ** 2 = 9,simpleAssign,1248 "Learning Python, 5th Edition",4 ** 3 = 64,simpleAssign,1248 "Learning Python, 5th Edition",X.square = 5,simpleAssign,1248 "Learning Python, 5th Edition",5 ** 2 = 25,simpleAssign,1248 "Learning Python, 5th Edition","eggs = 88 # eggs stored on class, spam on instance",simpleAssign,1250 "Learning Python, 5th Edition",eggs = 88 # In 2.X all are isinstance(object) auto,simpleAssign,1250 "Learning Python, 5th Edition",X = Class(),simpleAssign,1250 "Learning Python, 5th Edition","GetAttr=========================================== getattr: other",simpleAssign,1252 "Learning Python, 5th Edition","GetAttribute====================================== getattribute: eggs",simpleAssign,1252 "Learning Python, 5th Edition","sue = Person('Sue Jones', job='dev', pay=100000)",simpleAssign,1254 "Learning Python, 5th Edition","tom = Manager('Tom Jones', 50000) # Manager.__init__",simpleAssign,1254 "Learning Python, 5th Edition","person = object.__getattribute__(self, 'person')",simpleAssign,1255 "Learning Python, 5th Edition","person = object.__getattribute__(self, 'person')",simpleAssign,1256 "Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1257 "Learning Python, 5th Edition",retireage = 59.5,simpleAssign,1257 "Learning Python, 5th Edition","value = value.lower().replace(' ', '_')",simpleAssign,1257 "Learning Python, 5th Edition","name = property(getName, setName)",simpleAssign,1257 "Learning Python, 5th Edition","age = property(getAge, setAge)",simpleAssign,1257 "Learning Python, 5th Edition","value = value.replace('-', '')",simpleAssign,1258 "Learning Python, 5th Edition","acct = property(getAcct, setAcct)",simpleAssign,1258 "Learning Python, 5th Edition",remain = property(remainGet),simpleAssign,1258 "Learning Python, 5th Edition",modulename = sys.argv[1] # Module name in command line,simpleAssign,1258 "Learning Python, 5th Edition",module = importlib.import_module(modulename) # Import module by name string,simpleAssign,1258 "Learning Python, 5th Edition",CardHolder = loadclass(),simpleAssign,1258 "Learning Python, 5th Edition","bob = CardHolder('1234-5678', 'Bob Smith', 40, '123 main st')",simpleAssign,1258 "Learning Python, 5th Edition",bob.age = 50,simpleAssign,1258 "Learning Python, 5th Edition","sue = CardHolder('5678-12-34', 'Sue Jones', 35, '124 main st')",simpleAssign,1258 "Learning Python, 5th Edition",sue.age = 200,simpleAssign,1258 "Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1260 "Learning Python, 5th Edition",retireage = 59.5,simpleAssign,1260 "Learning Python, 5th Edition","value = value.lower().replace(' ', '_')",simpleAssign,1260 "Learning Python, 5th Edition",name = Name(),simpleAssign,1260 "Learning Python, 5th Edition",age = Age(),simpleAssign,1260 "Learning Python, 5th Edition","value = value.replace('-', '')",simpleAssign,1260 "Learning Python, 5th Edition",if len(value) != instance.acctlen: # Use instance class data,simpleAssign,1260 "Learning Python, 5th Edition",acct = Acct(),simpleAssign,1260 "Learning Python, 5th Edition",remain = Remain(),simpleAssign,1260 "Learning Python, 5th Edition",CardHolder = loadclass(),simpleAssign,1261 "Learning Python, 5th Edition","bob = CardHolder('1234-5678', 'Bob Smith', 40, '123 main st')",simpleAssign,1261 "Learning Python, 5th Edition","sue = CardHolder('5678-12-34', 'Sue Jones', 35, '124 main st')",simpleAssign,1261 "Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1262 "Learning Python, 5th Edition",retireage = 59.5,simpleAssign,1262 "Learning Python, 5th Edition","value = value.lower().replace(' ', '_')",simpleAssign,1262 "Learning Python, 5th Edition",instance.__name = value,simpleAssign,1262 "Learning Python, 5th Edition",name = Name() # class.name vs mangled attr,simpleAssign,1262 "Learning Python, 5th Edition",instance.__age = value,simpleAssign,1262 "Learning Python, 5th Edition",age = Age() # class.age vs mangled attr,simpleAssign,1262 "Learning Python, 5th Edition","value = value.replace('-', '')",simpleAssign,1262 "Learning Python, 5th Edition",if len(value) != instance.acctlen: # Use instance class data,simpleAssign,1262 "Learning Python, 5th Edition",instance.__acct = value,simpleAssign,1262 "Learning Python, 5th Edition",acct = Acct() # class.acct vs mangled name,simpleAssign,1262 "Learning Python, 5th Edition",remain = Remain(),simpleAssign,1262 "Learning Python, 5th Edition","bob = CardHolder('1234-5678', 'Bob Smith', 40, '123 main st')",simpleAssign,1263 "Learning Python, 5th Edition","bob = CardHolder('1234-5678', 'Bob Smith', 40, '123 main st')",simpleAssign,1263 "Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1264 "Learning Python, 5th Edition",retireage = 59.5,simpleAssign,1264 "Learning Python, 5th Edition","value = value.lower().replace(' ', '_') # addr stored directly",simpleAssign,1264 "Learning Python, 5th Edition","value = value.replace('-', '')",simpleAssign,1265 "Learning Python, 5th Edition",name] = value # Avoid looping (or via object),simpleAssign,1265 "Learning Python, 5th Edition",acctlen = 8 # Class data,simpleAssign,1265 "Learning Python, 5th Edition",retireage = 59.5,simpleAssign,1265 "Learning Python, 5th Edition",superget = object.__getattribute__ # Don't loop: one level up,simpleAssign,1266 "Learning Python, 5th Edition","value = value.lower().replace(' ', '_') # addr stored directly",simpleAssign,1266 "Learning Python, 5th Edition","name] = value # Avoid loops, orig names",simpleAssign,1266 "Learning Python, 5th Edition",set to the original function decorated (name = property(name)). Property setter,simpleAssign,1267 "Learning Python, 5th Edition",F = decorator(F) # Rebind function name to decorator result,simpleAssign,1273 "Learning Python, 5th Edition",meth(...): ... # meth = staticmethod(meth),simpleAssign,1274 "Learning Python, 5th Edition",name(self): ... # name = property(name),simpleAssign,1274 "Learning Python, 5th Edition",func(): ... # func = decorator(func),simpleAssign,1274 "Learning Python, 5th Edition",func(): ... # func = decorator(func),simpleAssign,1274 "Learning Python, 5th Edition","func(x, y): # func = decorator(func)",simpleAssign,1275 "Learning Python, 5th Edition","method(self, x, y): # method = decorator(method)",simpleAssign,1276 "Learning Python, 5th Edition","func(x, y): # func = decorator(func)",simpleAssign,1276 "Learning Python, 5th Edition","method(self, x, y): # method = decorator(method)",simpleAssign,1276 "Learning Python, 5th Edition",X = C(),simpleAssign,1276 "Learning Python, 5th Edition",x = C(99) # Make an instance,simpleAssign,1277 "Learning Python, 5th Edition",C = decorator(C) # Rebind class name to decorator result,simpleAssign,1277 "Learning Python, 5th Edition",x = C(99) # Essentially calls decorator(C)(99),simpleAssign,1277 "Learning Python, 5th Edition",C: ... # C = decorator(C),simpleAssign,1278 "Learning Python, 5th Edition",C: ... # C = decorator(C),simpleAssign,1278 "Learning Python, 5th Edition",C: # C = decorator(C),simpleAssign,1278 "Learning Python, 5th Edition","x = C(6, 7) # Really calls Wrapper(6, 7)",simpleAssign,1278 "Learning Python, 5th Edition",C: ... # C = Decorator(C),simpleAssign,1279 "Learning Python, 5th Edition",x = C(),simpleAssign,1279 "Learning Python, 5th Edition",y = C() # Overwrites x!,simpleAssign,1279 "Learning Python, 5th Edition",f = A(B(C(f))),simpleAssign,1280 "Learning Python, 5th Edition",X = C(),simpleAssign,1280 "Learning Python, 5th Edition",C = spam(eggs(C)),simpleAssign,1280 "Learning Python, 5th Edition",X = C(),simpleAssign,1280 "Learning Python, 5th Edition",func(): # func = d1(d2(d3(func))),simpleAssign,1281 "Learning Python, 5th Edition",func(): # func = d1(d2(d3(func))),simpleAssign,1281 "Learning Python, 5th Edition","F = decorator(A, B)(F) # Rebind F to result of decorator's return value",simpleAssign,1282 "Learning Python, 5th Edition",F(): ... # F = decorator(F),simpleAssign,1282 "Learning Python, 5th Edition",C: ... # C = decorator(C),simpleAssign,1283 "Learning Python, 5th Edition","spam(a, b, c): # spam = tracer(spam)",simpleAssign,1283 "Learning Python, 5th Edition",calls = 0,simpleAssign,1284 "Learning Python, 5th Edition","spam(a, b, c): # Same as: spam = tracer(spam)",simpleAssign,1285 "Learning Python, 5th Edition","eggs(x, y): # Same as: eggs = tracer(eggs)",simpleAssign,1285 "Learning Python, 5th Edition","spam(a=4, b=5, c=6) # spam is an instance attribute",simpleAssign,1285 "Learning Python, 5th Edition","eggs(4, y=4) # self.calls is per-decoration here",simpleAssign,1285 "Learning Python, 5th Edition",calls = 0,simpleAssign,1286 "Learning Python, 5th Edition","spam(a, b, c): # Same as: spam = tracer(spam)",simpleAssign,1286 "Learning Python, 5th Edition","eggs(x, y): # Same as: eggs = tracer(eggs)",simpleAssign,1286 "Learning Python, 5th Edition","spam(a=4, b=5, c=6) # wrapper calls spam",simpleAssign,1286 "Learning Python, 5th Edition","eggs(4, y=4) # Global calls is not per-decoration here!",simpleAssign,1286 "Learning Python, 5th Edition",calls = 0 # Instead of class attrs or global,simpleAssign,1287 "Learning Python, 5th Edition","spam(a, b, c): # Same as: spam = tracer(spam)",simpleAssign,1287 "Learning Python, 5th Edition","eggs(x, y): # Same as: eggs = tracer(eggs)",simpleAssign,1287 "Learning Python, 5th Edition","spam(a=4, b=5, c=6) # wrapper calls spam",simpleAssign,1287 "Learning Python, 5th Edition","eggs(4, y=4) # Nonlocal calls _is_ per-decoration here",simpleAssign,1287 "Learning Python, 5th Edition","them, with func.attr=value. Because a factory function makes a new function on each",simpleAssign,1288 "Learning Python, 5th Edition",wrapper.calls = 0,simpleAssign,1288 "Learning Python, 5th Edition","spam(a, b, c): # Same as: spam = tracer(spam)",simpleAssign,1288 "Learning Python, 5th Edition","eggs(x, y): # Same as: eggs = tracer(eggs)",simpleAssign,1288 "Learning Python, 5th Edition","spam(a=4, b=5, c=6) # wrapper calls spam",simpleAssign,1288 "Learning Python, 5th Edition","eggs(4, y=4) # wrapper.calls _is_ per-decoration here",simpleAssign,1288 "Learning Python, 5th Edition","spam(a, b, c): # spam = tracer(spam)",simpleAssign,1289 "Learning Python, 5th Edition","spam(a=4, b=5, c=6) # spam saved in an instance attribute",simpleAssign,1289 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = tracer(giveRaise)",simpleAssign,1290 "Learning Python, 5th Edition",lastName(self): # lastName = tracer(lastName),simpleAssign,1290 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000) # tracer remembers method funcs",simpleAssign,1290 "Learning Python, 5th Edition","calls = 0 # Else ""self"" is decorator instance only!",simpleAssign,1291 "Learning Python, 5th Edition","spam(a, b, c): # spam = tracer(spam)",simpleAssign,1291 "Learning Python, 5th Edition","spam(a=4, b=5, c=6)",simpleAssign,1291 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = tracer(giveRaise)",simpleAssign,1292 "Learning Python, 5th Edition",lastName(self): # lastName = tracer(lastName),simpleAssign,1292 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1292 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1292 "Learning Python, 5th Edition",attr = Descriptor(),simpleAssign,1293 "Learning Python, 5th Edition",X = Subject(),simpleAssign,1293 "Learning Python, 5th Edition","spam(a, b, c): # spam = tracer(spam)",simpleAssign,1293 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = tracer(giveRaise)",simpleAssign,1293 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = tracer(giveRaise)",simpleAssign,1295 "Learning Python, 5th Edition","spam(a, b, c): # spam = tracer(spam)",simpleAssign,1295 "Learning Python, 5th Edition",force = list if sys.version_info[0] == 3 else (lambda X: X),simpleAssign,1295 "Learning Python, 5th Edition",start = time.clock(),simpleAssign,1295 "Learning Python, 5th Edition","result = self.func(*args, **kargs)",simpleAssign,1295 "Learning Python, 5th Edition",elapsed = time.clock() - start,simpleAssign,1296 "Learning Python, 5th Edition","result = listcomp(5) # Time for this call, all calls, return value",simpleAssign,1296 "Learning Python, 5th Edition",result = mapcall(5),simpleAssign,1296 "Learning Python, 5th Edition",allTime = 0.17780527629411225,simpleAssign,1296 "Learning Python, 5th Edition",allTime = 0.3328064956447921,simpleAssign,1296 "Learning Python, 5th Edition",map/comp = 1.872,simpleAssign,1296 "Learning Python, 5th Edition","timeit.timeit(number=1, stmt=lambda: listcomp(1000000))",simpleAssign,1297 "Learning Python, 5th Edition",start = time.clock(),simpleAssign,1299 "Learning Python, 5th Edition","result = self.func(*args, **kargs)",simpleAssign,1299 "Learning Python, 5th Edition",elapsed = time.clock() - start,simpleAssign,1299 "Learning Python, 5th Edition",force = list if sys.version_info[0] == 3 else (lambda X: X),simpleAssign,1299 "Learning Python, 5th Edition",listcomp(N): # Like listcomp = timer(...)(listcomp),simpleAssign,1299 "Learning Python, 5th Edition","result = func(5) # Time for this call, all calls, return value",simpleAssign,1300 "Learning Python, 5th Edition",allTime = 0.1834406801777564,simpleAssign,1300 "Learning Python, 5th Edition",allTime = 0.3403542519173618,simpleAssign,1300 "Learning Python, 5th Edition",map/comp = 1.855,simpleAssign,1300 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1300 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1300 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1300 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1301 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1301 "Learning Python, 5th Edition",x = listcomp(5000),simpleAssign,1301 "Learning Python, 5th Edition","instances[aClass] = aClass(*args, **kwargs)",simpleAssign,1302 "Learning Python, 5th Edition","bob = Person('Bob', 40, 10) # Really calls onCall",simpleAssign,1302 "Learning Python, 5th Edition","sue = Person('Sue', 50, 20) # Same, single object",simpleAssign,1302 "Learning Python, 5th Edition","X = Spam(val=42) # One Person, one Spam",simpleAssign,1302 "Learning Python, 5th Edition",Y = Spam(99),simpleAssign,1302 "Learning Python, 5th Edition","the None check could use is instead of == here, but it’s a trivial test either way):",simpleAssign,1303 "Learning Python, 5th Edition",instance = None,simpleAssign,1303 "Learning Python, 5th Edition",onCall.instance = None,simpleAssign,1303 "Learning Python, 5th Edition","x = Wrapper([1,2,3]) # Wrap a list",simpleAssign,1304 "Learning Python, 5th Edition","x = Wrapper({""a"": 1, ""b"": 2}) # Wrap a dictionary",simpleAssign,1304 "Learning Python, 5th Edition",Spam: # Spam = Tracer(Spam),simpleAssign,1305 "Learning Python, 5th Edition",Person: # Person = Tracer(Person),simpleAssign,1305 "Learning Python, 5th Edition",food = Spam() # Triggers Wrapper(),simpleAssign,1305 "Learning Python, 5th Edition","bob = Person('Bob', 40, 50) # bob is really a Wrapper",simpleAssign,1305 "Learning Python, 5th Edition","sue = Person('Sue', rate=100, hours=60) # sue is a different Wrapper",simpleAssign,1305 "Learning Python, 5th Edition",MyList(list): pass # MyList = Tracer(MyList),simpleAssign,1306 "Learning Python, 5th Edition","x = MyList([1, 2, 3]) # Triggers Wrapper()",simpleAssign,1306 "Learning Python, 5th Edition",WrapList = Tracer(list) # Or perform decoration manually,simpleAssign,1306 "Learning Python, 5th Edition","x = WrapList([4, 5, 6]) # Else subclass statement required",simpleAssign,1306 "Learning Python, 5th Edition","bob = Person('Bob', 40, 50)",simpleAssign,1307 "Learning Python, 5th Edition","sue = Person('Sue', rate=100, hours=60)",simpleAssign,1307 "Learning Python, 5th Edition","bob = Wrapper(Person('Bob', 40, 50))",simpleAssign,1307 "Learning Python, 5th Edition","sue = Wrapper(Person('Sue', rate=100, hours=60))",simpleAssign,1307 "Learning Python, 5th Edition",Spam: # Like: Spam = Tracer(Spam),simpleAssign,1308 "Learning Python, 5th Edition",food = Spam() # Triggers __call__,simpleAssign,1308 "Learning Python, 5th Edition",Person: # Person = Tracer(Person),simpleAssign,1308 "Learning Python, 5th Edition",bob = Person('Bob') # bob is really a Wrapper,simpleAssign,1308 "Learning Python, 5th Edition",Sue = Person('Sue'),simpleAssign,1308 "Learning Python, 5th Edition",food = Wrapper(Spam()) # Special creation syntax,simpleAssign,1309 "Learning Python, 5th Edition",food = Spam() # Normal creation syntax,simpleAssign,1309 "Learning Python, 5th Edition","bob = getInstance(Person, 'Bob', 40, 10) # Versus: bob = Person('Bob', 40, 10)",simpleAssign,1309 "Learning Python, 5th Edition","bob = getInstance(Person('Bob', 40, 10)) # Versus: bob = Person('Bob', 40, 10)",simpleAssign,1309 "Learning Python, 5th Edition","result = tracer(func, (1, 2)) # Special call syntax",simpleAssign,1310 "Learning Python, 5th Edition",Rebinds name: func = tracer(func),simpleAssign,1310 "Learning Python, 5th Edition","result = func(1, 2) # Normal call syntax",simpleAssign,1310 "Learning Python, 5th Edition","X=Class().init()). Over time, though, despite being fundamentally a",simpleAssign,1312 "Learning Python, 5th Edition",registry[obj.__name__] = obj # Add to registry,simpleAssign,1312 "Learning Python, 5th Edition",return(x ** 2) # spam = register(spam),simpleAssign,1312 "Learning Python, 5th Edition",Eggs: # Eggs = register(Eggs),simpleAssign,1312 "Learning Python, 5th Edition",X = Eggs(2),simpleAssign,1313 "Learning Python, 5th Edition",func.marked = True # Assign function attribute for later use,simpleAssign,1313 "Learning Python, 5th Edition",func.label = text,simpleAssign,1314 "Learning Python, 5th Edition","spam(a, b): # spam = annotate(...)(spam)",simpleAssign,1314 "Learning Python, 5th Edition","Decorator same as: Doubler = Private('data', 'size')(Doubler).",simpleAssign,1315 "Learning Python, 5th Edition",traceMe = False,simpleAssign,1315 "Learning Python, 5th Edition",attr] = value # Avoid looping,simpleAssign,1315 "Learning Python, 5th Edition",traceMe = True,simpleAssign,1315 "Learning Python, 5th Edition","X = Doubler('X is', [1, 2, 3])",simpleAssign,1316 "Learning Python, 5th Edition","Y = Doubler('Y is', [-10, −20, −30])",simpleAssign,1316 "Learning Python, 5th Edition",X.size = lambda S: 0,simpleAssign,1316 "Learning Python, 5th Edition",traceMe = False,simpleAssign,1319 "Learning Python, 5th Edition",Person: # Person = onInstance with state,simpleAssign,1320 "Learning Python, 5th Edition","X = Person('Bob', 40)",simpleAssign,1320 "Learning Python, 5th Edition","X = Person('bob', 40) # X is an onInstance",simpleAssign,1320 "Learning Python, 5th Edition",X = Person(),simpleAssign,1323 "Learning Python, 5th Edition",X = Person() # Name validations still work,simpleAssign,1323 "Learning Python, 5th Edition","exec('__%s__ = ProxyDesc(""__%s__"")' % (attr, attr))",simpleAssign,1327 "Learning Python, 5th Edition","__add__ = ProxyDesc(""__add__"")",simpleAssign,1327 "Learning Python, 5th Edition","__str__ = ProxyDesc(""__str__"")",simpleAssign,1327 "Learning Python, 5th Edition",aClass.__getattribute__ = getattributes,simpleAssign,1328 "Learning Python, 5th Edition",aClass.__setattr__ = setattributes # Insert accessors,simpleAssign,1328 "Learning Python, 5th Edition","sue = Person('Sue Jones', 'dev', 100000)",simpleAssign,1332 "Learning Python, 5th Edition",birthday = 5/31/1963,simpleAssign,1332 "Learning Python, 5th Edition",birthday = 5/31/1963,simpleAssign,1333 "Learning Python, 5th Edition",birthday = 5/31/1963,simpleAssign,1333 "Learning Python, 5th Edition",trace = True,simpleAssign,1333 "Learning Python, 5th Edition",code = func.__code__,simpleAssign,1333 "Learning Python, 5th Edition",allargs = code.co_varnames[:code.co_argcount],simpleAssign,1333 "Learning Python, 5th Edition",funcname = func.__name__,simpleAssign,1333 "Learning Python, 5th Edition",expected = list(allargs),simpleAssign,1334 "Learning Python, 5th Edition",positionals = expected[:len(pargs)],simpleAssign,1334 "Learning Python, 5th Edition","errmsg = errmsg.format(funcname, argname, low, high)",simpleAssign,1334 "Learning Python, 5th Edition",position = positionals.index(argname),simpleAssign,1334 "Learning Python, 5th Edition","errmsg = errmsg.format(funcname, argname, low, high)",simpleAssign,1334 "Learning Python, 5th Edition","persinfo(age=40, name='Bob')",simpleAssign,1334 "Learning Python, 5th Edition","birthday(5, D=1, Y=1963)",simpleAssign,1335 "Learning Python, 5th Edition","persinfo(age=150, name='Bob')",simpleAssign,1335 "Learning Python, 5th Edition","birthday(5, D=40, Y=1963)",simpleAssign,1335 "Learning Python, 5th Edition",giveRaise = rangetest(...)(giveRaise),simpleAssign,1335 "Learning Python, 5th Edition","bob = Person('Bob Smith', 'dev', 100000)",simpleAssign,1335 "Learning Python, 5th Edition","sue = Person('Sue Jones', 'dev', 100000)",simpleAssign,1335 "Learning Python, 5th Edition",bob.giveRaise(percent=1.20),simpleAssign,1335 "Learning Python, 5th Edition","omitargs(a, b=7, c=8, d=9):",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(1, 2, 3, d=4)",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(1, d=4)",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(d=4, a=1)",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(1, b=2, d=4)",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(d=8, c=7, a=1)",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(1, 2, 3, d=11) # Bad d",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(11, d=4) # Bad a",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(d=4, a=11) # Bad a",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(1, b=11, d=4) # Bad b",simpleAssign,1335 "Learning Python, 5th Edition","omitargs(d=8, c=7, a=11) # Bad a",simpleAssign,1335 "Learning Python, 5th Edition",birthday = 5/1/1963,simpleAssign,1335 "Learning Python, 5th Edition",x = 1 # Plus two more local variables,simpleAssign,1336 "Learning Python, 5th Edition",y = 2,simpleAssign,1336 "Learning Python, 5th Edition",code = func.__code__ # Code object of function object,simpleAssign,1336 "Learning Python, 5th Edition",code.co_varnames[:code.co_argcount] # <== First N locals are expected args,simpleAssign,1336 "Learning Python, 5th Edition",name=value” syntax must appear after any simple “name” in both places. As we’ve,simpleAssign,1337 "Learning Python, 5th Edition","omitargs(d=8, c=7, b=6)",simpleAssign,1339 "Learning Python, 5th Edition",code = func.__code__,simpleAssign,1339 "Learning Python, 5th Edition",code = func.__code__,simpleAssign,1339 "Learning Python, 5th Edition","func(a, b, c): # func = rangetest(...)(func)",simpleAssign,1340 "Learning Python, 5th Edition","func(a, b, c): # func = rangetest(...)(func)",simpleAssign,1341 "Learning Python, 5th Edition","func(1, 2, c=3) # Runs onCall, argchecks in scope",simpleAssign,1341 "Learning Python, 5th Edition",argchecks = func.__annotations__,simpleAssign,1341 "Learning Python, 5th Edition","func(a:(1, 5), b, c:(0.0, 1.0)): # func = rangetest(func)",simpleAssign,1341 "Learning Python, 5th Edition","func(1, 2, c=3) # Runs onCall, annotations on func",simpleAssign,1341 "Learning Python, 5th Edition",positionals = list(allargs)[:len(pargs)],simpleAssign,1342 "Learning Python, 5th Edition","func(a, b, c, d): # func = typetest(...)(func)",simpleAssign,1343 "Learning Python, 5th Edition","func(a: int, b, c: float, d): # func = typetest(func)",simpleAssign,1343 "Learning Python, 5th Edition","result = func(*args, **kargs)",simpleAssign,1345 "Learning Python, 5th Edition",elapsed = time.clock() - start,simpleAssign,1345 "Learning Python, 5th Edition",onCall.alltime = 0,simpleAssign,1345 "Learning Python, 5th Edition",force = list if sys.version_info[0] == 3 else (lambda X: X),simpleAssign,1345 "Learning Python, 5th Edition",listcomp(N): # Like listcomp = timer(...)(listcomp),simpleAssign,1346 "Learning Python, 5th Edition","result = func(5) # Time for this call, all calls, return value",simpleAssign,1346 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = timer()(giveRaise)",simpleAssign,1346 "Learning Python, 5th Edition",lastName(self): # lastName = timer(...)(lastName),simpleAssign,1346 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1346 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1346 "Learning Python, 5th Edition",allTime = 0.5793010457092784,simpleAssign,1346 "Learning Python, 5th Edition",allTime = 1.0861149923442373,simpleAssign,1346 "Learning Python, 5th Edition",traceMe = False,simpleAssign,1347 "Learning Python, 5th Edition",Person: # Person = onInstance with state,simpleAssign,1348 "Learning Python, 5th Edition","X = Person('Bob', 40)",simpleAssign,1349 "Learning Python, 5th Edition",trace = False,simpleAssign,1350 "Learning Python, 5th Edition",code = func.__code__,simpleAssign,1351 "Learning Python, 5th Edition",expected = list(code.co_varnames[:code.co_argcount]),simpleAssign,1351 "Learning Python, 5th Edition",positionals = expected[:len(pargs)],simpleAssign,1351 "Learning Python, 5th Edition",position = positionals.index(argname),simpleAssign,1351 "Learning Python, 5th Edition",try: result = test(),simpleAssign,1351 "Learning Python, 5th Edition","sum(1, d=4, b=2, c=3.0)",simpleAssign,1351 "Learning Python, 5th Edition","fails(lambda: sum(1, d=4, b=2, c=99))",simpleAssign,1351 "Learning Python, 5th Edition","when trace=True, in all but the last of these ""X"" is",simpleAssign,1352 "Learning Python, 5th Edition","fails(lambda: nester(1, 2, Z=3)) # Nested typetest is run: keyword",simpleAssign,1352 "Learning Python, 5th Edition","fails(lambda: nester(0, 2, 'spam')) # <==Outer rangetest not run: posit.",simpleAssign,1352 "Learning Python, 5th Edition","fails(lambda: nester(X=0, Y=2, Z='spam')) # Outer rangetest is run: keyword",simpleAssign,1352 "Learning Python, 5th Edition",date = 1/2/1960,simpleAssign,1352 "Learning Python, 5th Edition",X = C(),simpleAssign,1353 "Learning Python, 5th Edition",X = Client1() # Make an instance,simpleAssign,1359 "Learning Python, 5th Edition",X = Client1(),simpleAssign,1360 "Learning Python, 5th Edition",X = Client1(),simpleAssign,1360 "Learning Python, 5th Edition",X = Client1() # X is instance of Client1,simpleAssign,1361 "Learning Python, 5th Edition",Client1 = extras(Client1),simpleAssign,1362 "Learning Python, 5th Edition",Client2 = extras(Client2),simpleAssign,1362 "Learning Python, 5th Edition",Client3 = extras(Client3),simpleAssign,1362 "Learning Python, 5th Edition",X = Client1(),simpleAssign,1362 "Learning Python, 5th Edition",Client1: ... # Client1 = extras(Client1),simpleAssign,1362 "Learning Python, 5th Edition",X = Client1() # Makes instance of augmented class,simpleAssign,1362 "Learning Python, 5th Edition",X = C() # Class instance object,simpleAssign,1365 "Learning Python, 5th Edition",X = C() # classes have a class too,simpleAssign,1366 "Learning Python, 5th Edition",X = C() # classes have no class themselves,simpleAssign,1366 "Learning Python, 5th Edition","class = type(classname, superclasses, attributedict)",simpleAssign,1367 "Learning Python, 5th Edition",data = 1 # Class data attribute,simpleAssign,1368 "Learning Python, 5th Edition","Spam = type('Spam', (Eggs,), {'data': 1, 'meth': meth, '__module__': '__main__'})",simpleAssign,1368 "Learning Python, 5th Edition",i = x(),simpleAssign,1368 "Learning Python, 5th Edition","class = Meta(classname, superclasses, attributedict)",simpleAssign,1370 "Learning Python, 5th Edition",data = 1 # Class data attribute,simpleAssign,1370 "Learning Python, 5th Edition","Spam = Meta('Spam', (Eggs,), {'data': 1, 'meth': meth, '__module__': '__main__'})",simpleAssign,1370 "Learning Python, 5th Edition",data = 1 # Class data attribute,simpleAssign,1371 "Learning Python, 5th Edition",X = Spam(),simpleAssign,1371 "Learning Python, 5th Edition",data = 1 # Class data attribute,simpleAssign,1372 "Learning Python, 5th Edition",X = Spam(),simpleAssign,1372 "Learning Python, 5th Edition",data = 1 # Function returns class,simpleAssign,1373 "Learning Python, 5th Edition",X = Spam(),simpleAssign,1373 "Learning Python, 5th Edition","Class = self.__New__(classname, supers, classdict)",simpleAssign,1374 "Learning Python, 5th Edition",data = 1 # Called at end of statement,simpleAssign,1374 "Learning Python, 5th Edition",X = Spam(),simpleAssign,1374 "Learning Python, 5th Edition","Class = self.__New__(classname, supers, classdict)",simpleAssign,1375 "Learning Python, 5th Edition",data = 1,simpleAssign,1376 "Learning Python, 5th Edition",X = Spam(),simpleAssign,1377 "Learning Python, 5th Edition",The metaclass=M declaration in a user-defined class is inherited by the class’s normal,simpleAssign,1379 "Learning Python, 5th Edition",X = Sub() # Normal instance of user-defined class,simpleAssign,1380 "Learning Python, 5th Edition",attr = 1,simpleAssign,1381 "Learning Python, 5th Edition",I = B() # I inherits from class but not meta!,simpleAssign,1381 "Learning Python, 5th Edition",class A: attr = 1,simpleAssign,1381 "Learning Python, 5th Edition",I = B(),simpleAssign,1381 "Learning Python, 5th Edition",attr = 1,simpleAssign,1381 "Learning Python, 5th Edition",class A: attr = 2,simpleAssign,1381 "Learning Python, 5th Edition",I = B(),simpleAssign,1381 "Learning Python, 5th Edition",attr = 1,simpleAssign,1381 "Learning Python, 5th Edition",class A: attr = 2,simpleAssign,1381 "Learning Python, 5th Edition",I = C(),simpleAssign,1382 "Learning Python, 5th Edition",attr1 = 1 # Metaclass inheritance tree,simpleAssign,1382 "Learning Python, 5th Edition",class C1: attr3 = 3 # Superclass inheritance tree,simpleAssign,1382 "Learning Python, 5th Edition",I = C() # Class data descriptors have precedence,simpleAssign,1384 "Learning Python, 5th Edition",class C: d = D() # Data descriptor attribute,simpleAssign,1385 "Learning Python, 5th Edition",I = C(),simpleAssign,1385 "Learning Python, 5th Edition",I.d = 1,simpleAssign,1385 "Learning Python, 5th Edition",class C: d = D(),simpleAssign,1385 "Learning Python, 5th Edition",I = C(),simpleAssign,1385 "Learning Python, 5th Edition",attr = 1 # Built-ins skip a step,simpleAssign,1387 "Learning Python, 5th Edition",I = C(),simpleAssign,1387 "Learning Python, 5th Edition",I.__str__ = lambda: 'instance',simpleAssign,1387 "Learning Python, 5th Edition",I.attr = 2; I.attr,simpleAssign,1387 "Learning Python, 5th Edition","def x(cls): print('ax', cls) # A metaclass (instances=classes)",simpleAssign,1388 "Learning Python, 5th Edition",I = B() # Instance method calls: get inst,simpleAssign,1389 "Learning Python, 5th Edition","y, z = 11, 22",simpleAssign,1389 "Learning Python, 5th Edition",I = B(),simpleAssign,1389 "Learning Python, 5th Edition",I = B(),simpleAssign,1390 "Learning Python, 5th Edition",I = B(),simpleAssign,1390 "Learning Python, 5th Edition",Client1.eggs = eggsfunc,simpleAssign,1392 "Learning Python, 5th Edition",Client1.ham = hamfunc,simpleAssign,1392 "Learning Python, 5th Edition",Client2.eggs = eggsfunc,simpleAssign,1392 "Learning Python, 5th Edition",Client2.ham = hamfunc,simpleAssign,1392 "Learning Python, 5th Edition",X = Client1('Ni!'),simpleAssign,1392 "Learning Python, 5th Edition",Y = Client2(),simpleAssign,1392 "Learning Python, 5th Edition",classdict['eggs'] = eggsfunc,simpleAssign,1393 "Learning Python, 5th Edition",classdict['ham'] = hamfunc,simpleAssign,1393 "Learning Python, 5th Edition",X = Client1('Ni!'),simpleAssign,1393 "Learning Python, 5th Edition",Y = Client2(),simpleAssign,1393 "Learning Python, 5th Edition",classdict['eggs'] = eggsfunc2,simpleAssign,1394 "Learning Python, 5th Edition",classdict['ham'] = lambda *args: 'Not supported',simpleAssign,1394 "Learning Python, 5th Edition","aClass.eggs = eggsfunc # Manages class, not instance",simpleAssign,1395 "Learning Python, 5th Edition",aClass.ham = hamfunc # Equiv to metaclass __init__,simpleAssign,1395 "Learning Python, 5th Edition",Client1: # Client1 = Extender(Client1),simpleAssign,1395 "Learning Python, 5th Edition",X = Client1('Ni!') # X is a Client1 instance,simpleAssign,1395 "Learning Python, 5th Edition",Y = Client2(),simpleAssign,1395 "Learning Python, 5th Edition",Person: # Person = Tracer(Person),simpleAssign,1396 "Learning Python, 5th Edition","bob = Person('Bob', 40, 50) # bob is really a Wrapper",simpleAssign,1396 "Learning Python, 5th Edition","aClass = type(classname, supers, classdict) # Make client class",simpleAssign,1397 "Learning Python, 5th Edition","bob = Person('Bob', 40, 50) # bob is really a Wrapper",simpleAssign,1397 "Learning Python, 5th Edition",x = 1,simpleAssign,1398 "Learning Python, 5th Edition",y = 2,simpleAssign,1398 "Learning Python, 5th Edition",I = B(),simpleAssign,1398 "Learning Python, 5th Edition",calls = 0 # Else self is decorator instance only,simpleAssign,1400 "Learning Python, 5th Edition","result = func(*args, **kargs)",simpleAssign,1400 "Learning Python, 5th Edition",elapsed = time.clock() - start,simpleAssign,1400 "Learning Python, 5th Edition",onCall.alltime = 0,simpleAssign,1400 "Learning Python, 5th Edition","giveRaise(self, percent): # giveRaise = tracer(giverRaise)",simpleAssign,1401 "Learning Python, 5th Edition",lastName(self): # lastName = tracer(lastName),simpleAssign,1401 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1401 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1401 "Learning Python, 5th Edition",classdict[attr] = tracer(attrval) # Decorate it,simpleAssign,1402 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1402 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1402 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1403 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1403 "Learning Python, 5th Edition","bob = Person('Bob Smith', 50000)",simpleAssign,1405 "Learning Python, 5th Edition","sue = Person('Sue Jones', 100000)",simpleAssign,1405 "Learning Python, 5th Edition","class=M). In Python 2.X, use a class attribute instead: __metaclass__ = M. In 3.X,",simpleAssign,1408 "Learning Python, 5th Edition","Basic, name=value, *pargs, **kargs, keyword-only",simpleAssign,1411 "Learning Python, 5th Edition",if sys.version_info[0] == 2: # 2.X compatibility,simpleAssign,1414 "Learning Python, 5th Edition",input = raw_input,simpleAssign,1414 "Learning Python, 5th Edition",htmlescape = cgi.escape,simpleAssign,1414 "Learning Python, 5th Edition",htmlescape = html.escape,simpleAssign,1415 "Learning Python, 5th Edition",maxline = 60 # For seperator lines,simpleAssign,1415 "Learning Python, 5th Edition",browser = True # Display in a browser,simpleAssign,1415 "Learning Python, 5th Edition","Official Certificate <=== Date: %s",simpleAssign,1415 "Learning Python, 5th Edition",date = time.asctime(),simpleAssign,1415 "Learning Python, 5th Edition",name = input('Enter your name: ').strip() or 'An unknown reader',simpleAssign,1415 "Learning Python, 5th Edition","text = template % (sept, date, name, book, sept)",simpleAssign,1415 "Learning Python, 5th Edition","htmlto = saveto.replace('.txt', '.html')",simpleAssign,1415 "Learning Python, 5th Edition","tags = text.replace(sept, '<hr>') # Insert a few tags",simpleAssign,1416 "Learning Python, 5th Edition","tags = tags.replace('===>', '<h1 align=center>')",simpleAssign,1416 "Learning Python, 5th Edition","tags = tags.replace('<===', '</h1>')",simpleAssign,1416 "Learning Python, 5th Edition",tags = tags.split('\n') # Line-by-line mods,simpleAssign,1416 "Learning Python, 5th Edition","foot = '<table>\n<td><img src=""ora-lp.jpg"" hspace=5>\n<td>%s</table>\n' % link",simpleAssign,1416 "Learning Python, 5th Edition",set PYTHONPATH=c:\pycode\utilities;d:\pycode\package1,simpleAssign,1430 "Learning Python, 5th Edition",C:\code> python -m pdb showargs.py a b -c # Debugging a script (c=continue),simpleAssign,1433 "Learning Python, 5th Edition",X = 0,simpleAssign,1434 "Learning Python, 5th Edition",C:\code> set PY_PYTHON=3 # Or via Control Panel/System,simpleAssign,1446 "Learning Python, 5th Edition",C:\code> set PY_PYTHON3=3.1 # Use PY_PYTHON2 for 2.X,simpleAssign,1446 "Learning Python, 5th Edition","PY_PYTHON=3). As mentioned in the prior point, manually changing your file associations",simpleAssign,1449 "Learning Python, 5th Edition","Extended sequence unpacking in 3.0: a, *b = seq",simpleAssign,1460 "Learning Python, 5th Edition",X != Y,simpleAssign,1460 "Learning Python, 5th Edition",K in D (or D.get(key) != None),simpleAssign,1460 "Learning Python, 5th Edition",X=D.keys(); X.sort(),simpleAssign,1461 "Learning Python, 5th Edition","def f(x): (a, b) = x",simpleAssign,1461 "Learning Python, 5th Edition",X=iter(file)),simpleAssign,1461 "Learning Python, 5th Edition",Use key=transform or,simpleAssign,1461 "Learning Python, 5th Edition",reverse=True,simpleAssign,1461 "Learning Python, 5th Edition","Dictionary <, >, <=, >= types.ListType",simpleAssign,1462 "Learning Python, 5th Edition",D['w'] = 0 # Create a new entry,simpleAssign,1469 "Learning Python, 5th Edition","D[(1,2,3)] = 4 # A tuple used as a key (immutable)",simpleAssign,1469 "Learning Python, 5th Edition",L[1:2] = 1,simpleAssign,1470 "Learning Python, 5th Edition","X, Y = Y, X",simpleAssign,1470 "Learning Python, 5th Edition",D['d'] = 4,simpleAssign,1471 "Learning Python, 5th Edition",L[2] = 3,simpleAssign,1471 "Learning Python, 5th Edition",x = 0,simpleAssign,1473 "Learning Python, 5th Edition","keys = list(D.keys()) # list() required in 3.X, not in 2.X",simpleAssign,1474 "Learning Python, 5th Edition",X = 5,simpleAssign,1474 "Learning Python, 5th Edition",i = 0,simpleAssign,1474 "Learning Python, 5th Edition",X = 5,simpleAssign,1475 "Learning Python, 5th Edition",X = 5,simpleAssign,1475 "Learning Python, 5th Edition",X = 5,simpleAssign,1475 "Learning Python, 5th Edition","L = list(map(lambda x: 2**x, range(7))) # Or [2**x for x in range(7)]",simpleAssign,1475 "Learning Python, 5th Edition",if type(args[0]) == type(0): # Integer?,simpleAssign,1476 "Learning Python, 5th Edition",sum = 0 # Init to zero,simpleAssign,1476 "Learning Python, 5th Edition",sum = args[0][:0] # Use empty slice of arg1,simpleAssign,1476 "Learning Python, 5th Edition",sum = args[0] # Init to arg1,simpleAssign,1476 "Learning Python, 5th Edition",tot = args[0],simpleAssign,1477 "Learning Python, 5th Edition",argskeys = list(args.keys()) # list needed in 3.X!,simpleAssign,1477 "Learning Python, 5th Edition",tot = args[argskeys[0]],simpleAssign,1477 "Learning Python, 5th Edition",args = list(args.values()) # list needed to index in 3.X!,simpleAssign,1477 "Learning Python, 5th Edition",tot = args[0],simpleAssign,1477 "Learning Python, 5th Edition","remember that if you assign (e = d) rather than copying, you generate a reference",simpleAssign,1478 "Learning Python, 5th Edition",new[key] = old[key],simpleAssign,1478 "Learning Python, 5th Edition",new[key] = d1[key],simpleAssign,1478 "Learning Python, 5th Edition",new[key] = d2[key],simpleAssign,1478 "Learning Python, 5th Edition",e = copyDict(d),simpleAssign,1478 "Learning Python, 5th Edition","z = addDict(x, y)",simpleAssign,1478 "Learning Python, 5th Edition",if y <= 1: # For some y > 1,simpleAssign,1479 "Learning Python, 5th Edition",x = y // 2 # 3.X / fails,simpleAssign,1479 "Learning Python, 5th Edition",reps = 10000,simpleAssign,1481 "Learning Python, 5th Edition",repslist = range(reps) # Pull out range list time for 2.X,simpleAssign,1481 "Learning Python, 5th Edition",res = sqrt(i),simpleAssign,1481 "Learning Python, 5th Edition","res = pow(i, .5)",simpleAssign,1481 "Learning Python, 5th Edition",res = i ** .5,simpleAssign,1481 "Learning Python, 5th Edition","elapsed, result = timer2.bestoftotal(test, _reps1=3, _reps=1000)",simpleAssign,1481 "Learning Python, 5th Edition",new[i] = i,simpleAssign,1482 "Learning Python, 5th Edition","total(dictcomp, 1000000, _reps=50)[0] # Total to make 50 1M-item dicts",simpleAssign,1482 "Learning Python, 5th Edition","total(dictloop, 1000000, _reps=50)[0]",simpleAssign,1482 "Learning Python, 5th Edition","t = list(map(lambda x: print(x, end=' '), range(5, 0, −1)))",simpleAssign,1483 "Learning Python, 5th Edition",if N == 1: # Fails at 999 by default,simpleAssign,1484 "Learning Python, 5th Edition",res = 1,simpleAssign,1484 "Learning Python, 5th Edition",res *= i # Iterative,simpleAssign,1484 "Learning Python, 5th Edition",tot = 0,simpleAssign,1485 "Learning Python, 5th Edition",tot = 0,simpleAssign,1485 "Learning Python, 5th Edition",somename = 42,simpleAssign,1488 "Learning Python, 5th Edition",new[k] = x[k],simpleAssign,1489 "Learning Python, 5th Edition",new[k] = y[k],simpleAssign,1489 "Learning Python, 5th Edition",x = Adder(),simpleAssign,1489 "Learning Python, 5th Edition",x = ListAdder(),simpleAssign,1489 "Learning Python, 5th Edition",x = DictAdder(),simpleAssign,1489 "Learning Python, 5th Edition",x = Adder([1]),simpleAssign,1489 "Learning Python, 5th Edition",x = ListAdder([1]),simpleAssign,1490 "Learning Python, 5th Edition",d = self.data.copy() # Change to use self.data instead of x,simpleAssign,1490 "Learning Python, 5th Edition","x = ListAdder([1, 2, 3])",simpleAssign,1490 "Learning Python, 5th Edition",x = MyList('spam'),simpleAssign,1491 "Learning Python, 5th Edition",calls = 0 # Shared by instances,simpleAssign,1492 "Learning Python, 5th Edition",x = MyListSub('spam'),simpleAssign,1492 "Learning Python, 5th Edition",y = MyListSub('foo'),simpleAssign,1492 "Learning Python, 5th Edition",x = Attrs(),simpleAssign,1493 "Learning Python, 5th Edition","x = Set([1, 2, 3, 4]) # Runs __init__",simpleAssign,1493 "Learning Python, 5th Edition","y = Set([3, 4, 5])",simpleAssign,1493 "Learning Python, 5th Edition","z = Set(""hello"") # __init__ removes duplicates",simpleAssign,1493 "Learning Python, 5th Edition","x = MultiSet([1, 2, 3, 4])",simpleAssign,1494 "Learning Python, 5th Edition","y = MultiSet([3, 4, 5])",simpleAssign,1494 "Learning Python, 5th Edition","z = MultiSet([0, 1, 2])",simpleAssign,1494 "Learning Python, 5th Edition",w = MultiSet('spam') # String sets,simpleAssign,1495 "Learning Python, 5th Edition",data1=spam,simpleAssign,1495 "Learning Python, 5th Edition",data2=eggs,simpleAssign,1495 "Learning Python, 5th Edition",data3=42,simpleAssign,1495 "Learning Python, 5th Edition",x = Lunch() # Self-test code,simpleAssign,1496 "Learning Python, 5th Edition",dirname = r'C:\Python33\Lib',simpleAssign,1499 "Learning Python, 5th Edition",filesize = os.path.getsize(filename),simpleAssign,1499 "Learning Python, 5th Edition",fullsize = os.path.getsize(fullname),simpleAssign,1500 "Learning Python, 5th Edition",thisDir = os.path.normpath(thisDir),simpleAssign,1500 "Learning Python, 5th Edition",visited[thisDir.upper()] = True,simpleAssign,1500 "Learning Python, 5th Edition",pysize = os.path.getsize(pypath),simpleAssign,1500 "Learning Python, 5th Edition","cols = line.split(',')",simpleAssign,1500 "Learning Python, 5th Edition",filename = sys.argv[1],simpleAssign,1501 "Learning Python, 5th Edition",numcols = int(sys.argv[2]),simpleAssign,1501 "Learning Python, 5th Edition","cols = line.split(',')",simpleAssign,1501 "Learning Python, 5th Edition",fontsize = 25,simpleAssign,1501 "Learning Python, 5th Edition",popup = Toplevel(),simpleAssign,1501 "Learning Python, 5th Edition",color = random.choice(colors),simpleAssign,1502 "Learning Python, 5th Edition","Label(popup, text='Popup', bg='black', fg=color).pack()",simpleAssign,1502 "Learning Python, 5th Edition",L.config(fg=color),simpleAssign,1502 "Learning Python, 5th Edition",L.config(fg=random.choice(colors)),simpleAssign,1502 "Learning Python, 5th Edition",win = Tk(),simpleAssign,1502 "Learning Python, 5th Edition","L = Label(win, text='Spam',",simpleAssign,1502 "Learning Python, 5th Edition",relief=RAISED),simpleAssign,1502 "Learning Python, 5th Edition","L.pack(side=TOP, expand=YES, fill=BOTH)",simpleAssign,1502 "Learning Python, 5th Edition","Button(win, text='timer', command=timer).pack(side=BOTTOM, fill=X)",simpleAssign,1502 "Learning Python, 5th Edition","Button(win, text='grow', command=grow).pack(side=BOTTOM, fill=X)",simpleAssign,1502 "Learning Python, 5th Edition","Button(parent, text='Spam', command=self.reply).pack(side=LEFT)",simpleAssign,1502 "Learning Python, 5th Edition","Button(parent, text='Grow', command=self.grow).pack(side=LEFT)",simpleAssign,1502 "Learning Python, 5th Edition","Button(parent, text='Stop', command=self.stop).pack(side=LEFT)",simpleAssign,1502 "Learning Python, 5th Edition",color = random.choice(self.colors),simpleAssign,1502 "Learning Python, 5th Edition",mailpasswd = getpass.getpass('Password for %s?' % mailserver),simpleAssign,1503 "Learning Python, 5th Edition",server = poplib.POP3(mailserver),simpleAssign,1503 "Learning Python, 5th Edition","msgCount, mboxSize = server.stat()",simpleAssign,1503 "Learning Python, 5th Edition",msginfo = server.list(),simpleAssign,1503 "Learning Python, 5th Edition",msgsize = msginfo[1][i].split()[1],simpleAssign,1503 "Learning Python, 5th Edition","resp, hdrlines, octets = server.top(msgnum, 0) # Get hdrs only",simpleAssign,1503 "Learning Python, 5th Edition",form = cgi.FieldStorage() # Parse form data,simpleAssign,1504 "Learning Python, 5th Edition",db['bob'] = rec1,simpleAssign,1504 "Learning Python, 5th Edition",db['sue'] = rec2,simpleAssign,1504 "Learning Python, 5th Edition",bob = db['bob'],simpleAssign,1504 "Learning Python, 5th Edition",db['bob'] = bob,simpleAssign,1505 "Learning Python, 5th Edition","conn = Connect(host='localhost', user='root', passwd='XXXXXXX')",simpleAssign,1505 "Learning Python, 5th Edition",curs = conn.cursor(),simpleAssign,1505 "Learning Python, 5th Edition",connection = FTP(sitename) # Connect to FTP site,simpleAssign,1506