[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Chris Angelico
On Thu, Feb 18, 2021 at 5:25 PM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > On Thu, Feb 18, 2021 at 1:53 AM Ricky Teachey wrote: > > > > I would personally love for SimpleNamespace to get a shorter name > > > and become a built-in. > > > > Okay. Let's start bikeshedding. If

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Stephen J. Turnbull
Chris Angelico writes: > On Thu, Feb 18, 2021 at 1:53 AM Ricky Teachey wrote: > > I would personally love for SimpleNamespace to get a shorter name > > and become a built-in. > > Okay. Let's start bikeshedding. If SimpleNamespace were to become a > builtin, what should its name be? It

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Stephen J. Turnbull
Abdulla Al Kathiri writes: > How is this not pythonic? > > series.apply(x -> x**2) > Compared to.. > series.apply(lambda x: x**2) The main problem is that the second already exists, and the first doesn't, while the first adds no new power to the language, and isn't enough more readable

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Chris Angelico
On Thu, Feb 18, 2021 at 1:59 PM Ben Rudiak-Gould wrote: > > On Wed, Feb 17, 2021 at 6:12 PM Chris Angelico wrote: >> >> But if object() could get arbitrary attributes, then __slots__ wouldn't work. > > > It seems to me that all you'd have to do is add a line or two to the add_dict > logic in

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Ben Rudiak-Gould
On Wed, Feb 17, 2021 at 6:12 PM Chris Angelico wrote: > But if object() could get arbitrary attributes, then __slots__ wouldn't > work. > It seems to me that all you'd have to do is add a line or two to the add_dict logic in type_new so that instances of object get a dict. Then instances of

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Chris Angelico
On Thu, Feb 18, 2021 at 1:00 PM Christopher Barker wrote: > > > On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: >> >> >> Still think that "object()" should be writable since this seems like an >> >> arbitrary restriction > > ... >> >> But I guess there's been discussion around this already.

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Christopher Barker
> On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: > >> Still think that "object()" should be writable since this seems like an > >> arbitrary restriction ... > But I guess there's been discussion around this already. > > ... but changing object would be problematic. Well, yes, due to

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Ricky Teachey
On Wed, Feb 17, 2021, 6:20 PM Daniel Moisset wrote: > If we're bike shedding, I'd go for "mutableobject". It's not terribly > short, but it is built on familiar python terminology and does exactly what > it says in the box: like object() but mutable > That is a pretty good suggestion. I'd like

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread David Mertz
Why is this a discussion?! Just start your program with: from types import SimpleNamespace as myfavname On Wed, Feb 17, 2021 at 11:22 PM Daniel Moisset wrote: > If we're bike shedding, I'd go for "mutableobject". It's not terribly > short, but it is built on familiar python terminology and

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Daniel Moisset
If we're bike shedding, I'd go for "mutableobject". It's not terribly short, but it is built on familiar python terminology and does exactly what it says in the box: like object() but mutable On Wed, 17 Feb 2021, 23:01 Chris Angelico, wrote: > On Thu, Feb 18, 2021 at 8:53 AM Brendan Barnwell >

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Chris Angelico
On Thu, Feb 18, 2021 at 8:53 AM Brendan Barnwell wrote: > > On 2021-02-17 11:21, Chris Angelico wrote: > > Okay. Let's start bikeshedding. If SimpleNamespace were to become a > > builtin, what should its name be? It needs to be short (obviously), > > but not TOO short, and it needs to be at least

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Paul Bryan
I agree, I don't think it justifies a builtin, because it is so simple to just define your own empty class. That said, it does come in handy, and I do use it for same reasons others have expressed. On Thu, 2021-02-18 at 11:50 +1300, Greg Ewing wrote: > On 18/02/21 3:51 am, Ricky Teachey wrote: >

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Greg Ewing
On 18/02/21 3:38 am, MRAB wrote: So a "byte" is part of a word (a word contains multiple characters). In the Burroughs B6900 architecture, programs consisted of 48-bit words broken up into 8-bit opcodes called "syllables". -- Greg ___ Python-ideas

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Greg Ewing
On 18/02/21 3:51 am, Ricky Teachey wrote: I would personally love for SimpleNamespace to get a shorter name and become a built-in. It is a fantastic object to use in all kinds of situations I find myself disagreeing with that. It's dead simple to define your own blank-object class, and you

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Abdulla Al Kathiri
Those are not anonymous functions though. > On 18 Feb 2021, at 1:43 AM, Joao S. O. Bueno wrote: > > def f1(x, y): >return x + y > > def f2(): > return 0 > > def f3(x): >return x ** 2 > ___ Python-ideas mailing list --

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Brendan Barnwell
On 2021-02-17 11:21, Chris Angelico wrote: Okay. Let's start bikeshedding. If SimpleNamespace were to become a builtin, what should its name be? It needs to be short (obviously), but not TOO short, and it needs to be at least somewhat descriptive, and it needs to not cause confusion with

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Joao S. O. Bueno
On Wed, 17 Feb 2021 at 18:15, Abdulla Al Kathiri < alkathiri.abdu...@gmail.com> wrote: > How is this not pythonic? > > series.apply(x -> x**2) > Compared to.. > series.apply(lambda x: x**2) > > > (x, y) -> x+y, () -> 0, (x) -> x**2 (for single parameter, we can write it > without parenthesis like

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Abdulla Al Kathiri
How is this not pythonic? series.apply(x -> x**2) Compared to.. series.apply(lambda x: x**2) (x, y) -> x+y, () -> 0, (x) -> x**2 (for single parameter, we can write it without parenthesis like the example above) are pythonic enough to my eyes. Abdulla > On 17 Feb 2021, at 10:59 PM, Joao

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Ricky Teachey
On Wed, Feb 17, 2021 at 2:32 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2021-02-18 at 06:21:19 +1100, > Chris Angelico wrote: > > > On Thu, Feb 18, 2021 at 1:53 AM Ricky Teachey wrote: > > > > > > I would personally love for SimpleNamespace to get a shorter name and > become a

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread 2QdxY4RzWzUUiLuE
On 2021-02-18 at 06:21:19 +1100, Chris Angelico wrote: > On Thu, Feb 18, 2021 at 1:53 AM Ricky Teachey wrote: > > > > I would personally love for SimpleNamespace to get a shorter name and > > become a built-in. > > Okay. Let's start bikeshedding. If SimpleNamespace were to become a >

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Chris Angelico
On Thu, Feb 18, 2021 at 1:53 AM Ricky Teachey wrote: > > From other thread: > > On Wed, Feb 17, 2021 at 5:19 AM Chris Angelico wrote: >> >> On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: >> > Still think that "object()" should be writable since this seems like an >> > arbitrary

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Gustavo Carneiro
On Wed, 17 Feb 2021 at 18:30, Ethan Furman wrote: > On 2/17/21 8:47 AM, Random832 wrote: > > On Tue, Feb 16, 2021, at 23:24, Stephen J. Turnbull wrote: > > >> except a couple of characters. So what currently looks like > >> > >> some_list.sort(key=lambda e: e[3].priority) > >> > >> would

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Joao S. O. Bueno
On Wed, 17 Feb 2021 at 15:31, Ethan Furman wrote: > On 2/17/21 8:47 AM, Random832 wrote: > > On Tue, Feb 16, 2021, at 23:24, Stephen J. Turnbull wrote: > > >> except a couple of characters. So what currently looks like > >> > >> some_list.sort(key=lambda e: e[3].priority) > >> > >> would

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Ethan Furman
On 2/17/21 8:47 AM, Random832 wrote: On Tue, Feb 16, 2021, at 23:24, Stephen J. Turnbull wrote: except a couple of characters. So what currently looks like some_list.sort(key=lambda e: e[3].priority) would then be some_list.sort(key=(e)->e[3].priority) Let's not pretend the

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Random832
On Tue, Feb 16, 2021, at 23:24, Stephen J. Turnbull wrote: > except a couple of characters. So what currently looks like > > some_list.sort(key=lambda e: e[3].priority) > > would then be > > some_list.sort(key=(e)->e[3].priority) Let's not pretend the key argument being keyword-only

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Ricky Teachey
>From other thread: On Wed, Feb 17, 2021 at 5:19 AM Chris Angelico wrote: > On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: > > Still think that "object()" should be writable since this seems like an > > arbitrary restriction (+SimpleNamespace is no builtin and at least I > > would use

[Python-ideas] SimpleNamespace vs object

2021-02-17 Thread Sven R. Kunze
Starting this as a new thread for the interested reader: On 17.02.21 11:18, Chris Angelico wrote: On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: Still think that "object()" should be writable since this seems like an arbitrary restriction (+SimpleNamespace is no builtin and at least I

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread MRAB
On 2021-02-17 05:57, Steven D'Aprano wrote: On Wed, Feb 17, 2021 at 11:13:08AM +1300, Greg Ewing wrote: On 17/02/21 7:10 am, Steven D'Aprano wrote: >"It's Greek letter, like pi that you may remember from maths >class. In some technical computer science, the Greek L, lambda, is used >as the

[Python-ideas] Re: Arrow functions polyfill

2021-02-17 Thread Chris Angelico
On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze wrote: > Still think that "object()" should be writable since this seems like an > arbitrary restriction (+SimpleNamespace is no builtin and at least I > would use object() for fast PoCs or dirty hackery). But I guess there's > been discussion around

[Python-ideas] Re: Arrow functions polyfill

2021-02-17 Thread Sven R. Kunze
On 16.02.21 17:26, Steven D'Aprano wrote: >>> from types import SimpleNamespace >>> obj = SimpleNamespace() >>> obj.spam = 1 >>> obj namespace(spam=1) Gives you a nice repr so when you are debugging you can actually see what the object is. I see that's Python 3