Catálogo de publicaciones - libros
Beginning Python: From Novice to Professional
Magnus Lie Hetland
Resumen/Descripción – provisto por la editorial
No disponible.
Palabras clave – provistas por la editorial
Software Engineering/Programming and Operating Systems
Disponibilidad
Institución detectada | Año de publicación | Navegá | Descargá | Solicitá |
---|---|---|---|---|
No detectada | 2005 | SpringerLink |
Información
Tipo de recurso:
libros
ISBN impreso
978-1-59059-519-0
ISBN electrónico
978-1-4302-0072-7
Editor responsable
Springer Nature
País de edición
Reino Unido
Fecha de publicación
2005
Información sobre derechos de publicación
© Apress 2005
Cobertura temática
Tabla de contenidos
Instant Hacking: The Basics
Magnus Lie Hetland
Finally, you now know how to create shiny, professional–looking software with fancy GUI installers—or how to automate the generation of those precious .tar.gz files. Here is a summary of the specific concepts covered:
. The Distutils toolkit lets you write installer scripts, conventionally called setup.py, which let you install modules, packages, and extensions, and which let you build distributable archives and simple Windows installers.
. You can run your setup.py script with several commands, such as build, build_ext, install, sdist, and bdist.
Installers. There are many installer generators available, and you can use many of them to install your Python programs, making the process easier for your users.
. You can use Distutils to have your C extensions compiled automatically, with Distutils automatically locating your Python installation and figuring out which compiler to use. You can even have it run SWIG automatically.
py2exe. The py2exe extension to Distutils can be used to create executable binaries from your Python programs. Along with a couple of extra files (which can be conveniently installed with an installer), these .exe files can be run without installing a Python interpreter separately.
Pp. 1-30
Lists and Tuples
Magnus Lie Hetland
Let’s review some of the most important concepts covered in this chapter:
. A sequence is a data structure in which the elements are numbered (starting with zero). Examples of sequence types are lists, strings, and tuples. Of these, lists are mutable (you can change them), whereas tuples and strings are immutable (once they’re created, they’re fixed). Parts of a sequence can be accessed through slicing, supplying two indices, indicating the starting and ending position of the slice. To change a list, you assign new values to its positions, or use assignment to overwrite entire slices.
. Whether a value can be found in a sequence (or other container) is checked with the operator in. Using in with strings is a special case—it will let you look for substrings.
. Some of the built‐in types (such as lists and strings, but not tuples) have many useful methods attached to them. These are a bit like functions, except that they are tied closely to a specific value. Methods are an important aspect of object–oriented programming, which we look at later, in Chapter 7.
Pp. 31-52
Working with Strings
Magnus Lie Hetland
In this chapter, you have seen two important ways of working with strings:
. The modulo operator (%) can be used to splice values into a string that contains conversion flags, such as %s. You can use this to format values in many ways, including right or left justification, setting a specific field width and precision, adding a sign (plus or minus), or left–padding with zeros.
. Strings have a plethora of methods. Some of them are extremely useful (such as split and join), while others are used less often (such as istitle or capitalize).
Pp. 53-66
Dictionaries: When Indices Won’t Do
Magnus Lie Hetland
In this chapter, you learned about the following:
. A mapping enables you to label its elements with any immutable object, the most usual types being strings and tuples. The only built–in mapping type in Python is the dictionary.
. You can apply the string formatting operation to dictionaries by including names (keys) in the formatting specifiers. When using tuples in string formatting, you need to have one formatting specifier for each element in the tuple. When using dictionaries, you can have fewer specifiers than you have items in the dictionary.
. Dictionaries have quite a few methods, which are called in the same way as list and string methods.
Pp. 67-79
Conditionals, Loops, and Some Other Statements
Magnus Lie Hetland
Let’s review some of the most important concepts covered in this chapter:
. A sequence is a data structure in which the elements are numbered (starting with zero). Examples of sequence types are lists, strings, and tuples. Of these, lists are mutable (you can change them), whereas tuples and strings are immutable (once they’re created, they’re fixed). Parts of a sequence can be accessed through slicing, supplying two indices, indicating the starting and ending position of the slice. To change a list, you assign new values to its positions, or use assignment to overwrite entire slices.
. Whether a value can be found in a sequence (or other container) is checked with the operator in. Using in with strings is a special case—it will let you look for substrings.
. Some of the built‐in types (such as lists and strings, but not tuples) have many useful methods attached to them. These are a bit like functions, except that they are tied closely to a specific value. Methods are an important aspect of object–oriented programming, which we look at later, in Chapter 7.
Pp. 81-108
Abstraction
Magnus Lie Hetland
In this chapter, you’ve learned several things about abstraction in general, and functions in particular:
. Abstraction is the art of hiding unnecessary details. You can make your program more abstract by defining functions that handle the details. Function definition. Functions are defined with the def statement. They are blocks of statements that receive values (parameters) from the “outside world” and may return one or more values as the result of their computation.
. Functions receive what they need to know in the form of parameters—variables that are set when the function is called. There are two types of parameters in Python, positional parameters and keyword parameters. Parameters can be made optional by giving them default values.
. Variables are stored in scopes (also called namespaces). There are two main scopes in Python—the global scope and the local scope. Scopes may be nested.
. A function can call itself—and if it does, it’s called recursion. Everything you can do with recursion can also be done by loops, but sometimes a recursive function is more readable.
. Python has some facilities for programming in a functional style. Among these are lambda expressions and the map, filter, and reduce functions.
Pp. 109-138
More Abstraction
Magnus Lie Hetland
This reference chapter has described every command, option and public DB:: variable provided by the Perl debugger. You will be able to use any of these tools to control your program’s execution, study its behavior, and inspect or change any data during the runtime of the program. Finally, you learned how to call the debugger in several different cases, depending on the context required.
Pp. 139-158
Exceptions
Magnus Lie Hetland
This reference chapter has described every command, option and public DB:: variable provided by the Perl debugger. You will be able to use any of these tools to control your program’s execution, study its behavior, and inspect or change any data during the runtime of the program. Finally, you learned how to call the debugger in several different cases, depending on the context required.
Pp. 159-171
Magic Methods, Properties, and Iterators
Magnus Lie Hetland
This reference chapter has described every command, option and public DB:: variable provided by the Perl debugger. You will be able to use any of these tools to control your program’s execution, study its behavior, and inspect or change any data during the runtime of the program. Finally, you learned how to call the debugger in several different cases, depending on the context required.
Pp. 173-202
Batteries Included
Magnus Lie Hetland
This reference chapter has described every command, option and public DB:: variable provided by the Perl debugger. You will be able to use any of these tools to control your program’s execution, study its behavior, and inspect or change any data during the runtime of the program. Finally, you learned how to call the debugger in several different cases, depending on the context required.
Pp. 203-253