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(206)

Re: [Python-ideas] Attribute-Getter Syntax Proposal

2019-03-08 Thread Chris Barker - NOAA Federal via Python-ideas
> > Rather than using map in this way, I would recommend a list comprehension: Exactly! I really don’t get why folks want to use map() so much when the comprehension syntax is often cleaner and easier. It was added for a reason :-) -CHB ___

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

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

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

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

2019-01-29 Thread Chris Barker - NOAA Federal via Python-ideas
> Alex Shafer via Python-ideas wrote: >> 1) I'm in favor of adding a stringify method to all collections > > Are you volunteering to update all the collection > classes in the world written in Python? :-) To be fair, we could add an implementation to the sequence ABC, and get pretty far. Not

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

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

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

2018-12-12 Thread Chris Barker - NOAA Federal via Python-ideas
>>> and the test for an iterator is: >>> >>> obj is iter(obj) Is that a hard and fast rule? I know it’s the vast majority of cases, but I imagine you could make an object that behaved exactly like an iterator, but returned some proxy object rather that itself. Not sure why one would do that,

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] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Chris Barker - NOAA Federal via Python-ideas
could do the subsetting before applying the function, so I think it’s a pretty rare use case. But go ahead and make it — I’ve been wrong before :-) -CHB Sent from my iPhone > On Dec 11, 2018, at 6:47 AM, Steven D'Aprano wrote: > >> On Mon, Dec 10, 2018 at 05:15:36PM -0800, Chri

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

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] Relative Imports

2018-11-13 Thread Chris Barker - NOAA Federal via Python-ideas
This is somewhat unpleasant to me, especially while developing something and trying to test it quickly. I just want to be able to use same relative imports and run single file with `python3 test_main.py` for example. I had the same frustration when I first tried to use relative imports. Then I

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

2018-11-05 Thread Chris Barker via Python-ideas
is 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,

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

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

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:

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 question. But I do think : >

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-11 Thread Chris Barker via Python-ideas
, 2018 at 12:34 PM, Chris Barker wrote: > 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 academi

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 > >

Re: [Python-ideas] Revisiting Immutable Mappings

2018-10-11 Thread Chris Barker - NOAA Federal via Python-ideas
> This violates the Liskov Substitution Principle. If we REALLY had a time machine, then dict would subclass frozendict, and we’d be all set. But to what extent do we need to support ALL the ways to check for an interface? Personally, I think EAFTP is the most “Pythonic”, but if folks want to

Re: [Python-ideas] support toml for pyproject support

2018-10-09 Thread Chris Barker - NOAA Federal via Python-ideas
If I had the energy to argue it I would also argue against using TOML > in those PEPs. I partook in that discussion, and I still have no idea why TOML was chosen, over, say, a defined subset of YAML, or a slightly extended JSON. But the folks that were highly invested and putting the work in

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

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.

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

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

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

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*

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

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

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

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

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

2018-08-24 Thread Chris Barker - NOAA Federal via Python-ideas
> If you're talking about my PyGUI project, using it with > wPython doesn't really make sense. Now that you say that, I think I’m mingling memories — there was another project that attempted to wrap TKInter, wxPython, QT .. I always thought that was ill advised. > The goal is to provide exactly

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

2018-08-24 Thread Chris Barker - NOAA Federal via Python-ideas
while True: button, (a,b) = form.Read() try: answer = int(a) + int(b) output.Update(answer) except: pass Whoa! You really want people to write their own event loop? That seems like a bad idea to me. If you want people to not have to think about events much, maybe

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

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:

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] 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

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

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

2018-08-17 Thread Chris Barker - NOAA Federal via Python-ideas
espace — you can mess with pretty much anything else in Python. -CHB Sent from my iPhone On Aug 17, 2018, at 12:46 PM, Chris Barker wrote: 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. >

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

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

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

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

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 keywo

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

2018-08-15 Thread Chris Barker - NOAA Federal via Python-ideas
> None is keyword, and just like any other keyword, it can't be re-bound. >> it's only a keyword because Python doesn't otherwise have a way of creating >> non-rebindable names. It's purpose is to represent the singular object of >> NoneType, and in that sense it's a literal as much as [] or

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

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] Syntactic sugar to declare partial functions

2018-08-14 Thread Chris Barker - NOAA Federal via Python-ideas
> > Do we often call functools.partial on arbitrary callable objects that we > don't know in advance? For my part, I don’t think I’ve ever used partial in production code. It just seems easier to simply fo it by hand with a closure ( Am I using that term right? I still don’t quite get the

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

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

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

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

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

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] Python docs page: In what ways is None special

2018-07-23 Thread Chris Barker - NOAA Federal via Python-ideas
I agree that some more docs on the specialness of None (and, to a lessor extent, True and False). A few comments: > None is a keyword > == None = 0 > SyntaxError: can't assign to keyword One of the implications of this is that “None” will always be the Singleton None object —

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

2018-07-23 Thread Chris Barker - NOAA Federal via Python-ideas
>lot. Actually, the ?. and ?[ > operators seem like they'd be much more useful if I did more JSON > processing - This has been mentioned a lot in this discussion— Maybe what we need is a smarter JSON processing package, rather than new operators. Granted, these operators would help the authors

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-21 Thread Chris Barker - NOAA Federal via Python-ideas
I starting g reading this thread in the middle, on a phone. But was very confused for a while because I didn’t notice that there were two ‘r’s at the beginning of .rreplace Just sayin’ -CHB Sent from my iPhone > On Jul 19, 2018, at 9:29 AM, Paul Moore wrote: > >> On 19 July 2018 at 16:25,

Re: [Python-ideas] Performance improvements via static typing

2018-07-21 Thread Chris Barker - NOAA Federal via Python-ideas
A note here: Earlier in the conversation about standardizing type hinting, I (among others) was interested in applying it to C-level static typing (e.g. Cython). Guido made it very clear that that was NOT a goal of type hints — rather, they were to be used for dynamic, python style types — so a

Re: [Python-ideas] Multi-core reference count garbage collection

2018-07-21 Thread Chris Barker - NOAA Federal via Python-ideas
> You wrote: > > I'd argue that the ref counts are not interesting at all, only a > > side effect of one possible solution to the object life time problem. > > I'm happy for you to regard multi-core reference counting (MCRC) as a toy > problem, which won't become part of useful software. Perhaps

Re: [Python-ideas] if we were to ever shorten `A if A else B` (was: PEP 505: None-aware operators)

2018-07-21 Thread Chris Barker - NOAA Federal via Python-ideas
> my vote would go to `A otherwise B` since it's unambiguous, the case you care > about the state of comes first, and it doesn't trip your brain up looking > for 'if'. :) And I’d hope “otherwise” is a rare variable name :-) - CHB > > ___ >

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

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

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

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

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: [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. > -

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

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

2018-07-06 Thread Chris Barker - NOAA Federal via Python-ideas
On Jul 6, 2018, at 2:10 AM, Steven D'Aprano wrote: I would consider statistics to have similarities - median, mean etc are aggregate functions. Not really, more like reduce, actually -/ you get a single result. Histograms are also doing something similar to grouping. .(Yes, a few

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,

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().

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

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.

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

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

2018-07-03 Thread Chris Barker via Python-ideas
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 >> wrote: >> &g

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 9:15 AM, Chris Barker wrote: > 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 &

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

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

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

2018-07-03 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

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, s

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

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

[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 warming to

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

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

2018-06-28 Thread Chris Barker - NOAA Federal via Python-ideas
> On Jun 28, 2018, at 5:30 PM, Chris Barker - NOAA Federal > wrote: > > So maybe a solution is an accumulator special case of defaultdict — it uses a > list be default and appends by default. > > Almost like counter... Which, of course, is pretty much what your proposa

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

2018-06-28 Thread Chris Barker - NOAA Federal via Python-ideas
> I think you accidentally swapped variables there: > student_school_list > vs student_by_school Oops, yeah. That’s what I get for whipping out a message before catching a bus. (And on a phone now) But maybe you could wrap the defaultdict constructor around a generator expression that

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 >

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
; https://pandas.pydata.org/pandas-docs/stable/generated/ >> pandas.DataFrame.groupby.html >> >> https://github.com/pandas-dev/pandas/blob/v0.23.1/pandas/ >> core/generic.py#L6586-L6659 >> >> >> Dask has a different groupby implementation: >> https://gist.github.com/darribas/4194

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

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

[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

  1   2   3   >