back soft

مطالب مرتبط با «python list of functions» در back soft | نویسنده: استخدام کار

Efficient way of parsing through genetic mutation data in python

Vote count: 0 Simplistically the question I'm asking is in a given set of DNA sequencing reads what bases were mutated. To do this I created a data structure like this: baseDict = {'a':0, 't':0, 'g':0, 'c':0} varDict = {'a':baseDict, 't':baseDict, 'g':baseDict, 'c':baseDict} So, a given base can be either A, T, G, or C, and then can be mutated to any of the four bases. So and A could be mutated to a T. I am reading through a file containing mutations, and using a lot of if...elif statements to p...

ادامه مطلب

Changing Colors and ClickEvent of an Item inside a ListView(Xamarin Android)

Vote count: 0 I've just started programming not long ago so please bare with me. The problem I am facing is I am unable to change the color of my Items inside the Listview to Black color. My ListView's background (Which I've removed in order to see the items inside Listview) is supposed to be white background as well. Inside my activity, I added my items using the adapter.add("Item"). Therefore I am lost trying to add an click event on that Item since it's a string. Tried : 1) Changing propertie...

ادامه مطلب

How to use .split, enumerate and lists to find positions of a word in a sentence

Vote count: 0 I have been asked to find the position(s) of an input word from an input sentence and I am having trouble figuring out how to use enumerate, .split and lists together. This is what I have so far: sntc=str(input("Please input a sentence with no punctuation.")) wrd=str(input("Please input a word from that sentence.")) words=sntc.split list(enumerate(sntc)) for x in y in enumerate: if x==(wrd): print ("The chosen word is in postion(s):",x+1) asked 38 secs agoBig Man Let's block ads!...

ادامه مطلب

Out Of Range Exception 2D Array To List Of Type Int

Vote count: 0 Why do I get an Out of Range Exception here? My Code -the method takes int[][] numbers as a Parameter- : List myList = new List(); for (int i = 0; i < numbers.GetUpperBound(0); i++) { for (int z = 0; z < numbers.GetUpperBound(1); z++) { myList.Add(intervals[i][z]); } } I tried to Google it, but I don't have any glue. asked 3 mins agoMatthias Herrma Let's block ads!...

ادامه مطلب

How to bind the multiple selected items of list box in xaml

Vote count: 0 I have Flags Enum value which I have bound into the item source of listbox.I have used SelectionMode as Multiple.I want assign all the selected items of the listbox to flag Enum property.How can I bind the selected items? asked 2 mins agoMS.Dev Let's block ads!...

ادامه مطلب

How to write wav sound file from a list of samples?

Vote count: 0 I've got a source code on the inteet which do extract the sample values from a WAV file to a text file, like this: 1.17667 1.23074 3.07474 -0.00396729 -0.00393677 -0.00558472 -0.0159912 -0.0299072 -0.128143 -0.0204773 -0.206482 -0.252014 -0.0100098 -0.0585938 -0.317963 -0.253143 -0.302917 -0.0115967... .. How can I use it the write back, and create a wav file ? here is the code for extracting the samples value : http://pastebin.com/K375dbdj Thank you ! asked 2 mins agoHung Nguyen L...

ادامه مطلب

IndexError: list index out of range, but error is inconsistent?

Vote count: 0 I am in a intro to GIS programming class and doing a hangman game for my final project. I am very much an amateur so this might be an easy fix that I am not understanding...Here is my code: import random, sys class Hangman: def init(self,word): self.word = word self.incorrect_letters = [] self.letters_guessed = [] def hangman_loss(self): retu self.hangman_win() or (len(self.incorrect_letters) == 7) def hangman_win(self): if '_' not in self.unknown_word(): retu True retu False def g...

ادامه مطلب

List of pointers in class. Expression must have pointer type

Vote count: -1 , class Node { public: string m_label; list m_adjacent; }; int main() { Node tab[5]; tab[0].m_label = "AWK"; tab[1].m_label = "ASCII"; tab[2].m_label = "Matery"; tab[3].m_label = "2016"; tab[4].m_label = "actor"; map map; map[tab[0].m_label] = tab[0]; map[tab[1].m_label] = tab[1]; map[tab[2].m_label] = tab[2]; map[tab[3].m_label] = tab[3]; map[tab[4].m_label] = tab[4]; Node * temp[4] = { &tab[1], &tab[2], &tab[3], &tab[4] }; map[tab[0].m_label].m_adjacent.push_back(temp[0]); map[t...

ادامه مطلب

I'd'd like to take a list of strings, find them in another csv file and print a field from the matching line

Vote count: 0 I have a large .csv file with a few thousand lines and a handful of columns. For simplicity, it looks a little like Name, ID One, 1 Two, 2 I'd like to write a script which takes a list of strings, treating each line as a separate entity, and finds the line containing a match to that entry on the list. Once it's found the line which matches, I'd like to print one of the fields to a new file. For example, given a list: 1 2 I'd like to be able to produce a file containing the associat...

ادامه مطلب

Python 3: Convert a single element list to a variable

Vote count: 0 I have a list called [[ 0.99950892]] I want to have just 0.99950892 However when I use [[ 0.99950892]][0][0][0]. The output is (0.99975443124+0j). I don't want the parenthesis and the imaginary part. What should I do? asked 3 mins agopeter 1 Answer Vote count: 0 >>> [[x]] = [[0.99950892]] >>> x.real 0.99950892 answered 55 secs agowim Let's block ads!...

ادامه مطلب

Python - how to get rid of escape sequences in sql query execution

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...

ادامه مطلب

Having trouble appending dictionary values to list in python

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...

ادامه مطلب

Why can't we create Arraylist of Arraylists [duplicate]

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 ...

ادامه مطلب

removing an object from arraylist without changing the index of other objects

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...

ادامه مطلب

How do I remove duplicates from a list in python if the item has more than x instances?

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!...

ادامه مطلب

How do you compare each element of a list

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!...

ادامه مطلب

How to check if a list element contains a regex in Python?

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...

ادامه مطلب

get the list of functions used in a R script

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!...

ادامه مطلب

How to mix numpy slices to list of indices?

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...

ادامه مطلب

How does python do list slices and modification on the LHS?

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!...

ادامه مطلب