[Python-ideas] Re: Make dataclass aware that it might be used with Enum

2022-07-10 Thread Chris Angelico
On Mon, 11 Jul 2022 at 03:54, Steve Jorgensen  wrote:
>
> David Mertz, Ph.D. wrote:
> > I've seen this thread, and also wondered why anyone could EVER want a
> > dataclass that is an enum.  Nothing I've seen in the thread gives me any
> > hint about that, really.
> > On Sun, Jul 10, 2022 at 7:44 AM Barry Scott ba...@barrys-emacs.org wrote:
> > > On 9 Jul 2022, at 22:53, Steve Jorgensen stevec...@gmail.com wrote:
> > > I don't think that dataclasses have the limited set of intended uses
> > > that you are interpreting them as having. To me, the fact that they can be
> > > frozen makes them a good fit with Enum.
> > > Please quote the email that you are replying to.
> > > It is usually considered a code smell to have a class that is two or more
> > > things.
> > > This seems to be what you are trying to do.
> > > How can one class be a set of fields and also the enum for one of its own
> > > fields?
> > > I do not understand why this is resonable.
> > > Barry
> > >
> > > Python-ideas mailing list -- python-ideas@python.org
> > > To unsubscribe send an email to python-ideas-le...@python.org
> > > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > > Message archived at
> > > https://mail.python.org/archives/list/python-ideas@python.org/message/V6U7UM...
> > > Code of Conduct: http://python.org/psf/codeofconduct/
> > >
> > > Python-ideas mailing list -- python-ideas@python.org
> > > To unsubscribe send an email to python-ideas-le...@python.org
> > > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > > Message archived at
> > > https://mail.python.org/archives/list/python-ideas@python.org/message/HZFZE3...
> > > Code of Conduct: http://python.org/psf/codeofconduct/
> > > --
> > Keeping medicines from the bloodstreams of the sick; food
> > from the bellies of the hungry; books from the hands of the
> > uneducated; technology from the underdeveloped; and putting
> > advocates of freedom in prisons.  Intellectual property is
> > to the 21st century what the slave trade was to the 16th.
>
> Sorry, I don't know how I communicated that I was trying to have one class be 
> a set of fields and also the enum for one of its own fields.
>
> I'm really just wanting to have each member of the enum be an instance of a 
> frozen dataclass. If an of the dataclass fields were of an enum type, then it 
> would presumably not be for the same enum. In my example, none of the fields 
> of the dataclass contains an enum. One contains a string, and the other 
> contains an int.
>

Just throwing an idea out there, but would it work better to have an
enum-namedtuple instead?

ChrisA
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YVF6OKL5UPCUWWU72R36WDIQ2KTWC5SF/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make dataclass aware that it might be used with Enum

2022-07-10 Thread Steve Jorgensen
David Mertz, Ph.D. wrote:
> I've seen this thread, and also wondered why anyone could EVER want a
> dataclass that is an enum.  Nothing I've seen in the thread gives me any
> hint about that, really.
> On Sun, Jul 10, 2022 at 7:44 AM Barry Scott ba...@barrys-emacs.org wrote:
> > On 9 Jul 2022, at 22:53, Steve Jorgensen stevec...@gmail.com wrote:
> > I don't think that dataclasses have the limited set of intended uses
> > that you are interpreting them as having. To me, the fact that they can be
> > frozen makes them a good fit with Enum.
> > Please quote the email that you are replying to.
> > It is usually considered a code smell to have a class that is two or more
> > things.
> > This seems to be what you are trying to do.
> > How can one class be a set of fields and also the enum for one of its own
> > fields?
> > I do not understand why this is resonable.
> > Barry
> > 
> > Python-ideas mailing list -- python-ideas@python.org
> > To unsubscribe send an email to python-ideas-le...@python.org
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> > https://mail.python.org/archives/list/python-ideas@python.org/message/V6U7UM...
> > Code of Conduct: http://python.org/psf/codeofconduct/
> > 
> > Python-ideas mailing list -- python-ideas@python.org
> > To unsubscribe send an email to python-ideas-le...@python.org
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> > https://mail.python.org/archives/list/python-ideas@python.org/message/HZFZE3...
> > Code of Conduct: http://python.org/psf/codeofconduct/
> > -- 
> Keeping medicines from the bloodstreams of the sick; food
> from the bellies of the hungry; books from the hands of the
> uneducated; technology from the underdeveloped; and putting
> advocates of freedom in prisons.  Intellectual property is
> to the 21st century what the slave trade was to the 16th.

Sorry, I don't know how I communicated that I was trying to have one class be a 
set of fields and also the enum for one of its own fields.

I'm really just wanting to have each member of the enum be an instance of a 
frozen dataclass. If an of the dataclass fields were of an enum type, then it 
would presumably not be for the same enum. In my example, none of the fields of 
the dataclass contains an enum. One contains a string, and the other contains 
an int.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KWL2FXQ2FKRMGBAB5PMR3GIRAQBC6CLR/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make dataclass aware that it might be used with Enum

2022-07-10 Thread David Mertz, Ph.D.
I've seen this thread, and also wondered why anyone could EVER want a
dataclass that is an enum.  Nothing I've seen in the thread gives me any
hint about that, really.

On Sun, Jul 10, 2022 at 7:44 AM Barry Scott  wrote:

>
>
> > On 9 Jul 2022, at 22:53, Steve Jorgensen  wrote:
> >
> > I don't think that dataclasses have the limited set of intended uses
> that you are interpreting them as having. To me, the fact that they can be
> frozen makes them a good fit with Enum.
>
> Please quote the email that you are replying to.
>
> It is usually considered a code smell to have a class that is two or more
> things.
> This seems to be what you are trying to do.
>
> How can one class be a set of fields and also the enum for one of its own
> fields?
> I do not understand why this is resonable.
>
> Barry
>
>
>
> > ___
> > Python-ideas mailing list -- python-ideas@python.org
> > To unsubscribe send an email to python-ideas-le...@python.org
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/V6U7UMQRTLDZ2W6SWREL472L6ZH7MHB5/
> > Code of Conduct: http://python.org/psf/codeofconduct/
> >
>
> ___
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/HZFZE3YMCMT6CF5VZHNM6ZJVDAX6LZXK/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HMYCB2RWSKK5SVKO2O2NF7OSHD4KZTR3/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make dataclass aware that it might be used with Enum

2022-07-10 Thread Barry Scott



> On 9 Jul 2022, at 22:53, Steve Jorgensen  wrote:
> 
> I don't think that dataclasses have the limited set of intended uses that you 
> are interpreting them as having. To me, the fact that they can be frozen 
> makes them a good fit with Enum.

Please quote the email that you are replying to.

It is usually considered a code smell to have a class that is two or more 
things.
This seems to be what you are trying to do.

How can one class be a set of fields and also the enum for one of its own 
fields?
I do not understand why this is resonable.

Barry



> ___
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/V6U7UMQRTLDZ2W6SWREL472L6ZH7MHB5/
> Code of Conduct: http://python.org/psf/codeofconduct/
> 

___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HZFZE3YMCMT6CF5VZHNM6ZJVDAX6LZXK/
Code of Conduct: http://python.org/psf/codeofconduct/