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.

loops (continued)list comprehensions (see listcomprehensions)Loop else block, 250pass statement, 250, 251readlines method, 261string iteration, 133while, 248–250examples, 249general format, 249M_ _main_ _ module, 434map function, 260, 263, 269, 352, 366functional programming and, 353list comprehensions and, 361mappings, 150math module, 69math on user inputs, 211matrixes, list comprehensions and, 358merging components, 31metaprograms, 435methods, 72, 458, 484–486bound, 536bound instance method objects, 534call possibilities, 486calling, 485calling superclass constructors, 486calls made through an instance, 484class (see also class methods)example, 485reassigning names, 555strings, 143unbound, 553unbound class method objects, 534MFC, 10min wakeup call, 336mixed types, expression operators, 97mix-in classes, 529mod_python package, 10modification, mutable types, 150module packages, 415–425from versus import, 419import basics, 415–418_ _init_ _.py files, 416dotted paths, 415from * statement behavior, 418module namespace initialization, 417package initialization, 417search path settings, 416import example, 418–420imports search paths, 420package imports, when required, 421why use package imports, 420–423modules, 38, 385–397, 630.pth file directories, 391advanced selection concepts, 393advanced topics, 426–447assignments, 401changing search path, 430classes, 471code reuse, 386coding basics, 398–414coding with multiple names, 49creating, 398–399cross-file name changes, 402data hiding in, 426_ _all_ _ variable, 427preventing copying, 426defining, 398design concepts, 434–437changing other module’svariables, 435cohesion, 434coupling, 434introspection, 435metaprograms, 435enabling future language features, 427extension, 399file selection, 393filenames, 398from * statement, 400from statement, 385, 400potential pitfalls, 403gotchas, 437–444from * statement, 440from statement, 439importing by name string, 438recursive from imports, 443reload function, 442reload, from, and interactivetesting, 441reloading, 440statement order, 437home directory, 391implementing shared services ordata, 386import and from equivalence, 402import as extension, 431import statement, 385, 399when required, 404import statement and attributes, 387–389import statmenthappening only once, 400692 | Index

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

Saved successfully!

Ooh no, something went wrong!