[Python-ideas] Standard tool for iterating over recursive data structures?

2020-12-31 Thread Steven D'Aprano
This isn't so much an idea for Python, as a request for ideas to solve a problem in Python. Back in the early days of Python, printing recursive lists could crash the interpreter: a = [1, 2, 3] a.append(a) print(a) If you try that today, you get a nice display: [1, 2, 3,

[Python-ideas] Re: Add user defined __eq__ to itertools.cycle class

2020-12-31 Thread Andres Torres
Link is broken :/ It should be https://github.com/sqlalchemy/sqlalchemy/issues/5810 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Add user defined __eq__ to itertools.cycle class

2020-12-31 Thread Andres Torres
Yep, thanks for the explanation! After some more research into this it appears this exact situation is accounted for within the `SQLAlchemy` library (reference: https://github.com/sqlalchemy/sqlalchemy/issues/5810)! Additionally, due to the complications brought up in this thread it seems like

[Python-ideas] Re: built in to clear terminal

2020-12-31 Thread Stephen J. Turnbull
Mike Miller writes: > Note, I added the word *important* on purpose. ;-) Ie, since you were lucky enough the time you did something like it, it's not important to anybody? > Reminds me of a story. As an teen I learned the lesson of what > happens when you flip the power switch of the

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

2020-12-31 Thread Stephen J. Turnbull
Brendan Barnwell writes: > So, to give an example, the iterator protocol should be documented > right where the `for` statement is documented, and it should be > explicitly framed as "this is the definition of what the `for` statement > does", not something separate. But for the

[Python-ideas] Re: Right way to dataclass -> dict conversion.

2020-12-31 Thread Eric V. Smith
On 12/31/2020 3:59 PM, Eric V. Smith wrote: On 12/31/2020 3:18 PM, Christopher Barker wrote: On Thu, Dec 31, 2020 at 11:51 AM Eric V. Smith > wrote: I'd suggest you just write your own function to do this. I consider adding dataclasses.asdict and .astuple to

[Python-ideas] Re: Add asyncSetUpClass and asyncTearDown to IsolatedAsyncioTestCase

2020-12-31 Thread Andres Torres
Would it be possible to amend the code to have them exist at this stage? Please forgive me if this is a silly question as I am not that well acquainted with asynchronous programming. Additionally, in the title there is a typo, it should say Add asyncSetUpClass and asyncTearDown__**Class**__

[Python-ideas] Re: Add user defined __eq__ to itertools.cycle class

2020-12-31 Thread Andres Torres
Thank you for reviewing my proposal. First and foremost, let me address the use case for this feature. I have an `SQL` database where I store `itertools.cycle` objects (via pickling) and I use SQLAlchemy to interact with this database. Whenever I "update" the cycler, by calling `next` on the

[Python-ideas] Re: PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
In this case, I was able to change my code to require the context be established outside of the call to the asynchronous generator. It puts more burden on the caller to setup context before making the call. Without a solution in place, is there a legitimate case for a context manager being

[Python-ideas] Re: PEP 533 Redux?

2020-12-31 Thread Brendan Moloney
This bit me a while back, and I spent some time reading through the PEP 533 discussion. It was determined that changing the default behavior of for loops would break too much code. I wonder if the new PEG parser would allow us to decorate for loops with context sensitive keywords to override

[Python-ideas] Re: Right way to dataclass -> dict conversion.

2020-12-31 Thread Eric V. Smith
On 12/31/2020 3:18 PM, Christopher Barker wrote: On Thu, Dec 31, 2020 at 11:51 AM Eric V. Smith > wrote: I'd suggest you just write your own function to do this. I consider adding dataclasses.asdict and .astuple to be mistakes. I agree there -- if you want

[Python-ideas] PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
I've now encountered an issue I believe that PEP 533 was intended to address: When an asynchronous context manager is created within an asynchronous generator, if the generator is not iterated fully, the context manager will not exit until the event loop cancels the task by raising a 

[Python-ideas] Re: Right way to dataclass -> dict conversion.

2020-12-31 Thread Christopher Barker
On Thu, Dec 31, 2020 at 11:51 AM Eric V. Smith wrote: > I'd suggest you just write your own function to do this. I consider > adding dataclasses.asdict and .astuple to be mistakes. > I agree there -- if you want something that can be used like this -- use a dict in the first place :-) Eric:

[Python-ideas] Re: Right way to dataclass -> dict conversion.

2020-12-31 Thread Eric V. Smith
On 12/29/2020 3:04 PM, Anton Abrosimov wrote: Way 5: Add default `False` `iter` flag to `dataclass` decorator. ``` def __iter__(self) : return ((f.name, getattr(axes, f.name)) for f in fields(axes)) ``` And use: `plot(**dict(axes))` I'd suggest you just write your own function to

[Python-ideas] Re: A PEP to encourage people to mind docstrings in stub files

2020-12-31 Thread Eric Traut
Many Python developers rely heavily on docstrings for interactive feedback during coding. Docstrings are consumed by language servers like [Pylance](https://github.com/microsoft/pylance-release) and [Pyright](https://github.com/microsoft/pyright) for completion suggestions, signature help

[Python-ideas] Re: pathlib enhancements

2020-12-31 Thread Todd
Hi Sven, Thanks for your support and feedback. On Thu, Dec 31, 2020, 07:23 Sven R. Kunze wrote: > Hi Todd, > > my comments below. Also would offer my time for reviewing/testing if > wanted. > > > On 22.11.20 20:53, Todd wrote: > > I know enhancements to pathlib gets brought up occasionally,

[Python-ideas] Re: pathlib enhancements

2020-12-31 Thread Sven R. Kunze
Hi Todd, my comments below. Also would offer my time for reviewing/testing if wanted. On 22.11.20 20:53, Todd wrote: I know enhancements to pathlib gets brought up occasionally, but it doesn't look like anyone has been willing to take the initiative and see things through to completion.  I

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

2020-12-31 Thread Chris Angelico
On Thu, Dec 31, 2020 at 3:13 PM Brendan Barnwell wrote: > > On 2020-12-29 15:01, Christopher Barker wrote: > > along with a COMPLETE list of > > the language features that make use of that protocol. > > > > > > That is pretty much impossible -- that's kind of the point of a protocol > >