12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

files (continued)manual close, 177opening, 176other file-like tools, 86other tools, 182reading entire file into a single string, 177reading entire file into list of linestrings, 177reading next line into a string, 177reading next N bytes into a string, 177using, 177writing a string of bytes into file, 177writing all line strings in a list intofile, 177filter function, 248, 353, 356find method, 145flexibility, breaking, 88floating-point literals, 94floating-point numbers, 93floating-point object math, 107for loops, 254–258basic usage, 256general format, 254inside a function, 306iterators, 260list comprehensions and, 360nested, 257readlines method, 261strings, 256tuples, 256tuple of targets, 257for/else statement, 202frameworks, 461freeware, 13from * statement, 400, 440from statement, 202, 400, 439import statement and, 402modules, 385potential pitfalls, 403recursive, 443frozen binaries, 31, 56function decorators, 505, 528, 556–558example, 558function design concepts, 369function gotchasdefaults and mutable objects, 373enclosing scope loop variables, 375functions without returns, 375local names, 372functional programming, 353filter, 353reduce, 354functions, 299–309, 310, 630advanced related topics, 344–381anonymous, 344–349apply, 350applying to arguments, 350as objects, 370calling, 292calls, 304coding, 300–303arguments, 301def statement, 301, 302–304global statement, 301return statement, 301, 302defined, 299filter, 353intersecting sequences, 306–308calls, 306for loop inside function, 306local variables, 308polymorphism, 307lambda, 344–349maximizing code reuse and minimizingredundancy, 300number tools, 106procedural decomposition, 300reduce, 354registering as event handlers, 503–505related statements and expressions, 299signal conditions with raise, 622that change objects in-place, 292why use, 300Ggarbage collection, 14, 81, 115general-set functions, 338generator expressions, 365generators, 360–366example, 362send method versus next method, 364_ _getattr_ _ method, 492, 498, 528_ _getattribute_ _ methodnew-style classes only, 552_ _getitem_ _ method, 492, 493global, 299global scopes, 311, 313global statement, 203, 301, 316–320global variables, minimizing, 317global-scope variables, accessing, 319graphical user interface, 9GTK, 10688 | Index

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!