On Thu, Jun 10, 2021 at 7:10 AM Chris Angelico wrote:
> This proposal is basically for a way to take an f-string-like
> construct and, instead of calling format() on each of the values and
> joining them together into a string, you do something else with it. Or
> from a language perspective, you
On Sat, Sep 26, 2020 at 8:40 PM Steven D'Aprano wrote:
> On Sat, Sep 26, 2020 at 01:47:56PM -0300, Sebastian Kreft wrote:
>
> > In this fashion have you considering having keyword only indices, that is
> > to only allow either obj[1, 2] or obj[row=1, col=2] (if the class
> supports
> > it), and
On Tue, Sep 1, 2020 at 9:59 AM David Mertz wrote:
> On Tue, Sep 1, 2020 at 11:45 AM Steven D'Aprano
> wrote:
>
>> (8) Dict unpacking is permitted:
>>
>> items = {'spam': 1, 'eggs': 2}
>> obj[index, **items]
>> # equivalent to obj[index, spam=1, eggs=2]
>>
>
> I would prefer to
On Sat, Aug 15, 2020 at 8:27 PM Guido van Rossum wrote:
> On Sat, Aug 15, 2020 at 8:02 PM Todd wrote:
>
>> On Sat, Aug 15, 2020 at 7:26 PM Stefano Borini
>> wrote:
>>
>>> > QUESTION
>>> > Suppose we have
>>> > >>> d[x=1, y=2] = 42
>>> > >>> d[x=1, y=2]
>>> > 42
>>> > where d is an
On Fri, Aug 7, 2020 at 6:29 PM Stephan Hoyer wrote:
> On Fri, Aug 7, 2020 at 9:12 AM Ricky Teachey wrote:
>
>> On Fri, Aug 7, 2020 at 4:19 AM Steven D'Aprano
>> wrote:
>>
>>> On Fri, Aug 07, 2020 at 05:54:18PM +1000, Steven D'Aprano wrote:
>>>
>
On Fri, Aug 7, 2020 at 9:12 AM Ricky Teachey wrote:
> On Fri, Aug 7, 2020 at 4:19 AM Steven D'Aprano
> wrote:
>
>> On Fri, Aug 07, 2020 at 05:54:18PM +1000, Steven D'Aprano wrote:
>>
>> > This proposal doesn't say anything about reversing the decision made
>> all
>> > those years ago to bundle
dexing with keyword arguments like da[space=0]
> > """
>
> This would be the thing I would think of first when indexing with
> keywords. But, there are a few points about named dimensions:
>
> First, using it for named dimensions, means you don't actually need
On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey wrote:
> >>> # The positional arguments aren't part of the KeyObject
> >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d), KeyObject(e=5,
> f=6))
>
> This raises a question that needs to be answered, then: what would be the
> utility of mixing
On Fri, Feb 21, 2020 at 12:43 AM Steven D'Aprano
wrote:
> On Thu, Feb 20, 2020 at 02:19:13PM -0800, Stephan Hoyer wrote:
>
> > > > Strong +1 for an array.zeros() constructor, and/or a lower level
> > > array.empty() which doesn't pre-fill values.
> > >
> &
On Thu, Feb 20, 2020 at 2:11 PM Chris Angelico wrote:
> On Fri, Feb 21, 2020 at 8:52 AM Stephan Hoyer wrote:
> >
> > On Thu, Feb 20, 2020 at 12:41 PM Steve Jorgensen
> wrote:
> >>
> >> Christopher Barker wrote:
> >> ...
> >> > &g
On Thu, Feb 20, 2020 at 12:41 PM Steve Jorgensen wrote:
> Christopher Barker wrote:
> ...
> > > Perhaps the OP wanted the internal array size initialized, but not
> used.
> > Currently the internal array will automatically be reallocated to grow as
> > needed. Which could be a performance hit if
On Thu, Apr 25, 2019 at 1:51 PM Ivan Levkivskyi
wrote:
> TBH, I don't think it is so bad that it requires a new syntax. But I am
> not strongly against it either. What I would like to add here is that if we
> will go with the replacement:
>
> Callable[[X, Y], Z] becomes (X, Y) -> Z
>
> then we
On Tue, Apr 2, 2019 at 5:43 PM Eric V. Smith wrote:
> PS: I really tried to find a way to use := in this example so I could
> put the assignment inside the 'if' statement, but as I think Tim Peters
> pointed out, without C's comma operator, you can't.
>
Conceivably cut_prefix could return None
On Mon, Mar 18, 2019 at 3:42 PM Greg Ewing
wrote:
> Tim Delaney wrote:
> > I would argue the opposite - the use of "is" shows a clear knowledge
> > that True and False are each a singleton and the author explicitly
> > intended to use them that way.
>
> I don't think you can infer that. It could
Would __iadd__ and __isub__ be added to collections.abc.MutableMapping?
This would be consistent with other infix operations on mutable ABCs, but
could potentially break backwards compatibility for anyone who has defined
a MutableMapping subclass that implements __add__ but not __iadd__.
On Sat,
On Mon, Jan 21, 2019 at 8:47 AM Jonathan Fine wrote:
> > Backtick expressions work exactly like lambdas, except that they are
> bound to the instance they are created in every time that class is used to
> create one.
>
> I would if possible very much like to see some real world examples of
>
On Sun, Jan 6, 2019 at 4:27 PM Steven D'Aprano wrote:
> I propose adding a "nan_policy" keyword-only parameter to the relevant
> statistics functions (mean, median, variance etc), and defining the
> following policies:
>
> IGNORE: quietly ignore all NANs
> FAIL: raise an exception if
On Sat, Jul 28, 2018 at 9:44 AM Jonathan Fine wrote:
> By all means start a PEP (on github) if you find it helps you. I think
> it's too early.
>
> If this problem has a pure Python solution, then I think it best to
> develop it as a third party module. I suggest the name slicetools.
> When
On Mon, Jul 23, 2018 at 4:37 PM David Mertz wrote:
> I find pandas.IndexSlice makes a lot of operations easier to spell. As
> simple as it is, it's a valuable capability. Rather than every library—or a
> number of them anyway—creating the same 4 lines of code with a different
> name, it would be
On Mon, Jul 23, 2018 at 4:19 PM Stefan Behnel wrote:
> Stephan Hoyer schrieb am 23.07.2018 um 18:01:
> > I think a SliceHelper class like this is a reasonable solution, but there
> > would be a lot of value having it a standard place somewhere in the
> >
On Mon, Jul 23, 2018 at 4:24 AM Paul Moore wrote:
> I thought the reason the proposal got nowhere was because it's pretty
> simple to define it yourself:
>
> >>> class SliceHelper:
> ... def __getitem__(self, slice):
> ... return slice
> ...
> >>> SH = SliceHelper()
> >>> SH[1::3]
>
We already have a built-in immutable set for Python. It's called frozenset.
On Fri, Dec 29, 2017 at 10:56 AM 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
On Thu, Sep 7, 2017 at 5:15 PM Nathaniel Smith wrote:
> On Thu, Sep 7, 2017 at 4:23 PM, Nick Coghlan wrote:
> > The gist of the idea is that with subinterpreters, your starting point
> > is multiprocessing-style isolation (i.e. you have to use pickle to
> >
On Wed, Jul 19, 2017 at 6:08 PM, Guido van Rossum wrote:
> Regarding that spec, I think there's something missing: given a list (or
> tuple!) of values, how do you turn it into an 'ntuple'? That seems a common
> use case, e.g. when taking database results like row_factory in
On Fri, Apr 28, 2017 at 4:55 AM, Tin Tvrtković wrote:
> I'm going to posit we need declarative classes. (This is what a library
> like attrs provides, basically.) For a class to be declarative, it needs to
> be possible to inspect the class for its attributes and more.
>
>
hows that that note hasn't changed in 10 years:
> https://github.com/python/cpython/blame/master/
> Doc/reference/datamodel.rst#L2210
>
> On Mon, Apr 24, 2017 at 3:15 PM, Terry Reedy <tjre...@udel.edu> wrote:
>
>> On 4/24/2017 12:14 PM, Stephan Hoyer wrote:
>>
>> Ba
On Sun, Apr 23, 2017 at 10:57 PM, Greg Ewing <greg.ew...@canterbury.ac.nz>
wrote:
> Stephan Hoyer wrote:
>
>> In practice, CPython requires that the right operand defines a different
>> method before it defers to it.
>>
>
> I'm not sure exactly what the rationa
I recently filed this as a bug, and was asked to repost to python-dev or
python-ideas for greater visibility:
http://bugs.python.org/issue30140
Without further ado, here is my original report:
---
We are writing a system for overloading NumPy operations (see PR [1] and
On Fri, Apr 21, 2017 at 9:43 AM, Ethan Furman wrote:
> You have to use the complete module name? Instead of `from callable_enum
> import Enum, Value`? Ouch
Yeah... it took me a while to come around to this one. But the rule does
start to pay off in large code bases.
On Thu, Apr 20, 2017 at 10:58 AM, Ethan Furman wrote:
> I'm curious, what did you find ugly with:
>
> class TestEnum(CallableEnum):
>
> @enum
> def hello(text):
> "a pleasant greeting"
> print('hello,', text)
>
> @enum
Enums are great. They allow you cleanly define a set of statically defined
options.
One way that I've found myself using enums recently is for dispatching (as
keys in a dictionary) between different interchangeable functions or
classes. My code looks something like this:
from enum import Enum
On Fri, Feb 10, 2017 at 9:20 AM, Nick Coghlan wrote:
> What I would personally hope to see from the proposal is that given:
>
> class Spam:
> pass
>
> def Spam.func(self):
> return __class__
>
> the effective runtime behaviour would be semantically
On Sun, Nov 6, 2016 at 5:32 PM, Nathaniel Smith wrote:
> Filtering out a subset of rows from a data frame in pandas; 'height'
> and 'age' refer to columns in the data frame (equivalent to
> data_frame[data_frame["height"] > 100 and data_frame["age"] < 5], but
> more ergonomic and
33 matches
Mail list logo