[Python-ideas] Re: `importlib.resources` access whole directories as resources

2022-05-15 Thread Greg Ewing
On 16/05/22 5:05 pm, Christopher Barker wrote: a directory is not a binary artifact -- it can't have actually data in it like a file can. and: the entire point of resources is to provide an abstraction -- the individual resources may not be files on disk at all These two statements are con

[Python-ideas] Re: `importlib.resources` access whole directories as resources

2022-05-15 Thread Christopher Barker
I honestly wasn't aware that this was added in 3.7 -- I always thought handling resources was up to setuptools or hand-written code. So it's nice to see that it's there in the stdlib. And while I haven't actually used this feature, I have read through the docs and have a few comments. On Sun, May

[Python-ideas] Re: Time to relax some restrictions on the walrus operator?

2022-05-15 Thread Rob Cliffe via Python-ideas
I'm sorry Steven, I didn't mean to denigrate your examples. Please note that I said I was in favour of relaxing the restrictions on the walrus operator. I guess I just meant that using the walrus operator generally adds extra complexity to code and means that more effort is required to read and

[Python-ideas] Re: Awaiting until a condition is met

2022-05-15 Thread MRAB
On 2022-05-16 00:47, Steven D'Aprano wrote: On Sun, May 15, 2022 at 03:34:15PM +0100, MRAB wrote: On 2022-05-15 03:10, Aaron Fink wrote: >Hello. > >I've been thinking it would be nice to be able to use await to suspend >execution until a condition is met (as represented by a function or >lambd

[Python-ideas] Re: Awaiting until a condition is met

2022-05-15 Thread Steven D'Aprano
On Sun, May 15, 2022 at 03:34:15PM +0100, MRAB wrote: > On 2022-05-15 03:10, Aaron Fink wrote: > >Hello. > > > >I've been thinking it would be nice to be able to use await to suspend > >execution until a condition is met (as represented by a function or > >lambda which returns a boolean. [...] >

[Python-ideas] Re: Improving -x switch on CLI interface

2022-05-15 Thread Steven D'Aprano
On Sun, May 15, 2022 at 07:32:56PM -0300, Rafael Nunes wrote: > Hi. Thanks for asking. > In .BAT files we could write some Windows Shell commands before python code > and python interpreter would ignore them. Hi Rafael, You have answered Eric's question with *what* you would do (write Windows S

[Python-ideas] Re: Improving -x switch on CLI interface

2022-05-15 Thread Eric V. Smith
Hi, Rafael. Can you give a use case where you’d find this helpful? Thanks. -- Eric > On May 14, 2022, at 1:15 PM, Rafael Nunes wrote: > >  > Hi. > What about improving the -x switch by passing the number of lines to ignore? > Ex: -x (default=1 line) > -x n (Python will ignore first n lines

[Python-ideas] Re: Improving -x switch on CLI interface

2022-05-15 Thread Rafael Nunes
Hi. Thanks for asking. In .BAT files we could write some Windows Shell commands before python code and python interpreter would ignore them. Em dom, 15 de mai de 2022 19:14, Eric V. Smith escreveu: > Hi, Rafael. > > Can you give a use case where you’d find this helpful? > > Thanks. > > -- > Er

[Python-ideas] Re: Awaiting until a condition is met

2022-05-15 Thread MRAB
On 2022-05-15 03:10, Aaron Fink wrote: Hello. I've been thinking it would be nice to be able to use await to suspend execution until a condition is met (as represented by a function or lambda which returns a boolean. Currently, as far as I can tell, the way to accomplish this is with a whil

[Python-ideas] Re: `importlib.resources` access whole directories as resources

2022-05-15 Thread Greg Werbin
I think this is a bit of an "XY" feature request. Currently, resources must be individual files inside a package. A directory cannot itself be a "resource". So for example if you have a directory structure like this: my_great_app/ __init__.py something.py data/ ass

[Python-ideas] Re: Awaiting until a condition is met

2022-05-15 Thread Greg Werbin
The generally-accepted solution for this task is to set an Event, rather than just returning a Boolean: def move_to(dest, done_event): ... done_event.set() async def main(): dest = ... done_event = asyncio.Event() create_task(move_to(dest, done_eve

[Python-ideas] Re: Awaiting until a condition is met

2022-05-15 Thread Chris Angelico
On Sun, 15 May 2022 at 23:00, Aaron Fink wrote: > > Hello. > > I've been thinking it would be nice to be able to use await to suspend > execution until a condition is met (as represented by a function or lambda > which returns a boolean. > > Currently, as far as I can tell, the way to accomplish

[Python-ideas] Awaiting until a condition is met

2022-05-15 Thread Aaron Fink
Hello. I've been thinking it would be nice to be able to use await to suspend execution until a condition is met (as represented by a function or lambda which returns a boolean. Currently, as far as I can tell, the way to accomplish this is with a while loop which frequently checks the condition,