Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-12 Thread Chris Barker via Python-ideas
Just in case I'm not the only one that had a hard time finding the latest version of this PEP, here it is in the PEPS Repo: https://github.com/python/peps/blob/master/pep-0584.rst -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-

Re: [Python-ideas] PEP 8 update on line length

2019-02-27 Thread Chris Barker via Python-ideas
On Wed, Feb 27, 2019 at 5:53 AM Rhodri James wrote: > > To be a bit less harsh -- that is, change the clause: > > > > "For code maintained exclusively or primarily by a team that can reach > > agreement on this issue, it is okay ..." > > > > To maybe just > > > > "For code maintained by a team t

Re: [Python-ideas] PEP 8 update on line length

2019-02-21 Thread Chris Barker via Python-ideas
On Thu, Feb 21, 2019 at 12:01 PM Raymond Hettinger < raymond.hettin...@gmail.com> wrote: > I concur. We now put expressions in f-strings and have assignment > expressions that easily spill over 80 characters if one uses all but the > most compact variable names. Comprehensions tend to make expre

Re: [Python-ideas] Add list.join() please

2019-01-31 Thread Chris Barker via Python-ideas
On Wed, Jan 30, 2019 at 10:14 PM Chris Angelico wrote: > > I didn't, but I don't know if Chris Barker did. > nope -- not me either :-) > (Can't swing a cat without hitting someone named Steve or Chris, in > some spelling or another!) > good thing there aren't a lot of cats being swung around,

Re: [Python-ideas] Stack traces ought to flag when a module has been changed on disk

2019-01-30 Thread Chris Barker via Python-ideas
On Wed, Jan 30, 2019 at 3:43 AM Jonathan Fine wrote: > I think Steve's suggestion fails in this situation. Suppose wibble.py > contains a function fn. Now do >import wibble >fn = wibble.fn ># Modify and save wibble.py >reload(wibble) >fn() > Sure -- but this is just a warning

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread Chris Barker via Python-ideas
A couple notes: On Tue, Jan 29, 2019 at 5:31 AM Jamesie Pic wrote: > can you clarify the documentation > topic you think should be improved or created ? "Assembling strings" > I would think "assembling strings", though there is a lot out there already. > or "inconsistencies between os.path.jo

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-06 Thread Chris Barker via Python-ideas
There is already a much simpler way of doing this: > try: > i = int("string") > except ValueError as e: > print(e) > print("continued on") > j = int(9.0) > > The point of the 'try' block is to encapsulate the code you want to *stop* > executing if an exception is ra

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Chris Barker via Python-ideas
On Tue, Dec 11, 2018 at 11:10 AM Terry Reedy wrote: > > I _think_ someone may be advocating that map() could return an > > iterable if it is passed a iterable, > > I believe you mean 'iterator' rather than 'iterable' here and below as a > sequence is an iterable. > well, the iterator / iterable

Re: [Python-ideas] Using sha512 instead of md5 on python.org/downloads

2018-12-10 Thread Chris Barker via Python-ideas
On Sun, Dec 9, 2018 at 10:32 PM Ronald Oussoren via Python-ideas < python-ideas@python.org> wrote: > BTW. I wonder how many actually verify these checksums, > Hardly anyone -- most of us verify the download by trying to use it :-) Which doesn't mean that we shouldn't have it -- but it will indee

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-10 Thread Chris Barker via Python-ideas
On Mon, Dec 10, 2018 at 5:23 AM E. Madison Bray wrote: > Indeed; I believe it is very useful to have a map-like object that is > effectively an augmented list/sequence. but what IS a "map-like object" -- I'm trying to imagine what that actually means. "map" takes a function and maps it onto a

Re: [Python-ideas] Serialization of CSV vs. JSON

2018-11-05 Thread Chris Barker via Python-ideas
necessary to avoid having to try parsing every > string value as a date time (and to specify precision: "2018" is not the > same as "2018 00:00:01") > > On Friday, November 2, 2018, Chris Barker via Python-ideas < > python-ideas@python.org> wrote: >

Re: [Python-ideas] dict.setdefault_call(), or API variations thereupon

2018-11-05 Thread Chris Barker via Python-ideas
On Fri, Nov 2, 2018 at 7:49 PM, Steven D'Aprano wrote: > Consider the use-case where you want to pass a different default value > to the dict each time: > exactly - the "default" is per call, not the same for the whole dict. though again, how common is this? > d.setdefault(key, expensive_f

