Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Side by Side Diff: Doc/library/functions.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/ftplib.rst ('k') | Doc/library/gzip.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. XXX document all delegations to __special__ methods 1 .. XXX document all delegations to __special__ methods
2 .. _built-in-funcs: 2 .. _built-in-funcs:
3 3
4 Built-in Functions 4 Built-in Functions
5 ================== 5 ==================
6 6
7 The Python interpreter has a number of functions and types built into it that 7 The Python interpreter has a number of functions and types built into it that
8 are always available. They are listed here in alphabetical order. 8 are always available. They are listed here in alphabetical order.
9 9
10 =================== ================= ================== ================ == ================== 10 =================== ================= ================== ================ == ==================
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0 324 close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0
325 <= abs(a % b) < abs(b)``. 325 <= abs(a % b) < abs(b)``.
326 326
327 327
328 .. function:: enumerate(iterable, start=0) 328 .. function:: enumerate(iterable, start=0)
329 329
330 Return an enumerate object. *iterable* must be a sequence, an 330 Return an enumerate object. *iterable* must be a sequence, an
331 :term:`iterator`, or some other object which supports iteration. The 331 :term:`iterator`, or some other object which supports iteration. The
332 :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a 332 :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a
333 tuple containing a count (from *start* which defaults to 0) and the 333 tuple containing a count (from *start* which defaults to 0) and the
334 values obtained from iterating over *iterable*. 334 corresponding value obtained from iterating over *iterable*.
335 335
336 >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter'] 336 >>> for i, season in enumerate('Spring Summer Fall Winter'.split(), start= 1):
337 >>> list(enumerate(seasons)) 337 print(i, season)
338 [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] 338 1 Spring
339 >>> list(enumerate(seasons, start=1)) 339 2 Summer
340 [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')] 340 3 Fall
341 4 Winter
341 342
342 Equivalent to:: 343 Equivalent to::
343 344
344 def enumerate(sequence, start=0): 345 def enumerate(sequence, start=0):
345 n = start 346 n = start
346 for elem in sequence: 347 for elem in sequence:
347 yield n, elem 348 yield n, elem
348 n += 1 349 n += 1
349 350
350 351
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1450
1450 .. rubric:: Footnotes 1451 .. rubric:: Footnotes
1451 1452
1452 .. [#] Note that the parser only accepts the Unix-style end of line convention. 1453 .. [#] Note that the parser only accepts the Unix-style end of line convention.
1453 If you are reading the code from a file, make sure to use newline conversion 1454 If you are reading the code from a file, make sure to use newline conversion
1454 mode to convert Windows or Mac-style newlines. 1455 mode to convert Windows or Mac-style newlines.
1455 1456
1456 .. [#] In the current implementation, local variable bindings cannot normally be 1457 .. [#] In the current implementation, local variable bindings cannot normally be
1457 affected this way, but variables retrieved from other scopes (such as modules ) 1458 affected this way, but variables retrieved from other scopes (such as modules )
1458 can be. This may change. 1459 can be. This may change.
OLDNEW
« no previous file with comments | « Doc/library/ftplib.rst ('k') | Doc/library/gzip.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+