|
|
Previous<
3
4
5
6
7
8
9
10
11
> Next
|
|
Its strings can use either single or double quotation marks, and you can have quotation marks of one kind inside a string that uses the other kind (i.e. "He said 'hello'." is valid). Multiline strings are enclosed in triple double (or single) quotes ("""). Python supports Unicode out of the box, using the syntax u"This is a unicode string". To fill a string with values, you use the % (modulo) operator and a tuple. Each %s gets replaced with an item from the tuple, left to right, and you can also use dictionary substitutions, like so:
|
|
|
|
There are a number of Special Interest Groups (SIGs) for focused collaborative efforts to develop, improve, or maintain specific Python resources. Each SIG has a charter, a coordinator, a mailing list, and a directory on the Python website. SIG membership is informal, defined by subscription to the SIG's mailing list. Anyone can join a SIG, and participate in the development discussions via the SIG's mailing list. Below is the list of currently active Python SIGs, with links to their resources. The link in the first column directs you to the SIG's home page: a page with more information about the SIG. The links in the "Info" column direct you to the SIG's archives, and to the SIG's Mailman page, which you can use to subscribe or unsubscribe yourself and to change your subscription options.
|
|
|
|
If you want an overview of the contents of a book, you don’t plow through all pages — you take a look at the table of contents, right? It simply lists the main topics of the book. Now — imagine writing a cookbook. Many of the recipes, like “Creamy Spam and Macaroni” and “Spam Swiss Pie” may contain similar things, like spam, in this case - yet you wouldn’t want to repeat how to make spam in every recipe. (OK… So you don’t actually make spam… But bear with me for the sake of example :)). You’d put the recipe for spam in a separate chapter, and simply refer to it in the other recipes. So — instead of writing the entire recipe every time, you only had to use the name of a chapter. In computer programming this is called abstraction.
|
|
|
|
Python also provides a significant level of support for doing arithmetic with complex numbers. Since this is a very specialized area, which is probably of interest to only a small percentage of potential Python users, I'm not going to provide any of the details. If this is something that interests you, see an example at this URL.
|
|
|
|
What is happening when this expression is executed? The first thing to say is that it is a mixed expression of operations and function calls. Let's start with the function calls. If a function is called with an argument representing a composed expression, this one is executed first and the result value is passed to the calling function. So the cds variable is evaluated, which returns the value that it refers to. This value is passed to the len function which returns the length of this value. The same happens for the float function. The operation count(cds, 'G') + count(cds, 'C') is evaluated first, and the result is passed as argument to float. |
|
|
|
| Previous< 3 4 5 6 7 8 9 10 11 > Next |
|
|
|
|
|
|
|
|
|