Re: [Python-ideas] Serialization of CSV vs. JSON

2018-11-02 Thread Chris Barker via Python-ideas
On Fri, Nov 2, 2018 at 9:31 AM, M.-A. Lemburg wrote: > Serialization of those data types is not defined in the JSON standard: > > https://www.json.org/ That being said, ISO 8601 is a standard for datetime stamps, and a defacto one for JSON So building encoding of datetime into Python's json en

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Chris Barker via Python-ideas
On Fri, Nov 2, 2018 at 3:59 AM, Steven D'Aprano wrote: > - I'm not volunteering to do the work (I don't know enough C to write > a patch). Unless somebody has a patch, we can't expect the core devs > who aren't interested in this feature to write it. > > (Hence, status quo wins a stalemate.)

Re: [Python-ideas] dict.setdefault_call(), or API variations thereupon

2018-11-02 Thread Chris Barker via Python-ideas
On Thu, Nov 1, 2018 at 8:34 PM, Steven D'Aprano wrote: > The bottom line is, if I understand your proposal, the functionality > already exists. All you need do is subclass dict and give it a > __missing__ method which does what you want. or subclass dict and give it a "setdefault_call") method

Re: [Python-ideas] Contracts in python -- a report & next steps

2018-10-24 Thread Chris Barker via Python-ideas
On Wed, Oct 24, 2018 at 12:57 AM, Chris Angelico wrote: > For the sake of those of us who REALLY don't feel like diving back > into the extensive threads on this subject, can you please summarize > the benefits of having this in the stdlib rather than as a third-party > library? > I'm not (curre

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-18 Thread Chris Barker via Python-ideas
On Thu, Oct 18, 2018 at 10:12 AM, Sven R. Kunze wrote: > On 18.10.18 18:49, Anders Hovmöller wrote: > >> If it's AND, shouldn't it be "hasinterfaces" (notice the s!)? > > yeah, that would make sense. Is someone proposing something here? The point I was making, is in the case of ABCs: issubclass

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-11 Thread Chris Barker via Python-ideas
On Thu, Oct 11, 2018 at 3:35 PM, Steven D'Aprano wrote: > On Thu, Oct 11, 2018 at 12:34:13PM -0700, Chris Barker via Python-ideas > wrote: > > > I don't care what is or isn't a subclass of what -- I don't think that's > a > > Pythonic questio

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-11 Thread Chris Barker via Python-ideas
BTW: In [7]: issubclass(set, frozenset) Out[7]: False In [8]: issubclass(frozenset, set) Out[8]: False no reason to do anything different here. and: In [13]: issubclass(MappingProxyType, abc.Hashable) Out[13]: False so yes, there is a need for something different -CHB On Thu, Oct 11, 201

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-11 Thread Chris Barker via Python-ideas
On Thu, Oct 11, 2018 at 9:54 AM, Jonathan Fine wrote: > Summary: Long post. Because of LSP, neither dict nor frozendict are a > subclass of the other. given Python's dynamic typing, these issues are kinda academic :-) > Intuition tells me that a frozen dictionary is a form of dictionary > > th

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

2018-09-26 Thread Chris Barker via Python-ideas
On Tue, Sep 25, 2018 at 10:10 PM Lee Braiden wrote: > It's the reason why type checking exists, and why bounds checking exists, > and why unit checking exists too. > And yet Python has none of those. They all provide safety, but also place a burden on the developer. So why use Python? I’m not a

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

2018-09-21 Thread Chris Barker via Python-ideas
On Fri, Sep 21, 2018 at 1:24 PM James Lu wrote: > One of the reasons Guido left was the insane volume of emails he had to > read on Python-ideas. > You'd have to ask Guido directly, but I don't think so. It wasn't the volume, but the nature and timing of the discussion that was so difficult. It

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

2018-09-20 Thread Chris Barker via Python-ideas
A point here: any proposal that is an actual proposal, rather than a idea that needs fleshing out, can benefit from being written down in a single document. It does NOT have to be an official PEP in order for that to happen. If you are advocating something, then write it down, post it gitHbu or s

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

2018-09-20 Thread Chris Barker via Python-ideas
On Thu, Sep 20, 2018 at 6:24 PM, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > And that's exactly what a mute on replies does. Most people will just > give up, which is appropriate. People who have (what they think is) a > good reason to continue can start a new thread wit

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

2018-09-20 Thread Chris Barker via Python-ideas
On Thu, Sep 20, 2018 at 1:39 PM, James Lu wrote: > In a forum, the beautiful is better than ugly issue would be locked. No > more posts can be added. > Exactly -- but that means we are stopping the discussion -- but we don't want to stop the discussion altogether, we want to have the productive

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

2018-09-20 Thread Chris Barker via Python-ideas
On Tue, Sep 18, 2018 at 9:05 PM, Franklin? Lee < leewangzhong+pyt...@gmail.com> wrote: > > What people may really be clamoring for is a larger moderation team, > or a heavier hand. They want more enforcement, not more effective > enforcement. > Or maybe clamoring for nothing -- it's just not that

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

2018-09-15 Thread Chris Barker via Python-ideas
On Sat, Sep 15, 2018 at 7:38 PM, Antoine Pitrou wrote: > To be fair, in my > > experience this has been a source of confusion to many Python > > newcomers, as the notion of "beauty", as with any other value > > judgment, is highly relative to the subject evaluating it. Indeed is *is* subjective

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

2018-09-11 Thread Chris Barker via Python-ideas
Did you mean to take this off-list? I hope not, as I'm bringing it back on. On Tue, Sep 11, 2018 at 8:09 AM, Anders Hovmöller wrote: > I've spent this whole thread thinking: "who in the world is writing code > with a lot of spam=spam arguments? If you are transferring that much state > in a func

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

2018-09-11 Thread Chris Barker via Python-ideas
On Mon, Sep 10, 2018 at 11:00 PM, Ethan Furman wrote: > > In my day job I spend a lot of time writing/customizing modules for a > framework called OpenERP (now Odoo*). Those modules are all subclasses, > and most work will require updating at least a couple parent methods -- so > most calls look

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

2018-09-10 Thread Chris Barker via Python-ideas
On Sun, Sep 9, 2018 at 7:37 AM, Anders Hovmöller wrote: I've spent this whole thread thinking: "who in the world is writing code with a lot of spam=spam arguments? If you are transferring that much state in a function call, maybe you should have a class that holds that state? Or pass in a **kwarg

Re: [Python-ideas] Add recordlcass to collections module

2018-09-04 Thread Chris Barker via Python-ideas
Chiming in here: dataclasses was just added to the stdlib. I understand that record class is not the same thing, but the use cases do overlap a great deal. So I think the cord goal for anyone that wants to see this in the stdlib is to demonstrate tbat recordclass Adds significant enough value to

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread Chris Barker via Python-ideas
On Fri, Aug 24, 2018 at 10:07 AM, MRAB wrote: > A canvas can contain images, lines and shapes, which is useful for > diagrams and drawings. And the TK Canvas is kinda the "killer app" of TK. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread Chris Barker via Python-ideas
A couple thoughts: You're essentially writing a new API on top of tkINter, you could probably have multiple "back-ends" -- i.e. be able to use the same code with wxPython or PySide behind it. In fact, there was an effort along these lines a few years back: http://www.cosc.canterbury.ac.nz/greg.e

Re: [Python-ideas] A GUI for beginners and experts alike (Mike Barnett)

2018-08-24 Thread Chris Barker via Python-ideas
On Fri, Aug 24, 2018 at 8:17 AM, Barry Scott wrote: > > A graphical "hello world" in QT is only half a dozen or less lines of > > code in total, so > > meets the simplicity requirement. > > I think 2 lines is simple, 12 is not really simple, is it? > well, if all you need is a single dialog box

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-22 Thread Chris Barker via Python-ideas
On Wed, Aug 22, 2018 at 9:51 AM, Stephan Houben wrote: > Let me stand up and say that I personally like lambda. It's the standard > terminology and not easily confused. > I agree. And secondly, even if I didn't like it, changing the name of something because it's a slightly less confusing name

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-22 Thread Chris Barker via Python-ideas
On Tue, Aug 21, 2018 at 3:07 PM, Jonathan Fine wrote: > > Maybe this is something Python's REPL should do? > > Good idea. > I can't find (with very little effort) any documentation of this, but I have a vague recollection that the core devs want to keep the built-in REPL really simple -- more ad

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Barker via Python-ideas
On Mon, Aug 20, 2018 at 7:21 AM, Steven D'Aprano wrote: > * Introducing a warning makes it clear that this is not a de facto > language standard, but a mere implementation detail subject to > change if somebody comes up with a better optimization for locals. > defacto standards are sub-optim

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-20 Thread Chris Barker via Python-ideas
> > > Summary: I look at the phrase 'strike a balance' in different languages, > > It is interesting that you picked up on "strike a balance" which has > been a standard English phrase for a very long time rather than the much > more resent, (and itself a form of jargon), "dumbing down". > > The ot

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 12:37 PM, Chris Angelico wrote: > > I've no idea what interpreter you're using, but it doesn't work for me. > That was in iPython, with python3.6.2 -- I wouldn't have expected it to be different in this case though -- really odd. OK -- tired again, and it indeed it faile

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
one more thought: given that: > > The contents of this dictionary should not be modified; changes may not >> affect the values of local and free variables used by the interpreter. >> > > and: > """ > locals() > > Update and return a dictionary representing the current local symbol table. > I wo

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 10:33 AM, Jonathan Fine wrote: > >> there > >> are times where I have really wanted to access the caller's environment, > >> not the environment where my function was defined. > > > what am I missing? can't you get that by passing locals() in to a > function? > > I think t

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Barker via Python-ideas
On Thu, Aug 16, 2018 at 1:28 AM, Steven D'Aprano wrote: > there > are times where I have really wanted to access the caller's environment, > not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? A bit clunky, sure, but e

Re: [Python-ideas] Python docs: page: In what ways in None special

2018-08-15 Thread Chris Barker via Python-ideas
Since I already spent a bunch of time on this, I did a PR: https://github.com/jfine2358/py-jfine2358/pull/2 further discussion should probably be in that PR / repo -CHB On Wed, Aug 15, 2018 at 9:02 AM, Chris Barker - NOAA Federal < chris.bar...@noaa.gov> wrote: > > None is keyword, and just l

Re: [Python-ideas] Python docs: page: In what ways in None special

2018-08-14 Thread Chris Barker via Python-ideas
On Tue, Aug 14, 2018 at 10:45 AM, Rhodri James wrote: > On 'None is a constant': > > Erm. I think you've got carried away with simplifying this and gone down > a blind alley. None is a literal, and like any other literal can't be > rebound. no, it's not -- None is keyword, and just like any o

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-14 Thread Chris Barker via Python-ideas
On Tue, Aug 14, 2018 at 10:25 AM, David Mertz wrote: > Great work! There are a few typos, I'll try to get to a PR on those. > > I wonder if it's worth noting that None is a singleton, while 42 is just a > value. I.e. there might be several distinct objects that happen to be the > int 42, but not

Re: [Python-ideas] Python certification

2018-08-09 Thread Chris Barker via Python-ideas
On Thu, Aug 9, 2018 at 10:40 AM, Jonathan Fine wrote: > There is, implicitly, a > syllabus in https://docs.python.org/3/tutorial/. > The tutorial, is, well, a tutorial, it is by no means a complete course of study. So no, I don't think it's an appropriate place to start to develop a certificati

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Chris Barker via Python-ideas
On Mon, Aug 6, 2018 at 11:11 AM, Chris Barker wrote: > So any new class that doesn't already make use of the bitwise operators > can do that. > just like set() -- which I think has been mentioned here already. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Chris Barker via Python-ideas
On Fri, Aug 3, 2018 at 9:13 PM, Todd wrote: > >> Also, in a common use-case, bitwise-and behaves the same as logical_and, >> e.g. >> >> if (arr > x) & (arr2 == y) >> >> This "works" because both arrays being bitwise-anded are boolean arrays. >> > > There are a few problems with using the bitwise

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-03 Thread Chris Barker via Python-ideas
On Fri, Aug 3, 2018 at 1:02 PM, Nicholas Chammas wrote: > The project overloaded the bitwise operators &, |, and ~ since they > could not > override the boolean operators and, or, and not. > > I actually think that is a good solution to this problem -- the fact is that for most data types bitwis

Re: [Python-ideas] With expressions

2018-08-03 Thread Chris Barker via Python-ideas
On Fri, Aug 3, 2018 at 3:49 AM, Robert Vanden Eynde wrote: > > When I say "functional programming", I speak about the paradigm used in > language like Haskell. In language like those, all constructs are > "expression-based". > sure -- but Python is explicitly NOT a functional language in that se

Re: [Python-ideas] Redefining method

2018-07-30 Thread Chris Barker via Python-ideas
On Mon, Jul 30, 2018 at 9:10 AM, Nick Coghlan wrote: If you need to replace them for some reason, it will preferably be > within a temporary bounded scope, using a tool like > unittest.mock.patch, rather than as a permanent change that affects > every other use of the class within the process.

Re: [Python-ideas] Including the unparse module in the standard library

2018-07-16 Thread Chris Barker via Python-ideas
On Mon, Jul 16, 2018 at 12:24 PM, Brett Cannon wrote: > > Since it isn't necessary for Python to function, I would say we probably > don''t want to pull it up. Then the maintenance burden grows much more. > might make sense to put it on pypi though, if someone want to take responsibility for it.

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

2018-07-13 Thread Chris Barker via Python-ideas
On Fri, Jul 13, 2018 at 12:38 PM, Michael Selik wrote: > Thanks for linking to these. > yup -- real use cases are really helpful. Though the other paradigm for grouping is use of setdefault() rather than defaultdict. So it would be nice to look for those, too. > I looked at many of them in my

Re: [Python-ideas] Add the imath module

2018-07-12 Thread Chris Barker via Python-ideas
On Thu, Jul 12, 2018 at 11:05 AM, Steven D'Aprano wrote: > I'm not sure that we need a specific module for integer-valued maths. I > think a more important change would be to allow math functions to be > written in Python, not just C: > > - move the current math library to a private _math library

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

2018-07-12 Thread Chris Barker via Python-ideas
On Mon, Jul 9, 2018 at 5:55 PM, Franklin? Lee wrote: > >> - The storage container. > > > > > > so this means you'r passing in a full set of storage containers? I'm a > vit > > confused by that -- if they might be pre-populated, then they would need > to > > be instance,s an you'd need to have one

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

2018-07-12 Thread Chris Barker via Python-ideas
On Mon, Jul 9, 2018 at 3:38 PM, David Mertz wrote: > In my mind, I *rarely* (which is more than never) have my data in the form > of a sequence of key/value pairs. The version of the API that assumes data > starts that way feels like either a niche case, or demands preprocessing > before it's re

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

2018-07-09 Thread Chris Barker via Python-ideas
On Fri, Jul 6, 2018 at 12:26 PM, Franklin? Lee I use this kind of function in several different projects over the > > years, and I rewrote it many times as needed. > > I added several options, such as: > - key function > - value function > - "ignore": Skip values with these keys. > - "postprocess

Re: [Python-ideas] Where should grouping() live

2018-07-09 Thread Chris Barker via Python-ideas
On Fri, Jul 6, 2018 at 5:13 PM, Michael Selik wrote: > On Tue, Jul 3, 2018 at 10:11 PM Chris Barker via Python-ideas < > python-ideas@python.org> wrote: > >> * There are types of data well suited to the key function approach, and >> other data not so well suited to it.

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

2018-07-05 Thread Chris Barker via Python-ideas
On Thu, Jul 5, 2018 at 3:26 AM, David Mertz wrote: > Yes, he said a definite no to a built-in. But he expressed a less specific > lack of enthusiasm for collections classes (including Counter, which exists > and which I personally use often). > And a Grouping class would do more than Counter, wh

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

2018-07-04 Thread Chris Barker via Python-ideas
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 call grouping_michael(). The alternate API we > might call grouping_chris(). Th

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

2018-07-04 Thread Chris Barker via Python-ideas
On Tue, Jul 3, 2018 at 6:23 AM, David Mertz wrote: > Guido said he has mooted this discussion > ... But before putting it on auto-archive, the BDFL said (1) NO GO on getting a new builtin; (2) NO OBJECTION to putting it in itertools. I don't recall him offering an opinion on a class in collect

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

2018-07-04 Thread Chris Barker via Python-ideas
On Wed, Jul 4, 2018 at 3:53 AM, INADA Naoki wrote: > But if it happens, I'm -1 on functools and collections. > They are used very much. Every Python tool import them regardless how > much of their contents are used. > really? collections? what for? I'm guessing namedtuple and maybe deque. But

Re: [Python-ideas] Where should grouping() live

2018-07-03 Thread Chris Barker via Python-ideas
So this ended up a long post, so the TL;DR * There are types of data well suited to the key function approach, and other data not so well suited to it. If you want to support the not as well suited use cases, you should have a value function as well and/or take a (key, value) pair. * There are so

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

2018-07-03 Thread Chris Barker via Python-ideas
s collections anyone in particular's baby? like itertools "belongs" to Raymond? -CHB > On Tue, Jul 3, 2018 at 12:19 PM Chris Barker via Python-ideas < > python-ideas@python.org> wrote: > >> On Tue, Jul 3, 2018 at 8:24 AM, Steven D'Aprano >> wro

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

2018-07-03 Thread Chris Barker via Python-ideas
It seems a really stupid reason to make this choice, but: If we make a Grouping class, it has an obvious home in the collections module If we make a grouping (or grouped) function, we don't know where to put it But since I like the Grouping class idea anyway, it's one more reason... -CHB On T

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

2018-07-03 Thread Chris Barker via Python-ideas
On Tue, Jul 3, 2018 at 8:33 AM, Steven D'Aprano wrote: > but why are we using key values by hand when grouping ought to do it for > us, as Michael Selik's version does? > > grouping(words, key=len) because supplying a key function is sometimes cleaner, and sometimes uglier than building up

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

2018-07-03 Thread Chris Barker via Python-ideas
On Tue, Jul 3, 2018 at 8:24 AM, Steven D'Aprano wrote: > On Tue, Jul 03, 2018 at 09:23:07AM -0400, David Mertz wrote: > > > My problem with the second idea is that *I* find it very wrong to have > > something in itertools that does not return an iterator. It wrecks the > > combinatorial algebr

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

2018-07-03 Thread Chris Barker via Python-ideas
On Mon, Jul 2, 2018 at 11:50 PM, Chris Barker wrote: > - keep the key function optional parameter. > - add a value function optional parameter. -- it really makes any case > where you don't want to store the whole item a lot easier. > > - Have the default key function be itemgetter(0) and the def

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

2018-07-02 Thread Chris Barker via Python-ideas
On Mon, Jul 2, 2018 at 9:39 AM, Michael Selik wrote: > On Mon, Jul 2, 2018 at 2:32 AM Nicolas Rolin >>> wrote: >>> For example the default could be such that grouping unpack tuples (key, value) from the iterator and do what's expected with it (group value by key). It is quite reas

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

2018-07-02 Thread Chris Barker via Python-ideas
On Fri, Jun 29, 2018 at 11:25 PM, Guido van Rossum wrote: > Hm, this actually feels heavier to me. But then again I never liked or > understood the need for Counter -- > actually, me neither -- and partly because it's too lightweight -- that is, it's still a regular dict, and you pretty much ha

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

2018-07-02 Thread Chris Barker via Python-ideas
On Sun, Jul 1, 2018 at 9:36 PM, Chris Barker wrote: > hmm, makes we wonder if it would make sense to update my implementation to > allow mapping types as well for the collection > general mapping types don't make sense -- but I added Counter. Which is a pretty special case, so I think it probabl

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

2018-07-01 Thread Chris Barker via Python-ideas
On Sun, Jul 1, 2018 at 7:12 PM, David Mertz wrote: > Michael changed from set to list at my urging. A list is more general. A > groupby in Pandas or SQL does not enforce uniqueness, but DOES preserve > order. > It really is better to construct the collection using lists—in the fully general ma

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

2018-07-01 Thread Chris Barker via Python-ideas
On Sun, Jul 1, 2018 at 7:28 PM, David Mertz wrote: > But it's pretty simple. Whether my idea of collections.Grouping is adapted > or whether a function/classmethod grouping() produces a plain dictionary, > or my custom class... > the casting would be the same: > > {k:set(v) for k,v in deps.ite

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

2018-07-01 Thread Chris Barker via Python-ideas
Ivan, Did you mean this to go to the list? I hope so, as I've cc-d it this time :-) On Sun, Jul 1, 2018 at 1:20 AM, Ivan Levkivskyi wrote: > On 1 July 2018 at 06:18, Chris Barker via Python-ideas < > python-ideas@python.org> wrote: > >> I'm really

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

2018-06-30 Thread Chris Barker via Python-ideas
On Fri, Jun 29, 2018 at 10:53 AM, Michael Selik wrote: > I've drafted a PEP for an easier way to construct groups of elements from > a sequence. https://github.com/selik/peps/blob/master/pep-.rst > > I'm really warming to the: Alternate: collections.Grouping version -- I really like this as

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
Hold the phone! On Thu, Jun 28, 2018 at 8:25 AM, Nicolas Rolin wrote: > student_by_school = defaultdict(list) > for student, school in student_school_list: > student_by_school[school].append(student) > > What I would expect would be a syntax with comprehension allowing me to > w

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
On Thu, Jun 28, 2018 at 4:59 PM, Steven D'Aprano wrote: > Can I make a plea for people to not post code with source highlighting > as HTML please? It is rendered like this for some of us: > > On Thu, Jun 28, 2018 at 10:01:00AM -0700, Chris Barker via Python-ideas > wrote: &

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
On Thu, Jun 28, 2018 at 4:23 PM, Greg Ewing wrote: > Nicolas Rolin wrote: > >> student_by_school = {group_by(school): student for school, student in >> student_school_list} >> > > In the spirit of making the target expression look like > a template for the generated elements, > >{school:

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
d = collections.defaultdict(lambda: [].append) >> for item in seq: >> d[key(item)](item) >> rv = {} >> for k, v in iteritems(d): >> rv[k] = v.__self__ >> return rv >> """ >> >> If you're willing to install Pandas (and

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
On Thu, Jun 28, 2018 at 3:17 PM, Chris Barker wrote: > There are also packages designed to make DB-style queries easier. > > Here's one I found with a quick google. > opps -- hit send too soon: http://178.62.194.22/ https://github.com/pythonql/pythonql -CHB -- Christopher Barker, Ph.D. Oce

Re: [Python-ideas] Allow a group by operation for dict comprehension

2018-06-28 Thread Chris Barker via Python-ideas
On Thu, Jun 28, 2018 at 8:25 AM, Nicolas Rolin wrote: > > I use list and dict comprehension a lot, and a problem I often have is to > do the equivalent of a group_by operation (to use sql terminology). > I don't know from SQL, so "group by" doesn't mean anything to me, but this: > For example i

[Python-ideas] list configuration

2018-06-28 Thread Chris Barker via Python-ideas
Hey all, I've been replying to messages lately, and getting a bounce back: """ Hello chris.bar...@noaa.gov, We're writing to let you know that the group you tried to contact (python-ideas) may not exist, or you may not have permission to post messages to the group. A few more details on why you

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-18 Thread Chris Barker via Python-ideas
On Sat, Jun 16, 2018 at 10:57 PM, Tim Peters wrote: Ya, decimal fp doesn't really solve anything except the shallow surprise > that decimal fractions generally aren't exactly representable as binary > fractions. Which is worth a whole lot for casual users, but doesn't > address any of the deep p

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-14 Thread Chris Barker via Python-ideas
On Wed, Jun 13, 2018 at 6:45 PM, Mikhail V wrote: > Another point is that people do like augmented operators much and for the > append - there are so many advises like: hey, use L += [item] ! > another data point -- in teaching, a number of newbie students do exactly that. Actually, they do: a

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-11 Thread Chris Barker via Python-ideas
On Sun, Jun 10, 2018 at 10:48 PM, Steven D'Aprano wrote: > > > In regard to the "special values", and exact results -- a good math lib > > should return results that are "exact" in all but maybe the last digit > > stored. So you could check inputs and outputs with, e.g. math.isclose() > to > > gi

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-11 Thread Chris Barker via Python-ideas
On Mon, Jun 11, 2018 at 10:24 AM, Michael Selik wrote: > Would sind and cosd make Euler's formula work correctly? Not trying to pick on you, but this question shows a key misunderstanding: There is nothing inherently more accurate in using degrees rather than radians for trigonometry. IT's nic

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-11 Thread Chris Barker via Python-ideas
On Mon, Jun 11, 2018 at 1:00 AM, Ronald Oussoren wrote: > > What is the real world advantage of such a class? So far I’ve only seen > examples where the current behavior is said to be confusing for students. EXACTLY! In [*49*]: math.sin(math.pi) Out[*49*]: 1.2246467991473532e-16 If the diff

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-10 Thread Chris Barker via Python-ideas
On Sun, Jun 10, 2018 at 11:26 AM, Robert Vanden Eynde < robertvandeney...@hotmail.com> wrote: > I agree that a big python library is more close to the standard python lib > than matlab. However, helping transition from matlab is a great concern in > the python scientific community, because matlab

Re: [Python-ideas] Making Path() a built in.

2018-06-05 Thread Chris Barker via Python-ideas
On Tue, Jun 5, 2018 at 4:42 PM, Steven D'Aprano wrote: > This is a quick and dirty survey of my code: > > [steve@ando python]$ grep Path *.py */*.py */*/*.py | wc -l > 21 > [steve@ando python]$ grep "enumerate(" *.py */*.py */*/*.py | wc -l > 307 > [steve@ando python]$ grep "zip(" *.py */*.py */*

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-05 Thread Chris Barker via Python-ideas
On Tue, Jun 5, 2018 at 4:10 PM, Steven D'Aprano wrote: > I'm confused... first you say that Ben makes a good case for this > functionality with the DB analogy, and then one sentence later, you say > the DB case is very different. So not a good case? I don't understand. > I wasn't trying to make

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-05 Thread Chris Barker via Python-ideas
I think your proposal got a bit confused by the choice of names, and that you were proposing two things, one of which I think already exists (setdefault). So, I _think_ what you are proposing is that there be a method something like: def exclusive_add(self, key, value): if key in self:

Re: [Python-ideas] datetime.timedelta literals

2018-06-04 Thread Chris Barker via Python-ideas
On Mon, Jun 4, 2018 at 3:21 PM, Paul Moore wrote: > > So maybe you could propose adding: > > > > seconds > > minutes > > hours > > days > > > > to the datetime module, and then we could write: > > > > 60*seconds == 1*minutes > > > > Without any changes to the language at all. > > This strikes me

Re: [Python-ideas] datetime.timedelta literals

2018-06-04 Thread Chris Barker via Python-ideas
On Mon, Jun 4, 2018 at 1:59 PM, Pål Grønås Drange wrote: > For the general user-defined literals, here are some example use cases: > I kind of like the idea of user-defined literals, but: > Yes, we could write all these as easily as function calls, > > deg(90) > celsius(20) > center('my string

Re: [Python-ideas] datetime.timedelta literals

2018-06-04 Thread Chris Barker via Python-ideas
On Mon, Jun 4, 2018 at 12:58 AM, Paul Moore wrote: > > That's good to hear, but if you don't mind asking, is your lack of > > support because you use timedelta "programatically" instead of > > hard-coded time units, or is there a different (or more) reason(s)? > > > > (I'm ready to yield, now I'm

Re: [Python-ideas] Make asyncio.get_event_loop a builtin

2018-05-22 Thread Chris Barker via Python-ideas
>>To that end, I propose making asyncio.get_event_loop() a builtin. I like the idea of making coroutines easier and use. I do too, but ... > > Eventloop could have an .__init__ method, or be a factory function, with a > 'loop' parameter. The value specifies which eventloop implementation > a

Re: [Python-ideas] String and bytes bitwise operations

2018-05-21 Thread Chris Barker via Python-ideas
On Sat, May 19, 2018 at 6:52 AM, Steven D'Aprano wrote: > Philosophical arguments about the nature of computer memory aside, byte > objects in Python are collections of ints. > not when you start talking about bit-wise operations :-) If a "byte" in python was an integer, then we'd use b**2 rath

Re: [Python-ideas] String and bytes bitwise operations

2018-05-18 Thread Chris Barker via Python-ideas
On Thu, May 17, 2018 at 11:07 PM, Greg Ewing wrote: > Steven D'Aprano wrote: > >> But XORing bytes seems perfectly reasonable. Bytes are numbers, even if >> we display them as ASCII characters. > > actually, bytes are, well, bytes ;-) -- that is, 8 bits. But the point is that "bitwise" operations

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Chris Barker via Python-ideas
now we really have gotten OT... But thanks! that was my question! -CHB Alexander covered the Python part of this, so I'll answer the possible > higher-level question: we haven't yet needed a "negative" leap > second, and it's considered unlikely (but not impossible) that we ever > will. That'

Re: [Python-ideas] Syntactic Sugar: Post-Conditions for Guard Clauses

2018-05-17 Thread Chris Barker via Python-ideas
On Thu, May 17, 2018 at 12:55 PM, Manuel Barkhau wrote: > continue if not is_valid(elem) > ... > how is this better than: if not is_valid(elem): continue ? But even if it is, that might be a consideration for a new language, but adding it to python now is prett

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Chris Barker via Python-ideas
On Thu, May 17, 2018 at 10:14 AM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > The other issue with leap-seconds is that python's datetime doesn't > support them :-) > > That's not entirely true. Since the implementation of PEP 495, it is > possible to represent the 23:59:60

  1   2   >