jagomart
digital resources
picture1_Hacking With Python Pdf 197432 | Generatorusenix


 117x       Filetype PDF       File size 0.36 MB       Source: www.dabeaz.com


File: Hacking With Python Pdf 197432 | Generatorusenix
python generator hacking david beazley http www dabeaz com presented at usenix technical conference san diego june 2009 copyright c 2009 david beazley http www dabeaz com 1 introduction at ...

icon picture PDF Filetype PDF | Posted on 07 Feb 2023 | 2 years ago
Partial capture of text on file.
                               Python Generator 
                                            Hacking
                                              David Beazley
                                        http://www.dabeaz.com
                           Presented at USENIX Technical Conference
                                         San Diego, June 2009
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 1
                                       Introduction
                         • At PyCon'2008 (Chicago), I gave a popular 
                            tutorial on generator functions
                                   http://www.dabeaz.com/generators
                         • At PyCon'2009 (Chicago), I followed it up 
                            with a tutorial on coroutines (a related topic)
                                   http://www.dabeaz.com/coroutines
                         • This tutorial is a kind of "mashup"
                         • Details from both, but not every last bit
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 2
                                               Goals
                         • Take a look at Python generator functions
                         • A feature of Python often overlooked, but 
                            which has a large number of practical uses
                         • Especially for programmers who would be 
                            likely to attend a USENIX conference
                         • So, my main goal is to take this facet of 
                            Python, shed some light on it, and show how 
                            it's rather "nifty."
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 3
                                      Support Files
                         • Files used in this tutorial are available here:
                        http://www.dabeaz.com/usenix2009/generators/
                         • Go there to follow along with the examples
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 4
                                         Disclaimer
                        • This isn't meant to be an exhaustive tutorial 
                            on every possible use of generators and 
                            related theory
                        • Will mostly go through a series of examples
                        • You'll have to consult Python documentation 
                            for some of the more subtle details
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 5
                                                Part I
                              Introduction to Iterators and Generators
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 6
                                            Iteration
                          • As you know, Python has a "for" statement
                          • You use it to iterate over a collection of items
                               >>> for x in [1,4,5,10]:
                               ...     print x,
                               ...
                               1 4 5 10
                               >>>
                          • And, as you have probably noticed, you can 
                              iterate over many different kinds of objects 
                              (not just lists)
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 7
                             Iterating over a Dict
                          • If you iterate over a dictionary you get keys
                              >>> prices = { 'GOOG' : 490.10,
                              ...            'AAPL' : 145.23,
                              ...            'YHOO' : 21.71 }
                              ...
                              >>> for key in prices:
                              ...     print key
                              ...
                              YHOO
                              GOOG
                              AAPL
                              >>>
                 Copyright (C) 2009,  David Beazley, http://www.dabeaz.com                 8
The words contained in this file might help you see if this file matches what you are looking for:

...Python generator hacking david beazley http www dabeaz com presented at usenix technical conference san diego june copyright c introduction pycon chicago i gave a popular tutorial on functions generators followed it up with coroutines related topic this is kind of mashup details from both but not every last bit goals take look feature often overlooked which has large number practical uses especially for programmers who would be likely to attend so my main goal facet shed some light and show how s rather nifty support files used in are available here go there follow along the examples disclaimer isn t meant an exhaustive possible use theory will mostly through series you ll have consult documentation more subtle part iterators iteration as know statement iterate over collection items x print probably noticed can many different kinds objects just lists iterating dict if dictionary get keys prices goog aapl yhoo key...

no reviews yet
Please Login to review.