Using __new__

2024-02-17 Thread Jonathan Gossage via Python-list
I am attempting to use the __new__ method in the following code: class SingletonExample(object): _instance = None def __new__(cls, **kwargs): if cls._instance is None: cls._instance = super().__new__(cls, **kwargs) return cls._instance def __init__(self, *

Re: Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
Mon, Sep 25, 2023 at 11:15 AM Thomas Passin via Python-list < python-list@python.org> wrote: > On 9/25/2023 10:15 AM, Jonathan Gossage via Python-list wrote: > > I am having a problem using generator expressions to supply the arguments > > for a class instance initialization.

Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
I am having a problem using generator expressions to supply the arguments for a class instance initialization. The following example shows the problem: class test1(object): def __init__(self, a, b): > self.name = a self.value = b st = 'Programming Renaissance, Any'.split(', '

Forward References

2023-09-03 Thread Jonathan Gossage via Python-list
I am attempting to use forward references in my program and I am failing. This also does not work with the older way of putting the name of a class as a string. Here is some sample code: from __future__ import annotations from dataclasses import dataclass from typing import TypeAlias ColorDef: