Doc/c-api/exceptions.rst-121- reference to each object before the call and after the call you no longer own Doc/c-api/exceptions.rst:122: these references. (If you don't understand this, don't use this function. I Doc/c-api/exceptions.rst-123- warned you.) -- Doc/c-api/long.rst-42- just get back a reference to the existing object. So it should be possible to Doc/c-api/long.rst:43: change the value of ``1``. I suspect the behaviour of Python in this case is Doc/c-api/long.rst-44- undefined. :-) -- Doc/distutils/builtdist.rst-31- Doc/distutils/builtdist.rst:32:As a simple example, if I run the following command in the Distutils source Doc/distutils/builtdist.rst-33-tree:: -- Doc/distutils/builtdist.rst-36- Doc/distutils/builtdist.rst:37:then the Distutils builds my module distribution (the Distutils itself in this Doc/distutils/builtdist.rst-38-case), does a "fake" installation (also in the :file:`build` directory), and Doc/distutils/builtdist.rst:39:creates the default type of built distribution for my platform. The default Doc/distutils/builtdist.rst-40-format for built distributions is a "dumb" tar file on Unix, and a simple -- Doc/distutils/builtdist.rst-147-.. XXX Need to document absolute vs. prefix-relative packages here, but first Doc/distutils/builtdist.rst:148: I have to implement it! Doc/distutils/builtdist.rst-149- -- Doc/extending/extending.rst-301- Doc/extending/extending.rst:302:I promised to show how :c:func:`spam_system` is called from Python programs. Doc/extending/extending.rst-303-First, we need to list its name and address in a "method table":: -- Doc/extending/extending.rst-446-Fortunately, the Python interpreter is easily called recursively, and there is a Doc/extending/extending.rst:447:standard interface to call a Python function. (I won't dwell on how to call the Doc/extending/extending.rst-448-Python parser with a particular string as input --- if you're interested, have a -- Doc/extending/extending.rst-838-(Sometimes, reference counting is also referred to as a garbage collection Doc/extending/extending.rst:839:strategy, hence my use of "automatic" to distinguish the two.) The big Doc/extending/extending.rst-840-advantage of automatic garbage collection is that the user doesn't need to call -- Doc/extending/extending.rst-1025-:c:macro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using Doc/extending/extending.rst:1026::c:macro:`Py_END_ALLOW_THREADS`. This is common around blocking I/O calls, to Doc/extending/extending.rst:1027:let other threads use the processor while waiting for the I/O to complete. Doc/extending/extending.rst-1028-Obviously, the following function has the same problem as the previous one:: -- Doc/extending/extending.rst-1076- be helpful here -- showing in more concrete terms what sort of actions could Doc/extending/extending.rst:1077: cause the problem. I can't very well imagine it from the description. Doc/extending/extending.rst-1078- -- Doc/extending/windows.rst-129- should be a direct subdirectory of the Python build tree, a sibling of Doc/extending/windows.rst:130: :file:`Include` and :file:`PC`). Select Win32 as the platform (in my version, Doc/extending/windows.rst-131- this is the only choice). Make sure the Create new workspace radio button is -- Doc/howto/argparse.rst-141- which command-line options the program is willing to accept. In this case, Doc/howto/argparse.rst:142: I've named it ``echo`` so that it's in line with its function. Doc/howto/argparse.rst-143- -- Doc/howto/argparse.rst-314-If you are familiar with command line usage, Doc/howto/argparse.rst:315:you will notice that I haven't yet touched on the topic of short Doc/howto/argparse.rst-316-versions of the options. It's quite simple:: -- Doc/howto/argparse.rst-711- Doc/howto/argparse.rst:712:That should be easy to follow. I've added that last output so you can see the Doc/howto/argparse.rst-713-sort of flexibility you get, i.e. mixing long form options with short form -- Doc/howto/curses.rst-394- Doc/howto/curses.rst:395:As I said before, a color pair consists of a foreground and background color. Doc/howto/curses.rst-396-The ``init_pair(n, f, b)`` function changes the definition of color pair *n*, to -- Doc/howto/curses.rst-419-blue or any other color you like. Unfortunately, the Linux console doesn't Doc/howto/curses.rst:420:support this, so I'm unable to try it out, and can't provide any examples. You Doc/howto/curses.rst-421-can check if your terminal can do this by calling :func:`can_change_color`, -- Doc/howto/functional.rst-180- Doc/howto/functional.rst:181:I'll start by looking at a Python language feature that's an important Doc/howto/functional.rst-182-foundation for writing functional-style programs: iterators. -- Doc/howto/functional.rst-535- Doc/howto/functional.rst:536:I recommend that you **always** put parentheses around a ``yield`` expression Doc/howto/functional.rst-537-when you're doing something with the returned value, as in the above example. -- Doc/howto/functional.rst-603- Doc/howto/functional.rst:604: If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I suggest Doc/howto/functional.rst-605- using a ``try: ... finally:`` suite instead of catching :exc:`GeneratorExit`. -- Doc/howto/functional.rst-944- Doc/howto/functional.rst:945:The last function I'll discuss, :func:`itertools.groupby(iter, key_func=None) Doc/howto/functional.rst-946-`, is the most complicated. ``key_func(elem)`` is a function -- Doc/howto/functional.rst-1123- Doc/howto/functional.rst:1124:Which alternative is preferable? That's a style question; my usual course is to Doc/howto/functional.rst-1125-avoid using ``lambda``. Doc/howto/functional.rst-1126- Doc/howto/functional.rst:1127:One reason for my preference is that ``lambda`` is quite limited in the Doc/howto/functional.rst-1128-functions it can define. The result has to be computable as a single -- Doc/howto/functional.rst-1146- Doc/howto/functional.rst:1147:But it would be best of all if I had simply used a ``for`` loop:: Doc/howto/functional.rst-1148- -- Doc/howto/functional.rst-1168- Doc/howto/functional.rst:1169:I really like these rules, but you're free to disagree Doc/howto/functional.rst-1170-about whether this lambda-free style is better. -- Doc/howto/regex.rst-505- Doc/howto/regex.rst:506:I generally prefer to work with the compiled object, even for one-time uses, but Doc/howto/regex.rst:507:few people will be as much of a purist about this as I am. Doc/howto/regex.rst-508- -- Doc/howto/regex.rst-977-Notice that the ``.`` needs to be treated specially because it's a Doc/howto/regex.rst:978:metacharacter; I've put it inside a character class. Also notice the trailing Doc/howto/regex.rst-979-``$``; this is added to ensure that all the rest of the string must be included -- Doc/howto/sockets.rst-15- operational. It doesn't cover the fine points (and there are a lot of them), but Doc/howto/sockets.rst:16: I hope it will give you enough background to begin using them decently. Doc/howto/sockets.rst-17- -- Doc/howto/sockets.rst-24-It's not really a tutorial - you'll still have work to do in getting things Doc/howto/sockets.rst:25:working. It doesn't cover the fine points (and there are a lot of them), but I Doc/howto/sockets.rst-26-hope it will give you enough background to begin using them decently. Doc/howto/sockets.rst-27- Doc/howto/sockets.rst:28:I'm only going to talk about INET (i.e. IPv4) sockets, but they account for at least 99% of Doc/howto/sockets.rst:29:the sockets in use. And I'll only talk about STREAM (i.e. TCP) sockets - unless you really Doc/howto/sockets.rst-30-know what you're doing (in which case this HOWTO isn't for you!), you'll get Doc/howto/sockets.rst:31:better behavior and performance from a STREAM socket than anything else. I will Doc/howto/sockets.rst-32-try to clear up the mystery of what a socket is, as well as some hints on how to Doc/howto/sockets.rst:33:work with blocking and non-blocking sockets. But I'll start by talking about Doc/howto/sockets.rst-34-blocking sockets. You'll need to know how they work before dealing with -- Doc/howto/sockets.rst-151-use ``read`` and ``write``. The latter is the way Java presents its sockets. Doc/howto/sockets.rst:152:I'm not going to talk about it here, except to warn you that you need to use Doc/howto/sockets.rst-153-``flush`` on sockets. These are buffered "files", and a common mistake is to -- Doc/howto/sockets.rst-167-the process of closing) the connection. You will not receive any more data on Doc/howto/sockets.rst:168:this connection. Ever. You may be able to send data successfully; I'll talk Doc/howto/sockets.rst-169-more about this later. -- Doc/howto/sockets.rst-175-But if you plan to reuse your socket for further transfers, you need to realize Doc/howto/sockets.rst:176:that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I repeat: if a socket Doc/howto/sockets.rst-177-``send`` or ``recv`` returns after handling 0 bytes, the connection has been -- Doc/howto/sockets.rst-249- Doc/howto/sockets.rst:250:In the interests of space, building your character, (and preserving my Doc/howto/sockets.rst-251-competitive position), these enhancements are left as an exercise for the -- Doc/howto/sockets.rst-279-``close`` it. The ``shutdown`` is an advisory to the socket at the other end. Doc/howto/sockets.rst:280:Depending on the argument you pass it, it can mean "I'm not going to send Doc/howto/sockets.rst:281:anymore, but I'll still listen", or "I'm not listening, good riddance!". Most Doc/howto/sockets.rst-282-socket libraries, however, are so used to programmers neglecting to use this -- Doc/howto/sockets.rst-333-number of choices. You can check return code and error codes and generally drive Doc/howto/sockets.rst:334:yourself crazy. If you don't believe me, try it sometime. Your app will grow Doc/howto/sockets.rst-335-large, buggy and suck CPU. So let's skip the brain-dead solutions and do it -- Doc/howto/sockets.rst-383-only. Also note that in C, many of the more advanced socket options are done Doc/howto/sockets.rst:384:differently on Windows. In fact, on Windows I usually use threads (which work Doc/howto/sockets.rst:385:very, very well) with my sockets. Doc/howto/sockets.rst-386- -- Doc/howto/urllib2.rst-340-So if you want to be prepared for :exc:`HTTPError` *or* :exc:`URLError` there are two Doc/howto/urllib2.rst:341:basic approaches. I prefer the second approach. Doc/howto/urllib2.rst-342- -- Doc/howto/urllib2.rst-587- `Quick Reference to HTTP Headers`_. Doc/howto/urllib2.rst:588:.. [#] In my case I have to use a proxy to access the internet at work. If you Doc/howto/urllib2.rst-589- attempt to fetch *localhost* URLs through this proxy it blocks them. IE Doc/howto/urllib2.rst-590- is set to use the proxy, which urllib picks up on. In order to test Doc/howto/urllib2.rst:591: scripts with a localhost server, I have to prevent urllib from using Doc/howto/urllib2.rst-592- the proxy. -- Doc/install/index.rst-15- install and maintain it for their users, i.e. system administrators. Doc/install/index.rst:16: Thus, I have to be sure to explain the basics at some point: Doc/install/index.rst-17- sys.path and PYTHONPATH at least. Should probably give pointers to -- Doc/install/index.rst-19- Doc/install/index.rst:20: Finally, it might be useful to include all the material from my "Care Doc/install/index.rst-21- and Feeding of a Python Installation" talk in here somewhere. Yow! -- Doc/install/index.rst-269-Python (command line)`. Once the interpreter is started, you type Python code Doc/install/index.rst:270:at the prompt. For example, on my Linux system, I type the three Python Doc/install/index.rst:271:statements shown below, and get the output as shown, to find out my Doc/install/index.rst-272-:file:`{prefix}` and :file:`{exec-prefix}`:: -- Doc/install/index.rst-1050- Doc/install/index.rst:1051:.. I don't understand what the next line means. --amk Doc/install/index.rst-1052-.. (inclusive the references on data structures.) -- Doc/install/index.rst-1059-installation options and the version and language of Windows. In a "just for Doc/install/index.rst:1060:me" installation, it will appear in the root of the installation directory. In Doc/install/index.rst-1061-a shared installation, it will be located in the system directory. -- Doc/library/audioop.rst-247-The ADPCM coders have never been tried against other ADPCM coders, only against Doc/library/audioop.rst:248:themselves. It could well be that I misinterpreted the standards in which case Doc/library/audioop.rst-249-they will not be interoperable with the respective standards. -- Doc/library/ctypes.rst-958- Doc/library/ctypes.rst:959:I will present an example here which uses the standard C library's Doc/library/ctypes.rst-960-:c:func:`qsort` function, that is used to sort items with the help of a callback -- Doc/library/doctest.rst-1777-will pay back the time it takes to collect them many times over as the years go Doc/library/doctest.rst:1778:by and things change. I'm still amazed at how often one of my :mod:`doctest` Doc/library/doctest.rst-1779-examples stops working after a "harmless" change. -- Doc/library/doctest.rst-1788-doctest makes writing prose a little easier than writing code, while writing Doc/library/doctest.rst:1789:comments in code is a little harder. I think it goes deeper than just that: Doc/library/doctest.rst-1790-the natural attitude when writing a doctest-based test is that you want to -- Doc/library/heapq.rst-251-heap. So, a heap is a good structure for implementing schedulers (this is what Doc/library/heapq.rst:252:I used for my MIDI sequencer :-). Doc/library/heapq.rst-253- -- Doc/library/heapq.rst-277- Doc/library/heapq.rst:278:In a word, heaps are useful memory structures to know. I use them in a few Doc/library/heapq.rst:279:applications, and I think it is good to keep a 'heap' module around. :-) Doc/library/heapq.rst-280- -- Doc/library/heapq.rst-288- participate at "progressing" the merge). Some tapes were even able to read Doc/library/heapq.rst:289: backwards, and this was also used to avoid the rewinding time. Believe me, real Doc/library/heapq.rst-290- good tape sorts were quite spectacular to watch! From all times, sorting has -- Doc/library/numbers.rst-147-There are 5 different cases for a mixed-type operation on subclasses Doc/library/numbers.rst:148:of :class:`Complex`. I'll refer to all of the above code that doesn't Doc/library/numbers.rst-149-refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as -- Doc/library/numbers.rst-151-of :class:`Complex` (``a : A <: Complex``), and ``b : B <: Doc/library/numbers.rst:152:Complex``. I'll consider ``a + b``: Doc/library/numbers.rst-153- -- Doc/library/ossaudiodev.rst-19- Sounds like things are also complicated for other BSDs. In response Doc/library/ossaudiodev.rst:20: to my python-dev query, Thomas Wouters said: Doc/library/ossaudiodev.rst-21- -- Doc/library/ossaudiodev.rst-37- Doc/library/ossaudiodev.rst:38: This probably all warrants a footnote or two, but I don't understand Doc/library/ossaudiodev.rst-39- things well enough right now to write it! --GPW -- Doc/library/ossaudiodev.rst-94- .. XXX it might also be motivated Doc/library/ossaudiodev.rst:95: by my unfounded-but-still-possibly-true belief that the default Doc/library/ossaudiodev.rst-96- audio device varies unpredictably across operating systems. -GW -- Doc/library/ossaudiodev.rst-337- Doc/library/ossaudiodev.rst:338: The I/O mode for the file, either ``"r"``, ``"rw"``, or ``"w"``. Doc/library/ossaudiodev.rst-339- -- Doc/library/tk.rst-41- Doc/library/tk.rst:42:.. Other sections I have in mind are Doc/library/tk.rst-43- Tkinter internals -- Doc/library/unittest.mock-examples.rst-514- Doc/library/unittest.mock-examples.rst:515:In some tests I wanted to mock out a call to `datetime.date.today() Doc/library/unittest.mock-examples.rst-516-`_ to return Doc/library/unittest.mock-examples.rst:517:a known date, but I didn't want to prevent the code under test from Doc/library/unittest.mock-examples.rst-518-creating new date objects. Unfortunately `datetime.date` is written in C, and Doc/library/unittest.mock-examples.rst:519:so I couldn't just monkey-patch out the static `date.today` method. Doc/library/unittest.mock-examples.rst-520- Doc/library/unittest.mock-examples.rst:521:I found a simple way of doing this that involved effectively wrapping the date Doc/library/unittest.mock-examples.rst-522-class with a mock, but passing through calls to the constructor to the real -- Doc/library/unittest.mock-examples.rst-660- Doc/library/unittest.mock-examples.rst:661:Whilst writing tests today I needed to patch an *unbound method* (patching the Doc/library/unittest.mock-examples.rst:662:method on the class rather than on the instance). I needed self to be passed Doc/library/unittest.mock-examples.rst:663:in as the first argument because I want to make asserts about which objects Doc/library/unittest.mock-examples.rst-664-were calling this particular method. The issue is that you can't patch with a -- Doc/library/unittest.mock-examples.rst-677-function will be turned into a bound method if it is fetched from an instance. Doc/library/unittest.mock-examples.rst:678:It will have `self` passed in as the first argument, which is exactly what I Doc/library/unittest.mock-examples.rst-679-wanted: -- Doc/library/unittest.mock-examples.rst-780-opportunity to copy the arguments and store them for later assertions. In this Doc/library/unittest.mock-examples.rst:781:example I'm using *another* mock to store the arguments so that I can use the Doc/library/unittest.mock-examples.rst-782-mock methods for doing the assertion. Again a helper function sets this up for Doc/library/unittest.mock-examples.rst:783:me. Doc/library/unittest.mock-examples.rst-784- -- Doc/library/unittest.mock.rst-2047- Doc/library/unittest.mock.rst:2048:Before I explain how auto-speccing works, here's why it is needed. Doc/library/unittest.mock.rst-2049- -- Doc/reference/introduction.rst-10- Doc/reference/introduction.rst:11:While I am trying to be as precise as possible, I chose to use English rather Doc/reference/introduction.rst-12-than formal specifications for everything except syntax and lexical analysis. -- Doc/tutorial/classes.rst-27- Doc/tutorial/classes.rst:28:(Lacking universally accepted terminology to talk about classes, I will make Doc/tutorial/classes.rst:29:occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since Doc/tutorial/classes.rst:30:its object-oriented semantics are closer to those of Python than C++, but I Doc/tutorial/classes.rst-31-expect that few readers have heard of it.) -- Doc/tutorial/classes.rst-56- Doc/tutorial/classes.rst:57:Before introducing classes, I first have to tell you something about Python's Doc/tutorial/classes.rst-58-scope rules. Class definitions play some neat tricks with namespaces, and you -- Doc/tutorial/classes.rst-75- Doc/tutorial/classes.rst:76:By the way, I use the word *attribute* for any name following a dot --- for Doc/tutorial/classes.rst-77-example, in the expression ``z.real``, ``real`` is an attribute of the object -- Doc/tutorial/classes.rst-419-There is no shorthand for referencing data attributes (or other methods!) from Doc/tutorial/classes.rst:420:within methods. I find that this actually increases the readability of methods: Doc/tutorial/classes.rst-421-there is no chance of confusing local variables and instance variables when