Hello,
Ruby has following feature. Suppose the existing class "Cls" is scope
(either defined before or imported from some module), then the code
like:
class Cls
def mixin_method(args)
...
end
end
Will "reopen" (Ruby term) that class and will add a new method
"mixin_method" to it.
Okay, thanks everyone for the feedback. I accept that there are more
practical difficulties than I expected, and the work-arounds I have are
not too onerous.
--
Steve
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an ema
On Thu, Jan 14, 2021 at 10:07 PM Paul Sokolovsky wrote:
> The question then: what are the best practices in *declarative* syntax
> to achieve the same effect in Python? (but of course, unlike Ruby,
> there should be explicit syntactic marker that we augment existing
> class, not redefine it).
Eas
On Thu, Jan 14, 2021 at 02:05:50PM +0300, Paul Sokolovsky wrote:
[...]
> Semantically, Python can achieve the same with "imperative" syntax like:
>
> def mixin_method(self, args):
> ...
> Cls.mixin_method = mixin_method
>
>
> The question then: what are the best practices in *declarative* s
Hello,
On Thu, 14 Jan 2021 22:14:17 +1100
Chris Angelico wrote:
> On Thu, Jan 14, 2021 at 10:07 PM Paul Sokolovsky
> wrote:
> > The question then: what are the best practices in *declarative*
> > syntax to achieve the same effect in Python? (but of course, unlike
> > Ruby, there should be expli
Hello,
On Thu, 14 Jan 2021 22:19:06 +1100
Steven D'Aprano wrote:
> On Thu, Jan 14, 2021 at 02:05:50PM +0300, Paul Sokolovsky wrote:
>
> [...]
> > Semantically, Python can achieve the same with "imperative" syntax
> > like:
> >
> > def mixin_method(self, args):
> > ...
> > Cls.mixin_method
You could also do this using just the __init_subclass__ method. Create some
class AddMixin, and use it like:
class _(AddMixin, using=mod.Cls):
...
The AddMixin class is something like:
class AddMixin:
def __init_subclass_(cls, *, using, **kwargs):
super().__init_subclass__(**kwar
Hi
There's interest here in arithmetic operations on NaN . I've just seen a
product listed as costing NaN pounds to buy a null amount. That was written
as £NaN/null.
The bargain item is Glade Shake & Vacuum Citrus, and you can see it at
https://www.tesco.com/groceries/en-GB/products/253732570
Se
> On 14 Jan 2021, at 17:14, Jonathan Fine wrote:
>
> Hi
>
> There's interest here in arithmetic operations on NaN . I've just seen a
> product listed as costing NaN pounds to buy a null amount. That was written
> as £NaN/null.
>
> The bargain item is Glade Shake & Vacuum Citrus, and you can