[Python-ideas] Re: tkinter Variable implementation

2020-12-12 Thread William Pickard
Actually, the error message should read something like this: A valid instance of Tk is required. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: a new data type: NamedValue -- similar to Enum

2020-12-12 Thread Steven D'Aprano
On Sat, Dec 12, 2020 at 07:01:55PM -0800, Ethan Furman wrote: > That's invalid. Duplicates allowed means: > > > ``` > > class K( NamedValue): > > A = 1 > > B = 1 > > ``` > B is not an alias for A. Presumably one has the same number with different > meaning. If that were an Enum: >

[Python-ideas] Re: a new data type: NamedValue -- similar to Enum

2020-12-12 Thread Steven D'Aprano
On Sat, Dec 12, 2020 at 06:00:17PM -0800, Ethan Furman wrote: > Enum is great! Okay, okay, my opinion might be biased. ;) > > There is one area where Enum is not great -- for a bunch of unrelated > values. I don't know how to interpret that. Surely *in practice* enums are always going to be

[Python-ideas] Re: a new data type: NamedValue -- similar to Enum

2020-12-12 Thread Ethan Furman
On 12/12/20 6:40 PM, Guido van Rossum wrote: unlike Enum, duplicates are allowed What does this even mean? ``` class K( NamedValue):     A = 1     A = 2 ``` That's invalid. Duplicates allowed means: > ``` > class K( NamedValue): > A = 1 > B = 1 > ``` B is not an alias for A.

[Python-ideas] Re: a new data type: NamedValue -- similar to Enum

2020-12-12 Thread Guido van Rossum
Okay, I'll bite. On Sat, Dec 12, 2020 at 6:00 PM Ethan Furman wrote: > unlike Enum, duplicates are allowed > What does this even mean? ``` class K( NamedValues): A = 1 A = 2 ``` Why would I want that? > unlike Enum, new values can be added after class definition > Sure, that points

[Python-ideas] tkinter Variable implementation

2020-12-12 Thread Ivo Shipkaliev
Hiya :) I'm recently working with tkinter and I noticed that: >>> import tkinter as tk >>> string_var = tk.StringVar() is throwing an AttributeError: > Traceback (most recent call last): > . . . > File "...\lib\tkinter\__init__.py", line 505, in __init__ > Variable.__init__(self,

[Python-ideas] a new data type: NamedValue -- similar to Enum

2020-12-12 Thread Ethan Furman
Enum is great! Okay, okay, my opinion might be biased. ;) There is one area where Enum is not great -- for a bunch of unrelated values. What would be nice is if we had something similar to Enum for the - repr() - constantness of the name/value relationship While I was looking in the

[Python-ideas] Re: Typed Python execution mode

2020-12-12 Thread Steven D'Aprano
On Thu, Dec 10, 2020 at 09:18:32PM -, redrad...@gmail.com wrote: > I do not want to make type-checker a part of CPython, I just what > options that will allow to run python with first some type-checker ... Okay. So we have a standard interpreter option to run a type-checker. Then tomorrow

[Python-ideas] Re: Typed Python execution mode

2020-12-12 Thread redradist
It is not to get something in stdlib, it is simple option in cli )) ___ 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/

[Python-ideas] Re: Conditional with statements

2020-12-12 Thread Steven D'Aprano
On Fri, Dec 11, 2020 at 07:41:27PM -0500, Jonathan Crall wrote: > If `__if__` was defined then > > ``` > with Ctx(): > print('hi') > ``` > > would only print `hi` if `__if__` returned True. This doesn't require a > syntax change. How do you pass arguments to the "if" dunder? A generalised