nowwe have dictionaryand can look up books by title using the normal syntax in summarycomprehensions are not advanced pythonnor are they "non-objectorientedtools that should be avoided they are simply more concise and optimized syntax for creating listsetor dictionary from an existing sequence generator expressions sometimes we want to process new sequence without placing new listsetor dictionary into system memory if we're just looping over items one at timeand don' actually care about having final container object createdcreating that container is waste of memory when processing one item at timewe only need the current object stored in memory at any one moment but when we create containerall the objects have to be stored in that container before we start processing them for exampleconsider program that processes log files very simple log might contain information in this formatjan : : debug jan : : info jan : : warning serious jan : : warning jan : : info jan : : debug if you want to figure something out jan : : info but helpful jan : : warning jan : : warning this is debugging message this is an information method this is warning it could be another warning sent here' some information debug messages are only useful information is usually harmlesswarnings should be heeded watch for warnings log files for popular web serversdatabasesor -mail servers can contain many gigabytes of data ( recently had to clean nearly terabytes of logs off misbehaving systemif we want to process each line in the logwe can' use list comprehensionit would create list containing every line in the file this probably wouldn' fit in ram and could bring the computer to its kneesdepending on the operating system if we used for loop on the log filewe could process one line at time before reading the next one into memory wouldn' be nice if we could use comprehension syntax to get the same effectthis is where generator expressions come in they use the same syntax as comprehensionsbut they don' create final container object to create generator expressionwrap the comprehension in (instead of [or {