copy

How can Python access the X11 clipboard?

风流意气都作罢 提交于 2019-12-04 09:21:55
问题 I want my Python script to be able to copy and paste to/from the clipboard via x11 (so that it will work on Linux). Can anyone point me to specific resources I can look at, or the concepts I would have to master? Is this possible to do with the Python X library at http://python-xlib.sourceforge.net ? 回答1: I favor a Tkinter-based solution over one which requires pygtk, simply because of the potential the latter has for installation challenges. Given this, my recommendation to Alvin Smith is to

Copy NSMutablearray to another

流过昼夜 提交于 2019-12-04 08:58:38
I am trying to copy NSMutableArray to another but it does not show me anything at the UITableView : NSMutableArray *objectsToAdd= [[NSMutableArray alloc] initWithObjects:@"one",@"two"]; NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:objectsToAdd,nil]; NSMutableArray *list = [[NSMutableArray alloc] init]; [self.list addObjectsFromArray:myArray]; Nothing show up! What is wrong? It crashes my app because I do not have nil at my NSMutableArray how can I add nil to it? addobject:nil does not work it crashes the app: static NSString * DisclosureButtonCellIdentifier = @

copy a graph (adjacency_list) to another one

风格不统一 提交于 2019-12-04 08:23:17
How can I copy a graph of type adjacency_list to another one graph of type adjacency_list ? typedef adjacency_list<setS, setS, undirectedS, NodeDataStruct, EdgeDataStruct> MyGraph; MyGraph g1, g2; // processing g1: adding vertices and edges ... // processing g2: adding some vertices and edges ... g1.clear(); g1 = g2 // this gives an execution error (exception) g1 = MyGraph(g2); // this also gives an execution error g2.clear(); Andrew Durward Have you tried copy_graph ? Hard to know what the problem is without seeing the errors but if I had to guess, I'd first make sure you're providing a

Rcpp Copy a vector to a vector

爷,独闯天下 提交于 2019-12-04 08:09:56
I am new to Rcpp and C++ coding in general, so forgive me for asking basic questions. The cpp part of the code is // test.cpp #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] void testRun() { IntegerVector Grp1 = IntegerVector::create(1,2,3,4); IntegerVector Grp2 = IntegerVector::create(3,4,5,6); Rf_PrintValue(Grp1); Grp1 = Grp2; Rf_PrintValue(Grp1); Grp2[3] = Grp2[3]+1; Rf_PrintValue(Grp1); } and when I run testrun(), I get the output > Rcpp::sourceCpp('test.cpp') > testRun() [1] 1 2 3 4 [1] 3 4 5 6 [1] 3 4 5 7 When I assign Gr2 to Gr1 in Gr1 = Gr2 , changing elements in Gr2 after

Copy files in folder up one directory in python

大憨熊 提交于 2019-12-04 07:45:56
I have a folder with a few files that I would like to copy one directory up (this folder also has some files that I don't want to copy). I know there is the os.chdir("..") command to move me to the directory. However, I'm not sure how to copy those files I need into this directory. Any help would be greatly appreciated. UPDATE: This is what I have now: from shutil import copytree, ignore_patterns copytree("/Users/aaron/Desktop/test/", "/Users/aaron/Desktop/", ignore=ignore_patterns('*.py', '*.txt')) I am getting the following error: Traceback (most recent call last): File "update.py", line 61,

Pythonic way of copying an iterable object

折月煮酒 提交于 2019-12-04 07:12:55
For a small project I'm working on I need to cycle through a list. For each element of this cycle I have to start another cycle through the same list, with the former element as first element of the new cycle. For example I'd like to be able to produce something like this: 1, 2, 3, 4, 1, 2, 3, 4, 1, ... 2, 3, 4, 1, 2, 3, 4, 1, 2, ... 3, 4, 1, 2, 3, 4, 1, 2, 3, ... 4, 1, 2, 3, 4, 1, 2, 3, 4, ... 1, 2, 3, 4, 1, 2, 3, 4, 1, ... ... I thought that copying a itertools.cycle after each .next() would conserve the current state, so that I can begin the new cycle with the element from the "outer" cycle

Copy directories if their subdirectories contain “connect.txt”

血红的双手。 提交于 2019-12-04 07:07:37
问题 I want to copy multiple directories from one location to another location only if any of the subdirectories of those contain connect.txt file in them. Example: ANIMAL\DOG\CONNECT.TXT PLANET\EARTH\CONNECT.TXT SYSTEM\USER\ADMIN.TXT Then I ONLY want to copy ANIMAL & PLANET directories to C:\DESKTOP . 回答1: move *\*\connect.txt C:\Desktop This uses a regular expression which would work if you're really wanting to look only under the subdirectories of all directories at some location. 来源: https:/

how to make a multithread copy files

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:46:05
问题 I want to copy many files in one, but using multiThread,supposing that file A is the file in which different threads copy datas, in this case each thread is meant to copy one file in file A, using this procedure: procedure ConcatenateFiles(const InFileNames: array of string; const OutFileName: string); var i: Integer; InStream, OutStream: TFileStream; begin OutStream := TFileStream.Create(OutFileName, fmCreate); try for i := 0 to high(InFileNames) do begin InStream := TFileStream.Create

Change objects in NSUserDefaults without creating and re-setting copies

家住魔仙堡 提交于 2019-12-04 06:40:47
I've got dictionary stored in NSUserDefaults and I need to add/remove items in this dictionary. It bothers me that to do this I have to create mutable copy of entire dictionary, change one element and replace entire dictionary with new copy. copy = [[defaults objectForKey:@"foo"] mutableCopy]; [copy setObject:… forKey:@"bar"]; [defaults setObject:copy forKey:@"foo"]; and it involves even more copying and re-setting for objects deeper in the hierarchy. Is there a better way? I've tried to use [defaults setValue:… forKeyPath:@"foo.bar"] but that doesn't seem to work (object is not mutable). I

Usage of the “copy” property attribute to maintain an immutable NSString

馋奶兔 提交于 2019-12-04 06:33:46
I am very new to iOS development and programming in Objective-C. I have been doing the exercises on the app dev library. This is the current exercise that I am trying to understand. 3. Test what happens if you set a mutable string as the person’s first name, then mutate that string before calling your modified sayHello method. Change the NSString property declarations by adding the copy attribute and test again. I attempt to do this however, the NSString that I modify does in fact change despite the use of the copy property attribute. Here are my declarations and implementations as well as my