Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/dkrenn/lazy_list-unbound-formatter' into u/dkrenn/seq…
Browse files Browse the repository at this point in the history
…uences/k-regular

* u/dkrenn/lazy_list-unbound-formatter:
  Trac #21200: simplify requirements for input (only iterable needed)
  • Loading branch information
dkrenn committed Aug 11, 2016
2 parents 9c64180 + d3e2df6 commit 7e166c3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/sage/misc/lazy_list.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ def lazy_list_formatter(L, name=None, separator=None, more=None,
INPUT:
- ``L`` -- an object supporting slicing. To be precise, extracting an
iterable of the first `n` values via ``iter(L[:n])`` has to be possible.
- ``L`` -- an iterable object.
- ``name`` -- (default: ``'lazy list'``) a string appearing
at first position (i.e., in front of the actual values)
Expand Down Expand Up @@ -339,7 +338,15 @@ def lazy_list_formatter(L, name=None, separator=None, more=None,
....: opening_delimiter='', closing_delimiter='',
....: separator=' ', more='->', preview=7)
'primes 2 3 5 7 11 13 17 ->'
TESTS::
sage: from itertools import count
sage: lazy_list_formatter(count(), name='iterator count')
'iterator count [0, 1, 2, ...]'
"""
from itertools import islice

if name is None:
name = 'lazy list'
if opening_delimiter is None:
Expand All @@ -357,7 +364,7 @@ def lazy_list_formatter(L, name=None, separator=None, more=None,
if s:
s += ' '
s += opening_delimiter
cdef list P = list(L[:preview+1])
cdef list P = list(islice(L, preview+1))
cdef list E = list('{!r}'.format(e)
for e in P[:preview])
if len(P) > preview:
Expand Down

0 comments on commit 7e166c3

Please sign in to comment.