[Python-ideas] Re: Allow `return yield from`

2022-03-28 Thread Michael Smith
On Mon, Mar 28, 2022 at 16:06 Patrick Reader wrote: > I would like to be able to use a `yield from` expression in a `return` > statement without parentheses, as a small quality of life tweak, i.e.: > > return yield from gen > > instead of > > return (yield from gen) What does this do? `return (

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Michael Smith
Hmm, I think the idea of the mathematical symbol is interesting, but I think users are more interested in constructing a new, eventually-not-empty set, than referencing the empty set. Semantically, I don't know if ∅() is satisfying. On Thu, Mar 17, 2022 at 08:19 Stéfane Fermigier wrote: > The “

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-01 Thread Michael Smith
+1 This is just a small improvement, but worthwhile. It's intuitive IMO to be able to use similar filtering expressions to comprehensions at the top of a for loop. Here's an example: # get the Hadoop version by scanning pyspark jars. # Vague attribution: https://stackoverflow.com/a/50242383 for

[Python-ideas] Re: Create a @deprecated decorator (annotation)

2021-07-29 Thread Michael Smith
Perhaps another approach would be to make a more general purpose warning decorator, that would give a warning when invoking a function or instantiating a class. It could be used for deprecation notices, of course, but has the potential for tooling to give other types of warnings, such as using a th

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-14 Thread Michael Smith
Jonathan Fine said > But here there is a cost. Arbitrary precision arithmetic (and roots) uses more memory and takes longer. I think a wider (perhaps naive) interpretation of the idea could be, "can we defer certain lossy calculations until they have to be done?" Fraction may do eager arbitrary p

[Python-ideas] Re: fsync-on-close io object

2020-12-26 Thread Michael Smith
On Thu, Dec 24, 2020 at 6:18 PM Cameron Simpson wrote: > > On 25Dec2020 09:29, Steven D'Aprano wrote: > >On Thu, Dec 24, 2020 at 12:15:08PM -0500, Michael A. Smith wrote: > > > >> With all the buffering that modern disks and filesystems do, a > >> specific question has come up a few times with re

[Python-ideas] Re: fsync-on-close io object

2020-12-26 Thread Michael Smith
Also sorry for the duplicate, Steven. On Thu, Dec 24, 2020 at 5:31 PM Steven D'Aprano wrote: > On Thu, Dec 24, 2020 at 12:15:08PM -0500, Michael A. Smith wrote: > > > With all the buffering that modern disks and filesystems do, a > > specific question has come up a few times with respect to whet

[Python-ideas] Re: fsync-on-close io object

2020-12-26 Thread Michael Smith
Sorry for the duplicate, Barry. I got bit by the "I don't reply-all by default" spider. On Sat, Dec 26, 2020 at 12:30 PM Barry Scott wrote: > > > > On 24 Dec 2020, at 17:15, Michael A. Smith wrote: > > > > With all the buffering that modern disks and filesystems do, a > > specific question has

[Python-ideas] Re: Typed Python execution mode

2020-12-10 Thread Michael Smith
On Thu, Dec 10, 2020 at 17:12 wrote: > No, it is not good design choose, because then all type-checker will have > different optional and it will be a mess ... > It should be done in one place like python I think the nature of open source is that all the tools have different options and it is a

[Python-ideas] Re: Call a function at invocation

2020-10-22 Thread Michael Smith
nd here it > is on python-ideas -- quite a coincidence! > > -CHB > > > > > > On Tue, Oct 20, 2020 at 11:16 PM Paul Sokolovsky > wrote: > >> Hello, >> >> On Wed, 21 Oct 2020 00:24:47 -0400 >> Michael Smith wrote: >> >> > O

[Python-ideas] Re: Call a function at invocation

2020-10-20 Thread Michael Smith
xt of the function, in this case. On Tue, Oct 20, 2020 at 20:32 Michael Smith wrote: > >> >> >> On Tue, Oct 20, 2020 at 23:12 Guido van Rossum wrote: >> >>> On Tue, Oct 20, 2020 at 8:06 PM Michael Smith >>> wrote: >>> >>>> On Tue, O

[Python-ideas] Re: Call a function at invocation

2020-10-20 Thread Michael Smith
On Tue, Oct 20, 2020 at 23:12 Guido van Rossum wrote: > On Tue, Oct 20, 2020 at 8:06 PM Michael Smith > wrote: > >> On Tue, Oct 20, 2020 at 10:19 PM Guido van Rossum >> wrote: >> > >> > I think it would be a tad more convincing if there was a way to pas

[Python-ideas] Re: Call a function at invocation

2020-10-20 Thread Michael Smith
e function only needs not require any formal parameters. It doesn't need to be special-er than that. It can handle args via sys.argv, as you suggested. Most of the `main` functions I write today are just like that. > On Tue, Oct 20, 2020 at 7:10 PM Michael Smith wrote: >> >> Th

[Python-ideas] Call a function at invocation

2020-10-20 Thread Michael Smith
There are many ways to invoke a function from the commandline. You can use setuptools' console_scripts entrypoint. You can use a decorator from click. And of course you can always do the classic if __name__ == "__main__": main() to call whatever main() is. But there are inconveniences with thes

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

2020-10-20 Thread Michael Smith
On Tue, Oct 20, 2020 at 06:02 J. Pic wrote: > Well personally I don't need print at all, I just read code and > imagine the output in my head and that's perfectly fine for me (I > don't even need a tty). > > Nonetheless, I believe the majority of Python users are not > necessarily familiar with P

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

2020-10-19 Thread Michael Smith
On Mon, Oct 19, 2020 at 19:28 J. Pic wrote: > +1 because print is a debugging tool mostly used in short lived > temporary code as such the parenthesis do not matter and do not > provide any value. A lot of debugger use print to instrumentalize their code during > development or debugging, as in

[Python-ideas] Re: New feature

2020-10-16 Thread Michael Smith
On Fri, Oct 16, 2020 at 22:42 Steven D'Aprano wrote: > On Fri, Oct 16, 2020 at 10:28:20PM -0400, David Mertz wrote: > > On Fri, Oct 16, 2020, 10:16 PM Steven D'Aprano > > > > > I think that if we go ahead with this, we shouldn't allow lack > > > of support for screen and/or tmux to stand in the w

[Python-ideas] Re: New feature

2020-10-13 Thread Michael Smith
I occasionally find it useful to clear the screen when doing demos/presentations. I think the case for it is clear (hah) enough based on its long history and presence in many terminal emulators. But then again, the terminals I use and readline support it already, so I don't need python repl to do

[Python-ideas] Re: Method to efficiently advance iterators for sequences that support random access

2020-10-06 Thread Michael Smith
On Tue, Oct 6, 2020 at 00:37 Kevin Mills wrote: > str_iterator, bytes_iterator, range_iterator, list_iterator, and > tuple_iterator (and probably others) should have a method that is capable > of efficiently advancing the iterator, instead of having to call next > repeatedly. > > I suggest adding

[Python-ideas] Re: Ensuring that a package is available.

2020-09-02 Thread Michael Smith
Pillow for one example). Installers downloading stuff is a whole security domain. But software I want to run implicitly invoking the installer adds a layer of complexity to that domain that I think outweighs the gain. - Michael Smith ___ Pytho

[Python-ideas] Re: use type hints and slices to specify a valid numerical range, example: `Angle = int[0:361]`

2020-08-08 Thread Michael Smith
On Sat, Aug 8, 2020 at 16:41 Dominik Vilsmeier wrote: > On 08.08.20 05:48, David Mertz wrote: > > On Fri, Aug 7, 2020, 6:03 PM Paul Moore wrote: > >> > x: int[0:] # any ints greater than or equal to zero would match, >> others would fail >> > x: int[:101] # any ints less than 101 match >> > x:

[Python-ideas] Re: Restricting Python

2020-07-19 Thread Michael Smith
Hi, Robert, I learned about an existing RestrictedPython implementation through Zope/Plone. I can see that it differs from your ideas in some ways, but I think at heart it gets to what you're trying to solve for. Have you read about it? https://restrictedpython.readthedocs.io/en/latest/idea.html