[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Jan Kaliszewski
2021-02-18 Chris Angelico dixit: [...] > Okay. Let's start bikeshedding. If SimpleNamespace were to become a > builtin, what should its name be? It needs to be short (obviously), > but not TOO short, and it needs to be at least somewhat descriptive, > and it needs to not cause confusion with

[Python-ideas] Re: SimpleNamespace vs object

2021-02-20 Thread Jan Kaliszewski
2021-02-17 Ricky Teachey dixit: > * patsy I love this one! :-) Cheers. *j PS. But it should be callable and, when called, it should raise RuntimeError("It's only a model!") ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Re: Best practices of class "reopening" a-la Ruby?

2021-01-17 Thread Jan Kaliszewski
2021-01-14 Paul Sokolovsky dixit: > 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

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-28 Thread Jan Kaliszewski
2020-12-28 Christopher Barker dixit: > I don't know about the OP, but all I wanted was a clear definition of > the part of the API needed to support **, and apparently it's a > keys() method that returns an iterator of the keys, and a __getitem__ [...] To be more precise: an *iterable* of the

Re: [Python-ideas] Catching the return value of a generator at the end of a for loop

2019-04-16 Thread Jan Kaliszewski
Hello, 2019-04-16 Stefano Borini dixit: > def g(): > yield 2 > yield 3 > return 6 [...] > for x in g() return v: > print(x) > > print(v) # prints 6 I like the idea -- occasionally (when dealing with `yield from`-intensive code...) I wish such a shortcut existed. I don't like

Re: [Python-ideas] Improving Catching Exceptions

2017-07-07 Thread Jan Kaliszewski
2017-06-25 Greg Ewing dixit: > > (2) There's a *specific* problem with property where a bug in your > > getter or setter that raises AttributeError will be masked, > > appearing as if the property itself doesn't exist. [...] > Case 2 needs to be addressed within the

Re: [Python-ideas] + operator on generators

2017-06-29 Thread Jan Kaliszewski
2017-06-25 Serhiy Storchaka dixit: > 25.06.17 15:06, lucas via Python-ideas пише: > > I often use generators, and itertools.chain on them. > > What about providing something like the following: > > > > a = (n for n in range(2)) > > b = (n for n in range(2, 4)) >

Re: [Python-ideas] + operator on generators

2017-06-29 Thread Jan Kaliszewski
2017-06-27 Stephan Houben dixit: > Is "itertools.chain" actually that common? > Sufficiently common to warrant its own syntax? Please, note that it can be upturned: maybe they are not so common as they could be because of all that burden with importing from separate module

Re: [Python-ideas] Defer Statement

2017-06-04 Thread Jan Kaliszewski
Hello, 2017-06-04 Nathaniel Smith dixit: > class LazyConstants: > def __getattr__(self, name): > value = compute_value_for(name) > setattr(self, name, value) > return value > > __getattr__ is only called as a fallback, so by setting the computed >