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)
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
> 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
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, and
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
if testResult ==
[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:
testResultAsString = Passed
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.
URL:http://cheeseshop.python.org/pypi/enum/
Looking at the documentation it looks excellent. But I don't
[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 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:
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 = TestOutcomes.PASSED
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.PASSED:
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:
[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 = Passed
elif
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 testResult == TestOutcomes.PASSED:
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 following code -
testResult =
[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.
I'd like to know if the Cheeseshop package 'enum' is useful to
you. Any constructive feedback would be appreciated.
URL: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
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:
return Passed
TheFlyingDutchman [EMAIL PROTECTED] writes:
URL: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
On Sep 10, 7:12 pm, Ben Finney [EMAIL PROTECTED]
wrote:
TheFlyingDutchman [EMAIL PROTECTED] writes:
URL: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
TheFlyingDutchman wrote:
On Sep 10, 7:12 pm, Ben Finney [EMAIL PROTECTED]
wrote:
TheFlyingDutchman [EMAIL PROTECTED] writes:
URL: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
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 the Development
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
understand the 0.4.2
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:
URL:http://cheeseshop.python.org/pypi/enum/
(Please preserve attribution lines so it's clear who 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
if testResult == TestOutcomes.PASSED:
26 matches
Mail list logo