Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105094
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Bash-like pipes in Python |
| Date | Fri, 18 Mar 2016 01:36:38 +1100 |
| Lines | 34 |
| Message-ID | <mailman.272.1458225402.12893.python-list@python.org> (permalink) |
| References | <56e97459$0$1600$c3e8da3$5496439d@news.astraweb.com> <87egbacq2j.fsf@elektro.pacujo.net> <56eabae8$0$1599$c3e8da3$5496439d@news.astraweb.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de xqmqfouW171rnL8n6bZvuAWS48pImM27rpd98TglV4Qg== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'val': 0.07; 'cc:addr:python-list': 0.09; 'appropriate.': 0.09; 'filter,': 0.09; 'script,': 0.09; 'whichever': 0.09; 'def': 0.13; 'appropriate': 0.14; '2016': 0.16; 'already!': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'iterators,': 0.16; 'quantum': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'processed': 0.27; 'yield': 0.27; 'skip:_ 10': 0.32; 'computing': 0.32; 'operate': 0.32; 'class': 0.33; "d'aprano": 0.33; 'right?': 0.33; 'steven': 0.33; 'subject:like': 0.33; 'except': 0.34; 'lists': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'filter': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'list.': 0.37; 'received:209': 0.38; 'data': 0.39; 'subject:-': 0.39; 'some': 0.40; 'customer': 0.62; 'skip:n 10': 0.62; 'mar': 0.65; 'here': 0.66; 'chrisa': 0.84; "it'd": 0.84; 'step,': 0.84; "they'd": 0.84; 'to:none': 0.91; 'pipeline': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=9arYtyKExAs6OH4gBYJnAyv5netHyObuKbbDH49d1uc=; b=k93Hky5cU2O9UUPRrbGCoD+gvPwvxyPIyyCuArzVVnUujvpQT5RQFcWW83zcwK+Y1y tTGinEtLBPY5EY26cn4l1eFHRhpFVsozW78vq4HrHSbsv4C/fW2ltTzF0UzrnK3lPYNK Ps7j/4hRlOIm/xfp0rT+vWfK4h79V0Z3VP4SVUCvBPyHK/Z/3S9e8HgrSRXjeVsucjYB gvLkcf7wc2BSWx3eUpOg7JJRzjbZBtiUF3jRMLOQe0X/9hA5E57dfaltGEtXHm8VkI/+ EmFshhiC2A5AjYQXLCimUUdNY1tMUWbP2l7CDto9WsR3sCiPwFyCMzochnq9PicLk0L6 xjag== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=9arYtyKExAs6OH4gBYJnAyv5netHyObuKbbDH49d1uc=; b=W7wWJUg97SEzTayGWK9RM5zaEUyTwjPf1od/fsQWbpHew/xxkcPhtewkBlo5JPMz26 x5rlVigkgmbh9Cxg6k/H15Hs/Kjy5qIYM10RRGu7GPBJ+MwhUVitoj0C98GF5y1Y4IlU my4YidjpIvh2ZFpV1lqLBJwPRbkjAK7lYRTe7XmFNIna2kGHKz1354rYPtbwpV9xhi2j jhiLCJheZYPPl0Wq8njZq7HLDLmNwTcIZc6GzwWmyXkjGuh8GdegbSt6QbkNnwlgTRs9 UaL4MzIQtTyi9g48d5M1tEfzS0JBBBfgCEmSiZUY9FDXR331OrlVtl/qzY5okXixGjRS p8EQ== |
| X-Gm-Message-State | AD7BkJLZIPSYcz7cTOrEQSK4bZ0O4a1xxAx9XYMRGXNyMGUIVCwib5MicaOiYkfZJzRJwFvEb+AiZYMA8R0Y4Q== |
| X-Received | by 10.50.43.226 with SMTP id z2mr8114502igl.94.1458225398739; Thu, 17 Mar 2016 07:36:38 -0700 (PDT) |
| In-Reply-To | <56eabae8$0$1599$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105094 |
Show key headers only | View raw
On Fri, Mar 18, 2016 at 1:10 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> At the moment, the data being processed by the Map, Filter, etc. are
> ordinary lists or iterators. In order to give them a customer __repr__, I
> would have to change the Map and Filter __ror__ method to return some
> custom type which behaves as an iterable but has the appropriate __repr__.
> I don't want to do that: I want the pipeline functions to return ordinary
> lists or iterators, whichever is appropriate.
They don't have to be iterators, just iterables, right? They could
return a one of these:
class QuantumList:
def __init__(self, iterable):
self.iter = iter(iterable)
self.list = []
def __iter__(self):
yield from self.list
while "moar stuff":
try: val = next(self.iter)
except StopIteration: return
self.list.append(val)
yield val
def __repr__(self):
self.list.extend(self.iter)
return repr(self.list)
This object has a generator/list duality, but if you observe it, it
collapses to a list. When used interactively, it'd be pretty much the
same as calling list() as the last step, but in a script, they'd
operate lazily.
Quantum computing is here already!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 01:57 +1100
Re: Bash-like pipes in Python Joel Goldstick <joel.goldstick@gmail.com> - 2016-03-16 11:09 -0400
Re: Bash-like pipes in Python Christian Gollwitzer <auriocus@gmx.de> - 2016-03-16 16:16 +0100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-16 11:20 -0400
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 21:58 +1100
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 13:49 +0200
Re: Bash-like pipes in Python Sivan Greenberg <sivan@vitakka.co> - 2016-03-17 14:10 +0200
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 14:44 +0200
Re: Bash-like pipes in Python "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 16:20 +0100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-16 11:21 -0400
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-17 02:39 +1100
Re: Bash-like pipes in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 19:04 +0200
Re: Bash-like pipes in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-18 01:10 +1100
Re: Bash-like pipes in Python Chris Angelico <rosuav@gmail.com> - 2016-03-18 01:36 +1100
Re: Bash-like pipes in Python Random832 <random832@fastmail.com> - 2016-03-17 12:31 -0400
Re: Bash-like pipes in Python Sivan Greenberg <sivan@vitakka.co> - 2016-03-17 19:20 +0200
csiph-web