[Python-ideas] Proposing additions to the standard library

2018-11-10 Thread Jonathan Crall
I'm interested in proposing several additions to the Python standard library, and I would like more information on the procedure for doing so. Are all additions done via a PEP? If not what is the procedure. If so, I've read that the first step was to email this board and get feedback. I have a

Re: [Python-ideas] Proposing additions to the standard library

2018-11-10 Thread Jonathan Crall
r usefulness of any of these functions to the stdlib? On Sat, Nov 10, 2018 at 9:14 PM Steven D'Aprano wrote: > On Sat, Nov 10, 2018 at 08:36:52PM -0500, Jonathan Crall wrote: > > I'm interested in proposing several additions to the Python standard > > library, and I would like more information

Re: [Python-ideas] Proposing additions to the standard library

2018-11-14 Thread Jonathan Crall
ginal question by the OP. > > Another interesting issue is the granularity of such a project. I > sometimes, and somewhat foolishly, make libraries such as toolz or boltons > a dependency of my projects, for just one or two function calls from my > code. > > Regards, > > S.

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-17 Thread Jonathan Crall
Based on the conversation so far, I agree with @Kyle Stanley's breakdown of the proposal. I think shelving the "*Add a new way to create and specify executor*" and focusing on "*Add a SerialExecutor, which does not use threads or processes*" is the best way forward. For context, I'm a machine

[Python-ideas] SerialExecutor for concurrent.futures + Convenience constructor

2020-02-15 Thread Jonathan Crall
I'd like to propose an improvement to `concurrent.futures`. The library's ThreadPoolExecutor and ProcessPoolExecutor are excellent tools, but there is currently no mechanism for configuring which type of executor you want. Also, there is no duck-typed class that behaves like an executor, but does

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-15 Thread Jonathan Crall
ve it. On the other hand I think a SerialExecutor is something that is sorely missing from the standard library. On Sat, Feb 15, 2020 at 5:16 PM Andrew Barnert wrote: > > On Feb 15, 2020, at 13:36, Jonathan Crall wrote: > > > > Also, there is no duck-typed class that behaves like an e

[Python-ideas] Re: more readable "if" for multiple "in" condition

2019-12-31 Thread Jonathan Crall
For what its worth, I find the proposed syntax confusing and difficult to read. Conceptually it makes sense, but using existing set operations seems like a far more readable way to handle this case. On Tue, Dec 31, 2019 at 11:03 AM Richard Damon wrote: > On 12/31/19 1:20 AM,

[Python-ideas] Re: 'Infinity' constant in Python

2020-09-08 Thread Jonathan Crall
Given that this is unlikely to see any change in core Python, perhaps you can get a decent solution with a third party library? If your main issue is that repr doesn't provide an "eval-able" string, then may I suggest using the "most-used" function in the ubelt utility library: ubelt.repr2 Two

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
I just want to point out that I can think of a valid use case for `clf`. I'm not sure if it was mentioned. In the case where you have a script that produces a lot of output, a common task might be scrolling to the beginning to check an output. If your screen was not fresh, and you had a lot of

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
they advertised as reusable used this (but then again I also get peeved when people execute print statements at import time). On Fri, Oct 16, 2020 at 5:02 PM Paul Moore wrote: > On Fri, 16 Oct 2020 at 20:43, Jonathan Crall wrote: > > > > @Chris Angelico If you are more application foc

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
0 at 5:40 AM Jonathan Crall wrote: > > > > I just want to point out that I can think of a valid use case for `clf`. > I'm not sure if it was mentioned. > > > > In the case where you have a script that produces a lot of output, a > common task might be scrolling to the b

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-06-29 Thread Jonathan Crall
FWIW I'm +1 on `d.keys()[i]`, `d.values()[i]`, `d.items()[i]`. I don't see any major issue with adding a __getitem__ to the view classes. I think it's a great idea, and it would make my life easier and would replace the primary use case where I currently use `ubelt.peek

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Jonathan Crall
I disagree that doing arithmetic on boolean variables doesn't make sense. Indicator variables which take a value of either zero are one are extremely common. Dirac or Kronecker delta functions are also examples of functions where it arithmetically makes sense to talk about values in the boolean

