Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #198018 > unrolled thread
| Started by | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| First post | 2026-09-19 01:33 +0000 |
| Last post | 2026-09-19 16:18 +0800 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: enums (was Re: if else is not readable) Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-19 01:33 +0000
Re: enums (was Re: if else is not readable) "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 16:18 +0800
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Date | 2026-09-19 01:33 +0000 |
| Subject | Re: enums (was Re: if else is not readable) |
| Message-ID | <118koop$1qieb$1@dont-email.me> |
On Sun, 6 Sep 2026 16:42:55 +0100, bart wrote:
> Such enums already exist, but with some restrictions: they must be a
> valid C identifier, so no embedded spaces for example:
>
> enum {
> sjhbshj,
> ala,
> bala,
> something
> };
>
> There is no limit on length, and variables containing such enums
> don't need to be 64 or even 32 bits; 8 bits will usually do.
>
> But you also need to list them in advance.
A bit limiting in capabilities, compared to, say, enums in C++, Java
or Python.
Python’s enums are particularly powerful. They’re not some separate
category of type built into the language, instead, they’re just
classes that inherit from a base class provided in a standard library
module. So you can use multiple inheritance and subclassing with them,
which you can’t in those other languages.
And that standard library module doesn’t actually do anything you
can’t do in your own Python code.
[toc] | [next] | [standalone]
| From | "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> |
|---|---|
| Date | 2026-09-19 16:18 +0800 |
| Message-ID | <wzrrS.304525$yky7.211101@fx09.ams4> |
| In reply to | #198018 |
On 9/19/2026 9:33 AM, Lawrence D’Oliveiro wrote:
> On Sun, 6 Sep 2026 16:42:55 +0100, bart wrote:
>
>> Such enums already exist, but with some restrictions: they must be a
>> valid C identifier, so no embedded spaces for example:
>>
>> enum {
>> sjhbshj,
>> ala,
>> bala,
>> something
>> };
>>
>> There is no limit on length, and variables containing such enums
>> don't need to be 64 or even 32 bits; 8 bits will usually do.
>>
>> But you also need to list them in advance.
>
> A bit limiting in capabilities, compared to, say, enums in C++, Java
> or Python.
>
> Python’s enums are particularly powerful. They’re not some separate
> category of type built into the language, instead, they’re just
> classes that inherit from a base class provided in a standard library
> module. So you can use multiple inheritance and subclassing with them,
> which you can’t in those other languages.
>
> And that standard library module doesn’t actually do anything you
> can’t do in your own Python code.
And the advantages are what, exactly? Why do you leave this off like
a cliffhanger?
--
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web