interactive

/usr/bin/find: cannot build its arguments dynamically

会有一股神秘感。 提交于 2019-11-26 21:43:12
问题 The following command works as expected interactively, in a terminal. $ find . -name '*.foo' -o -name '*.bar' ./a.foo ./b.bar $ However , if I do this, I get no results! $ ftypes="-name '*.foo' -o -name '*.bar'" $ echo $ftypes -name '*.foo' -o -name '*.bar' $ find . $ftypes $ My understanding was/is that $ftypes would get expanded by bash before find got a chance to run. In which case, the ftypes approach should also have worked. What is going on here? Many thanks in advance. PS: I have a

Checking for interactive shell in a Python script

痴心易碎 提交于 2019-11-26 20:45:50
I need to determine whether the shell which invoked my Python script was in interactive mode or not. If it was in interactive mode, the program should pipe output to less(1) for easy reading. If not, it should simply print its output to stdout, to allow it to be piped away to a printer, file, or a different pager. In a shell script, I would have checked if the prompt variable $PS1 was defined, or looked for the -i option among the flags stored in the $- variable. What is the preferred method for testing interactivity from within Python? This is often works well enough import os, sys if os

How to assign the result of the previous expression to a variable?

邮差的信 提交于 2019-11-26 18:43:53
Suppose I'm using R's interactive console, and I've just done something like this: long_running_command() That long-running command returns a value, and I've just realized that I wanted to assign that value to a variable instead of discard it. So how can I get that value without running the command again? Is there a command like this? result = get_last_return_value() Marek .Last.value is an answer. It was answered once but you have better title. 来源: https://stackoverflow.com/questions/3689279/how-to-assign-the-result-of-the-previous-expression-to-a-variable

git add --interactive “Your edited hunk does not apply”

浪子不回头ぞ 提交于 2019-11-26 18:33:11
I'm trying to use git add --interactive to selectively add some changes to my index, but I continually receive the "Your edited hunk does not apply. Edit again..." message. I get this message even if I choose the e option, and immediately save/close my editor. In other words, without editing the hunk at all, the patch doesn't apply. Here's the exact example I'm using (I'm trying to put together a small demo): Original file: first change second change off branch third change off branch second change third change fourth change New file: Change supporting feature 1 first change second change off

Interactive matplotlib plot with two sliders

廉价感情. 提交于 2019-11-26 18:24:01
I used matplotlib to create some plot, which depends on 8 variables. I would like to study how the plot changes when I change some of them. I created some script that calls the matplotlib one and generates different snapshots that later I convert into a movie, it is not bad, but a bit clumsy. I wonder if somehow I could interact with the plot regeneration using keyboard keys to increase / decrease values of some of the variables and see instantly how the plot changes. What is the best approach for this? Also if you can point me to interesting links or a link with a plot example with just two

Read password from stdin

本小妞迷上赌 提交于 2019-11-26 15:49:28
Scenario: An interactive CLI Python program, that is in need for a password. That means also, there's no GUI solution possible. In bash I could get a password read in without re-prompting it on screen via read -s Is there something similar for Python? I.e., password = raw_input('Password: ', dont_print_statement_back_to_screen) Alternative: Replace the typed characters with '*' before sending them back to screen (aka browser' style). >>> import getpass >>> pw = getpass.getpass() Yes, getpass : "Prompt the user for a password without echoing." Edit: I had not played with this module myself yet,

What are the available interactive languages that run in tiny memory? [closed]

大憨熊 提交于 2019-11-26 14:59:10
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I am looking for general purpose programming languages that have an interactive (live coding) prompt work in 32 KB of RAM by itself or 8 KB when the compiler is hosted on a separate machine run on a microcontroller with as little as 8-32 KB RAM total (without an MMU). Below is my

get output from a paramiko ssh exec_command continuously

为君一笑 提交于 2019-11-26 13:18:52
问题 I am executing a long-running python script via ssh on a remote machine using paramiko. Works like a charm, no problems so far. Unfortunately, the stdout (respectively the stderr) are only displayed after the script has finished! However, due to the execution time, I'd much prefer to output each new line as it is printed , not afterwards. remote = paramiko.SSHClient() remote.set_missing_host_key_policy(paramiko.AutoAddPolicy()) remote.connect("host", username="uname", password="pwd") #

Implement an interactive shell over ssh in Python using Paramiko?

最后都变了- 提交于 2019-11-26 12:19:29
问题 I want to write a program (in Python 3.x on Windows 7) that executes multiple commands on a remote shell via ssh. After looking at paramikos\' exec_command() function, I realized it\'s not suitable for my use case (because the channel gets closed after the command is executed), as the commands depend on environment variables (set by prior commands) and can\'t be concatenated into one exec_command() call as they are to be executed at different times in the program. Thus, I want to execute

Is there a way to squash a number of commits non-interactively?

 ̄綄美尐妖づ 提交于 2019-11-26 11:51:07
问题 I\'m trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive? 回答1: Make sure your working tree is clean, then git reset --soft HEAD~3 git commit -m 'new commit message' 回答2: I personally like wilhelmtell's solution: git reset --soft HEAD~3 git commit -m 'new commit message' However, I made an alias with some error checking so that you can do this: git squash 3 'my commit message' I recommend setting up aliases that