Vote count: 0 I am creating a sql query in python of the sort: select lastupdatedatetime from auth_principal_entity where lastupdateddatetime < '02-05-16 03:46:51:527000000 PM' When it is executed, there are escape sequences that are being added which doesn't retu me answers. Although when we print it in stdout, it looks perfect, but for python's understanding it has escape sequences which I don't want in the execution command 'select lastupdatedatetime from auth_principal_entity where lastupdat...
ادامه مطلبVote count: -1 So in python I have a dictionary that is composed of a name for the key and a class object associated with the name as the object. I need to append these objects to a list one by one from the dictionary, however when I attempt to use a for loop to do so it only appends the same object over and over agian. When I try to append dict.values(), I have them appended to a list but with the word dict_values being the first thing in the list when it should only be the values themselves. D...
ادامه مطلبVote count: 0 I have the following code: class CEvent { public: CEvent(std::string const&) {} }; std::unordered_map m_messageList; CEvent& GetMessageEvent(std::string const& name) { auto it = m_messageList.find(name); if (it != m_messageList.end()) { auto pair = m_messageList.emplace(std::piecewise_construct, std::forward_as_tuple(name), // Copy-construct 'name' as the key std::forward_as_tuple(name)); // Construct CEvent in-place with the name retu pair.first->second; } retu it->second; } (Live...
ادامه مطلبVote count: 323 I'm a bit confused about how Java generics handle inheritance / polymorphism. Assume the following hierarchy - Animal (Parent) Dog - Cat (Children) So suppose I have a method doSomething(List animals). By all the rules of inheritance and polymorphism, I would assume that a List is a List and a List is a List - and so either one could be passed to this method. Not so. If I want to achieve this behavior, I have to explicitly tell the method to accept a list of any subset of Animal ...
ادامه مطلبVote count: 0 So i need to delete a specific object under the index number of how many times my loop has passed in an arraylist. lets say i want to delete my object that has an index 0 on arraylist but the object on index 1 and index 2 (and so on) still need to be the same index number as before i removed index 0. for (int i = 0; i < 4 i++) { player thisPlayer = players.get(i); if (not important){ players.remove(thisPlayer); } if player 1 needs to be removed, the other players need to maintain t...
ادامه مطلبVote count: -2 For eg if I have old_list = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9] and I want to remove elements with more than (x = 2) 2 instances and make it look like this new_list = [1, 3, 4, 5, 7, 8] asked 1 min agoDisObs Let's block ads!...
ادامه مطلبVote count: 0 how do you compare each element of a list and print out the higher value at each index? use def compare_list(my_list1, my_list2) asked 43 secs agoEmily Let's block ads!...
ادامه مطلبVote count: -1 I have a file with information about sequences. Every sequence has some lines. The sequences are separated by five white lines. I want to change the file into a list, and split it by 5 newlines. So that I have a list, with every sequence as one element. Then I want to remove the sequences that not contain the regular expression. At the end, I want a list, with only the sequences that contain the regex. Now I have this. Can anyone help me further? import re def main(): ReadFile() f...
ادامه مطلبVote count: 0 This may be a basic question but I am struggling with a way to count values without doing multiple foreach loops. I have this array of objects (partial list included): array(51) { [0]=> object(stdClass)#971 (4) { ["hole"]=> string(1) "2" ["club"]=> string(1) "6" ["shot_type"]=> string(1) "6" ["shot_loc"]=> string(1) "6" } [1]=> object(stdClass)#970 (4) { ["hole"]=> string(1) "2" ["club"]=> string(2) "16" ["shot_type"]=> string(1) "8" ["shot_loc"]=> string(1) "1" } [2]=> object(stdC...
ادامه مطلبVote count: 0 I am looking for a nice way to get the list of functions used in a R script. Either using a dictionary or simply using R parser? Thank you asked 1 min agoRockScience Let's block ads!...
ادامه مطلبVote count: 0 I have a numpy.array, called grid, with shape: grid.shape = [N, M_1, M_2, ..., M_N] The values of N, M_1, M_2, ..., M_N are known only after initialization. For this example, let's say N=3 and M_1 = 20, M_2 = 17, M_3 = 9 I am trying to loop over this array, as follows: for indices, val in np.ndenumerate(grid[0]): print indices _some_func_with_N_arguments(*grid[:, indices]) However grid[:, indices] retus an array which is 3 x 3 x 17 x 9, whereas I want it to be an array of three ele...
ادامه مطلبVote count: 0 I know how thew syntax works for this, but I would like to know the process of how python replaces and alters the list on the left hand side. Ex. L = [0, 1, 2, 3, 4] L[0:2] = [5] print L #L is now [5, 2, 3, 4] So how does python go about the process above? This may be very unclear and I apologize in advance. Thank you. asked 2 mins agoSpegooterCode Let's block ads!...
ادامه مطلبVote count: 0 I'm quite new to C# and still leaing, my apologies if this is a simple question. When a user orders an item(s), the items are assigned an OrderId which is then related to an Order using this OrderId. Now however I need to link both of these and display them so only the user ordering them can view them(Based on the Useame which is stored in Orders Class) How would I do this in my ViewOrdersController? asked 1 min agoAndre Queen Let's block ads!...
ادامه مطلبVote count: 0 Here is what I've done so far: struct rep_list { struct node *head; struct node *tail; } typedef rep_list *list; int length(const list lst) { if (lst->head == NULL) { retu 0; } else { lst->head = lst->head->next; retu 1 + length(lst); } } This works, but the head of the list the function accepts as a parameter gets changed. I don't know how to fix that. I'm not allowed to change the function definition so it should always accept a list variable. Any ideas? asked 1 min agoRrmm Let's...
ادامه مطلبVote count: 0 Basically I have a User entity and that user will have followers. One possible way I could think of on how to model this is to have a multi-valued property of type Key, which will store Keys of the followers in a list. Like this.. DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Entity userEntity; Key k = entity.getKey(); Entity user = new Entity("User"); List followers = new ArrayList(); followers.add(k); user.setProperty("FollowersList", followers); dat...
ادامه مطلبVote count: 0 Brief overview of the programme: When launching script, the dialog window is appearing and asking you to select directory path (class MyApp) When selected - one need to push "Start Monitoring" button. This action withdraw main window (root) and initialize container (class FrameContainer) consisting of two frames, namely 'PageOne' and 'PageTwo' (see corresponding classes). Button "Back Home" on "Page One" should destroy the instance of class FrameContainer and show again the dialog ...
ادامه مطلبVote count: 0 In certain styles of python, everything is a generator, e.g. uses yield rather than constructing and retuing a list. If you need to use it as a list, you can just call list(gen). If I have a list already, what is the cost of calling list(my_list)? Use: I have a variable that I know has an iterator and might be a list, but I need to use it as a list. Is it better/more pythonic to do my_list = list(my_list) or some other way of checking its list-ness? If it matters I'm using Python 3...
ادامه مطلبVote count: 0 I have a view pager with two tabs in my app (A and B). The first tab i.e A has a listview. Clicking on any of the items in the list opens a new fragment (let's call it C) with another list. The tab B also has a listview. The list in tab B and the list contained in the fragment C have the same type of items. That is each item of both list is of the same class. I have used a recycler view with a custom adapter to create the list. Since both lists in tab B and fragment c are of the sa...
ادامه مطلبVote count: 0 So here is the standard way to read in a JSON file in python import json from pprint import pprint with open('ig001.json') as data_file: data = json.load(data_file) pprint(data) However, my JSON file that I want to read has multiple JSON objects in it. So it looks something like: [{},{}.... ] [{},{}.... ] Where this represents 2 JSON objects, and inside each object inside each {}, there are a bunch of key:value pairs. So when I try to read this using the standard read code that I h...
ادامه مطلبVote count: 0 I am trying to find the maximum length of the last key-value pair in the list of ordered dictionary. Example: # below is the list of ordered dict my_list = [{'Table': 'Config', 'Column': 'config_id', 'DataType': 'int'}, {'Table': 'Config', 'Column': 'config_name', 'DataType': 'varchar'}, {'Table': 'Config', 'Column': 'config_value', 'DataType': 'numeric'}] # Expected out put Out put: 8 # as the key (in this case "DataType") has max chars and if any value for the same key has max ch...
ادامه مطلب