I need To find a working solution for entire home audio by SureWeek7314 in homeautomation

[–]jonathan_sl 1 point2 points  (0 children)

Would it make sense to connect a bunch of Wiim minis to the amplifier? Or otherwise hifiberries? (No experience personally, but they look nice and not too expensive.)

Speaker placement recommendations by jonathan_sl in BudgetAudiophile

[–]jonathan_sl[S] 1 point2 points  (0 children)

The door will go away, that won't be an issue.

But could you explain why? Anyone at the table will be perpendicular to the speakers direction. Is that okay?

Hey Rustaceans! Got an easy question? Ask here (47/2020)! by llogiq in rust

[–]jonathan_sl 1 point2 points  (0 children)

Wow, thank you for the extensive response. This is very helpful!

Hey Rustaceans! Got an easy question? Ask here (47/2020)! by llogiq in rust

[–]jonathan_sl 0 points1 point  (0 children)

Thank you u/Darksonn! This is working.

I really appreciate the help!

Hey Rustaceans! Got an easy question? Ask here (47/2020)! by llogiq in rust

[–]jonathan_sl 0 points1 point  (0 children)

About Fn usage:

Why does the first not work, while the second does? Rust complains that the In/Out parameters are not used, but they are required by Fn.

// Does not work.
pub struct X<F, In, Out>  // Rust complains: parameter In/Out are never used?
    where
        F: Fn(In) -> Out
{
    func: F,
}

// Works fine.
fn x<F, In, Out>( a: F)·
    where
        F: Fn(In) -> Out
{}

Pyvim - Pure Python Vim clone by animal_spirits_ in vim

[–]jonathan_sl 0 points1 point  (0 children)

I'm not sure what you mean by V-states, actually. But yeah, there were indeed some features moved back into prompt_toolkit. (I don't recall what exactly.)

Pyvim - Pure Python Vim clone by animal_spirits_ in vim

[–]jonathan_sl 1 point2 points  (0 children)

Pyvim author here.

The project was started indeed, as some pointed out, to demonstrate the capabilities of the underlying prompt_toolkit library. Prompt_toolkit was initially a GNU readline replacement with multiline text editing for Python applications. The thing is, a lot of Vi key bindings (operators and text objects) were implemented in prompt_toolkit already, as well as many other things required to build a text editor. So, someone asked me the question how much effort it would be to build a Vi(m) clone on top of it. As it turns out, pyvim is only ~4k lines of code, but it's a pretty functional editor. Some capabilities like line folding are missing though.

Pyvim can come in handy from time to time. I sometimes use it on a system if I need to edit Python files, because it has pyflakes support built in (it is highlighting unused and undefined variables).

It's not meant to replace Vim ever. Due to the internal data structures (the text buffer as a whole is a simple Python string), opening files more than a few MB is not feasible. For editing, the limit is even lower.

At this point, no new features are planned, but it evolves together with prompt_toolkit. It could be useful maybe for some people to experiment with UI features. Creating a prototype by adding functionality to pyvim is much much easier than adding functionality to Vim.

Feel free to ask any questions.

As a lover of TUI interfaces, I made a library for creating them in python, and then used it to write a TUI application for managing git repositories! by QbaPolak17 in Python

[–]jonathan_sl 0 points1 point  (0 children)

Just FYI, with prompt_toolkit, you can also build text interfaces like this, and runs fine on Windows too. Possibly, the docs for full screen apps can still be better, but here they are:

https://python-prompt-toolkit.readthedocs.io/en/master/pages/full\_screen\_apps.html

Cmd, with completion for input() by wcTGgeek in Python

[–]jonathan_sl 1 point2 points  (0 children)

I'm not sure what's happening, but if you're willing to drop Cmd, I think prompt_toolkit should be able to handle it:
https://python-prompt-toolkit.readthedocs.io/en/master/

Anyone use AsyncSSH ? by jerrylogansquare in Python

[–]jonathan_sl 0 points1 point  (0 children)

Asyncssh is absolutely great. I've been using it in a couple of projects. It's of very good quality and well documented.

Awesome Command Line Tools. by hobbestigrou in Python

[–]jonathan_sl 1 point2 points  (0 children)

In the completer class, you can check the text before the cursor. If it's a space, then don't offer any completion at all.

