On 20/11/2019 08:25, Stephen J. Turnbull wrote:
Rob Cliffe via Python-ideas writes:
> I (and no doubt others) am less likely to engage with a thread if I
> have to spend more time than necessary trying to understand it.
You write as if that's a bad thing.;-) I consider that I often make
Rob Cliffe via Python-ideas writes:
> I (and no doubt others) am less likely to engage with a thread if I
> have to spend more time than necessary trying to understand it.
You write as if that's a bad thing. ;-) I consider that I often make
the largest contribution to this list by reading
On 20/10/2019 03:56:22, Steve Jorgensen wrote:
When using a custom classdict to implement a DSL or use in the body of a class
definition, from what I can tell by experiment, the classdict takes priority,
and the surrounding context is only referenced if trying to get an item from
the
On 10/22/2019 03:13 PM, Steve Jorgensen wrote:
Ethan Furman wrote:
Experimenting is good! However, you'll want to either build your own metaclass
and/or prepared dict, or do some work on your __new__/__init__
methods for building enum members. Currently, you are reassigning _value_ in
Ethan Furman wrote:
> > Experimenting is good! However, you'll want to either build your own
> > metaclass
> and/or prepared dict, or do some work on your __new__/__init__
> methods for building enum members. Currently, you are reassigning _value_ in
> __init__, which leaves some internal
On 10/21/2019 10:33 PM, Steve Jorgensen wrote:
class ChoiceEnum(Enum):
def __init__(self, src=None, label=None):
super().__init__()
if isinstance(src, Label):
value = None
label = str(src)
else:
Andrew Barnert wrote:
> On Oct 20, 2019, at 03:36, Steve Jorgensen ste...@stevej.name wrote:
> And there are multiple PyPI projects that build Django choices on top of
> Enum, which
> show that the only thing you need is to override __getitem__ to replace its
> mapping
> behavior with sequence
Andrew Barnert wrote:
> On Oct 20, 2019, at 03:36, Steve Jorgensen ste...@stevej.name wrote:
> Maybe the additional functionality in Enum gets in your way for some reason I
> don’t
> understand, that doesn’t affect other people who want Django choices. But
> otherwise, I
> don’t see how it
Steve Jorgensen wrote:
> Oops. Obviously, the above is pseudo-code because I left ('~OTHER~',
> 'Something
> else') the first assert, and I have (Food, Food) instead of
> (Food,) * 4 for the second assert. Possibly some other mistakes as well.
Umm, like the fact that I'm testing for colors
Oops. Obviously, the above is pseudo-code because I left `('~OTHER~',
'Something else')` the first assert, and I have `(Food, Food)` instead of
`(Food,) * 4` for the second assert. Possibly some other mistakes as well.
___
Python-ideas mailing list --
Anders Hovmöller wrote:
> We try to do the same thing in various libraries. We've settled on using
> existing
> python and end up with syntax like:
> class MyForm(Form):
> field = Field()
> or in your case
> class Colors(TokenContainer):
> red = Token()
> green = Token()
> blue =
On Oct 20, 2019, at 03:36, Steve Jorgensen wrote:
>
> Andrew Barnert wrote:
>> What you’re describing is just enum.Enum, minus half its features, but a
>> sequence
>> instead of a mapping.
>> I’m not sure why you’d ever want this,
>
> Actually, it's a bit different. This is for building a
On 10/19/2019 11:25 PM, Andrew Barnert via Python-ideas wrote:
On Oct 19, 2019, at 22:57, Steve Jorgensen wrote:
The idea is to use a class as a singleton collection of choices where every
choice appears both as an attribute of the class/singleton and as a value/label
pair when treating it
> On 20 Oct 2019, at 12:41, Steve Jorgensen wrote:
>
> Anders Hovmöller wrote:
>> We try to do the same thing in various libraries. We've settled on using
>> existing
>> python and end up with syntax like:
>> class MyForm(Form):
>>field = Field()
>> or in your case
>> class
Anders Hovmöller wrote:
> We try to do the same thing in various libraries. We've settled on using
> existing
> python and end up with syntax like:
> class MyForm(Form):
> field = Field()
> or in your case
> class Colors(TokenContainer):
> red = Token()
> green = Token()
> blue =
Andrew Barnert wrote:
> What you’re describing is just enum.Enum, minus half its features, but a
> sequence
> instead of a mapping.
> I’m not sure why you’d ever want this,
Actually, it's a bit different. This is for building a collection of
value/label pairs where the values are as likely to
Steven D'Aprano wrote:
> I've read the entire thread, and I don't understand what builtins has to
> do with your problem.
Just that, as a workaround, I can have the classdict object raise KeyError for
anything that's a member of builtins so that the builtins are used instead of
being masked.
On Sun, Oct 20, 2019 at 02:56:22AM -, Steve Jorgensen wrote:
> I have been able to at least unmask builtins by having the classdict
> object first try to get a result from `__builtins__` and then fall
> back to itself.
I've read the entire thread, and I don't understand what builtins has
On Oct 19, 2019, at 22:57, Steve Jorgensen wrote:
>
> The idea is to use a class as a singleton collection of choices where every
> choice appears both as an attribute of the class/singleton and as a
> value/label pair when treating it as a sequence.
What you’re describing is just enum.Enum,
We try to do the same thing in various libraries. We've settled on using
existing python and end up with syntax like:
class MyForm(Form):
field = Field()
or in your case
class Colors(TokenContainer):
red = Token()
green = Token()
blue = Token()
(this is using
Several requests for a specific use case. This is something I have been working
on just to practice getting a deeper understanding of Python metaprogramming,
so whether this is something that someone should be trying to do is, of course,
a matter of opinion.
The idea is to use a class as a
Steve Jorgensen wrote:
> I'm not sure what the best way to deal with this would be, but my first
> thought is to
> maybe have a property that can be set on the metaclass type such as
> metacls.relictant_classdict = True.
Oops. Typo. That should say `metacls.reluctant_classdict = True`.
> That said, though, I'm not sure that this was even what you were asking
about :)
It would be significantly more helpful if the OP had an example for the
specific case where they wanted contextually defined variables to take
priority over the classdict, and explained _why_ this behavior might be
On 10/19/2019 07:56 PM, Steve Jorgensen wrote:
When using a custom classdict to implement a DSL or use in the body of a class
definition, from what I can tell by experiment, the classdict takes priority,
and the surrounding context is only referenced if trying to get an item from
the
24 matches
Mail list logo