pytho****@googl*****
pytho****@googl*****
2011年 11月 12日 (土) 16:09:29 JST
3 new revisions: Revision: 9eae56002b95 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 17:57:25 2011 Log: sphinxext 更新 http://code.google.com/p/python-doc-ja/source/detail?r=9eae56002b95 Revision: 13456d53bbd7 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 17:59:50 2011 Log: glossary の .diff ファイル削除 http://code.google.com/p/python-doc-ja/source/detail?r=13456d53bbd7 Revision: a2939d821e84 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 23:08:31 2011 Log: whatsnew/2.7 loggingまで翻訳 http://code.google.com/p/python-doc-ja/source/detail?r=a2939d821e84 ============================================================================== Revision: 9eae56002b95 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 17:57:25 2011 Log: sphinxext 更新 http://code.google.com/p/python-doc-ja/source/detail?r=9eae56002b95 Deleted: /tools/sphinxext/indexsidebar.html.diff Modified: /tools/sphinxext/indexcontent.html /tools/sphinxext/indexsidebar.html /tools/sphinxext/static/_jp.js ======================================= --- /tools/sphinxext/indexsidebar.html.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,23 +0,0 @@ -@@ -1,19 +1,19 @@ - <h3>Download</h3> - <p><a href="{{ pathto('download') }}">Download these documents</a></p> - <h3>Docs for other versions</h3> - <ul> -- <li><a href="http://docs.python.org/2.7/">Python 2.7 (stable)</a></li> -- <li><a href="http://docs.python.org/3.1/">Python 3.1 (stable)</a></li> -- <li><a href="http://docs.python.org/dev/py3k/">Python 3.2 (in development)</a></li> -+ <li><a href="http://docs.python.org/2.6/">Python 2.6 (stable)</a></li> -+ <li><a href="http://docs.python.org/3.2/">Python 3.2 (stable)</a></li> -+ <li><a href="http://docs.python.org/dev/">Python 3.3 (in development)</a></li> - <li><a href="http://www.python.org/doc/versions/">Old versions</a></li> - </ul> - - <h3>Other resources</h3> - <ul> - {# XXX: many of these should probably be merged in the main docs #} - <li><a href="http://www.python.org/doc/faq/">FAQs</a></li> - <li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li> - <li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li> - <li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> - <li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> - <li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> ======================================= --- /tools/sphinxext/indexcontent.html Fri Nov 11 09:41:02 2011 +++ /tools/sphinxext/indexcontent.html Fri Nov 11 17:57:25 2011 @@ -9,7 +9,7 @@ {% endblock %}. </p> <p> - Python 2.6.6 のドキュメントの日本語訳です。 + Python 2.7.2 のドキュメントの日本語訳です。 </p> </p> {% block tables %} ======================================= --- /tools/sphinxext/indexsidebar.html Tue Nov 16 19:16:13 2010 +++ /tools/sphinxext/indexsidebar.html Fri Nov 11 17:57:25 2011 @@ -1,24 +1,21 @@ - <h3>英語ドキュメント</h3> - <ul> - <li><a href="http://docs.python.org/2.6/">Python 2.6 (原文)</a></li> - <li><a href="http://docs.python.org/2.7/">Python 2.7 (2系最新版 )</a></li> - <li><a href="http://docs.python.org/3.1/">Python 3.1 (3系最新版 )</a></li> - <li><a href="http://docs.python.org/3.2/">Python 3.2 (開発版 )</a></li> - <li><a href="http://www.python.org/doc/versions/">古いバージョン </a></li> - </ul> - - <h3>Other resources</h3> - <ul> - <li><a href="http://www.python.jp/">日本Pythonユーザーグループ </a></li> - {# XXX: many of these should probably be merged in the main docs #} - <li><a href="http://www.python.org/doc/faq/">FAQs</a></li> - <li><a href="http://www.python.org/doc/intros/">Introductions</a></li> - <li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li> - <li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li> - <li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> - <li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> - <li><a href="http://www.python.org/topics/">Topic Guides</a></li> - <li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> - <li><a href="http://www.python.org/doc/av/">Audio/Visual Talks</a></li> - <li><a href="http://www.python.org/doc/other/">Other Doc Collections</a></li> - </ul> +<h3>英語ドキュメント</h3> +<ul> +<li><a href="http://docs.python.org/2.7/">Python 2.7 (原文)</a></li> +<li><a href="http://docs.python.org/3.2/">Python 3.2 (最新版)</a></li> +<li><a href="http://www.python.org/doc/versions/">古いバージョン</a></li> +</ul> + +<h3>Other resources</h3> +<ul> +<li><a href="http://www.python.jp/">日本Pythonユーザーグループ</a></li> +{# XXX: many of these should probably be merged in the main docs #} +<li><a href="http://www.python.org/doc/intros/">Introductions</a></li> +<li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li> +<li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li> +<li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> +<li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> +<li><a href="http://www.python.org/topics/">Topic Guides</a></li> +<li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> +<li><a href="http://www.python.org/doc/av/">Audio/Visual Talks</a></li> +<li><a href="http://www.python.org/doc/other/">Other Doc Collections</a></li> +</ul> ======================================= --- /tools/sphinxext/static/_jp.js Sat Nov 20 20:39:52 2010 +++ /tools/sphinxext/static/_jp.js Fri Nov 11 17:57:25 2011 @@ -2,11 +2,11 @@ var url = document.URL.replace(/#.*/, ''); var parts = url.split('/'); - var base = 'http://docs.python.org/2.6/'; + var base = 'http://docs.python.org/2.7/'; base += parts[parts.length-2] + '/' + parts[parts.length-1]; $('a.headerlink').each(function() { var html = '<a href="' + base + $(this).attr('href') + - '" class="reference internal" title="原文へのリン ク"><small>(原文)</small></a>'; + '" title="原文へのリンク"><small>(原文 )</small></a>'; $(this).after(html); }) }); ============================================================================== Revision: 13456d53bbd7 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 17:59:50 2011 Log: glossary の .diff ファイル削除 http://code.google.com/p/python-doc-ja/source/detail?r=13456d53bbd7 Deleted: /glossary.rst.diff /glossary.rst.diff.html ======================================= --- /glossary.rst.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,404 +0,0 @@ -@@ -10,33 +10,33 @@ - - ``>>>`` - The default Python prompt of the interactive shell. Often seen for code - examples which can be executed interactively in the interpreter. - - ``...`` - The default Python prompt of the interactive shell when entering code for - an indented code block or within a pair of matching left and right - delimiters (parentheses, square brackets or curly braces). - - 2to3 - A tool that tries to convert Python 2.x code to Python 3.x code by -- handling most of the incompatibilites which can be detected by parsing the -+ handling most of the incompatibilities which can be detected by parsing the - source and traversing the parse tree. - - 2to3 is available in the standard library as :mod:`lib2to3`; a standalone - entry point is provided as :file:`Tools/scripts/2to3`. See - :ref:`2to3-reference`. - - abstract base class -- Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by -+ :ref:`abstract-base-classes` complement :term:`duck-typing` by - providing a way to define interfaces when other techniques like - :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for - data structures (in the :mod:`collections` module), numbers (in the - :mod:`numbers` module), and streams (in the :mod:`io` module). You can - create your own ABC with the :mod:`abc` module. - - argument - A value passed to a function or method, assigned to a named local - variable in the function body. A function or method may have both - positional arguments and keyword arguments in its definition. - Positional and keyword arguments may be variable-length: ``*`` accepts - or passes (if in the function definition or call) several positional -@@ -54,24 +54,27 @@ - BDFL - Benevolent Dictator For Life, a.k.a. `Guido van Rossum - <http://www.python.org/~guido/>`_, Python's creator. - - bytecode - Python source code is compiled into bytecode, the internal representation - of a Python program in the interpreter. The bytecode is also cached in - ``.pyc`` and ``.pyo`` files so that executing the same file is faster the - second time (recompilation from source to bytecode can be avoided). This - "intermediate language" is said to run on a :term:`virtual machine` - that executes the machine code corresponding to each bytecode. - -+ A list of bytecode instructions can be found in the documentation for -+ :ref:`the dis module <bytecodes>`. -+ - class - A template for creating user-defined objects. Class definitions - normally contain method definitions which operate on instances of the - class. - - classic class - Any class which does not inherit from :class:`object`. See - :term:`new-style class`. Classic classes will be removed in Python 3.0. - - coercion - The implicit conversion of an instance of one type to another during an - operation which involves two arguments of the same type. For example, -@@ -94,27 +97,28 @@ - written with this latter notation; the imaginary part is written with a - ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the - :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly - advanced mathematical feature. If you're not aware of a need for them, - it's almost certain you can safely ignore them. - - context manager - An object which controls the environment seen in a :keyword:`with` - statement by defining :meth:`__enter__` and :meth:`__exit__` methods. - See :pep:`343`. - - CPython -- The canonical implementation of the Python programming language. The -- term "CPython" is used in contexts when necessary to distinguish this -- implementation from others such as Jython or IronPython. -+ The canonical implementation of the Python programming language, as -+ distributed on `python.org <http://python.org>`_. The term "CPython" -+ is used when necessary to distinguish this implementation from others -+ such as Jython or IronPython. - - decorator - A function returning another function, usually applied as a function - transformation using the ``@wrapper`` syntax. Common examples for - decorators are :func:`classmethod` and :func:`staticmethod`. - - The decorator syntax is merely syntactic sugar, the following two - function definitions are semantically equivalent:: - - def f(...): - ... - f = staticmethod(f) -@@ -131,41 +135,40 @@ - :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a - descriptor, its special binding behavior is triggered upon attribute - lookup. Normally, using *a.b* to get, set or delete an attribute looks up - the object named *b* in the class dictionary for *a*, but if *b* is a - descriptor, the respective descriptor method gets called. Understanding - descriptors is a key to a deep understanding of Python because they are - the basis for many features including functions, methods, properties, - class methods, static methods, and reference to super classes. - - For more information about descriptors' methods, see :ref:`descriptors`. - - dictionary -- An associative array, where arbitrary keys are mapped to values. The use -- of :class:`dict` closely resembles that for :class:`list`, but the keys can -- be any object with a :meth:`__hash__` function, not just integers. -- Called a hash in Perl. -+ An associative array, where arbitrary keys are mapped to values. The keys -+ can be any object with :meth:`__hash__` function and :meth:`__eq__` -+ methods. Called a hash in Perl. - - docstring - A string literal which appears as the first expression in a class, - function or module. While ignored when the suite is executed, it is - recognized by the compiler and put into the :attr:`__doc__` attribute - of the enclosing class, function or module. Since it is available via - introspection, it is the canonical place for documentation of the - object. - - duck-typing -- A pythonic programming style which determines an object's type by inspection -- of its method or attribute signature rather than by explicit relationship -- to some type object ("If it looks like a duck and quacks like a duck, it -+ A programming style which does not look at an object's type to determine -+ if it has the right interface; instead, the method or attribute is simply -+ called or used ("If it looks like a duck and quacks like a duck, it - must be a duck.") By emphasizing interfaces rather than specific types, - well-designed code improves its flexibility by allowing polymorphic - substitution. Duck-typing avoids tests using :func:`type` or - :func:`isinstance`. (Note, however, that duck-typing can be complemented - with :term:`abstract base class`\ es.) Instead, it typically employs - :func:`hasattr` tests or :term:`EAFP` programming. - - EAFP - Easier to ask for forgiveness than permission. This common Python coding - style assumes the existence of valid keys or attributes and catches - exceptions if the assumption proves false. This clean and fast style is - characterized by the presence of many :keyword:`try` and :keyword:`except` -@@ -173,117 +176,131 @@ - common to many other languages such as C. - - expression - A piece of syntax which can be evaluated to some value. In other words, - an expression is an accumulation of expression elements like literals, names, - attribute access, operators or function calls which all return a value. - In contrast to many other languages, not all language constructs are expressions. - There are also :term:`statement`\s which cannot be used as expressions, - such as :keyword:`print` or :keyword:`if`. Assignments are also statements, - not expressions. - - extension module -- A module written in C or C++, using Python's C API to interact with the core and -- with user code. -+ A module written in C or C++, using Python's C API to interact with the -+ core and with user code. - - finder - An object that tries to find the :term:`loader` for a module. It must - implement a method named :meth:`find_module`. See :pep:`302` for - details. - -+ floor division -+ Mathematical division that rounds down to nearest integer. The floor -+ division operator is ``//``. For example, the expression ``11 // 4`` -+ evaluates to ``2`` in contrast to the ``2.75`` returned by float true -+ division. Note that ``(-11) // 4`` is ``-3`` because that is ``-2.75`` -+ rounded *downward*. See :pep:`238`. -+ - function - A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. - - __future__ -- A pseudo module which programmers can use to enable new language features -+ A pseudo-module which programmers can use to enable new language features - which are not compatible with the current interpreter. For example, the - expression ``11/4`` currently evaluates to ``2``. If the module in which - it is executed had enabled *true division* by executing:: - - from __future__ import division - - the expression ``11/4`` would evaluate to ``2.75``. By importing the - :mod:`__future__` module and evaluating its variables, you can see when a - new feature was first added to the language and when it will become the - default:: - - >>> import __future__ - >>> __future__.division - _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) - - garbage collection - The process of freeing memory when it is not used anymore. Python - performs garbage collection via reference counting and a cyclic garbage - collector that is able to detect and break reference cycles. - - .. index:: single: generator - - generator - A function which returns an iterator. It looks like a normal function -- except that values are returned to the caller using a :keyword:`yield` -- statement instead of a :keyword:`return` statement. Generator functions -- often contain one or more :keyword:`for` or :keyword:`while` loops which -- :keyword:`yield` elements back to the caller. The function execution is -- stopped at the :keyword:`yield` keyword (returning the result) and is -- resumed there when the next element is requested by calling the -- :meth:`next` method of the returned iterator. -+ except that it contains :keyword:`yield` statements for producing a series -+ a values usable in a for-loop or that can be retrieved one at a time with -+ the :func:`next` function. Each :keyword:`yield` temporarily suspends -+ processing, remembering the location execution state (including local -+ variables and pending try-statements). When the generator resumes, it -+ picks-up where it left-off (in contrast to functions which start fresh on -+ every invocation). - - .. index:: single: generator expression - - generator expression - An expression that returns an iterator. It looks like a normal expression - followed by a :keyword:`for` expression defining a loop variable, range, - and an optional :keyword:`if` expression. The combined expression - generates values for an enclosing function:: - - >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81 - 285 - - GIL - See :term:`global interpreter lock`. - - global interpreter lock -- The lock used by Python threads to assure that only one thread -- executes in the :term:`CPython` :term:`virtual machine` at a time. -- This simplifies the CPython implementation by assuring that no two -- processes can access the same memory at the same time. Locking the -- entire interpreter makes it easier for the interpreter to be -- multi-threaded, at the expense of much of the parallelism afforded by -- multi-processor machines. Efforts have been made in the past to -- create a "free-threaded" interpreter (one which locks shared data at a -- much finer granularity), but so far none have been successful because -- performance suffered in the common single-processor case. -+ The mechanism used by the :term:`CPython` interpreter to assure that -+ only one thread executes Python :term:`bytecode` at a time. -+ This simplifies the CPython implementation by making the object model -+ (including critical built-in types such as :class:`dict`) implicitly -+ safe against concurrent access. Locking the entire interpreter -+ makes it easier for the interpreter to be multi-threaded, at the -+ expense of much of the parallelism afforded by multi-processor -+ machines. -+ -+ However, some extension modules, either standard or third-party, -+ are designed so as to release the GIL when doing computationally-intensive -+ tasks such as compression or hashing. Also, the GIL is always released -+ when doing I/O. -+ -+ Past efforts to create a "free-threaded" interpreter (one which locks -+ shared data at a much finer granularity) have not been successful -+ because performance suffered in the common single-processor case. It -+ is believed that overcoming this performance issue would make the -+ implementation much more complicated and therefore costlier to maintain. - - hashable - An object is *hashable* if it has a hash value which never changes during - its lifetime (it needs a :meth:`__hash__` method), and can be compared to - other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method). - Hashable objects which compare equal must have the same hash value. - - Hashability makes an object usable as a dictionary key and a set member, - because these data structures use the hash value internally. - - All of Python's immutable built-in objects are hashable, while no mutable - containers (such as lists or dictionaries) are. Objects which are - instances of user-defined classes are hashable by default; they all - compare unequal, and their hash value is their :func:`id`. - - IDLE - An Integrated Development Environment for Python. IDLE is a basic editor - and interpreter environment which ships with the standard distribution of -- Python. Good for beginners, it also serves as clear example code for -- those wanting to implement a moderately sophisticated, multi-platform GUI -- application. -+ Python. - - immutable - An object with a fixed value. Immutable objects include numbers, strings and - tuples. Such an object cannot be altered. A new object has to - be created if a different value has to be stored. They play an important - role in places where a constant hash value is needed, for example as a key - in a dictionary. - - integer division - Mathematical division discarding any remainder. For example, the - expression ``11/4`` currently evaluates to ``2`` in contrast to the - ``2.75`` returned by float division. Also called *floor division*. -@@ -340,24 +357,44 @@ - :meth:`next` method just raise :exc:`StopIteration` again. Iterators are - required to have an :meth:`__iter__` method that returns the iterator - object itself so every iterator is also iterable and may be used in most - places where other iterables are accepted. One notable exception is code - which attempts multiple iteration passes. A container object (such as a - :class:`list`) produces a fresh new iterator each time you pass it to the - :func:`iter` function or use it in a :keyword:`for` loop. Attempting this - with an iterator will just return the same exhausted iterator object used - in the previous iteration pass, making it appear like an empty container. - - More information can be found in :ref:`typeiter`. - -+ key function -+ A key function or collation function is a callable that returns a value -+ used for sorting or ordering. For example, :func:`locale.strxfrm` is -+ used to produce a sort key that is aware of locale specific sort -+ conventions. -+ -+ A number of tools in Python accept key functions to control how elements -+ are ordered or grouped. They include :func:`min`, :func:`max`, -+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`, -+ :func:`heapq.nlargest`, and :func:`itertools.groupby`. -+ -+ There are several ways to create a key function. For example. the -+ :meth:`str.lower` method can serve as a key function for case insensitive -+ sorts. Alternatively, an ad-hoc key function can be built from a -+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, -+ the :mod:`operator` module provides three key function constuctors: -+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and -+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO -+ <sortinghowto>` for examples of how to create and use key functions. -+ - keyword argument - Arguments which are preceded with a ``variable_name=`` in the call. - The variable name designates the local name in the function to which the - value is assigned. ``**`` is used to accept or pass a dictionary of - keyword arguments. See :term:`argument`. - - lambda - An anonymous inline function consisting of a single :term:`expression` - which is evaluated when the function is called. The syntax to create - a lambda function is ``lambda [arguments]: expression`` - - LBYL -@@ -376,26 +413,29 @@ - return a list with the results. ``result = ["0x%02x" % x for x in - range(256) if x % 2 == 0]`` generates a list of strings containing - even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if` - clause is optional. If omitted, all elements in ``range(256)`` are - processed. - - loader - An object that loads a module. It must define a method named - :meth:`load_module`. A loader is typically returned by a - :term:`finder`. See :pep:`302` for details. - - mapping -- A container object (such as :class:`dict`) which supports arbitrary key -- lookups using the special method :meth:`__getitem__`. -+ A container object that supports arbitrary key lookups and implements the -+ methods specified in the :class:`Mapping` or :class:`MutableMapping` -+ :ref:`abstract base classes <abstract-base-classes>`. Examples include -+ :class:`dict`, :class:`collections.defaultdict`, -+ :class:`collections.OrderedDict` and :class:`collections.Counter`. - - metaclass - The class of a class. Class definitions create a class name, a class - dictionary, and a list of base classes. The metaclass is responsible for - taking those three arguments and creating the class. Most object oriented - programming languages provide a default implementation. What makes Python - special is that it is possible to create custom metaclasses. Most users - never need this tool, but when the need arises, metaclasses can provide - powerful, elegant solutions. They have been used for logging attribute - access, adding thread-safety, tracking object creation, implementing - singletons, and many other tasks. - -@@ -533,20 +573,27 @@ - (") or an apostrophe ('). While they don't provide any functionality - not available with single-quoted strings, they are useful for a number - of reasons. They allow you to include unescaped single and double - quotes within a string and they can span multiple lines without the - use of the continuation character, making them especially useful when - writing docstrings. - - type - The type of a Python object determines what kind of object it is; every - object has a type. An object's type is accessible as its - :attr:`__class__` attribute or can be retrieved with ``type(obj)``. - -+ view -+ The objects returned from :meth:`dict.viewkeys`, :meth:`dict.viewvalues`, -+ and :meth:`dict.viewitems` are called dictionary views. They are lazy -+ sequences that will see changes in the underlying dictionary. To force -+ the dictionary view to become a full list use ``list(dictview)``. See -+ :ref:`dict-views`. -+ - virtual machine - A computer defined entirely in software. Python's virtual machine - executes the :term:`bytecode` emitted by the bytecode compiler. - - Zen of Python - Listing of Python design principles and philosophies that are helpful in - understanding and using the language. The listing can be found by typing - "``import this``" at the interactive prompt. ======================================= --- /glossary.rst.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,478 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>glossary.rst</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -10,33 +10,33 @@</span> - - ``>>>`` - The default Python prompt of the interactive shell. Often seen for code - examples which can be executed interactively in the interpreter. - - ``...`` - The default Python prompt of the interactive shell when entering code for - an indented code block or within a pair of matching left and right - delimiters (parentheses, square brackets or curly braces). - - 2to3 - A tool that tries to convert Python 2.x code to Python 3.x code by -<span class="gd">- handling most of the incompatibilites which can be detected by parsing the</span> -<span class="gi">+ handling most of the incompatibilities which can be detected by parsing the</span> - source and traversing the parse tree. - - 2to3 is available in the standard library as :mod:`lib2to3`; a standalone - entry point is provided as :file:`Tools/scripts/2to3`. See - :ref:`2to3-reference`. - - abstract base class -<span class="gd">- Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by</span> -<span class="gi">+ :ref:`abstract-base-classes` complement :term:`duck-typing` by</span> - providing a way to define interfaces when other techniques like - :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for - data structures (in the :mod:`collections` module), numbers (in the - :mod:`numbers` module), and streams (in the :mod:`io` module). You can - create your own ABC with the :mod:`abc` module. - - argument - A value passed to a function or method, assigned to a named local - variable in the function body. A function or method may have both - positional arguments and keyword arguments in its definition. - Positional and keyword arguments may be variable-length: ``*`` accepts - or passes (if in the function definition or call) several positional -<span class="gu">@@ -54,24 +54,27 @@</span> - BDFL - Benevolent Dictator For Life, a.k.a. `Guido van Rossum - <http://www.python.org/~guido/>`_, Python's creator. - - bytecode - Python source code is compiled into bytecode, the internal representation - of a Python program in the interpreter. The bytecode is also cached in - ``.pyc`` and ``.pyo`` files so that executing the same file is faster the - second time (recompilation from source to bytecode can be avoided). This - "intermediate language" is said to run on a :term:`virtual machine` - that executes the machine code corresponding to each bytecode. - -<span class="gi">+ A list of bytecode instructions can be found in the documentation for</span> -<span class="gi">+ :ref:`the dis module <bytecodes>`.</span> -<span class="gi">+</span> - class - A template for creating user-defined objects. Class definitions - normally contain method definitions which operate on instances of the - class. - - classic class - Any class which does not inherit from :class:`object`. See - :term:`new-style class`. Classic classes will be removed in Python 3.0. - - coercion - The implicit conversion of an instance of one type to another during an - operation which involves two arguments of the same type. For example, -<span class="gu">@@ -94,27 +97,28 @@</span> - written with this latter notation; the imaginary part is written with a - ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the - :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly - advanced mathematical feature. If you're not aware of a need for them, - it's almost certain you can safely ignore them. - - context manager - An object which controls the environment seen in a :keyword:`with` - statement by defining :meth:`__enter__` and :meth:`__exit__` methods. - See :pep:`343`. - - CPython -<span class="gd">- The canonical implementation of the Python programming language. The</span> -<span class="gd">- term "CPython" is used in contexts when necessary to distinguish this</span> -<span class="gd">- implementation from others such as Jython or IronPython.</span> -<span class="gi">+ The canonical implementation of the Python programming language, as</span> -<span class="gi">+ distributed on `python.org <http://python.org>`_. The term "CPython"</span> -<span class="gi">+ is used when necessary to distinguish this implementation from others</span> -<span class="gi">+ such as Jython or IronPython.</span> - - decorator - A function returning another function, usually applied as a function - transformation using the ``@wrapper`` syntax. Common examples for - decorators are :func:`classmethod` and :func:`staticmethod`. - - The decorator syntax is merely syntactic sugar, the following two - function definitions are semantically equivalent:: - - def f(...): - ... - f = staticmethod(f) -<span class="gu">@@ -131,41 +135,40 @@</span> - :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a - descriptor, its special binding behavior is triggered upon attribute - lookup. Normally, using *a.b* to get, set or delete an attribute looks up - the object named *b* in the class dictionary for *a*, but if *b* is a - descriptor, the respective descriptor method gets called. Understanding - descriptors is a key to a deep understanding of Python because they are - the basis for many features including functions, methods, properties, - class methods, static methods, and reference to super classes. - - For more information about descriptors' methods, see :ref:`descriptors`. - - dictionary -<span class="gd">- An associative array, where arbitrary keys are mapped to values. The use</span> -<span class="gd">- of :class:`dict` closely resembles that for :class:`list`, but the keys can</span> -<span class="gd">- be any object with a :meth:`__hash__` function, not just integers.</span> -<span class="gd">- Called a hash in Perl.</span> -<span class="gi">+ An associative array, where arbitrary keys are mapped to values. The keys</span> -<span class="gi">+ can be any object with :meth:`__hash__` function and :meth:`__eq__`</span> -<span class="gi">+ methods. Called a hash in Perl.</span> - - docstring - A string literal which appears as the first expression in a class, - function or module. While ignored when the suite is executed, it is - recognized by the compiler and put into the :attr:`__doc__` attribute - of the enclosing class, function or module. Since it is available via - introspection, it is the canonical place for documentation of the - object. - - duck-typing -<span class="gd">- A pythonic programming style which determines an object's type by inspection</span> -<span class="gd">- of its method or attribute signature rather than by explicit relationship</span> -<span class="gd">- to some type object ("If it looks like a duck and quacks like a duck, it</span> -<span class="gi">+ A programming style which does not look at an object's type to determine</span> -<span class="gi">+ if it has the right interface; instead, the method or attribute is simply</span> -<span class="gi">+ called or used ("If it looks like a duck and quacks like a duck, it</span> - must be a duck.") By emphasizing interfaces rather than specific types, - well-designed code improves its flexibility by allowing polymorphic - substitution. Duck-typing avoids tests using :func:`type` or - :func:`isinstance`. (Note, however, that duck-typing can be complemented - with :term:`abstract base class`\ es.) Instead, it typically employs - :func:`hasattr` tests or :term:`EAFP` programming. - - EAFP - Easier to ask for forgiveness than permission. This common Python coding - style assumes the existence of valid keys or attributes and catches - exceptions if the assumption proves false. This clean and fast style is - characterized by the presence of many :keyword:`try` and :keyword:`except` -<span class="gu">@@ -173,117 +176,131 @@</span> - common to many other languages such as C. - - expression - A piece of syntax which can be evaluated to some value. In other words, - an expression is an accumulation of expression elements like literals, names, - attribute access, operators or function calls which all return a value. - In contrast to many other languages, not all language constructs are expressions. - There are also :term:`statement`\s which cannot be used as expressions, - such as :keyword:`print` or :keyword:`if`. Assignments are also statements, - not expressions. - - extension module -<span class="gd">- A module written in C or C++, using Python's C API to interact with the core and</span> -<span class="gd">- with user code.</span> -<span class="gi">+ A module written in C or C++, using Python's C API to interact with the</span> -<span class="gi">+ core and with user code.</span> - - finder - An object that tries to find the :term:`loader` for a module. It must - implement a method named :meth:`find_module`. See :pep:`302` for - details. - -<span class="gi">+ floor division</span> -<span class="gi">+ Mathematical division that rounds down to nearest integer. The floor</span> -<span class="gi">+ division operator is ``//``. For example, the expression ``11 // 4``</span> -<span class="gi">+ evaluates to ``2`` in contrast to the ``2.75`` returned by float true</span> -<span class="gi">+ division. Note that ``(-11) // 4`` is ``-3`` because that is ``-2.75``</span> -<span class="gi">+ rounded *downward*. See :pep:`238`.</span> -<span class="gi">+</span> - function - A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. - - __future__ -<span class="gd">- A pseudo module which programmers can use to enable new language features</span> -<span class="gi">+ A pseudo-module which programmers can use to enable new language features</span> - which are not compatible with the current interpreter. For example, the - expression ``11/4`` currently evaluates to ``2``. If the module in which - it is executed had enabled *true division* by executing:: - - from __future__ import division - - the expression ``11/4`` would evaluate to ``2.75``. By importing the - :mod:`__future__` module and evaluating its variables, you can see when a - new feature was first added to the language and when it will become the - default:: - - >>> import __future__ - >>> __future__.division - _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) - - garbage collection - The process of freeing memory when it is not used anymore. Python - performs garbage collection via reference counting and a cyclic garbage - collector that is able to detect and break reference cycles. - - .. index:: single: generator - - generator - A function which returns an iterator. It looks like a normal function -<span class="gd">- except that values are returned to the caller using a :keyword:`yield`</span> -<span class="gd">- statement instead of a :keyword:`return` statement. Generator functions</span> -<span class="gd">- often contain one or more :keyword:`for` or :keyword:`while` loops which</span> -<span class="gd">- :keyword:`yield` elements back to the caller. The function execution is</span> -<span class="gd">- stopped at the :keyword:`yield` keyword (returning the result) and is</span> -<span class="gd">- resumed there when the next element is requested by calling the</span> -<span class="gd">- :meth:`next` method of the returned iterator.</span> -<span class="gi">+ except that it contains :keyword:`yield` statements for producing a series</span> -<span class="gi">+ a values usable in a for-loop or that can be retrieved one at a time with</span> -<span class="gi">+ the :func:`next` function. Each :keyword:`yield` temporarily suspends</span> -<span class="gi">+ processing, remembering the location execution state (including local</span> -<span class="gi">+ variables and pending try-statements). When the generator resumes, it</span> -<span class="gi">+ picks-up where it left-off (in contrast to functions which start fresh on</span> -<span class="gi">+ every invocation).</span> - - .. index:: single: generator expression - - generator expression - An expression that returns an iterator. It looks like a normal expression - followed by a :keyword:`for` expression defining a loop variable, range, - and an optional :keyword:`if` expression. The combined expression - generates values for an enclosing function:: - - >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81 - 285 - - GIL - See :term:`global interpreter lock`. - - global interpreter lock -<span class="gd">- The lock used by Python threads to assure that only one thread</span> -<span class="gd">- executes in the :term:`CPython` :term:`virtual machine` at a time.</span> -<span class="gd">- This simplifies the CPython implementation by assuring that no two</span> -<span class="gd">- processes can access the same memory at the same time. Locking the</span> -<span class="gd">- entire interpreter makes it easier for the interpreter to be</span> -<span class="gd">- multi-threaded, at the expense of much of the parallelism afforded by</span> -<span class="gd">- multi-processor machines. Efforts have been made in the past to</span> -<span class="gd">- create a "free-threaded" interpreter (one which locks shared data at a</span> -<span class="gd">- much finer granularity), but so far none have been successful because</span> -<span class="gd">- performance suffered in the common single-processor case.</span> -<span class="gi">+ The mechanism used by the :term:`CPython` interpreter to assure that</span> -<span class="gi">+ only one thread executes Python :term:`bytecode` at a time.</span> -<span class="gi">+ This simplifies the CPython implementation by making the object model</span> -<span class="gi">+ (including critical built-in types such as :class:`dict`) implicitly</span> -<span class="gi">+ safe against concurrent access. Locking the entire interpreter</span> -<span class="gi">+ makes it easier for the interpreter to be multi-threaded, at the</span> -<span class="gi">+ expense of much of the parallelism afforded by multi-processor</span> -<span class="gi">+ machines.</span> -<span class="gi">+</span> -<span class="gi">+ However, some extension modules, either standard or third-party,</span> -<span class="gi">+ are designed so as to release the GIL when doing computationally-intensive</span> -<span class="gi">+ tasks such as compression or hashing. Also, the GIL is always released</span> -<span class="gi">+ when doing I/O.</span> -<span class="gi">+</span> -<span class="gi">+ Past efforts to create a "free-threaded" interpreter (one which locks</span> -<span class="gi">+ shared data at a much finer granularity) have not been successful</span> -<span class="gi">+ because performance suffered in the common single-processor case. It</span> -<span class="gi">+ is believed that overcoming this performance issue would make the</span> -<span class="gi">+ implementation much more complicated and therefore costlier to maintain.</span> - - hashable - An object is *hashable* if it has a hash value which never changes during - its lifetime (it needs a :meth:`__hash__` method), and can be compared to - other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method). - Hashable objects which compare equal must have the same hash value. - - Hashability makes an object usable as a dictionary key and a set member, - because these data structures use the hash value internally. - - All of Python's immutable built-in objects are hashable, while no mutable - containers (such as lists or dictionaries) are. Objects which are - instances of user-defined classes are hashable by default; they all - compare unequal, and their hash value is their :func:`id`. - - IDLE - An Integrated Development Environment for Python. IDLE is a basic editor - and interpreter environment which ships with the standard distribution of -<span class="gd">- Python. Good for beginners, it also serves as clear example code for</span> -<span class="gd">- those wanting to implement a moderately sophisticated, multi-platform GUI</span> -<span class="gd">- application.</span> -<span class="gi">+ Python.</span> - - immutable - An object with a fixed value. Immutable objects include numbers, strings and - tuples. Such an object cannot be altered. A new object has to - be created if a different value has to be stored. They play an important - role in places where a constant hash value is needed, for example as a key - in a dictionary. - - integer division - Mathematical division discarding any remainder. For example, the - expression ``11/4`` currently evaluates to ``2`` in contrast to the - ``2.75`` returned by float division. Also called *floor division*. -<span class="gu">@@ -340,24 +357,44 @@</span> - :meth:`next` method just raise :exc:`StopIteration` again. Iterators are - required to have an :meth:`__iter__` method that returns the iterator - object itself so every iterator is also iterable and may be used in most - places where other iterables are accepted. One notable exception is code - which attempts multiple iteration passes. A container object (such as a - :class:`list`) produces a fresh new iterator each time you pass it to the - :func:`iter` function or use it in a :keyword:`for` loop. Attempting this - with an iterator will just return the same exhausted iterator object used - in the previous iteration pass, making it appear like an empty container. - - More information can be found in :ref:`typeiter`. - -<span class="gi">+ key function</span> -<span class="gi">+ A key function or collation function is a callable that returns a value</span> -<span class="gi">+ used for sorting or ordering. For example, :func:`locale.strxfrm` is</span> -<span class="gi">+ used to produce a sort key that is aware of locale specific sort</span> -<span class="gi">+ conventions.</span> -<span class="gi">+</span> -<span class="gi">+ A number of tools in Python accept key functions to control how elements</span> -<span class="gi">+ are ordered or grouped. They include :func:`min`, :func:`max`,</span> -<span class="gi">+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,</span> -<span class="gi">+ :func:`heapq.nlargest`, and :func:`itertools.groupby`.</span> -<span class="gi">+</span> -<span class="gi">+ There are several ways to create a key function. For example. the</span> -<span class="gi">+ :meth:`str.lower` method can serve as a key function for case insensitive</span> -<span class="gi">+ sorts. Alternatively, an ad-hoc key function can be built from a</span> -<span class="gi">+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,</span> -<span class="gi">+ the :mod:`operator` module provides three key function constuctors:</span> -<span class="gi">+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and</span> -<span class="gi">+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO</span> -<span class="gi">+ <sortinghowto>` for examples of how to create and use key functions.</span> -<span class="gi">+</span> - keyword argument - Arguments which are preceded with a ``variable_name=`` in the call. - The variable name designates the local name in the function to which the - value is assigned. ``**`` is used to accept or pass a dictionary of - keyword arguments. See :term:`argument`. - - lambda - An anonymous inline function consisting of a single :term:`expression` - which is evaluated when the function is called. The syntax to create - a lambda function is ``lambda [arguments]: expression`` - - LBYL -<span class="gu">@@ -376,26 +413,29 @@</span> - return a list with the results. ``result = ["0x%02x" % x for x in - range(256) if x % 2 == 0]`` generates a list of strings containing - even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if` - clause is optional. If omitted, all elements in ``range(256)`` are - processed. - - loader - An object that loads a module. It must define a method named - :meth:`load_module`. A loader is typically returned by a - :term:`finder`. See :pep:`302` for details. - - mapping -<span class="gd">- A container object (such as :class:`dict`) which supports arbitrary key</span> -<span class="gd">- lookups using the special method :meth:`__getitem__`.</span> -<span class="gi">+ A container object that supports arbitrary key lookups and implements the</span> -<span class="gi">+ methods specified in the :class:`Mapping` or :class:`MutableMapping`</span> -<span class="gi">+ :ref:`abstract base classes <abstract-base-classes>`. Examples include</span> -<span class="gi">+ :class:`dict`, :class:`collections.defaultdict`,</span> -<span class="gi">+ :class:`collections.OrderedDict` and :class:`collections.Counter`.</span> - - metaclass - The class of a class. Class definitions create a class name, a class - dictionary, and a list of base classes. The metaclass is responsible for - taking those three arguments and creating the class. Most object oriented - programming languages provide a default implementation. What makes Python - special is that it is possible to create custom metaclasses. Most users - never need this tool, but when the need arises, metaclasses can provide - powerful, elegant solutions. They have been used for logging attribute - access, adding thread-safety, tracking object creation, implementing - singletons, and many other tasks. - -<span class="gu">@@ -533,20 +573,27 @@</span> - (") or an apostrophe ('). While they don't provide any functionality - not available with single-quoted strings, they are useful for a number - of reasons. They allow you to include unescaped single and double - quotes within a string and they can span multiple lines without the - use of the continuation character, making them especially useful when - writing docstrings. - - type - The type of a Python object determines what kind of object it is; every - object has a type. An object's type is accessible as its - :attr:`__class__` attribute or can be retrieved with ``type(obj)``. - -<span class="gi">+ view</span> -<span class="gi">+ The objects returned from :meth:`dict.viewkeys`, :meth:`dict.viewvalues`,</span> -<span class="gi">+ and :meth:`dict.viewitems` are called dictionary views. They are lazy</span> -<span class="gi">+ sequences that will see changes in the underlying dictionary. To force</span> -<span class="gi">+ the dictionary view to become a full list use ``list(dictview)``. See</span> -<span class="gi">+ :ref:`dict-views`.</span> -<span class="gi">+</span> - virtual machine - A computer defined entirely in software. Python's virtual machine - executes the :term:`bytecode` emitted by the bytecode compiler. - - Zen of Python - Listing of Python design principles and philosophies that are helpful in - understanding and using the language. The listing can be found by typing - "``import this``" at the interactive prompt. -</pre></div> - -</body> -</html> ============================================================================== Revision: a2939d821e84 Author: Naoki INADA <inada****@klab*****> Date: Fri Nov 11 23:08:31 2011 Log: whatsnew/2.7 loggingまで翻訳 http://code.google.com/p/python-doc-ja/source/detail?r=a2939d821e84 Modified: /whatsnew/2.7.rst ======================================= --- /whatsnew/2.7.rst Fri Nov 11 09:56:34 2011 +++ /whatsnew/2.7.rst Fri Nov 11 23:08:31 2011 @@ -397,24 +397,23 @@ メッセージをフィルターし、異なるフォーマットを行い、メッセージを 沢山の種類のハンドラーに渡します。 -All this flexibility can require a lot of configuration. You can -write Python statements to create objects and set their properties, -but a complex set-up requires verbose but boring code. -:mod:`logging` also supports a :func:`~logging.fileConfig` -function that parses a file, but the file format doesn't support -configuring filters, and it's messier to generate programmatically. - -Python 2.7 adds a :func:`~logging.dictConfig` function that -uses a dictionary to configure logging. There are many ways to -produce a dictionary from different sources: construct one with code; -parse a file containing JSON; or use a YAML parsing library if one is -installed. For more information see :ref:`logging-config-api`. - -The following example configures two loggers, the root logger and a -logger named "network". Messages sent to the root logger will be -sent to the system log using the syslog protocol, and messages -to the "network" logger will be written to a :file:`network.log` file -that will be rotated once the log reaches 1MB. +この柔軟性は、多くの設定を必要とします。 +オブジェクトを生成してプロパティを設定する Python コードを書くこともできま すが、 +複雑なセットアップをしようとすると退屈なコードを書かないといけなくなりま す。 +:mod:`logging` は設定ファイルのパースを行う :func:`~logging.fileConfig` +関数を提供していますが、このファイルフォーマットはフィルターの設定をサポー ト +していませんし、プログラムで生成するのはさらに面倒になります。 + +Python 2.7 は logging の設定のために辞書を使う :func:`~logging.dictConfig` +関数を追加しました。いろいろな入力から辞書を作成する方法があります。 +コードで作ったり、 JSON ファイルをパースしたり、YAMLのパーサーを +インストールしてあればそれを使うことができます。 +詳しい情報は :ref:`logging-config-api` を参照してください。 + +次の例は2つのロガー、 root logger と "network" という名前の logger +root logger に送られたメッセージは syslog プロトコルを利用してシステムに +送られ、 "network" logger に送られたメッセージは1MBごとにローテートされる +:file:`network.log` ファイルに書きこまれます。 :: @@ -460,27 +459,25 @@ netlogger = logging.getLogger('network') netlogger.error('Connection failed') -Three smaller enhancements to the :mod:`logging` module, all -implemented by Vinay Sajip, are: +他にも、 :mod:`logging` モジュールには Vinary Sajip によって実装された +3 つの改良があります。 .. rev79293 -* The :class:`~logging.handlers.SysLogHandler` class now supports - syslogging over TCP. The constructor has a *socktype* parameter - giving the type of socket to use, either :const:`socket.SOCK_DGRAM` - for UDP or :const:`socket.SOCK_STREAM` for TCP. The default - protocol remains UDP. - -* :class:`~logging.Logger` instances gained a :meth:`~logging.Logger.getChild` - method that retrieves a descendant logger using a relative path. - For example, once you retrieve a logger by doing ``log = getLogger('app')``, - calling ``log.getChild('network.listen')`` is equivalent to - ``getLogger('app.network.listen')``. - -* The :class:`~logging.LoggerAdapter` class gained a - :meth:`~logging.LoggerAdapter.isEnabledFor` method that takes a - *level* and returns whether the underlying logger would - process a message of that level of importance. +* :class:`~logging.handlers.SysLogHandler` クラスは TCP 経由の syslog + をサポートします。コンストラクタの *socktype* 引数は使用するソケットの + 種類として、 UDP を使う :const:`socket.SOCK_DGRAM` と TCP を使う + :const:`socket.SOCK_STREAM` のどちらかを取ります。デフォルトはUDPのままで す。 + +* :class:`~logging.Logger` インスタンスに :meth:`~logging.Logger.getChild` + メソッドが追加されました。これは、相対パスで下位の logger を返します。 + 例えば、 ``log = getLogger('app')`` として logger を取得した後、 + ``log.getChild('network.listen')`` は ``getLogger('app.network.listen')`` + と同じになります。 + +* :class:`~logging.LoggerAdapter` クラス に :meth:`~logging.LoggerAdapter.isEnabledFor` + メソッドが追加されました。 *level* を引数に取り、ベースの logger がその重 要度 + レベルのメッセージを処理するかどうかを返します。 .. XXX: Logger objects don't have a class declaration so the link don't work