New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified __call__ interface? #64
Comments
I've also been using it a lot recently, and I like. 👍 What if we kept the def __call__(self, cycle=False, **kwargs):
if cycle:
return self.cycle(**kwargs)
else:
return self.generate(**kwargs) |
I dig it. Tuples are still an oddball, and I'd prefer to keep that one separate. How about I implement this after merging the doc updates so that everything can be updated in one pass? |
Roger roger
…On Sat, Mar 18, 2017 at 1:08 PM Brian McFee ***@***.***> wrote:
I dig it. Tuples are still an oddball, and I'd prefer to keep that one
separate.
How about I implement this after merging the doc updates so that
everything can be updated in one pass?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA4t888WA0dKMabIvsm7RYKDHlqiDeitks5rnDnRgaJpZM4Mhhkv>
.
|
I realize I slept on this issue the first time around and apologize in advance, but I would be keen to revisit this discussion maybe? 😞 🙏 Specifically, I'd propose making Commentary
|
I think this might cause some difficulties with how streamers get used inside Given the above, I'm not sure dropping the call interface (or implementing a direct iterable interface) is the best option, but I'm open to persuasion. |
well, here's some simple(r) math: what's the more annoying anti-pattern, a high occurrence of empty parens, or two call signatures for the same functionality? |
The original reason, if I recall correctly, for not allowing you to
__iter__ over streamers directly is language in the Python docs about how
__iter__ should behave, with regards to StopIterations. It was an
intentional design decision based on those Python definitions.
(I'm on my phone or I'd look up the details. I'll get to it in a bit if
@bmcfee doesn't beat me to it)
…On Mon, Apr 3, 2017, 09:57 Eric J. Humphrey ***@***.***> wrote:
well, here's some simple(r) math: what's the more annoying anti-pattern, a
high occurrence of empty parens, or two call signatures for the same
functionality?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA4t86NG3blhquqfSz4nxjwcIclR5BVyks5rsSUVgaJpZM4Mhhkv>
.
|
hrm, well in that case, I would augment my proposal to:
|
I would be okay with either solution.
I think (a) is more elegant, and (b) is more explicit.
If I may point back to the original proposal on this Issue, the objective
here is to create or add a simplified API for the End-User which is less
verbose than `streamer.generate()`. I think I would prefer to actually do
both (a) and (b) here, and internally to `Pescador`, or in complicated use
cases, prefer the explicit API, but offer a simplified/concise API as a
"shortcut", which simply calls the Explicit API under the hood.
…On Mon, Apr 3, 2017 at 10:19 AM Eric J. Humphrey ***@***.***> wrote:
hrm, well in that case, I would augment my proposal to:
- Iterating on a Streamer behaves as one would expect (it raises
StopIteration and runs to exhaustion), and one of...
- *(a)* Explicitly calling the streamer (__call__) with args allows
the Streamer to augment it's behavior, such as cycle itself or
terminate early via max_iter, which I would assume violates PEP
conventions around iterators or *(b)* do we need __call__ when we have
both generate() and cycle()?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA4t83HOGl47DwR9I_pHQx5wvtUkqBR1ks5rsSoxgaJpZM4Mhhkv>
.
|
having thought about it more, I agree with you on 👍 (a) ... a simplified / concise interface for doing non-standard things is nice, and I can imagine that it'd be useful to control these parameters with config-args, rather than augmenting code. |
tiny update: I'm having a really interesting / useful day catching up to pescador. Given the mix of |
closed with #88 |
I've been using pescador a bit over the last few weeks, and find myself wondering if we could tighten up the API a little before the 1.0 release.
Specifically,
streamer.generate()
is a bit verbose; how about adding a__call__
method so we can instead do something like:This wouldn't help for
cycle
ortuples
, but it would cut down a bit of boilerplate code for the most common use cases.The text was updated successfully, but these errors were encountered: