Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
838b4b01
Kaydet (Commit)
838b4b01
authored
Mar 22, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
No need to specify explicit "doctest_block" anymore.
üst
473f1642
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
functional.rst
Doc/howto/functional.rst
+2
-2
decimal.rst
Doc/library/decimal.rst
+6
-3
re.rst
Doc/library/re.rst
+5
-5
No files found.
Doc/howto/functional.rst
Dosyayı görüntüle @
838b4b01
...
@@ -450,7 +450,7 @@ is what generators provide; they can be thought of as resumable functions.
...
@@ -450,7 +450,7 @@ is what generators provide; they can be thought of as resumable functions.
Here's the simplest example of a generator function:
Here's the simplest example of a generator function:
.. testcode::
doctest_block
.. testcode::
def generate_ints(N):
def generate_ints(N):
for i in range(N):
for i in range(N):
...
@@ -560,7 +560,7 @@ returns ``None``.
...
@@ -560,7 +560,7 @@ returns ``None``.
Here's a simple counter that increments by 1 and allows changing the value of
Here's a simple counter that increments by 1 and allows changing the value of
the internal counter.
the internal counter.
.. testcode::
doctest_block
.. testcode::
def counter (maximum):
def counter (maximum):
i = 0
i = 0
...
...
Doc/library/decimal.rst
Dosyayı görüntüle @
838b4b01
...
@@ -175,12 +175,15 @@ operations.
...
@@ -175,12 +175,15 @@ operations.
Decimals interact well with much of the rest of Python. Here is a small decimal
Decimals interact well with much of the rest of Python. Here is a small decimal
floating point flying circus:
floating point flying circus:
.. doctest::
:options: +NORMALIZE_WHITESPACE
>>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())
>>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())
>>> max(data)
>>> max(data)
Decimal('9.25')
Decimal('9.25')
>>> min(data)
>>> min(data)
Decimal('0.03')
Decimal('0.03')
>>> sorted(data)
# doctest: +NORMALIZE_WHITESPACE
>>> sorted(data)
[Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'),
[Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'),
Decimal('2.35'), Decimal('3.45'), Decimal('9.25')]
Decimal('2.35'), Decimal('3.45'), Decimal('9.25')]
>>> sum(data)
>>> sum(data)
...
@@ -1646,7 +1649,7 @@ A. Yes, all binary floating point numbers can be exactly expressed as a
...
@@ -1646,7 +1649,7 @@ A. Yes, all binary floating point numbers can be exactly expressed as a
Decimal. An exact conversion may take more precision than intuition would
Decimal. An exact conversion may take more precision than intuition would
suggest, so we trap :const:`Inexact` to signal a need for more precision:
suggest, so we trap :const:`Inexact` to signal a need for more precision:
.. testcode::
doctest_block
.. testcode::
def float_to_decimal(f):
def float_to_decimal(f):
"Convert a floating point number to a Decimal with no loss of information"
"Convert a floating point number to a Decimal with no loss of information"
...
@@ -1659,7 +1662,7 @@ suggest, so we trap :const:`Inexact` to signal a need for more precision:
...
@@ -1659,7 +1662,7 @@ suggest, so we trap :const:`Inexact` to signal a need for more precision:
except Inexact:
except Inexact:
ctx.prec += 1
ctx.prec += 1
.. doctest::
doctest_block
.. doctest::
>>> float_to_decimal(math.pi)
>>> float_to_decimal(math.pi)
Decimal('3.141592653589793115997963468544185161590576171875')
Decimal('3.141592653589793115997963468544185161590576171875')
...
...
Doc/library/re.rst
Dosyayı görüntüle @
838b4b01
...
@@ -938,7 +938,7 @@ Checking For a Pair
...
@@ -938,7 +938,7 @@ Checking For a Pair
In this example, we'll use the following helper function to display match
In this example, we'll use the following helper function to display match
objects a little more gracefully:
objects a little more gracefully:
.. testcode::
doctest_block
.. testcode::
def displaymatch(match):
def displaymatch(match):
if match is None:
if match is None:
...
@@ -973,7 +973,7 @@ To match this with a regular expression, one could use backreferences as such:
...
@@ -973,7 +973,7 @@ To match this with a regular expression, one could use backreferences as such:
To find out what card the pair consists of, one could use the :func:`group`
To find out what card the pair consists of, one could use the :func:`group`
method of :class:`MatchObject` in the following manner:
method of :class:`MatchObject` in the following manner:
.. doctest::
doctest_block
.. doctest::
>>> pair.match("717ak").group(1)
>>> pair.match("717ak").group(1)
'7'
'7'
...
@@ -1112,7 +1112,7 @@ triple-quoted string syntax:
...
@@ -1112,7 +1112,7 @@ triple-quoted string syntax:
The entries are separated by one or more newlines. Now we convert the string
The entries are separated by one or more newlines. Now we convert the string
into a list with each nonempty line having its own entry:
into a list with each nonempty line having its own entry:
.. doctest::
doctest_block
.. doctest::
:options: +NORMALIZE_WHITESPACE
:options: +NORMALIZE_WHITESPACE
>>> entries = re.split("\n+", input)
>>> entries = re.split("\n+", input)
...
@@ -1126,7 +1126,7 @@ Finally, split each entry into a list with first name, last name, telephone
...
@@ -1126,7 +1126,7 @@ Finally, split each entry into a list with first name, last name, telephone
number, and address. We use the ``maxsplit`` parameter of :func:`split`
number, and address. We use the ``maxsplit`` parameter of :func:`split`
because the address has spaces, our splitting pattern, in it:
because the address has spaces, our splitting pattern, in it:
.. doctest::
doctest_block
.. doctest::
:options: +NORMALIZE_WHITESPACE
:options: +NORMALIZE_WHITESPACE
>>> [re.split(":? ", entry, 3) for entry in entries]
>>> [re.split(":? ", entry, 3) for entry in entries]
...
@@ -1139,7 +1139,7 @@ The ``:?`` pattern matches the colon after the last name, so that it does not
...
@@ -1139,7 +1139,7 @@ The ``:?`` pattern matches the colon after the last name, so that it does not
occur in the result list. With a ``maxsplit`` of ``4``, we could separate the
occur in the result list. With a ``maxsplit`` of ``4``, we could separate the
house number from the street name:
house number from the street name:
.. doctest::
doctest_block
.. doctest::
:options: +NORMALIZE_WHITESPACE
:options: +NORMALIZE_WHITESPACE
>>> [re.split(":? ", entry, 4) for entry in entries]
>>> [re.split(":? ", entry, 4) for entry in entries]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment