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

2022-05-18 Thread Jeff Allen
On 16/05/2022 23:22, Filipe Laíns wrote: No, Python source files are resources too. "resource" is an abstract concept akin to files, its propose is to allow support other use-cases than just files on the OS file system (eg. zip file, tarball, database). Adding a "directory" reference goes agains

[Python-ideas] Expand the try-expect syntax to support conditional expect block

2022-05-18 Thread Nadav Misgav
Hello, I was thinking of a way to expand the current try-expect block to support condinitial expect block. I was imagining the new syntax as try: expression block expect Exception if condition expression block where the expect expression block would only run if the condition is met else

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

2022-05-18 Thread Filipe Laíns
On Tue, 2022-05-17 at 23:04 -0700, Christopher Barker wrote: > If we go back to the OPs point, they were saying that they didn't like that > you have to put an __init__.py in a dir in order to put resources in it. And I > get that idea, but that wouldn't be making a dir a resource, it would be > al

[Python-ideas] Re: Expand the try-expect syntax to support conditional expect block

2022-05-18 Thread Serhiy Storchaka
18.05.22 22:08, Nadav Misgav пише: I was thinking of a way to expand the current try-expect block to support condinitial expect block. I was imagining the new syntax as try:     expression block expect Exception if condition     expression block where the expect expression block would only r

[Python-ideas] Re: Expand the try-expect syntax to support conditional expect block

2022-05-18 Thread nadav . misgav
Awesome! never seen this syntax used before and the above libraries are not using it. Can you elaborate on the else part ? Why is it needed for the syntax to be correct and could you put any expression in the parenthesis ? ___ Python-ideas mailing list

[Python-ideas] Re: Expand the try-expect syntax to support conditional expect block

2022-05-18 Thread Jeremiah Gabriel Pascual
It's Python's conditional expression, `expression_true if condition else expression_false`. It's the same thing as C's ternary: `condition ? expression_true : expression_false` Also yes, you could put any expression in the parentheses. Just that the empty one is actually just an empty tuple. ___