[Python-ideas] Re: Bringing the print statement back

2020-06-10 Thread Jonathan Crall
I wouldn't mind if this *only *worked for the specific characters "print". However, I think that allowing developers to call complex methods without parentheses will lead to very difficult to read code.I think that surrounding arguments with non-whitespace buffer characters is important for

[Python-ideas] Re: Bringing the print statement back

2020-06-11 Thread Jonathan Crall
h is the only reason I'm giving it special status. Regardless, I'd rather not have this feature. As you said it's not 100% backwards compatible, so the usefulness is limited. On Thu, Jun 11, 2020 at 11:49 AM Steven D'Aprano wrote: > On Wed, Jun 10, 2020 at 08:00:26PM -0400, Jonathan Crall wrote

[Python-ideas] Re: Conditional with statements

2020-12-15 Thread Jonathan Crall
Thanks for the link, the rationale for rejection seems reasonable. On Fri, Dec 11, 2020 at 8:19 PM Chris Angelico wrote: > On Sat, Dec 12, 2020 at 11:42 AM Jonathan Crall > wrote: > > > > I'm not sure if this has been asked / suggested before. > > > > I'm wond

[Python-ideas] Conditional with statements

2020-12-11 Thread Jonathan Crall
I'm not sure if this has been asked / suggested before. I'm wondering if there is any interest in conditional or loop-based `with` statements. I think it could be done without a syntax change. ### Napkin proposal Context managers could define `__if__` or `__for__`, and if those dunder methods

[Python-ideas] Re: Conditional with statements

2021-02-09 Thread Jonathan Crall
@Iasizoillo > Only if you don't setup vars like official example* or not calc some statistic after timered block I wrote the official docs, so I'm aware of that case. In the case where setup variables are required it make sense to me to have an extra level of indentation. It just bothers me that

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-10 Thread Jonathan Crall
I'd like to give a shoutout to a package I wrote called mkinit, which helps autogenerate explicit `__init__.py` files to mitigate some of the issues you mentioned (especially with respect to `from blah import *`). https://github.com/Erotemic/mkinit On Sat, Apr 10, 2021 at 3:08 PM Guido van

[Python-ideas] Re: Conditional with statements

2021-02-06 Thread Jonathan Crall
I ran into another case where I wish I had some sort of conditional if. I was writing code to cache autogenerated demodata. import ubelt as ub from os.path import join import json kwargs = {'example': 'config'} dpath = ub.ensure_app_cache_dir('my_modname', 'demodata')

[Python-ideas] Re: Conditional with statements

2021-02-07 Thread Jonathan Crall
ote: > Hello, > > On Sat, 6 Feb 2021 19:57:33 -0500 > Jonathan Crall wrote: > > > I ran into another case where I wish I had some sort of conditional > > if. > > Right, conditional "if" is exactly what we miss in Python. > > Yes, it's a typo, but i

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-01 Thread Jonathan Crall
That's effectively every module I write. I don't think that's uncommon or bad practice. On Sat, Oct 2, 2021, 12:05 AM Chris Angelico wrote: > On Sat, Oct 2, 2021 at 2:01 PM Jonathan Crall wrote: > > > > @Steven D'Aprano Yes my original post is somewhat pithy and has som

