On 6/16/2023 7:37 PM, dn via Python-list wrote:
On 16/06/2023 23.47, Thomas Passin via Python-list wrote:
On 6/16/2023 1:40 AM, dn via Python-list wrote:
Have you figured-out a use for the @enum.member and @enum.nonmember
decorators (new in Python 3.11)?
mypy is having trouble with 3.11 enu
On 16/06/2023 23.47, Thomas Passin via Python-list wrote:
On 6/16/2023 1:40 AM, dn via Python-list wrote:
Have you figured-out a use for the @enum.member and @enum.nonmember
decorators (new in Python 3.11)?
mypy is having trouble with 3.11 enums:
"There are 83 open Enum mypy issues at the t
On 6/16/2023 1:40 AM, dn via Python-list wrote:
Have you figured-out a use for the @enum.member and @enum.nonmember
decorators (new in Python 3.11)?
"What's New" says:
Added the member() and nonmember() decorators, to ensure the decorated
object is/is not converted to an enum member.
The PS
Ethan Furman writes:
> I'm asking because in doing some work on Enum it became apparent to me
> that having nested classes was not a smooth, satisfying experience,
> and I'm considering treating them the same way as methods (they will
> no longer be converted into members).
For reference (and to
ast wrote:
> https://docs.python.org/3.5/library/enum.html#planet
>
> Documentation says that the value of the enum
> members will be passed to this method.
>
> But in that case __init__ waits for two arguments, mass
> and radius, while enum member's value is a tuple.
>
> It seems that there is
Steven D'Aprano wrote:
> Is it silly to create an enumeration with only a single member? That is, a
> singleton enum?
>
> from enum import Enum
>
> class Unique(Enum):
> FOO = auto()
>
>
> The reason I ask is that I have two functions that take an enum argument.
> The first takes one of th
On 01/10/2017 05:43 AM, Steven D'Aprano wrote:
Is it silly to create an enumeration with only a single member? That is, a
singleton enum?
Don't think so, for the same reason that lists with one element make sense.
def ham(arg):
if isinstance(arg, MarxBros) or arg is Unique.FOO:
On 01/10/2017 12:37 AM, Chris Angelico wrote:
On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote:
That is, a singleton enum?
Why stop there? You can make empty ones too. (Zerotons?)
Sure you *can*, but I can't think of any time they'd be useful. Can
you give an example?
Sure. Any time
On Tue, Jan 10, 2017 at 7:33 PM, Paul Rubin wrote:
>> That is, a singleton enum?
>
> Why stop there? You can make empty ones too. (Zerotons?)
Sure you *can*, but I can't think of any time they'd be useful. Can
you give an example?
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano writes:
> Is it silly to create an enumeration with only a single member?
No.
> That is, a singleton enum?
Why stop there? You can make empty ones too. (Zerotons?)
> The reason I ask is that I have two functions that take an enum
> argument.
Sounds like a good reason.
>
Steven D'Aprano writes:
> Is it silly to create an enumeration with only a single member? That
> is, a singleton enum?
>
> from enum import Enum
>
> class Unique(Enum):
> FOO = auto()
>
>
> The reason I ask is that I have two functions that take an enum
> argument. The first takes one of three
On 01/09/2017 08:43 PM, Steven D'Aprano wrote:
Is it silly to create an enumeration with only a single member? That is, a
singleton enum?
from enum import Enum
class Unique(Enum):
FOO = auto()
The reason I ask is that I have two functions that take an enum argument. The
first takes one
On 04/13/2016 07:21 AM, Ethan Furman wrote:
On 04/13/2016 07:07 AM, Marko Rauhamaa wrote:
class Color(enum.Enum):
red
blue
green
This last one is to the point but raises a NameError.
Using the aenum library that last one is possible. It also has
NamedConstan
On 04/13/2016 07:07 AM, Marko Rauhamaa wrote:
class Color(enum.Enum):
red
blue
green
This last one is to the point but raises a NameError.
Using the aenum library that last one is possible. It also has
NamedConstant and a metaclass-derived NamedTuple!
--
On Wed, Apr 13, 2016 at 7:50 AM, Grant Edwards
wrote:
> FWIW, as an old Pascal programmer, I too would have been surprised
> that an "enum" is not ordinal and doesn't support a next/prev and
> iteration.
They do support iteration, but it's by order of declaration, not by value.
--
https://mail.p
Grant Edwards :
> On 2016-04-13, Michael Selik wrote:
>> An Enum corresponds to "nominal" data that is coded as a number
>> simply for storage rather than meaning.
>
> FWIW, as an old Pascal programmer, I too would have been surprised
> that an "enum" is not ordinal and doesn't support a next/pre
On 2016-04-13, Michael Selik wrote:
> On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon
> wrote:
>
>> I have been looking at the enum documentation and it seems enums
>> are missing two features I rather find important.
>>
>> 1) Given an Enum value, someway to get the next/previous
>>one
>>
>> 2)
On Wednesday, April 13, 2016 at 5:39:13 PM UTC+5:30, Michael Selik wrote:
> On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon
> wrote:
>
> > I have been looking at the enum documentation and it
> > seems enums are missing two features I rather find
> > important.
> >
> > 1) Given an Enum value, someway
On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon
wrote:
> I have been looking at the enum documentation and it
> seems enums are missing two features I rather find
> important.
>
> 1) Given an Enum value, someway to get the next/previous
>one
>
> 2) Given two Enum values, iterate over the values
On 04/13/2016 12:12 PM, Antoon Pardon wrote:
I have been looking at the enum documentation and it
seems enums are missing two features I rather find
important.
1) Given an Enum value, someway to get the next/previous
one
2) Given two Enum values, iterate over the values between
them.
D
Rustom Mody :
> Given the eg in the docs:
> from enum import Enum
> class Color(Enum):
> red = 1
> blue = 2
> green = 3
>
Color(Color.red.value+1)
>
But:
>>> class Color(enum.Enum):
... red = 0xff
... green = 0x00ff00
... blue = 0xff
...
>>> Colo
On Wednesday, April 13, 2016 at 3:43:41 PM UTC+5:30, Antoon Pardon wrote:
> I have been looking at the enum documentation and it
> seems enums are missing two features I rather find
> important.
>
> 1) Given an Enum value, someway to get the next/previous
>one
>
> 2) Given two Enum values, it
> Like that?
>
> >>> class M2(enum.EnumMeta):
>... def __contains__(self, value):
>... print(value, "? never", sep="")
>... return False
>...
> >>> Colors.__class__
>
> >>> Colors.red in Colors
> checking Colors.red
> True
> >>> Colors.__class__ = M2
> >>> Colors.red in Colors
Joseph L. Casale wrote:
> import enum
> class M(enum.EnumMeta):
>>... def __contains__(self, value):
>>... print("checking", value)
>>... return super().__contains__(value)
>>...
> class Colors(enum.Enum, metaclass=M):
>>... red = 1
>>... green = 2
>>...
import enum
class M(enum.EnumMeta):
>... def __contains__(self, value):
>... print("checking", value)
>... return super().__contains__(value)
>...
class Colors(enum.Enum, metaclass=M):
>... red = 1
>... green = 2
>... blue = 3
>...
Colors.red in C
Joseph L. Casale wrote:
> Is it possible to override __contains__ from the meta class in the derived
> class with the Enum type?
>>> import enum
>>> class M(enum.EnumMeta):
... def __contains__(self, value):
... print("checking", value)
... return super().__contains__(value)
.
On 2013-08-07, Ian Kelly wrote:
> On Tue, Aug 6, 2013 at 7:55 PM, Ben Finney wrote:
>> Ian Kelly writes:
>> Terrain that is ?radiated? would be terrain that has some kind of spokes
>> spreading out from its centre. I think you mean ?irradiated?.
>>
>> Hope the game goes well :-)
>
> It's actuall
On Tue, Aug 6, 2013 at 6:33 PM, Ethan Furman wrote:
> class Environment(AutoNumber):
>
> gaia = 2.0
> fertile = 1.5
> terran = 1.0
> jungle = 1.0
> ocean = 1.0
> arid = 1.0
> steppe = 1.0
> desert = 1.0
> minimal = 1.0
> barren = 0.5
> tundra = 0.5
>
On Tue, Aug 6, 2013 at 7:55 PM, Ben Finney wrote:
> Ian Kelly writes:
> Terrain that is “radiated” would be terrain that has some kind of spokes
> spreading out from its centre. I think you mean “irradiated”.
>
> Hope the game goes well :-)
It's actually a reimplementation of a game from 1993, s
Ian Kelly writes:
> class Environment(OrderedEnum):
I have nothing to add regarding the Python code, but I wanted to make a
language correction:
> gaia = 1
> fertile = 2
> terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10)
> barren, tundra, dead, inferno, toxic,
On 08/06/2013 04:46 PM, Ian Kelly wrote:
On Aug 6, 2013 5:15 PM, "Ethan Furman" mailto:et...@stoneleaf.us>> wrote:
Use the .value attribute instead. You could also substitute self for
Environment.
It feels more natural and readable to compare the enum instances rather than
their value att
On Wed, 07 Aug 2013 00:46:39 +0100, Ian Kelly
wrote:
On Aug 6, 2013 5:15 PM, "Ethan Furman" wrote:
Use the .value attribute instead. You could also substitute self for
Environment.
It feels more natural and readable to compare the enum instances rather
than their value attributes. If I
On Aug 6, 2013 5:15 PM, "Ethan Furman" wrote:
>
> Use the .value attribute instead. You could also substitute self for
Environment.
It feels more natural and readable to compare the enum instances rather
than their value attributes. If I am ordering the values then that seems to
imply that the e
On 08/06/2013 04:00 PM, Ian Kelly wrote:
Use the .value attribute instead. You could also substitute self for
Environment.
class Environment(Enum):
gaia = 1
fertile = 2
terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10)
barren, tundra, dead, inferno, tox
On 2007-09-11, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> Perhaps Ben should have followed the usual practice of
> commercial, closed- source software developers and started
> counting his version numbers at one instead of zero, miss a few
> releases, use randomly large increments occasionally, a
On Mon, 10 Sep 2007 18:03:11 -0700, TheFlyingDutchman wrote:
>> I'd like to know if the Cheeseshop package 'enum' is useful to you. Any
>> constructive feedback would be appreciated.
>>
>> http://cheeseshop.python.org/pypi/enum/>
>
> Looking at the documentation it looks excellent. But I don'
[EMAIL PROTECTED] wrote:
> Hi,
>
> I have the following class -
>
> class TestOutcomes:
> PASSED = 0
> FAILED = 1
> ABORTED = 2
>
> plus the following code -
>
> testResult = TestOutcomes.PASSED
>
> testResultAsString
> if testResult == TestOutcomes.PASSED:
> testResultAsStrin
Zara wrote:
> On Mon, 10 Sep 2007 02:28:57 -0700, [EMAIL PROTECTED] wrote:
>
>
>> Hi,
>>
>> I have the following class -
>>
>> class TestOutcomes:
>>PASSED = 0
>>FAILED = 1
>>ABORTED = 2
>>
>> plus the following code -
>>
>> testResult = TestOutcomes.PASSED
>>
>> testResultAsString
>
On Mon, 10 Sep 2007 02:28:57 -0700, [EMAIL PROTECTED] wrote:
>Hi,
>
>I have the following class -
>
>class TestOutcomes:
>PASSED = 0
>FAILED = 1
>ABORTED = 2
>
>plus the following code -
>
>testResult = TestOutcomes.PASSED
>
>testResultAsString
>if testResult == TestOutcomes.PASSED:
>
On Sep 10, 7:55 pm, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
> TheFlyingDutchman wrote:
> > On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> >> TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> http://cheeseshop.python.org/pypi/enum/>
> >> (Please preserve attribution lines so
On Sep 10, 8:02 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> > > TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > > > Looking at the documentation it looks excellent. But I don't
> > >
TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
> > TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > > Looking at the documentation it looks excellent. But I don't
> > > understand the 0.4.2 version number,
> >
> > Note the tag that says
TheFlyingDutchman wrote:
> On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
>> TheFlyingDutchman <[EMAIL PROTECTED]> writes:
http://cheeseshop.python.org/pypi/enum/>
>> (Please preserve attribution lines so it's clear who wrote what.)
>>
>>
>>> Looking at the documentation it look
On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > > http://cheeseshop.python.org/pypi/enum/>
>
> (Please preserve attribution lines so it's clear who wrote what.)
>
> > Looking at the documentation it looks excellent. But I don't
> > u
TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > http://cheeseshop.python.org/pypi/enum/>
(Please preserve attribution lines so it's clear who wrote what.)
> Looking at the documentation it looks excellent. But I don't
> understand the 0.4.2 version number,
Note the tag that says the "Deve
TheFlyingDutchman a écrit :
> On Sep 8, 9:52 am, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>
>>TheFlyingDutchman a écrit :
(snip)
>>>class TestOutcomes:
>>>PASSED = 0
>>>FAILED = 1
>>>ABORTED = 2
>>
>>>def ToString(outcome):
>>>if outcome == TestOutcomes.PASSED:
>>>
>
> I'd like to know if the Cheeseshop package 'enum' is useful to
> you. Any constructive feedback would be appreciated.
>
> http://cheeseshop.python.org/pypi/enum/>
Looking at the documentation it looks excellent. But I don't
understand the 0.4.2 version number, particularly when you refer
[EMAIL PROTECTED] writes:
> But it would be much nicer if I had a function to covert to string
> as part of the TestOutcomes class. How would I implement this?
Others have given ad hoc implementations that may do what you want.
I'd like to know if the Cheeseshop package 'enum' is useful to
you.
On Sep 8, 9:52 am, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> TheFlyingDutchman a écrit :
>
>
>
> > On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote:
>
> >>Hi,
>
> >>I have the following class -
>
> >>class TestOutcomes:
> >>PASSED = 0
> >>FAILED = 1
> >>ABORTED = 2
>
> >>plus the foll
TheFlyingDutchman a écrit :
> On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote:
>
>>Hi,
>>
>>I have the following class -
>>
>>class TestOutcomes:
>>PASSED = 0
>>FAILED = 1
>>ABORTED = 2
>>
>>plus the following code -
>>
>>testResult = TestOutcomes.PASSED
>>
>>testResultAsString
>>if testR
[EMAIL PROTECTED] wrote:
> I have the following class -
>
> class TestOutcomes:
> PASSED = 0
> FAILED = 1
> ABORTED = 2
>
> plus the following code -
>
> testResult = TestOutcomes.PASSED
>
> testResultAsString
> if testResult == TestOutcomes.PASSED:
> testResultAsString = "Pas
On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote:
> Hi,
>
> I have the following class -
>
> class TestOutcomes:
> PASSED = 0
> FAILED = 1
> ABORTED = 2
>
> plus the following code -
>
> testResult = TestOutcomes.PASSED
>
> testResultAsString
> if testResult == TestOutcomes.PASSED:
> te
On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have the following class -
>
> class TestOutcomes:
> PASSED = 0
> FAILED = 1
> ABORTED = 2
>
> plus the following code -
>
> testResult = TestOutcomes.PASSED
>
> testResultAsString
> if testResult == TestOutcomes.PASS
On 10 Sep, 13:35, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote:
>
>
>
>
>
> > Hi,
>
> > I have the following class -
>
> > class TestOutcomes:
> > PASSED = 0
> > FAILED = 1
> > ABORTED = 2
>
> > plus the following code -
>
> > testResult = T
On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote:
> Hi,
>
> I have the following class -
>
> class TestOutcomes:
> PASSED = 0
> FAILED = 1
> ABORTED = 2
>
> plus the following code -
>
> testResult = TestOutcomes.PASSED
>
> testResultAsString
> if testResult == TestOutcomes.PASSED:
> te
[EMAIL PROTECTED] wrote:
> But it would be much nicer if I had a function to covert to string as
> part of the TestOutcomes class. How would I implement this?
Perhaps: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413486
--
http://mail.python.org/mailman/listinfo/python-list
On Friday 04 March 2005 02:54 pm, M.N.A.Smadi wrote:
> does python support a C-like enum statement where one can define a
> variable with prespesified range of values?
No, but in most situations where I would've used an enum, I use a
trivial class like this:
class states:
ON, OFF, UNKNOWN,
M.N.A.Smadi wrote:
> does python support a C-like enum statement where one can define a
> variable with prespesified range of values?
The thing is, variables don't have types; objects do. A variable can
be bound to an object of any type, so there's no way to prespecify a
range of values for a va
M.N.A.Smadi wrote:
does python support a C-like enum statement where one can define a
variable with prespesified range of values?
thanks
m.smadi
>>> BLUE, RED, GREEN = 1,5,8
>>> BLUE
1
>>> RED
5
>>> GREEN
8
--
http://mail.python.org/mailman/listinfo/python-list
M.N.A.Smadi wrote:
does python support a C-like enum statement where one can define a
variable with prespesified range of values?
Not built in, but there are various solutions available, some simpler
than others. See the Infrequently Asked Questions:
http://www.norvig.com/python-iaq.html
--
Ste
Not completely sure I understand (my C is weak).
But you can do:
x=range(9)
x's contents will be
[0,1,2,3,4,5,6,7,8]
or
x=range(12,25)
x's conetnst will be
[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
if you mean a way to limit x's contents to a predefined
list of values, you need to
61 matches
Mail list logo