[Python-ideas] Re: SimpleNamespace vs object

2021-03-02 Thread Sven R. Kunze
On 18.02.21 05:43, Chris Angelico wrote: On Thu, Feb 18, 2021 at 1:59 PM Ben Rudiak-Gould wrote: 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 object would get a dict, and nothing else

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Mike Miller
On 2021-02-21 20:51, Chris Angelico wrote: In my mind, the current front-runners are: * namespace * ns * thing * mutableobject * mobject * attrobject * bunch Short and PascalCase please, to avoid collisions: * Stuff With credit to George Carlin. ;-) Some of these work as well, Kit is not

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Steven D'Aprano
On Mon, Feb 22, 2021 at 11:22:09AM +, Rob Cliffe via Python-ideas wrote: > What's wrong with "namespace"?  None of the other names IMO convey the > intended/suggested use nearly as well. The problem with "namespace" is that the intended us is not as a namespace, but as a dict using `.` synt

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Rob Cliffe via Python-ideas
On 22/02/2021 04:51, Chris Angelico wrote: On Mon, Feb 22, 2021 at 1:11 PM Brendan Barnwell wrote: Why not just put SimpleNamespace in the collections module? The one in types could be aliased to it (or vice versa if we really don't want to change anything). That seems like it's a

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Steven D'Aprano
On Mon, Feb 22, 2021 at 06:26:28PM +1100, Chris Angelico wrote: > Ultimately, SimpleNamespace is useless if it can't be found. "Can't" be found is an exaggeration. The std lib is full of little gems, and people learn them and use them. Generally when people talk about something that "can't be f

[Python-ideas] Re: SimpleNamespace vs object

2021-02-22 Thread Steven D'Aprano
On Mon, Feb 22, 2021 at 10:27:55AM +0300, Paul Sokolovsky wrote: > Such short generic names shouldn't be used for types added so late in > the language evolution. Those are names for variables. (And lowercase in > general, with the exception of handful(!) core types). A handful you say. int, flo

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Paul Sokolovsky
Hello, On Mon, 22 Feb 2021 18:26:28 +1100 Chris Angelico wrote: > On Mon, Feb 22, 2021 at 6:08 PM Paul Sokolovsky > wrote: > > One explanation why SimpleNamespace is not in "collections" is > > because ... it's not a collection. One of the basic traits of any > > collection is that it "contains

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Chris Angelico
On Mon, Feb 22, 2021 at 6:27 PM Paul Sokolovsky wrote: > > Hello, > > On Mon, 22 Feb 2021 15:51:37 +1100 > Chris Angelico wrote: > > [] > > > In my mind, the current front-runners are: > > > > * namespace > > > * ns > > * thing > > * mobject > > * bunch > > Such short generic names shouldn't be u

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Paul Sokolovsky
Hello, On Mon, 22 Feb 2021 15:51:37 +1100 Chris Angelico wrote: [] > In my mind, the current front-runners are: > > * namespace > * ns > * thing > * mobject > * bunch Such short generic names shouldn't be used for types added so late in the language evolution. Those are names for variables.

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Chris Angelico
On Mon, Feb 22, 2021 at 6:08 PM Paul Sokolovsky wrote: > One explanation why SimpleNamespace is not in "collections" is because > ... it's not a collection. One of the basic traits of any collection is > that it "contains" things, and thus it can be directly iterated over to > traverse those conte

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Paul Sokolovsky
Hello, On Sun, 21 Feb 2021 16:51:37 -0800 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

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 Thread Chris Angelico
On Mon, Feb 22, 2021 at 1:11 PM 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-21 Thread David Mertz
On Mon, Feb 22, 2021 at 2:09 AM Brendan Barnwell wrote: > Thinking about this more, I think the main obstacle to use of > SimpleNamespace isn't the name, it's its the location. No one is going > to look in the types module for something like this. Why not just put > SimpleNamespace in t

[Python-ideas] Re: SimpleNamespace vs object

2021-02-21 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 "object"

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Steven D'Aprano
Are we just trying to list every imaginable word that is even vaguely related to the concept of "something that holds something"? If we have plate, tray, board then surely we should include saucer, cup, bowl, pot, frying_pan, cheeseboard, box, suitcase, luggage, handbag, ... Trying to exhaustiv

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread 2QdxY4RzWzUUiLuE
On 2021-02-20 at 13:44:21 -0500, David Mertz wrote: > Cheeseshop! But then it would never contain the attribute I ask for, and throw a different exception every time! ;-) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread David Mertz
Cheeseshop! On Sat, Feb 20, 2021, 1:08 PM Jan Kaliszewski wrote: > 2021-02-18 Chris Angelico dixit: > > [...] > > 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

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Jan Kaliszewski
2021-02-18 Chris Angelico dixit: [...] > 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 "obj

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Ricky Teachey
On Sat, Feb 20, 2021, 12:56 PM Jan Kaliszewski wrote: > 2021-02-17 Ricky Teachey dixit: > > > * patsy > > I love this one! :-) > > Cheers. > *j > > PS. But it should be callable and, when called, it should raise > RuntimeError("It's only a model!") > Have to admit I was proud of this idea. Hah

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Jan Kaliszewski
2021-02-17 Ricky Teachey dixit: > * patsy I love this one! :-) Cheers. *j PS. But it should be callable and, when called, it should raise RuntimeError("It's only a model!") ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe se

[Python-ideas] Re: SimpleNamespace vs object

2021-02-19 Thread Dan Strokirk
> If SimpleNamespace were to become a builtin, what should its name be? Just to have the obvious out of the way: * obj() - fits with most other builtins in that they are abbreviations and 3-4 letters * data() - same, might be confused with dataclass * container() * values() Most of these are lik

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread Chris Angelico
On Thu, Feb 18, 2021 at 9:57 PM Steven D'Aprano wrote: > > On Thu, Feb 18, 2021 at 06:21:19AM +1100, Chris Angelico 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 t

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread M.-A. Lemburg
On 18.02.2021 12:00, Steven D'Aprano wrote: > On Wed, Feb 17, 2021 at 11:28:05AM -0800, Brendan Barnwell wrote: > >> When I see people suggest >> SimpleNamespace, it's usually just to use it as a dict which is accessed >> with attribute syntax instead of item syntax. > > If its a dict, it must

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread Steven D'Aprano
On Wed, Feb 17, 2021 at 11:28:05AM -0800, Brendan Barnwell wrote: > When I see people suggest > SimpleNamespace, it's usually just to use it as a dict which is accessed > with attribute syntax instead of item syntax. If its a dict, it must have dict methods. That leads to conflict: data fields

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread Steven D'Aprano
On Thu, Feb 18, 2021 at 06:21:19AM +1100, Chris Angelico 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? The traditional name i

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread Paul Sokolovsky
Hello, On Thu, 18 Feb 2021 21:27:18 +1100 Steven D'Aprano wrote: [] > Or we could just use a one-liner: > > >>> from types import SimpleNamespace > > and get all of that for free. And if it were a builtin, it would be a > zero-liner. Right. If the whole CPython stdlib were builtin, it

[Python-ideas] Re: SimpleNamespace vs object

2021-02-18 Thread Steven D'Aprano
On Thu, Feb 18, 2021 at 11:50:17AM +1300, Greg Ewing wrote: > It's dead simple to define > your own blank-object class, and you get to give it a name that > reflects what you're really doing with it. I don't understand > why there's such a fascination with things like SimpleNamespace. Right, it t

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

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

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

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

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

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

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

[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 "object"

[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 built-in.

[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 > builtin,

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

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