[Python-ideas] Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-01 Thread Jonathan Crall
I was curious if / what sort of proposals have been considered for simplifying the pattern: ``` def main(): ... if __name__ == "__main__": main() ``` I imagine this topic must have come up before, so I'd be interested in any relevant history. But unless I'm missing something, it seems

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-01 Thread Jonathan Crall
Python just checking that there is a dunder main function, and calling it. That would be in the spirit of dunder getattr, which imo is one of the best improvements Python has made. On Fri, Oct 1, 2021, 9:01 PM Steven D'Aprano wrote: > On Fri, Oct 01, 2021 at 03:35:26PM -0400, Jonathan Cr

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-01 Thread Jonathan Crall
gt; Behavior: >> >> 1. Load module as normal. >> 2. If __name__ is "__main__" or module is named in python -m, call >> __main__ function. >> >> Paul >> >> >> On Fri, 2021-10-01 at 15:35 -0400, Jonathan Crall wrote: >> >&g

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-01 Thread Jonathan Crall
le as normal. > 2. If __name__ is "__main__" or module is named in python -m, call > __main__ function. > > Paul > > > On Fri, 2021-10-01 at 15:35 -0400, Jonathan Crall wrote: > > I was curious if / what sort of proposals have been considered for > sim

[Python-ideas] Re: Syntax Sugar for __name__ == "__main__" boilerplate?

2021-10-03 Thread Jonathan Crall
@Marc-Andre One of the motivations of this proposal is to incentivize writing code in a local scope, rather than a global one. People in this thread have made the argument "Python is a scripting language, so it should do that". Ok, fine. Yes `print('hello world')` is more idiomatic than the one

[Python-ideas] Re: Adding pep-8-casing-compliant aliases for unittest and logging

2021-11-12 Thread Jonathan Crall
IMO (a subset of) pytest is the superior unit-testing framework. Just having functions prefixed with `test_` is easy and intuitive. It also works well with xdoctest, but I would use it even if that wasn't the case. (That being said, I think the current implementation of fixtures - where you can't

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-18 Thread Jonathan Crall
Not a huge fan of an f-prefix for a frozen set (I prefer just recognizing the case and optimizing the byte code, I don't think frozensets are used often enough to justify its own syntax), but I love {,} for an empty set. On Tue, Jan 18, 2022 at 4:13 PM Rob Cliffe via Python-ideas <

[Python-ideas] Re: Auto dedent -c arguments.

2023-04-29 Thread Jonathan Crall
y done via the Python C-API, but in terms of keeping things lightweight, I might need some help on how to effectively use the wide c-string API to implement this. On Mon, Apr 10, 2023 at 4:46 AM Barry wrote: > > > On 10 Apr 2023, at 02:18, Jonathan Crall wrote: > >  > There's no

[Python-ideas] Re: Auto dedent -c arguments.

2023-04-09 Thread Jonathan Crall
the feature to CPython? On Sun, Apr 9, 2023 at 4:09 PM Barry Scott wrote: > > On 04/04/2023 15:18, Jonathan Crall wrote: > > I have what I think is a fairly low impact quality of life improvement to > suggest for the python CLI. > > When I'm not working in Python I tend to be working

[Python-ideas] Auto dedent -c arguments.

2023-04-04 Thread Jonathan Crall
I have what I think is a fairly low impact quality of life improvement to suggest for the python CLI. When I'm not working in Python I tend to be working in bash. But often I want to break out and do something quick in Python. I find the `python -c ` CLI very useful for this. For one liners it's

[Python-ideas] Re: "Curated" package repo?

2023-07-04 Thread Jonathan Crall
I like the idea of a vetted package index that pip can point to. The more I think about it, the more I think that it needs some sort of peer review system as the barrier to entry, and my thoughts to to establishing some DeSci DAO that could distribute the peer review of packages amongst a set of

[Python-ideas] Re: "Curated" package repo?

2023-07-25 Thread Jonathan Crall
> On Mon, Jul 24, 2023 at 10:04 AM Chris Angelico wrote: > can you tell me what this vetting procedure proves that isn't already proven by mere popularity itself? I think that's what this thread is trying to discuss. Do I have the exact perfect implementation? No. But I imagine it to be akin to

[Python-ideas] Re: "Curated" package repo?

2023-07-24 Thread Jonathan Crall
If popular packages weren't favored that would be a problem. Popularity should be correlated with "trustworthiness" or whatever the metric this curated repo seeks to maximize. I think the important thing is that the packages are both popular and have passed some sort of vetting procedure. For