command

How can I convert string to source code in python?

随声附和 提交于 2020-01-30 08:25:26
问题 As you see, ifinner is a string, so if I just write after if, always will be true. What can i do, to concert it to source code? x=2 ifinner = "x==3" if ifinner: print("Yeah") else: print("It works!") 回答1: You can use eval() function to evaluate Python source code. Quoting the documentation: eval(expression, globals=None, locals=None) The arguments are a string and optional globals and locals . If provided, globals must be a dictionary. If provided, locals can be any mapping object. 回答2: Try

How to print #!/bin/bash using echo command [duplicate]

穿精又带淫゛_ 提交于 2020-01-30 05:52:06
问题 This question already has answers here : Why can't I echo the characters #! in a string in bash? [duplicate] (5 answers) Closed 5 years ago . I have tried the escape character but it doesn't seems works with ! . I need this to auto-configure packages using scripts. 回答1: ! is magic in a default interactive bash session, but not in scripts ( set +H to disable in an interactive prompt). In any case: echo '#!/bin/bash' 回答2: Or with no quotes and escaping the # and the ! : echo \#\!/bin/bash 回答3:

Unix help to extract/print 50 lines after every 3rd occurrence pattern till end of file

江枫思渺然 提交于 2020-01-25 14:33:55
问题 I need help with extract/print 4 lines after every 3rd occurrence pattern till end of file. Consider below is example of log file ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 1 Extract line 2 Extract line 3 Extract line 4 ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 5 Extract line 6 Extract line 7 Extract line 8 ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 9 Extract line 10 Extract line 11 Extract

Unix help to extract/print 50 lines after every 3rd occurrence pattern till end of file

馋奶兔 提交于 2020-01-25 14:31:28
问题 I need help with extract/print 4 lines after every 3rd occurrence pattern till end of file. Consider below is example of log file ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 1 Extract line 2 Extract line 3 Extract line 4 ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 5 Extract line 6 Extract line 7 Extract line 8 ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND ERROR_FILE_NOT_FOUND Extract line 9 Extract line 10 Extract line 11 Extract

Add a single file to each rar file in a folder

帅比萌擦擦* 提交于 2020-01-25 03:53:05
问题 I'm trying to figure out how to add a file in each .rar file in a folder. For example I have: rar1.rar rar2.rar rar3.rar And I want the 'readme.txt' file added to each of them. Or if that isn't possible I can just extract all the .rar files turning them into folder then use this batch code to compress them? How do I include the readme.txt file? @ECHO OFF cd C:\Users\userss\Desktop\compressing SET PATH=C:;C:\Program Files\WinRAR;C:\Windows\system32;C:\Windows;C:\Win dows\System32\Wbem;%PATH%

Using >nul in a variable

泄露秘密 提交于 2020-01-24 19:50:21
问题 Does anyone know how to stop >nul being ignored when set in a variable, or is this not possible? I have a feeling that it's one of those things that will only work once all variables have been expanded or something, but it can't hurt to ask. Example: @echo off :: Won't work SET pause_5=ping localhost /n 6 >nul %pause_5% :: Will work SET pause_5=ping localhost /n 6 %pause_5% >nul exit 回答1: Put quotes around the argument: set "pause_5=ping localhost /n 6 >nul" Another option is to escape

In WPF,MVVM should ViewModel be involved in opening a window, e.g. About-window?

送分小仙女□ 提交于 2020-01-24 17:08:06
问题 I have a standard WPF treeview and have bound items to view model classes. I now wish to handle behaviour when items are double-clicked (opening documents visual-studio-style). I can get event-handler to fire in the control housing the treeview (xaml shown), but how do I bind to specific behaviour on the view model classes - e.g. ProjectViewModel? Preferable bound to ICommand-implementer, as this is used elsewhere... Thanks for any comments, Anders, Denmark <TreeView ItemsSource="{Binding

In WPF,MVVM should ViewModel be involved in opening a window, e.g. About-window?

南笙酒味 提交于 2020-01-24 17:08:05
问题 I have a standard WPF treeview and have bound items to view model classes. I now wish to handle behaviour when items are double-clicked (opening documents visual-studio-style). I can get event-handler to fire in the control housing the treeview (xaml shown), but how do I bind to specific behaviour on the view model classes - e.g. ProjectViewModel? Preferable bound to ICommand-implementer, as this is used elsewhere... Thanks for any comments, Anders, Denmark <TreeView ItemsSource="{Binding

SQL get number of columns in a particular row having a particular value

♀尐吖头ヾ 提交于 2020-01-24 14:27:41
问题 I know that I can get the number of rows having a particular value in a particular column by making use of the COUNT(*) function, but I want to find the number of COLUMNS in a particular row that have a particular value. Any suggestions on how to do this? I would have posted an example of what I've tried up till now, but I'm completely lost on this one... Edit 1 - Here's some sample data and the expected result: Table - trackbill | u1 | u1paid | u2 | u2paid | u3 | u3paid | u4 | u4paid | u5 |

WPF Two Commands handlers, One Command

假如想象 提交于 2020-01-22 15:21:09
问题 Im deriving from a third party control. It is implementing ApplicationCommands.SelectAll. However the behaviour i want is slightly different. there is no virtual method i can override, and when i register a class handler, like so CommandManager.RegisterClassCommandBinding(typeof(MyDerivedControl), new CommandBinding(ApplicationCommands.SelectAll, new ExecutedRoutedEventHandler(OnExecutedSelectAll), new CanExecuteRoutedEventHandler(OnCanExecuteSelectAll))); My methods do not get called. The