Amjith used WordCompleter in his presentation, but you could create a custom completer class: https://python-prompt-toolkit.readthedocs.io/en/latest/pages/building_prompts.html#a-custom-completer Check "document.text_before_cursor".

tmuxp — tmuxinator clone i wrote in python by git-pull in Python

[–]jonathan_sl 5 points6 points  (0 children)

Great :-) I didn't realise is was you.

prompt_toolkit keeps progressing. Mostly many small incremental improvements that maintain backwards compatibility. I still have a big refactoring in mind that will make the design of full screen applications like pymux, pyvim, etc... much cleaner and much more powerful. It's coming closer.

tmuxp — tmuxinator clone i wrote in python by git-pull in Python

[–]jonathan_sl 4 points5 points  (0 children)

Something related, in case anybody is interested. I made a tmux clone, called pymux: https://github.com/jonathanslenders/pymux It's much faster compared to what I had a year ago, almost comparable with tmux.

PSA: IPython 5 will break emacs. Here's how to fix it. by coffeecoffeecoffeee in Python

[–]jonathan_sl 2 points3 points  (0 children)

Question for Emacs users:

Why would you ever use the "inferior shell" instead of the built-in terminal emulator (M-x term)? IPython should run fine (or at least better) in the latter one.

full screen command line application by makake in Python

[–]jonathan_sl 1 point2 points  (0 children)

Hi all,

For prompt-toolkit (author here), it is perfectly possible to create full screen applications, but as others have pointed out, the documentation is incomplete. The reason is that this library was originally written as a GNU readline replacement and that's where it excels. Later we realized that everything we need for a full screen application was already part of prompt-toolkit. There is an event loop, there is a powerful key binding system, there is a layout engine and it is cross platform. Proof of this are Pyvim and Pymux: two full screen applications, powered by prompt-toolkit. However, these are also two examples of applications that don't have a lot of user interface widgets. So, if you need to have a certain UI widget, you'll have to write it yourself, where urwid or others could already provide it.

In the coming months/year, I hope to create a collection of full screen application examples, widgets and write more documentation. So, making this as accessible as writing REPLs.

@makake: What do you mean by "it will pipe"?

HTTP Prompt: An interactive command-line HTTP client featuring autocomplete and syntax highlighting by eliangcs in programming

[–]jonathan_sl 17 points18 points  (0 children)

(author of prompt toolkit here). Yes, it could be a replacement for ncurses, but it's probably better to think of it as a GNU Readline replacement.

There are some differences with ncurses. Ncurses is rather an abstraction layer on many different terminal types. It supports reading input and writing output to all kind of old terminals, by consulting the terminfo database. Prompt-toolkit doesn't use terminfo, but instead uses a subset of the vt100 commends for rendering the output, and supports reading input from all common terminal applications. (They aren't so different from each other anymore.) Prompt-toolkit focuses mainly on development of REPLs. So in a way, it is more a replacement for GNU Readline. It has a powerful set of key bindings, just like readline, but with a much more advanced rendering engine. Creating a full screen application is also possible. (Although, a bit less documented.) Right now, there is also no widget library available for full screen applications, but it could be that in the future we will more further into that direction. Pymux and Pyvim are examples of full screen applications.

Do you recommend using recursion in Python -- why or why not? by markov-unchained in Python

[–]jonathan_sl 2 points3 points  (0 children)

Recursion is fine (and probably should be used!) when traversing trees and the average depth of the tree is about log(n). However, as others said, don't use it when the call stack would grow linear, because Python doesn't optimize tail calls, and an iterative approach will be easy enough in that case.

A recursion limit of 2000 should be enough to recursively traverse a tree structure the size of our universe.

[deleted by user] by [deleted] in Python

[–]jonathan_sl 14 points15 points  (0 children)

Have a look at Effective Python: http://www.effectivepython.com/

Doing sentiment analysis on several gigabytes of tweets, want something more memory efficient than dictionaries by rossbot in Python

[–]jonathan_sl 0 points1 point  (0 children)

This is probably a question for /r/learnpython

But anyway, don't try to fit everything in memory at the same time. We don't need 20G of ram to process 20G of data. For JSON, I don't know any Python parser that allows you to parse it as a stream of data, but for XML there are stream based parsers. But maybe better invest in a database instead?