Re: [Python-ideas] New function to add into the "random" module

2017-02-02 Thread Franklin? Lee
On Thu, Feb 2, 2017 at 7:01 AM, wrote: > from random import * > > > > def randfloat(x , y , maxfloatpt=None): > > if x > y: > > x , y = y , x > > lenx = len(str(x)) > > leny = len(str(y)) > > intx = int(x) > > inty = int(y) > > bigger =

Re: [Python-ideas] discontinue iterable strings

2016-08-20 Thread Franklin? Lee
On Aug 20, 2016 2:27 AM, "Alexander Heger" wrote: > The point is it does not try to disassemble it into elements as it would do with other iterables > > >>> np.array([1,2,3]) > array([1, 2, 3]) > >>> np.array([1,2,3]).shape > (3,) It isn't so much that strings are special, it's

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Franklin? Lee
a missile to hammer in a nail.) On Oct 14, 2016 9:46 AM, "Franklin? Lee" <leewangzhong+pyt...@gmail.com> wrote: > > On Oct 14, 2016 9:14 AM, "Gustavo Carneiro" <gjcarne...@gmail.com> wrote: > > > > Sorry if I missed the boat, but only just now

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Franklin? Lee
On Oct 14, 2016 9:14 AM, "Gustavo Carneiro" wrote: > > Sorry if I missed the boat, but only just now saw this PEP. > > Glancing through the PEP, I don't see mentioned anywhere the SQL alternative of having a coalesce() function:

Re: [Python-ideas] Construct a matrix from a list: matrix multiplication

2017-03-31 Thread Franklin? Lee
On Fri, Mar 31, 2017 at 3:58 AM, Chris Angelico wrote: > This keeps on coming up in one form or another - either someone > multiplies a list of lists and ends up surprised that they're all the > same, or is frustrated with the verbosity of the alternatives. > > Can we use the

Re: [Python-ideas] a memory-efficient variant of itertools.tee

2017-05-27 Thread Franklin? Lee
On Fri, May 26, 2017 at 2:45 PM, Stephan Houben wrote: > Hi all, > > The itertools.tee function can hold on to objects "unnecessarily". > In particular, if you do > > iter2 = itertools.tee(iter1, 2)[0] > > i.e. you "leak" one of the returned iterators, then all returned >

[Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
Consider the following code, which creates a generator that immediately returns 1, and then catches the StopIteration twice. def generatorfunction(): if False: yield return 1 def get_return(gen): try: next(gen) except StopIteration as e:

Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
> hanging on to the exception object longer than necessary was not in our best > interest. > > On Mon, Dec 11, 2017 at 1:10 AM, Franklin? Lee > <leewangzhong+pyt...@gmail.com> wrote: >> >> Consider the following code, which creates a generator that >> immediately ret

Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
On Mon, Dec 11, 2017 at 6:44 PM, Yury Selivanov <yselivanov...@gmail.com> wrote: > On Mon, Dec 11, 2017 at 6:21 PM, Franklin? Lee > <leewangzhong+pyt...@gmail.com> wrote: >> What about hanging onto just the value, and creating new StopIteration >> instances instead

Re: [Python-ideas] A cute Python implementation of itertools.tee

2018-05-14 Thread Franklin? Lee
The topic reminded me of Stephan Houben's streamtee. https://github.com/stephanh42/streamtee/blob/master/streamtee.py It was an attempt at a memory-efficient tee, but it turned out tee was efficient enough. It uses a thunk-like method and recursion to remove the need for an explicit linked list.

Re: [Python-ideas] A partial (wacky?) alternative to assignment expressions

2018-05-14 Thread Franklin? Lee
On Mon, May 14, 2018 at 8:35 PM, Steven D'Aprano wrote: > I'm hoping that the arguments for assignment expressions will be over by > Christmas *wink* so as a partial (and hopefully less controversial) > alternative, what do people think of the idea of flagging certain >

Re: [Python-ideas] Modern language design survey for "assign and compare" statements

2018-05-21 Thread Franklin? Lee
On Mon, May 21, 2018 at 7:40 PM, Steven D'Aprano wrote: > On Mon, May 21, 2018 at 09:43:45AM -0700, Mike Miller wrote: >> To clarify there were three main criteria, and one minor. Newer, >> popular/becoming industry standard, and designed to address shortcomings in >>

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Franklin? Lee
I assume there can't be space between the backslash and the name, to prevent ambiguity like in the following: # Is this `foo = not [1]` or `foo = \not[1]`? foo = (\ not[1]) A sampling of \ in other languages, for consideration: - Haskell: A lambda. E.g. `\x -> x+1` - TeX: A

Re: [Python-ideas] Give regex operations more sugar

2018-06-13 Thread Franklin? Lee
On Wed, Jun 13, 2018 at 8:15 PM, Greg Ewing wrote: > Chris Angelico wrote: >> >> This would want to be semantically different from chained >> calls, in that a single replace([x,y,z], q) would avoid re-replacing; > > > +1, this would be REALLY handy! > > It's easy to trip yourself up with chained

Re: [Python-ideas] Give regex operations more sugar

2018-06-15 Thread Franklin? Lee
On Thu, Jun 14, 2018 at 2:12 AM, Brendan Barnwell wrote: > On 2018-06-13 22:29, Steven D'Aprano wrote: >> >> On Wed, Jun 13, 2018 at 10:59:34PM +0200, Michel Desmoulin wrote: >> >>> > Attaching an entire module to a type is probably worse than >>> > adding a slew of extra methods to the type. >>>

Re: [Python-ideas] Let try-except check the exception instance

2018-05-30 Thread Franklin? Lee
Would guards (such as from the switch-case discussions) be a good fit? try: ... except RuntimeError as e if e.message == "tie": ... On Thu, May 31, 2018, 00:48 Danilo J. S. Bellini wrote: > Hi! > I was working on handling some exceptions from external software > (e.g. database

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-26 Thread Franklin? Lee
On Wed, Jun 20, 2018, 00:05 Serhiy Storchaka wrote: > 19.06.18 22:18, James Edwards пише: > > I've only recently looked for these special methods, so that in and of > > itself may be the reason these methods aren't exposed, but I could think > > of objects that may wish to implement __min__ and

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-27 Thread Franklin? Lee
On Wed, Jun 27, 2018, 10:31 Steven D'Aprano wrote: > On Wed, Jun 27, 2018 at 06:52:14AM -0700, Michael Selik wrote: > > > > > Have you ever written ``max(range(x))`` in production code? > > > > > > I have never written that. > > > > > > But I have written ``max(iterable)`` dozens of times, where

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-27 Thread Franklin? Lee
On Wed, Jun 27, 2018 at 11:30 AM, Michael Selik wrote: > On Wed, Jun 27, 2018 at 8:16 AM Franklin? Lee > wrote: >> >> On Wed, Jun 27, 2018, 10:31 Steven D'Aprano wrote: >>> >>> On Wed, Jun 27, 2018 at 06:52:14AM -0700, Michael Selik wrote: >>> >

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-26 Thread Franklin? Lee
On Tue, Jun 26, 2018 at 11:34 AM, Franklin? Lee wrote: > On Wed, Jun 20, 2018, 00:05 Serhiy Storchaka wrote: >> >> 19.06.18 22:18, James Edwards пише: >> > I've only recently looked for these special methods, so that in and of >> > itself may be the reason th

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-30 Thread Franklin? Lee
On Fri, Dec 29, 2017 at 11:25 PM, Steven D'Aprano wrote: > On Sat, Dec 30, 2017 at 02:56:46AM +1100, Chris Angelico wrote: >> On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano wrote: >> > The lack of support for the `in` operator is a major difference,

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-31 Thread Franklin? Lee
On Sun, Dec 31, 2017 at 12:09 PM, MRAB wrote: > On 2017-12-31 08:13, Paddy3118 wrote: >> >> Hmm, yea I had not thought of how it would look - I had thought formost of >> not needing to necessarily learn about bitsets.when learning about passing a >> large number of

Re: [Python-ideas] Possible Enhancement to py Launcher - set default

2018-02-05 Thread Franklin? Lee
On Mon, Feb 5, 2018 at 6:04 AM, Paul Moore wrote: > On 5 February 2018 at 08:10, Steve Barnes wrote: >> When a new version of python is in alpha/beta it is often desirable to >> have it installed for tests but remain on a previous version for day to

Re: [Python-ideas] Complicate str methods

2018-02-08 Thread Franklin? Lee
On Thu, Feb 8, 2018 at 5:45 AM, Franklin? Lee <leewangzhong+pyt...@gmail.com> wrote: > On Feb 7, 2018 17:28, "Serhiy Storchaka" <storch...@gmail.com> wrote: > > The name of complicated str methods is regular expressions. For doing these > > operations effi

Re: [Python-ideas] Complicate str methods

2018-02-08 Thread Franklin? Lee
On Feb 8, 2018 13:06, "Serhiy Storchaka" <storch...@gmail.com> wrote: 08.02.18 12:45, Franklin? Lee пише: > Could it be that re uses an optimization that can also be used in str? > CPython uses a modified Boyer-Moore for str.find: > https://github.com/python/cpython/b

Re: [Python-ideas] Complicate str methods

2018-02-08 Thread Franklin? Lee
On Feb 7, 2018 17:28, "Serhiy Storchaka" <storch...@gmail.com> wrote: 04.02.18 00:04, Franklin? Lee пише: Let s be a str. I propose to allow these existing str methods to take > params in new forms. > > s.replace(old, new): > Allow passing in a collection o

Re: [Python-ideas] Complicate str methods

2018-02-03 Thread Franklin? Lee
On Sat, Feb 3, 2018 at 6:43 PM, Terry Reedy <tjre...@udel.edu> wrote: > On 2/3/2018 5:04 PM, Franklin? Lee wrote: >> >> Let s be a str. I propose to allow these existing str methods to take >> params in new forms. > > > Thanks for the honest title. As you sor

[Python-ideas] Complicate str methods

2018-02-03 Thread Franklin? Lee
Let s be a str. I propose to allow these existing str methods to take params in new forms. s.replace(old, new): Allow passing in a collection of olds. Allow passing in a single argument, a mapping of olds to news. Allow the olds in the mapping to be tuples of strings. s.split(sep),

Re: [Python-ideas] Complicate str methods

2018-02-08 Thread Franklin? Lee
On Thu, Feb 8, 2018 at 11:24 AM, Steve Dower wrote: > Easily fixed by installing one of the alternate regex libraries. MRAB's regex library, the most prominent alternative, does not use the linear-time search algorithm. The only libraries I know that do are the ones with

Re: [Python-ideas] Internal function idea

2017-12-28 Thread Franklin? Lee
On Thu, Dec 28, 2017 at 5:21 AM, William Rose wrote: > I agree with the point that it should allow builtin but the main purpose of > it is to not allow global variables But functions are also accessed using global names. What is your answer to the potential problem of

Re: [Python-ideas] Internal function idea

2017-12-28 Thread Franklin? Lee
On Fri, Dec 29, 2017 at 1:01 AM, Chris Angelico <ros...@gmail.com> wrote: > On Fri, Dec 29, 2017 at 1:31 PM, Franklin? Lee > <leewangzhong+pyt...@gmail.com> wrote: >> On Thu, Dec 28, 2017 at 5:21 AM, William Rose <william27.07...@gmail.com> >> wrote: >&

Re: [Python-ideas] Repr of lambda

2017-12-20 Thread Franklin? Lee
On Mon, Dec 18, 2017 at 8:31 AM, Steve Barnes wrote: > > On 18/12/2017 11:43, Steven D'Aprano wrote: >> On Mon, Dec 18, 2017 at 07:54:17AM +, Steve Barnes wrote: >> >>> Isn't this exactly the sort of information already available via >>> inspect.getardspec,

Re: [Python-ideas] Internal function idea

2017-12-26 Thread Franklin? Lee
On Sat, Dec 23, 2017, 09:23 William Rose, wrote: > > I had an idea that it could be helpful to have local functions as well as > normal ones. They would be called the same way as normal ones but def would > be replaced by internal and inside they could only access

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-09-06 Thread Franklin? Lee
On Thu, Sep 6, 2018 at 2:23 PM Chris Angelico wrote: > > On Fri, Sep 7, 2018 at 4:11 AM, Franklin? Lee > wrote: > > On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing > > wrote: > >> > >> Guido van Rossum wrote: > >> > we might propose (as the OP

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-09-06 Thread Franklin? Lee
On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing wrote: > > Guido van Rossum wrote: > > we might propose (as the OP did) that this: > > > > a, b, c += x, y, z > > > > could be made equivalent to this: > > > > a += x > > b += y > > c += z > > But not without violating the principle that > >

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-09-06 Thread Franklin? Lee
n Thu, Sep 6, 2018 at 2:47 PM Chris Angelico wrote: > > On Fri, Sep 7, 2018 at 4:38 AM, Franklin? Lee > wrote: > > The following are equivalent and compile down to the same code: > > a, b, c = lst > > [a, b, c] = lst > > > > The left hand side is n

Re: [Python-ideas] Keyword only argument on function call

2018-09-07 Thread Franklin? Lee
On Fri, Sep 7, 2018 at 2:22 PM Rhodri James wrote: > > Top posting for once, since no one is quoting well in this thread: > > Does this in any way answer David's question? I'm serious; you've spent > a lot of words that, as best I can tell, say exactly nothing about how > keyword arguments would

Re: [Python-ideas] Fwd: grouping / dict of lists

2018-07-09 Thread Franklin? Lee
On Mon, Jul 9, 2018 at 12:22 PM, Chris Barker wrote: > On Fri, Jul 6, 2018 at 12:26 PM, Franklin? Lee I use this kind of function >> I added several options, such as: >> - key function >> - value function >> - "ignore": Skip values with these keys. >>

Re: [Python-ideas] Where should grouping() live (was: grouping / dict of lists)

2018-07-09 Thread Franklin? Lee
(Fixing quote and attribution.) On Fri, Jul 6, 2018, 11:32 Chris Barker - NOAA Federal via Python-ideas wrote: > > On Jul 6, 2018, at 2:10 AM, Steven D'Aprano wrote: > > > On Fri, Jul 06, 2018 at 09:49:37AM +0100, Cammil Taank wrote: > > > I would consider statistics > > > > to have

Re: [Python-ideas] Fwd: grouping / dict of lists

2018-07-06 Thread Franklin? Lee
On Thu, Jul 5, 2018 at 1:23 AM, Chris Barker via Python-ideas wrote: > On Wed, Jul 4, 2018 at 6:34 AM, David Mertz wrote: > >> >> You've misunderstood part of the discussion. There are two different >> signatures being discussed/proposed for a grouping() function. >> >> The one you show we might

Re: [Python-ideas] collections.Counter should implement __mul__, __rmul__

2018-04-22 Thread Franklin? Lee
Instead of extending Counter to fit fancier usecases, why not have a new class that is designed for arithmetic? I, for one, would love Numpy-style list and dict classes in the standard library. And they wouldn't be confusingly called Counter, and have strange behaviors with negative values. I

Re: [Python-ideas] CoC violation

2018-09-21 Thread Franklin? Lee
On Fri, Sep 21, 2018 at 10:52 AM Elazar wrote: > > > > On Fri, Sep 21, 2018, 16:56 Philipp A. wrote: >> >> The main clause differentiating bad, weaponizable CoCs from good ones is >> >> "Assume good faith" >> >> Everything will be OK if good faith can reasonably be assumed (E.g. when >> someone

Re: [Python-ideas] "old" values in postconditions

2018-09-25 Thread Franklin? Lee
Ew, magic. `{{foo}}` is already valid syntax (though it will always fail). I don't like this path. If the proposal requires new syntax or magic, it will be less likely to get accepted or even pip'd. Remember also that PyPy, IronPython, and Jython are still alive, and the latter two are still

Re: [Python-ideas] Why is design-by-contracts not widely

2018-09-25 Thread Franklin? Lee
Those arguments are rules of thumb, which may or may not apply to DbC, and speculation, based on why DbC isn't more popular, to explain why DbC isn't more popular. They are general arguments for features in general, whereas Marko has been giving arguments for why DbC in particular is good or why

Re: [Python-ideas] "old" values in postconditions

2018-09-25 Thread Franklin? Lee
On Sun, Sep 23, 2018 at 2:05 AM Marko Ristin-Kaufmann wrote: > > Hi, > > (I'd like to fork from a previous thread, "Pre-conditions and > post-conditions", since it got long and we started discussing a couple of > different things. Let's discuss in this thread the implementation of a > library

Re: [Python-ideas] "old" values in postconditions

2018-09-25 Thread Franklin? Lee
Ah. It wasn't clear to me from the thread that James was using `inspect`. As it happens, not only does getsource give more than it should, it also gives less than it should. The following bug still exists in 3.6.1. It was closed as a wontfix bug back in Python 2 because, I presume, fixing it

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-15 Thread Franklin? Lee
I am very disappointed with the responses to this thread. We have mockery, dismissiveness, and even insinuations about OP's psychological health. Whether or not OP is a troll, and whether or not OP's idea has merit, that kind of response is unnecessary and unhelpful. (While I lean toward OP being

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-16 Thread Franklin? Lee
On Sun, Sep 16, 2018 at 4:14 AM Antoine Pitrou wrote: > > Yeah, right. > > You know, when I was pointing out Calvin not being very brave by > attacking a bunch of people without giving names, my aim was to merely > point out how dishonest and disrespectful his attitude his. *Not* to > encourage

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-17 Thread Franklin? Lee
On Mon, Sep 17, 2018 at 10:50 AM Jacco van Dorp wrote: > > Op ma 17 sep. 2018 om 16:40 schreef Wes Turner : >> >> I think it's meant to be ironic? >> >> Why would that be the first sentence of a poem about software and the Python >> newsgroup/mailing list community? >> >> A certain percentage of

Re: [Python-ideas] Retire or reword the namesake of the Language

2018-09-17 Thread Franklin? Lee
Monty Python had the goal of making people laugh, while python-ideas has the goal of improving Python. With those priorities, we can have fun, but not at the expense of potential contributions and contributors. Other people aren't perfect, but sometimes you have to adapt to them for the sake of

Re: [Python-ideas] Moving to another forum system where moderation is possible

2018-09-18 Thread Franklin? Lee
On Tue, Sep 18, 2018 at 2:37 PM Jonathan Goble wrote: > > On Tue, Sep 18, 2018, 2:00 PM Franklin? Lee > wrote: >> >> On Tue, Sep 18, 2018 at 11:02 AM Jonathan Goble wrote: >> > >> > The biggest moderation issue I see with mailing lists is the inability

Re: [Python-ideas] Moving to another forum system where moderation is possible

2018-09-18 Thread Franklin? Lee
On Tue, Sep 18, 2018 at 11:02 AM Jonathan Goble wrote: > > On Tue, Sep 18, 2018 at 10:49 AM Robert Vanden Eynde > wrote: >> >> About moderation, what's the problem on the list ? > > > The biggest moderation issue I see with mailing lists is the inability to > lock threads and delete posts

Re: [Python-ideas] Moving to another forum system where

2018-09-18 Thread Franklin? Lee
On Tue, Sep 18, 2018 at 8:21 PM James Lu wrote: > > > Is that really an issue here? I personally haven't seen threads where > > Brett tried to stop an active discussion, but people ignored him and > > kept fighting. > Not personally with Brett, but I have seen multiple people try to stop the >

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-17 Thread Franklin? Lee
On Sun, Sep 16, 2018 at 2:04 PM Antoine Pitrou wrote: > > On Sun, 16 Sep 2018 13:32:26 -0400 > "Franklin? Lee" > wrote: > > On Sun, Sep 16, 2018 at 4:14 AM Antoine Pitrou wrote: > > > > > > Yeah, right. > > > > > > You know, when I

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-17 Thread Franklin? Lee
On Mon, Sep 17, 2018 at 3:17 AM Jacco van Dorp wrote: > > Op zo 16 sep. 2018 om 05:40 schreef Franklin? Lee > : >> >> Jacco: >> - This is completely disrespectful and way over the line. Don't try to >> make a psychological evaluation from two emails, especially

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Franklin? Lee
On Tue, Jun 18, 2019 at 5:01 AM Emin Bugra Saral via Python-ideas wrote: > > `<:` kind of notation would look more clear, I agree. > > My proposition came after thinking the wording used in Python. > > issubclass() - is subclass? > > By definition, subclass reminds me set theory. >

[Python-ideas] help() with operators [was: Comparison operator support (>= and <=) for type]

2019-06-20 Thread Franklin? Lee
n 19, 2019, 15:19 Chris Angelico wrote: > On Thu, Jun 20, 2019 at 4:31 AM Guido van Rossum wrote: > > > > On Wed, Jun 19, 2019 at 11:27 AM Chris Angelico > wrote: > >> > >> On Thu, Jun 20, 2019 at 2:07 AM Franklin? Lee > >> wrote: > >> > For exam

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-15 Thread Franklin? Lee
On Fri, Jun 14, 2019, 13:49 Brett Cannon wrote: > I think the logic breaks down with multiple inheritance. If you make C(A, B), > then you can say C > A and C > B, but then you can't say A > B or A < B which > breaks sorting. The logic is fine. Classes can be considered as containers of their

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-16 Thread Franklin? Lee
On Sun, Jun 16, 2019 at 8:58 AM Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 6/16/19 7:49 AM, Franklin? Lee wrote: > > > On Sat, Jun 15, 2019 at 10:26 PM Guido van Rossum > wrote: > > >> I don't actually know how viable this proposal is, but

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-16 Thread Franklin? Lee
On Sat, Jun 15, 2019 at 10:26 PM Guido van Rossum wrote: > I don't actually know how viable this proposal is, but given that it's being > debated at some length, I'd like to put in my opinion that *if* we're going > to define an operator that's (roughly) synonymous with issubclass(), it >